forked from extern/Unexpected-Keyboard
Add optional NumPad
Shows a NumPad depending on preference: Never/Landscape/Always
This commit is contained in:
parent
ea0b873dd8
commit
baec5a76ee
@ -10,12 +10,16 @@
|
|||||||
<string name="pref_accents_e_all_installed">Akzente für alle installierten Sprachen anzeigen</string>
|
<string name="pref_accents_e_all_installed">Akzente für alle installierten Sprachen anzeigen</string>
|
||||||
<string name="pref_accents_e_selected">Akzente nur für die gewählte Sprache anzeigen</string>
|
<string name="pref_accents_e_selected">Akzente nur für die gewählte Sprache anzeigen</string>
|
||||||
<string name="pref_accents_e_none">Akzente verbergen</string>
|
<string name="pref_accents_e_none">Akzente verbergen</string>
|
||||||
<string name="pref_autocapitalisation_title">Automatische Großschreibung</string>
|
<string name="pref_show_numpad_title">Ziffernblock anzeigen</string>
|
||||||
<string name="pref_autocapitalisation_summary">Umschalttaste am Satzanfang aktivieren</string>
|
<string name="pref_show_numpad_never">Nie</string>
|
||||||
<string name="pref_extra_keys_title">Tasten hinzufügen</string>
|
<string name="pref_show_numpad_landscape">Nur im Querformat</string>
|
||||||
|
<string name="pref_show_numpad_always">Immer</string>
|
||||||
<string name="pref_programming_layout_title">Tastaturlayout zum Programmieren</string>
|
<string name="pref_programming_layout_title">Tastaturlayout zum Programmieren</string>
|
||||||
|
<string name="pref_extra_keys_title">Zusätzliche Zeichen zur Tastatur hinzufügen</string>
|
||||||
<string name="pref_programming_layout_none">Keines</string>
|
<string name="pref_programming_layout_none">Keines</string>
|
||||||
<string name="pref_category_typing">Tippen</string>
|
<string name="pref_category_typing">Tippen</string>
|
||||||
|
<string name="pref_autocapitalisation_title">Automatische Großschreibung</string>
|
||||||
|
<string name="pref_autocapitalisation_summary">Shift-Taste am Satzanfang aktivieren</string>
|
||||||
<string name="pref_swipe_dist_title">Länge der Wischgeste</string>
|
<string name="pref_swipe_dist_title">Länge der Wischgeste</string>
|
||||||
<string name="pref_swipe_dist_summary">Abstand der Zeichen in den Ecken der Tasten (%s)</string>
|
<string name="pref_swipe_dist_summary">Abstand der Zeichen in den Ecken der Tasten (%s)</string>
|
||||||
<string name="pref_long_timeout_title">Zeitüberschreitung bei Tastenwiederholung</string>
|
<string name="pref_long_timeout_title">Zeitüberschreitung bei Tastenwiederholung</string>
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
<string name="pref_accents_e_all_installed">Afficher les accents pour les langues installées</string>
|
<string name="pref_accents_e_all_installed">Afficher les accents pour les langues installées</string>
|
||||||
<string name="pref_accents_e_selected">Afficher les accents pour la langue sélectionnée</string>
|
<string name="pref_accents_e_selected">Afficher les accents pour la langue sélectionnée</string>
|
||||||
<string name="pref_accents_e_none">Cacher les accents</string>
|
<string name="pref_accents_e_none">Cacher les accents</string>
|
||||||
|
<string name="pref_show_numpad_title">Afficher le pavé numérique</string>
|
||||||
|
<string name="pref_show_numpad_never">Jamais</string>
|
||||||
|
<string name="pref_show_numpad_landscape">Seulement en mode paysage</string>
|
||||||
|
<string name="pref_show_numpad_always">Toujour</string>
|
||||||
<string name="pref_autocapitalisation_title">Majuscule automatique</string>
|
<string name="pref_autocapitalisation_title">Majuscule automatique</string>
|
||||||
<string name="pref_autocapitalisation_summary">Active Shift au début des phrases</string>
|
<string name="pref_autocapitalisation_summary">Active Shift au début des phrases</string>
|
||||||
<string name="pref_category_typing">Saisie</string>
|
<string name="pref_category_typing">Saisie</string>
|
||||||
|
@ -67,6 +67,16 @@
|
|||||||
<item>@string/pref_accents_e_selected</item>
|
<item>@string/pref_accents_e_selected</item>
|
||||||
<item>@string/pref_accents_e_none</item>
|
<item>@string/pref_accents_e_none</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="pref_show_numpad_values">
|
||||||
|
<item>never</item>
|
||||||
|
<item>landscape</item>
|
||||||
|
<item>always</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_show_numpad_entries">
|
||||||
|
<item>@string/pref_show_numpad_never</item>
|
||||||
|
<item>@string/pref_show_numpad_landscape</item>
|
||||||
|
<item>@string/pref_show_numpad_always</item>
|
||||||
|
</string-array>
|
||||||
<string-array name="pref_accents_values">
|
<string-array name="pref_accents_values">
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
<string name="pref_accents_e_all_installed">Show accents for all installed languages</string>
|
<string name="pref_accents_e_all_installed">Show accents for all installed languages</string>
|
||||||
<string name="pref_accents_e_selected">Only show accents for the selected language</string>
|
<string name="pref_accents_e_selected">Only show accents for the selected language</string>
|
||||||
<string name="pref_accents_e_none">Hide accents</string>
|
<string name="pref_accents_e_none">Hide accents</string>
|
||||||
|
<string name="pref_show_numpad_title">Show NumPad</string>
|
||||||
|
<string name="pref_show_numpad_never">Never</string>
|
||||||
|
<string name="pref_show_numpad_landscape">Only in landscape mode</string>
|
||||||
|
<string name="pref_show_numpad_always">Always</string>
|
||||||
<string name="pref_autocapitalisation_title">Automatic capitalisation</string>
|
<string name="pref_autocapitalisation_title">Automatic capitalisation</string>
|
||||||
<string name="pref_autocapitalisation_summary">Press Shift at the beginning of a sentence</string>
|
<string name="pref_autocapitalisation_summary">Press Shift at the beginning of a sentence</string>
|
||||||
<string name="pref_extra_keys_title">Add keys to the keyboard</string>
|
<string name="pref_extra_keys_title">Add keys to the keyboard</string>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<keyboard bottom_row="false" extra_keys="false">
|
<keyboard bottom_row="false" extra_keys="false" num_pad="false">
|
||||||
<row>
|
<row>
|
||||||
<key width="0.75" key0="esc" key2="~" key4="!"/>
|
<key width="0.75" key0="esc" key2="~" key4="!"/>
|
||||||
<key width="0.75" key0="(" key2="[" key4="{"/>
|
<key width="0.75" key0="(" key2="[" key4="{"/>
|
||||||
|
27
res/xml/numpad.xml
Normal file
27
res/xml/numpad.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<keyboard bottom_row="false">
|
||||||
|
<row>
|
||||||
|
<key key0="7"/>
|
||||||
|
<key key0="8"/>
|
||||||
|
<key key0="9"/>
|
||||||
|
<key key0="/"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<key key0="4"/>
|
||||||
|
<key key0="5"/>
|
||||||
|
<key key0="6"/>
|
||||||
|
<key key0="*"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<key key0="1"/>
|
||||||
|
<key key0="2"/>
|
||||||
|
<key key0="3"/>
|
||||||
|
<key key0="-"/>
|
||||||
|
</row>
|
||||||
|
<row height="0.95">
|
||||||
|
<key key0="0"/>
|
||||||
|
<key key0="."/>
|
||||||
|
<key key0="="/>
|
||||||
|
<key key0="+"/>
|
||||||
|
</row>
|
||||||
|
</keyboard>
|
@ -3,6 +3,7 @@
|
|||||||
<PreferenceCategory android:title="@string/pref_category_layout">
|
<PreferenceCategory android:title="@string/pref_category_layout">
|
||||||
<ListPreference android:key="layout" android:title="@string/pref_layout_title" android:summary="%s" android:defaultValue="system" android:entries="@array/pref_layout_entries" android:entryValues="@array/pref_layout_values"/>
|
<ListPreference android:key="layout" android:title="@string/pref_layout_title" android:summary="%s" android:defaultValue="system" android:entries="@array/pref_layout_entries" android:entryValues="@array/pref_layout_values"/>
|
||||||
<ListPreference android:key="accents" android:title="@string/pref_accents_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_accents_entries" android:entryValues="@array/pref_accents_values"/>
|
<ListPreference android:key="accents" android:title="@string/pref_accents_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_accents_entries" android:entryValues="@array/pref_accents_values"/>
|
||||||
|
<ListPreference android:key="show_numpad" android:title="@string/pref_show_numpad_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_show_numpad_entries" android:entryValues="@array/pref_show_numpad_values"/>
|
||||||
<ListPreference android:key="programming_layout" android:title="@string/pref_programming_layout_title" android:summary="%s" android:defaultValue="none" android:entries="@array/pref_programming_layout_entries" android:entryValues="@array/pref_programming_layout_values"/>
|
<ListPreference android:key="programming_layout" android:title="@string/pref_programming_layout_title" android:summary="%s" android:defaultValue="none" android:entries="@array/pref_programming_layout_entries" android:entryValues="@array/pref_programming_layout_values"/>
|
||||||
<PreferenceScreen android:title="@string/pref_extra_keys_title">
|
<PreferenceScreen android:title="@string/pref_extra_keys_title">
|
||||||
<juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="0"/>
|
<juloo.keyboard2.ExtraKeyCheckBoxPreference app:index="0"/>
|
||||||
|
@ -25,6 +25,7 @@ final class Config
|
|||||||
// From preferences
|
// From preferences
|
||||||
public int layout; // Or '-1' for the system defaults
|
public int layout; // Or '-1' for the system defaults
|
||||||
public int programming_layout; // Or '-1' for none
|
public int programming_layout; // Or '-1' for none
|
||||||
|
public boolean show_numpad = false;
|
||||||
public float swipe_dist_px;
|
public float swipe_dist_px;
|
||||||
public boolean vibrateEnabled;
|
public boolean vibrateEnabled;
|
||||||
public long longPressTimeout;
|
public long longPressTimeout;
|
||||||
@ -100,8 +101,12 @@ final class Config
|
|||||||
// Scale some dimensions depending on orientation
|
// Scale some dimensions depending on orientation
|
||||||
float horizontalIntervalScale = 1.f;
|
float horizontalIntervalScale = 1.f;
|
||||||
float characterSizeScale = 1.f;
|
float characterSizeScale = 1.f;
|
||||||
|
String show_numpad_s = prefs.getString("show_numpad", "never");
|
||||||
|
show_numpad = "always".equals(show_numpad_s);
|
||||||
if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) // Landscape mode
|
if (res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) // Landscape mode
|
||||||
{
|
{
|
||||||
|
if ("landscape".equals(show_numpad_s))
|
||||||
|
show_numpad = true;
|
||||||
keyboardHeightPercent = prefs.getInt("keyboard_height_landscape", 50);
|
keyboardHeightPercent = prefs.getInt("keyboard_height_landscape", 50);
|
||||||
horizontalIntervalScale = 2.f;
|
horizontalIntervalScale = 2.f;
|
||||||
characterSizeScale = 1.25f;
|
characterSizeScale = 1.25f;
|
||||||
@ -208,6 +213,8 @@ final class Config
|
|||||||
});
|
});
|
||||||
if (extra_keys.size() > 0)
|
if (extra_keys.size() > 0)
|
||||||
kw = kw.addExtraKeys(extra_keys.iterator());
|
kw = kw.addExtraKeys(extra_keys.iterator());
|
||||||
|
if (original_kw.num_pad && show_numpad)
|
||||||
|
kw = kw.addNumPad();
|
||||||
return kw;
|
return kw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +199,13 @@ public class Keyboard2View extends View
|
|||||||
return null;
|
return null;
|
||||||
for (KeyboardData.Key key : row.keys)
|
for (KeyboardData.Key key : row.keys)
|
||||||
{
|
{
|
||||||
x += (key.shift + key.width) * _keyWidth;
|
float xLeft = x + key.shift * _keyWidth;
|
||||||
if (tx < x)
|
float xRight = xLeft + key.width * _keyWidth;
|
||||||
|
if (tx < xLeft)
|
||||||
|
return null;
|
||||||
|
if (tx < xRight)
|
||||||
return key;
|
return key;
|
||||||
|
x = xRight;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,15 @@ class KeyboardData
|
|||||||
public final float keysHeight;
|
public final float keysHeight;
|
||||||
/** Whether to add extra keys. */
|
/** Whether to add extra keys. */
|
||||||
public final boolean extra_keys;
|
public final boolean extra_keys;
|
||||||
|
/** Whether to possibly add NumPad. */
|
||||||
|
public final boolean num_pad;
|
||||||
|
|
||||||
public KeyboardData mapKeys(MapKey f)
|
public KeyboardData mapKeys(MapKey f)
|
||||||
{
|
{
|
||||||
ArrayList<Row> rows_ = new ArrayList<Row>();
|
ArrayList<Row> rows_ = new ArrayList<Row>();
|
||||||
for (Row r : rows)
|
for (Row r : rows)
|
||||||
rows_.add(r.mapKeys(f));
|
rows_.add(r.mapKeys(f));
|
||||||
return new KeyboardData(rows_, keysWidth, extra_keys);
|
return new KeyboardData(rows_, keysWidth, extra_keys, num_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add keys from the given iterator into the keyboard. Extra keys are added
|
/** Add keys from the given iterator into the keyboard. Extra keys are added
|
||||||
@ -46,7 +48,32 @@ class KeyboardData
|
|||||||
for (int c = 1; c <= 4; c++)
|
for (int c = 1; c <= 4; c++)
|
||||||
addExtraKeys_to_row(rows, k, r, c);
|
addExtraKeys_to_row(rows, k, r, c);
|
||||||
}
|
}
|
||||||
return new KeyboardData(rows, keysWidth, extra_keys);
|
return new KeyboardData(rows, keysWidth, extra_keys, num_pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardData addNumPad()
|
||||||
|
{
|
||||||
|
if (!num_pad || _numPadKeyboardData == null)
|
||||||
|
return this;
|
||||||
|
ArrayList<Row> extendedRows = new ArrayList<Row>();
|
||||||
|
Iterator<Row> iterNumPadRows = _numPadKeyboardData.rows.iterator();
|
||||||
|
for (Row row : rows)
|
||||||
|
{
|
||||||
|
ArrayList<KeyboardData.Key> keys = new ArrayList<Key>(row.keys);
|
||||||
|
if (iterNumPadRows.hasNext())
|
||||||
|
{
|
||||||
|
Row numPadRow = iterNumPadRows.next();
|
||||||
|
List<Key> nps = numPadRow.keys;
|
||||||
|
if (nps.size() > 0) {
|
||||||
|
float firstNumPadShift = 0.5f + keysWidth - row.keysWidth;
|
||||||
|
keys.add(nps.get(0).withShift(firstNumPadShift));
|
||||||
|
for (int i = 1; i < nps.size(); i++)
|
||||||
|
keys.add(nps.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
extendedRows.add(new Row(keys, row.height, row.shift));
|
||||||
|
}
|
||||||
|
return new KeyboardData(extendedRows, compute_max_width(extendedRows), extra_keys, num_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key findKeyWithValue(KeyValue kv)
|
public Key findKeyWithValue(KeyValue kv)
|
||||||
@ -75,6 +102,7 @@ class KeyboardData
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Row _bottomRow = null;
|
private static Row _bottomRow = null;
|
||||||
|
private static KeyboardData _numPadKeyboardData = null;
|
||||||
private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
||||||
|
|
||||||
public static KeyboardData load(Resources res, int id)
|
public static KeyboardData load(Resources res, int id)
|
||||||
@ -86,6 +114,10 @@ class KeyboardData
|
|||||||
{
|
{
|
||||||
if (_bottomRow == null)
|
if (_bottomRow == null)
|
||||||
_bottomRow = parse_bottom_row(res.getXml(R.xml.bottom_row));
|
_bottomRow = parse_bottom_row(res.getXml(R.xml.bottom_row));
|
||||||
|
if (_numPadKeyboardData == null)
|
||||||
|
{
|
||||||
|
_numPadKeyboardData = parse_keyboard(res.getXml(R.xml.numpad));
|
||||||
|
}
|
||||||
l = parse_keyboard(res.getXml(id));
|
l = parse_keyboard(res.getXml(id));
|
||||||
_layoutCache.put(id, l);
|
_layoutCache.put(id, l);
|
||||||
}
|
}
|
||||||
@ -103,13 +135,14 @@ class KeyboardData
|
|||||||
throw new Exception("Empty layout file");
|
throw new Exception("Empty layout file");
|
||||||
boolean bottom_row = parser.getAttributeBooleanValue(null, "bottom_row", true);
|
boolean bottom_row = parser.getAttributeBooleanValue(null, "bottom_row", true);
|
||||||
boolean extra_keys = parser.getAttributeBooleanValue(null, "extra_keys", true);
|
boolean extra_keys = parser.getAttributeBooleanValue(null, "extra_keys", true);
|
||||||
|
boolean num_pad = parser.getAttributeBooleanValue(null, "num_pad", true);
|
||||||
ArrayList<Row> rows = new ArrayList<Row>();
|
ArrayList<Row> rows = new ArrayList<Row>();
|
||||||
while (expect_tag(parser, "row"))
|
while (expect_tag(parser, "row"))
|
||||||
rows.add(Row.parse(parser));
|
rows.add(Row.parse(parser));
|
||||||
float kw = compute_max_width(rows);
|
float kw = compute_max_width(rows);
|
||||||
if (bottom_row)
|
if (bottom_row)
|
||||||
rows.add(_bottomRow.updateWidth(kw));
|
rows.add(_bottomRow.updateWidth(kw));
|
||||||
return new KeyboardData(rows, kw, extra_keys);
|
return new KeyboardData(rows, kw, extra_keys, num_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float compute_max_width(List<Row> rows)
|
private static float compute_max_width(List<Row> rows)
|
||||||
@ -127,7 +160,7 @@ class KeyboardData
|
|||||||
return Row.parse(parser);
|
return Row.parse(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyboardData(List<Row> rows_, float kw, boolean xk)
|
protected KeyboardData(List<Row> rows_, float kw, boolean xk, boolean np)
|
||||||
{
|
{
|
||||||
float kh = 0.f;
|
float kh = 0.f;
|
||||||
for (Row r : rows_)
|
for (Row r : rows_)
|
||||||
@ -136,6 +169,7 @@ class KeyboardData
|
|||||||
keysWidth = kw;
|
keysWidth = kw;
|
||||||
keysHeight = kh;
|
keysHeight = kh;
|
||||||
extra_keys = xk;
|
extra_keys = xk;
|
||||||
|
num_pad = np;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Row
|
public static class Row
|
||||||
@ -146,7 +180,7 @@ class KeyboardData
|
|||||||
/** Extra empty space on the top. */
|
/** Extra empty space on the top. */
|
||||||
public final float shift;
|
public final float shift;
|
||||||
/** Total width of the row. */
|
/** Total width of the row. */
|
||||||
private final float keysWidth;
|
public final float keysWidth;
|
||||||
|
|
||||||
protected Row(List<Key> keys_, float h, float s)
|
protected Row(List<Key> keys_, float h, float s)
|
||||||
{
|
{
|
||||||
@ -278,6 +312,11 @@ class KeyboardData
|
|||||||
return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys);
|
return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Key withShift(float s)
|
||||||
|
{
|
||||||
|
return new Key(key0, key1, key2, key3, key4, width, s, edgekeys);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See Pointers.onTouchMove() for the represented direction.
|
* See Pointers.onTouchMove() for the represented direction.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user