forked from extern/Unexpected-Keyboard
Remove the digits when numpad is visible
This commit is contained in:
parent
78a461f740
commit
c7184303e9
@ -172,11 +172,12 @@ final class Config
|
|||||||
// Extra keys are removed from the set as they are encountered during the
|
// Extra keys are removed from the set as they are encountered during the
|
||||||
// first iteration then automatically added.
|
// first iteration then automatically added.
|
||||||
final Set<KeyValue> extra_keys = new HashSet<KeyValue>();
|
final Set<KeyValue> extra_keys = new HashSet<KeyValue>();
|
||||||
|
final Set<KeyValue> remove_keys = new HashSet<KeyValue>();
|
||||||
if (extra_keys_subtype != null)
|
if (extra_keys_subtype != null)
|
||||||
extra_keys.addAll(extra_keys_subtype);
|
extra_keys.addAll(extra_keys_subtype);
|
||||||
extra_keys.addAll(extra_keys_param);
|
extra_keys.addAll(extra_keys_param);
|
||||||
if (show_numpad)
|
if (show_numpad)
|
||||||
kw = kw.addNumPad();
|
KeyboardData.num_pad.getKeys(remove_keys);
|
||||||
kw = kw.mapKeys(new KeyboardData.MapKeyValues() {
|
kw = kw.mapKeys(new KeyboardData.MapKeyValues() {
|
||||||
public KeyValue apply(KeyValue key, boolean localized)
|
public KeyValue apply(KeyValue key, boolean localized)
|
||||||
{
|
{
|
||||||
@ -185,6 +186,8 @@ final class Config
|
|||||||
extra_keys.remove(key);
|
extra_keys.remove(key);
|
||||||
if (localized && !is_extra_key)
|
if (localized && !is_extra_key)
|
||||||
return null;
|
return null;
|
||||||
|
if (remove_keys.contains(key))
|
||||||
|
return null;
|
||||||
switch (key.getKind())
|
switch (key.getKind())
|
||||||
{
|
{
|
||||||
case Event:
|
case Event:
|
||||||
@ -218,6 +221,8 @@ final class Config
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (show_numpad)
|
||||||
|
kw = kw.addNumPad();
|
||||||
if (extra_keys.size() > 0)
|
if (extra_keys.size() > 0)
|
||||||
kw = kw.addExtraKeys(extra_keys.iterator());
|
kw = kw.addExtraKeys(extra_keys.iterator());
|
||||||
return kw;
|
return kw;
|
||||||
|
@ -9,6 +9,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ class KeyboardData
|
|||||||
public KeyboardData addNumPad()
|
public KeyboardData addNumPad()
|
||||||
{
|
{
|
||||||
ArrayList<Row> extendedRows = new ArrayList<Row>();
|
ArrayList<Row> extendedRows = new ArrayList<Row>();
|
||||||
Iterator<Row> iterNumPadRows = _num_pad.rows.iterator();
|
Iterator<Row> iterNumPadRows = num_pad.rows.iterator();
|
||||||
for (Row row : rows)
|
for (Row row : rows)
|
||||||
{
|
{
|
||||||
ArrayList<KeyboardData.Key> keys = new ArrayList<Key>(row.keys);
|
ArrayList<KeyboardData.Key> keys = new ArrayList<Key>(row.keys);
|
||||||
@ -82,6 +83,12 @@ class KeyboardData
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getKeys(Set<KeyValue> dst)
|
||||||
|
{
|
||||||
|
for (Row r : rows)
|
||||||
|
r.getKeys(dst);
|
||||||
|
}
|
||||||
|
|
||||||
private static void addExtraKeys_to_row(ArrayList<Row> rows, final Iterator<KeyValue> extra_keys, int row_i, final int d)
|
private static void addExtraKeys_to_row(ArrayList<Row> rows, final Iterator<KeyValue> extra_keys, int row_i, final int d)
|
||||||
{
|
{
|
||||||
if (!extra_keys.hasNext())
|
if (!extra_keys.hasNext())
|
||||||
@ -96,17 +103,17 @@ class KeyboardData
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Row _bottom_row;
|
public static Row bottom_row;
|
||||||
private static KeyboardData _num_pad;
|
public static KeyboardData num_pad;
|
||||||
private static KeyboardData _pin_entry;
|
public static KeyboardData pin_entry;
|
||||||
private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
||||||
|
|
||||||
public static void init(Resources res)
|
public static void init(Resources res)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_bottom_row = parse_bottom_row(res.getXml(R.xml.bottom_row));
|
bottom_row = parse_bottom_row(res.getXml(R.xml.bottom_row));
|
||||||
_num_pad = parse_keyboard(res.getXml(R.xml.numpad));
|
num_pad = parse_keyboard(res.getXml(R.xml.numpad));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -116,9 +123,9 @@ class KeyboardData
|
|||||||
|
|
||||||
public static KeyboardData load_pin_entry(Resources res)
|
public static KeyboardData load_pin_entry(Resources res)
|
||||||
{
|
{
|
||||||
if (_pin_entry == null)
|
if (pin_entry == null)
|
||||||
_pin_entry = load(res, R.xml.pin);
|
pin_entry = load(res, R.xml.pin);
|
||||||
return _pin_entry;
|
return pin_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load a layout from a resource ID. Returns [null] on error. */
|
/** Load a layout from a resource ID. Returns [null] on error. */
|
||||||
@ -161,14 +168,14 @@ class KeyboardData
|
|||||||
{
|
{
|
||||||
if (!expect_tag(parser, "keyboard"))
|
if (!expect_tag(parser, "keyboard"))
|
||||||
throw new Exception("Empty layout file");
|
throw new Exception("Empty layout file");
|
||||||
boolean bottom_row = attribute_bool(parser, "bottom_row", true);
|
boolean add_bottom_row = attribute_bool(parser, "bottom_row", true);
|
||||||
float specified_kw = attribute_float(parser, "width", 0f);
|
float specified_kw = attribute_float(parser, "width", 0f);
|
||||||
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 = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
|
float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
|
||||||
if (bottom_row)
|
if (add_bottom_row)
|
||||||
rows.add(_bottom_row.updateWidth(kw));
|
rows.add(bottom_row.updateWidth(kw));
|
||||||
return new KeyboardData(rows, kw);
|
return new KeyboardData(rows, kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +235,12 @@ class KeyboardData
|
|||||||
return new Row(keys, h, shift);
|
return new Row(keys, h, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getKeys(Set<KeyValue> dst)
|
||||||
|
{
|
||||||
|
for (Key k : keys)
|
||||||
|
k.getKeys(dst);
|
||||||
|
}
|
||||||
|
|
||||||
public Row mapKeys(MapKey f)
|
public Row mapKeys(MapKey f)
|
||||||
{
|
{
|
||||||
ArrayList<Key> keys_ = new ArrayList<Key>();
|
ArrayList<Key> keys_ = new ArrayList<Key>();
|
||||||
@ -317,6 +330,17 @@ class KeyboardData
|
|||||||
slider, indication);
|
slider, indication);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getKeys(Set<KeyValue> dst)
|
||||||
|
{
|
||||||
|
getCorner(dst, key0);
|
||||||
|
getCorner(dst, key1);
|
||||||
|
getCorner(dst, key2);
|
||||||
|
getCorner(dst, key3);
|
||||||
|
getCorner(dst, key4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getCorner(Set<KeyValue> dst, Corner k) { if (k != null) dst.add(k.kv); }
|
||||||
|
|
||||||
public KeyValue getKeyValue(int i)
|
public KeyValue getKeyValue(int i)
|
||||||
{
|
{
|
||||||
Corner c;
|
Corner c;
|
||||||
|
Loading…
Reference in New Issue
Block a user