abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorJules Aguillon2024-07-14 16:15:18 +0200
committerJules Aguillon2024-07-14 16:15:18 +0200
commit4629410230b50c07d873f21db57b2be9052724f1 (patch)
treee2de82a3f24e4b53292e7512c3d34d07893ce7ac /srcs/juloo.keyboard2/Keyboard2.java
parentb9526d918d4db06f7b4000deb8d44aa342ce65ff (diff)
downloadunexpected-keyboard-4629410230b50c07d873f21db57b2be9052724f1.tar.gz
unexpected-keyboard-4629410230b50c07d873f21db57b2be9052724f1.zip
Fix unintended layout used for unsupported languages
The arabic layout was used as the default on devices where all the installed languages are not supported by the keyboard. This is not intended. This is probably caused by 'getCurrentInputMethodSubtype' returning the first layout in the list of disabled subtypes in alphabetical or language tag order. Re-ordering the subtypes in method.xml had no effect. Setting 'overridesImplicitlyEnabledSubtype' in method.xml has no measured effect.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 0c82aaf..f08f177 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -136,13 +136,9 @@ public class Keyboard2 extends InputMethodService
return ExtraKeys.EMPTY;
}
- @TargetApi(12)
- private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
+ private void refreshAccentsOption(InputMethodManager imm, List<InputMethodSubtype> enabled_subtypes)
{
- List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
List<ExtraKeys> extra_keys = new ArrayList<ExtraKeys>();
- // Gather extra keys from all enabled subtypes
- extra_keys.add(extra_keys_of_subtype(subtype));
for (InputMethodSubtype s : enabled_subtypes)
extra_keys.add(extra_keys_of_subtype(s));
_config.extra_keys_subtype = ExtraKeys.merge(extra_keys);
@@ -153,6 +149,18 @@ public class Keyboard2 extends InputMethodService
return (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
}
+ @TargetApi(12)
+ private String defaultLayoutForSubtypes(InputMethodManager imm, List<InputMethodSubtype> enabled_subtypes)
+ {
+ // Android might return a random subtype, for example, the first in the
+ // list alphabetically.
+ InputMethodSubtype current_subtype = imm.getCurrentInputMethodSubtype();
+ for (InputMethodSubtype s : enabled_subtypes)
+ if (s.getLanguageTag().equals(current_subtype.getLanguageTag()))
+ return s.getExtraValueOf("default_layout");
+ return null;
+ }
+
private void refreshSubtypeImm()
{
InputMethodManager imm = get_imm();
@@ -161,13 +169,14 @@ public class Keyboard2 extends InputMethodService
_config.extra_keys_subtype = null;
if (VERSION.SDK_INT >= 12)
{
+ List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
if (subtype != null)
{
- String s = subtype.getExtraValueOf("default_layout");
+ String s = defaultLayoutForSubtypes(imm, enabled_subtypes);
if (s != null)
default_layout = LayoutsPreference.layout_of_string(getResources(), s);
- refreshAccentsOption(imm, subtype);
+ refreshAccentsOption(imm, enabled_subtypes);
}
}
if (default_layout == null)