diff options
| author | Jules Aguillon | 2022-03-13 00:14:18 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2022-03-13 00:14:18 +0100 |
| commit | ee6e892ef4b85d3f9e57f03efcbf971b6fb373b2 (patch) | |
| tree | f1b95cd56ef5f62596dcdc5ae626667fdc613c68 /srcs/juloo.keyboard2/Keyboard2.java | |
| parent | 2ea256e769bbd6ae175670bc11ee5abed7f9640f (diff) | |
| download | unexpected-keyboard-ee6e892ef4b85d3f9e57f03efcbf971b6fb373b2.tar.gz unexpected-keyboard-ee6e892ef4b85d3f9e57f03efcbf971b6fb373b2.zip | |
Define localized keys as a set instead of flags
Using flags for removing keys like € and ß need too many flags and won't
scale to more localized keys.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 2db63e6..0cc2512 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -19,6 +19,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import java.util.List; +import java.util.HashSet; +import java.util.Set; public class Keyboard2 extends InputMethodService implements SharedPreferences.OnSharedPreferenceChangeListener @@ -70,32 +72,34 @@ public class Keyboard2 extends InputMethodService _currentTextLayout = l; } - private int extra_keys_of_subtype(InputMethodSubtype subtype) + private void extra_keys_of_subtype(Set<String> dst, InputMethodSubtype subtype) { String extra_keys = subtype.getExtraValueOf("extra_keys"); - int flags = 0; - if (extra_keys != null) - for (String acc : extra_keys.split("\\|")) - flags |= Config.extra_key_flag_of_name(acc); - return flags; + if (extra_keys == null) + return; + String[] ks = extra_keys.split("\\|"); + for (int i = 0; i < ks.length; i++) + dst.add(ks[i]); } private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype) { - int to_keep = 0; + HashSet<String> extra_keys = new HashSet<String>(); switch (_config.accents) { case 1: - to_keep |= extra_keys_of_subtype(subtype); + extra_keys_of_subtype(extra_keys, subtype); for (InputMethodSubtype s : getEnabledSubtypes(imm)) - to_keep |= extra_keys_of_subtype(s); + extra_keys_of_subtype(extra_keys, s); break; - case 2: to_keep |= extra_keys_of_subtype(subtype); break; - case 3: to_keep = KeyValue.FLAGS_HIDDEN_KEYS; break; + case 2: + extra_keys_of_subtype(extra_keys, subtype); + break; + case 3: extra_keys = null; break; case 4: break; default: throw new IllegalArgumentException(); } - _config.key_flags_to_remove = ~to_keep & KeyValue.FLAGS_HIDDEN_KEYS; + _config.extra_keys = extra_keys; } private void refreshSubtypeLegacyFallback() @@ -103,8 +107,8 @@ public class Keyboard2 extends InputMethodService // Fallback for the accents option: Only respect the "None" case switch (_config.accents) { - case 1: case 2: case 3: _config.key_flags_to_remove = 0; break; - case 4: _config.key_flags_to_remove = KeyValue.FLAGS_HIDDEN_KEYS; break; + case 1: case 2: case 3: _config.extra_keys = null; break; + case 4: _config.extra_keys = new HashSet<String>(); break; } // Fallback for the layout option: Use qwerty in the "system settings" case _currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout; |
