diff options
author | 2012-06-28 12:03:11 +0900 | |
---|---|---|
committer | 2012-06-28 13:44:09 +0900 | |
commit | 7f7947c97b141cbb338c5164e9e19d1ac9ff3d1c (patch) | |
tree | 5c2fef3d4e9ae6025b8f7cf32f180773d9237058 /java/src/com | |
parent | 04f0b2113d82e755dc0d31a9547fb30d317ceac3 (diff) | |
download | latinime-7f7947c97b141cbb338c5164e9e19d1ac9ff3d1c.tar.gz latinime-7f7947c97b141cbb338c5164e9e19d1ac9ff3d1c.tar.xz latinime-7f7947c97b141cbb338c5164e9e19d1ac9ff3d1c.zip |
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
Diffstat (limited to 'java/src/com')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeLocale.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java index ca293060a..acc17ef3f 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java +++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java @@ -60,6 +60,10 @@ public class SubtypeLocale { // Exceptional locales to display name map. private static final HashMap<String, String> sExceptionalDisplayNamesMap = new HashMap<String, String>(); + // 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<String,String> sLocaleAndExtraValueToKeyboardLayoutSetMap = + new HashMap<String,String>(); 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) { |