From 7f7947c97b141cbb338c5164e9e19d1ac9ff3d1c Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 28 Jun 2012 12:03:11 +0900 Subject: [PATCH] Keep subtypes in method.xml the same as pre-JellyBean This change prevents Android Keyboard subtypes being mistakenly disabled when upgrading from pre-JellyBean to JellyBean. Bug: 6750906 Change-Id: I05de6c512e7aa17356e415476e5248986c7d4253 --- java/res/values/donottranslate.xml | 46 +++++++++++++++++++ java/res/xml/method.xml | 42 ++++++++--------- .../inputmethod/latin/SubtypeLocale.java | 21 ++++++++- 3 files changed, 87 insertions(+), 22 deletions(-) diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index d6a68d0dc..0970aeee0 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -181,6 +181,52 @@ %s (BDS) + + + en_US:TrySuppressingImeSwitcher,AsciiCapable,SupportTouchPositionCorrection + qwerty + en_GB:TrySuppressingImeSwitcher,AsciiCapable,SupportTouchPositionCorrection + qwerty + ar:SupportTouchPositionCorrection + arabic + cs:AsciiCapable,SupportTouchPositionCorrection + qwertz + da:AsciiCapable,SupportTouchPositionCorrection + nordic + de:AsciiCapable,SupportTouchPositionCorrection + qwertz + es:AsciiCapable,SupportTouchPositionCorrection + spanish + fi:AsciiCapable,SupportTouchPositionCorrection + nordic + fr:AsciiCapable,SupportTouchPositionCorrection + azerty + fr_CA:AsciiCapable,SupportTouchPositionCorrection + qwerty + hr:AsciiCapable,SupportTouchPositionCorrection + qwertz + hu:AsciiCapable,SupportTouchPositionCorrection + qwertz + it:AsciiCapable,SupportTouchPositionCorrection + qwerty + iw:SupportTouchPositionCorrection + hebrew + nb:AsciiCapable,SupportTouchPositionCorrection + nordic + nl:AsciiCapable,SupportTouchPositionCorrection + qwerty + pl:AsciiCapable,SupportTouchPositionCorrection + qwerty + ru:SupportTouchPositionCorrection + east_slavic + sr:SupportTouchPositionCorrection + south_slavic + sv:AsciiCapable,SupportTouchPositionCorrection + nordic + tr:AsciiCapable,SupportTouchPositionCorrection + qwerty + + com.google.android.inputmethod.latin.dictionarypack com.google.android.inputmethod.latin.dictionarypack.DictionarySettingsActivity diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 07bff098b..7f8a23a0e 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -76,19 +76,19 @@ android:label="@string/subtype_en_US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" - android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,TrySuppressingImeSwitcher,AsciiCapable" + android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable,SupportTouchPositionCorrection" /> sExceptionalDisplayNamesMap = new HashMap(); + // Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value. + // This is for compatibility to keep the same subtype ids as pre-JellyBean. + private static final HashMap sLocaleAndExtraValueToKeyboardLayoutSetMap = + new HashMap(); private SubtypeLocale() { // Intentional empty constructor for utility class. @@ -97,6 +101,14 @@ public class SubtypeLocale { final int resId = res.getIdentifier(resourceName, null, RESOURCE_PACKAGE_NAME); sExceptionalLocaleToWithLayoutNameIdsMap.put(localeString, resId); } + + final String[] keyboardLayoutSetMap = res.getStringArray( + R.array.locale_and_extra_value_to_keyboard_layout_set_map); + for (int i = 0; i < keyboardLayoutSetMap.length; i += 2) { + final String key = keyboardLayoutSetMap[i]; + final String keyboardLayoutSet = keyboardLayoutSetMap[i + 1]; + sLocaleAndExtraValueToKeyboardLayoutSetMap.put(key, keyboardLayoutSet); + } } public static String[] getPredefinedKeyboardLayoutSet() { @@ -193,7 +205,14 @@ public class SubtypeLocale { } public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) { - final String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET); + String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET); + if (keyboardLayoutSet == null) { + // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard + // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with + // pre-JellyBean. + final String key = subtype.getLocale() + ":" + subtype.getExtraValue(); + keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key); + } // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is // fixed. if (keyboardLayoutSet == null) {