diff --git a/res/xml/method.xml b/res/xml/method.xml index 4aa79df..481bb4f 100644 --- a/res/xml/method.xml +++ b/res/xml/method.xml @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index b2a0d83..8a2199f 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -33,7 +33,7 @@ final class Config // Dynamically set public boolean shouldOfferSwitchingToNextInputMethod; - public int accent_flags_to_remove; + public int key_flags_to_remove; public final IKeyEventHandler handler; @@ -61,7 +61,7 @@ final class Config refresh(context); // initialized later shouldOfferSwitchingToNextInputMethod = false; - accent_flags_to_remove = 0; + key_flags_to_remove = 0; handler = h; } @@ -107,7 +107,7 @@ final class Config } /* Used for the accents option. */ - public static int accentFlag_of_name(String name) + public static int extra_key_flag_of_name(String name) { switch (name) { diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 4dd4242..26b3c9e 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -47,6 +47,15 @@ class KeyValue FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 | FLAG_ACCENT_SUPERSCRIPT | FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_RING; + // Language specific keys + public static final int FLAGS_LANGS = 0; + + public static final int FLAGS_NOT_HIDDEN_ACCENTS = FLAG_ACCENT_SUPERSCRIPT | + FLAG_ACCENT_SUBSCRIPT; + // Keys that have to be enabled per language + public static final int FLAGS_HIDDEN_KEYS = + (FLAGS_ACCENTS & ~FLAGS_NOT_HIDDEN_ACCENTS) | FLAGS_LANGS; + public final String name; public final String symbol; public final char char_; diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index b820b98..2d807cf 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -81,33 +81,32 @@ public class Keyboard2 extends InputMethodService _currentTextLayout = l; } - private int accents_of_subtype(InputMethodSubtype subtype) + private int extra_keys_of_subtype(InputMethodSubtype subtype) { - String accents_option = subtype.getExtraValueOf("accents"); + String extra_keys = subtype.getExtraValueOf("extra_keys"); int flags = 0; - if (accents_option != null) - for (String acc : accents_option.split("\\|")) - flags |= Config.accentFlag_of_name(acc); + if (extra_keys != null) + for (String acc : extra_keys.split("\\|")) + flags |= Config.extra_key_flag_of_name(acc); return flags; } private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype) { - final int DONT_REMOVE = KeyValue.FLAG_ACCENT_SUPERSCRIPT | KeyValue.FLAG_ACCENT_SUBSCRIPT; - int to_keep = DONT_REMOVE; + int to_keep = 0; switch (_config.accents) { case 1: - to_keep |= accents_of_subtype(subtype); + to_keep |= extra_keys_of_subtype(subtype); for (InputMethodSubtype s : getEnabledSubtypes(imm)) - to_keep |= accents_of_subtype(s); + to_keep |= extra_keys_of_subtype(s); break; - case 2: to_keep |= accents_of_subtype(subtype); break; - case 3: to_keep = KeyValue.FLAGS_ACCENTS; break; + case 2: to_keep |= extra_keys_of_subtype(subtype); break; + case 3: to_keep = KeyValue.FLAGS_HIDDEN_KEYS; break; case 4: break; default: throw new IllegalArgumentException(); } - _config.accent_flags_to_remove = ~to_keep & KeyValue.FLAGS_ACCENTS; + _config.key_flags_to_remove = ~to_keep & KeyValue.FLAGS_HIDDEN_KEYS; } private void refreshSubtypeLegacyFallback() @@ -115,8 +114,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.accent_flags_to_remove = 0; break; - case 4: _config.accent_flags_to_remove = KeyValue.FLAGS_ACCENTS; break; + 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; } // Fallback for the layout option: Use qwerty in the "system settings" case _currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout; diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 603984d..d0b1a6d 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -61,8 +61,8 @@ public class Keyboard2View extends View { if (!_config.shouldOfferSwitchingToNextInputMethod) kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD)); - if (_config.accent_flags_to_remove != 0) - kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.accent_flags_to_remove)); + if (_config.key_flags_to_remove != 0) + kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.key_flags_to_remove)); _keyboard = kw; reset(); }