forked from extern/Unexpected-Keyboard
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.
This commit is contained in:
parent
b9526d918d
commit
4629410230
@ -12,7 +12,7 @@
|
||||
<subtype android:label="%s" android:languageTag="el" android:imeSubtypeLocale="el" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=grek_qwerty,extra_keys=£@l|€"/>
|
||||
<subtype android:label="%s" android:languageTag="en-CA" android:imeSubtypeLocale="en_CA" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us"/>
|
||||
<subtype android:label="%s" android:languageTag="en-GB" android:imeSubtypeLocale="en_GB" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_gb,extra_keys=£@l"/>
|
||||
<subtype android:label="%s" android:languageTag="en-US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us"/>
|
||||
<subtype android:label="%s" android:languageTag="en-US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us" android:overridesImplicitlyEnabledSubtype="true"/>
|
||||
<subtype android:label="%s" android:languageTag="es" android:imeSubtypeLocale="es_ES" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_es,extra_keys=accent_aigu:á:é:í:ó:ú@d|accent_tilde:ñ@n|accent_grave@f|accent_trema@u|€"/>
|
||||
<subtype android:label="%s" android:languageTag="fa" android:imeSubtypeLocale="fa_IR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=arab_pc_ir"/>
|
||||
<subtype android:label="%s" android:languageTag="fr-CA" android:imeSubtypeLocale="fr_CA" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_azerty_fr,extra_keys=accent_grave:à:è:ù@f|accent_aigu:é@d|accent_circonflexe:â:ê:ô@f|accent_cedille:ç@c|accent_trema:ë:ï:ü:ÿ@u"/>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user