mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-24 16:23:14 +01:00
Fix crash on Android 6
The call to getLanguageTag() introduced in 4629410
requires API 24.
This commit is contained in:
parent
9d76227982
commit
d8fc4e80e3
@ -150,14 +150,16 @@ public class Keyboard2 extends InputMethodService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(12)
|
@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
|
// Android might return a random subtype, for example, the first in the
|
||||||
// list alphabetically.
|
// list alphabetically.
|
||||||
InputMethodSubtype current_subtype = imm.getCurrentInputMethodSubtype();
|
InputMethodSubtype current_subtype = imm.getCurrentInputMethodSubtype();
|
||||||
for (InputMethodSubtype s : enabled_subtypes)
|
for (InputMethodSubtype s : enabled_subtypes)
|
||||||
if (s.getLanguageTag().equals(current_subtype.getLanguageTag()))
|
if (s.getLanguageTag().equals(current_subtype.getLanguageTag()))
|
||||||
return s.getExtraValueOf("default_layout");
|
return s;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,10 +172,10 @@ public class Keyboard2 extends InputMethodService
|
|||||||
if (VERSION.SDK_INT >= 12)
|
if (VERSION.SDK_INT >= 12)
|
||||||
{
|
{
|
||||||
List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
|
List<InputMethodSubtype> enabled_subtypes = getEnabledSubtypes(imm);
|
||||||
InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
|
InputMethodSubtype subtype = defaultSubtypes(imm, enabled_subtypes);
|
||||||
if (subtype != null)
|
if (subtype != null)
|
||||||
{
|
{
|
||||||
String s = defaultLayoutForSubtypes(imm, enabled_subtypes);
|
String s = subtype.getExtraValueOf("default_layout");
|
||||||
if (s != null)
|
if (s != null)
|
||||||
default_layout = LayoutsPreference.layout_of_string(getResources(), s);
|
default_layout = LayoutsPreference.layout_of_string(getResources(), s);
|
||||||
refreshAccentsOption(imm, enabled_subtypes);
|
refreshAccentsOption(imm, enabled_subtypes);
|
||||||
|
Loading…
Reference in New Issue
Block a user