diff options
| author | Jules Aguillon | 2023-09-15 18:00:27 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2023-09-15 18:00:27 +0200 |
| commit | 66b1bdc9c90e1f29ecec096286136b527ec6b8ed (patch) | |
| tree | 581d6f693ba487a91775725e7d6e3ffe7437c2b1 /srcs/juloo.keyboard2/Config.java | |
| parent | d771e9d2c7de7d62f5514995f4a224e1e293a376 (diff) | |
| download | unexpected-keyboard-66b1bdc9c90e1f29ecec096286136b527ec6b8ed.tar.gz unexpected-keyboard-66b1bdc9c90e1f29ecec096286136b527ec6b8ed.zip | |
Refactor: Preferred positions for extra keys
The new PreferredPos class represents where an extra key should be
placed
Currently used to place keys at the same positions they were placed
before.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index da78f7f..bde4aea 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -9,8 +9,10 @@ import android.util.TypedValue; import android.view.KeyEvent; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; final class Config @@ -59,8 +61,8 @@ final class Config public int actionId; // Meaningful only when 'actionLabel' isn't 'null' public boolean swapEnterActionKey; // Swap the "enter" and "action" keys public ExtraKeys extra_keys_subtype; - public Set<KeyValue> extra_keys_param; - public List<KeyValue> extra_keys_custom; + public Map<KeyValue, KeyboardData.PreferredPos> extra_keys_param; + public Map<KeyValue, KeyboardData.PreferredPos> extra_keys_custom; public final IKeyEventHandler handler; public boolean orientation_landscape = false; @@ -174,16 +176,16 @@ final class Config final KeyValue action_key = action_key(); // Extra keys are removed from the set as they are encountered during the // first iteration then automatically added. - final Set<KeyValue> extra_keys = new HashSet<KeyValue>(); + final Map<KeyValue, KeyboardData.PreferredPos> extra_keys = new HashMap<KeyValue, KeyboardData.PreferredPos>(); final Set<KeyValue> remove_keys = new HashSet<KeyValue>(); - extra_keys.addAll(extra_keys_param); - extra_keys.addAll(extra_keys_custom); + extra_keys.putAll(extra_keys_param); + extra_keys.putAll(extra_keys_custom); if (extra_keys_subtype != null) { Set<KeyValue> present = new HashSet<KeyValue>(); present.addAll(kw.getKeys().keySet()); - present.addAll(extra_keys_param); - present.addAll(extra_keys_custom); + present.addAll(extra_keys_param.keySet()); + present.addAll(extra_keys_custom.keySet()); extra_keys_subtype.compute(extra_keys, new ExtraKeys.Query(kw.script, present)); } @@ -193,7 +195,7 @@ final class Config kw = kw.mapKeys(new KeyboardData.MapKeyValues() { public KeyValue apply(KeyValue key, boolean localized) { - boolean is_extra_key = extra_keys.contains(key); + boolean is_extra_key = extra_keys.containsKey(key); if (is_extra_key) extra_keys.remove(key); if (localized && !is_extra_key) @@ -246,7 +248,7 @@ final class Config if (number_row) kw = kw.addNumberRow(); if (extra_keys.size() > 0) - kw = kw.addExtraKeys(extra_keys.iterator()); + kw = kw.addExtraKeys(extra_keys.entrySet().iterator()); return kw; } |
