diff options
| author | Jules Aguillon | 2024-07-27 00:25:33 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2024-07-27 00:25:33 +0200 |
| commit | d8fc4e80e35921adb7165992d3e4599c30224950 (patch) | |
| tree | c7a4da5d27342700e65b57c1dbf82f4a193c9b62 /srcs | |
| parent | 9d7622798296ec8ce1427c87ffdc0dddec048294 (diff) | |
| download | unexpected-keyboard-d8fc4e80e35921adb7165992d3e4599c30224950.tar.gz unexpected-keyboard-d8fc4e80e35921adb7165992d3e4599c30224950.zip | |
Fix crash on Android 6
The call to getLanguageTag() introduced in 4629410 requires API 24.
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index f08f177..4886cc3 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -150,14 +150,16 @@ public class Keyboard2 extends InputMethodService } @TargetApi(12) - private String defaultLayoutForSubtypes(InputMethodManager imm, List<InputMethodSubtype> enabled_subtypes) + private InputMethodSubtype defaultSubtypes(InputMethodManager imm, List<InputMethodSubtype> enabled_subtypes) { + if (VERSION.SDK_INT < 24) + return imm.getCurrentInputMethodSubtype(); // 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 s; return null; } @@ -170,10 +172,10 @@ public class Keyboard2 extends InputMethodService if (VERSION.SDK_INT >= 12) { List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm); - InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype(); + InputMethodSubtype subtype = defaultSubtypes(imm, enabled_subtypes); if (subtype != null) { - String s = defaultLayoutForSubtypes(imm, enabled_subtypes); + String s = subtype.getExtraValueOf("default_layout"); if (s != null) default_layout = LayoutsPreference.layout_of_string(getResources(), s); refreshAccentsOption(imm, enabled_subtypes); |
