Loading java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +3 −3 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype, final int width) { // Choose appropriate language name to fit into the width. final String fullText = getFullDisplayName(subtype, getResources()); final String fullText = getFullDisplayName(subtype); if (fitsTextIntoWidth(width, fullText, paint)) { return fullText; } Loading Loading @@ -1445,12 +1445,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack // zz azerty T AZERTY AZERTY // Get InputMethodSubtype's full display name in its locale. static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) { static String getFullDisplayName(final InputMethodSubtype subtype) { if (SubtypeLocale.isNoLanguage(subtype)) { return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype); } return SubtypeLocale.getSubtypeDisplayName(subtype, res); return SubtypeLocale.getSubtypeDisplayName(subtype); } // Get InputMethodSubtype's short display name in its locale. Loading java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java +3 −4 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { if (DEBUG_SUBTYPE_ID) { android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s", subtype.getLocale(), subtype.hashCode(), subtype.hashCode(), SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources()))); SubtypeLocale.getSubtypeDisplayName(subtype))); } if (subtype.containsExtraValueKey(ASCII_CAPABLE)) { items.add(createItem(context, subtype.getLocale())); Loading Loading @@ -205,8 +205,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { setDialogTitle(R.string.add_style); setKey(KEY_NEW_SUBTYPE); } else { final String displayName = SubtypeLocale.getSubtypeDisplayName( subtype, getContext().getResources()); final String displayName = SubtypeLocale.getSubtypeDisplayName(subtype); setTitle(displayName); setDialogTitle(displayName); setKey(KEY_PREFIX + subtype.getLocale() + "_" Loading Loading @@ -498,7 +497,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { final Context context = getActivity(); final Resources res = context.getResources(); final String message = res.getString(R.string.custom_input_style_already_exists, SubtypeLocale.getSubtypeDisplayName(subtype, res)); SubtypeLocale.getSubtypeDisplayName(subtype)); Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } Loading java/src/com/android/inputmethod/latin/SettingsFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment final StringBuilder styles = new StringBuilder(); for (final InputMethodSubtype subtype : subtypes) { if (styles.length() > 0) styles.append(", "); styles.append(SubtypeLocale.getSubtypeDisplayName(subtype, res)); styles.append(SubtypeLocale.getSubtypeDisplayName(subtype)); } customInputStyles.setSummary(styles); } Loading java/src/com/android/inputmethod/latin/SubtypeLocale.java +25 −18 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public final class SubtypeLocale { public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic; private static boolean sInitialized = false; private static Resources sResources; private static String[] sPredefinedKeyboardLayoutSet; // Keyboard layout to its display name map. private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = Loading Loading @@ -71,10 +72,11 @@ public final class SubtypeLocale { } // Note that this initialization method can be called multiple times. public static synchronized void init(Context context) { public static synchronized void init(final Context context) { if (sInitialized) return; final Resources res = context.getResources(); sResources = res; final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts); sPredefinedKeyboardLayoutSet = predefinedLayoutSet; Loading Loading @@ -121,15 +123,15 @@ public final class SubtypeLocale { return sPredefinedKeyboardLayoutSet; } public static boolean isExceptionalLocale(String localeString) { public static boolean isExceptionalLocale(final String localeString) { return sExceptionalLocaleToWithLayoutNameIdsMap.containsKey(localeString); } private static final String getNoLanguageLayoutKey(String keyboardLayoutName) { private static final String getNoLanguageLayoutKey(final String keyboardLayoutName) { return NO_LANGUAGE + "_" + keyboardLayoutName; } public static int getSubtypeNameId(String localeString, String keyboardLayoutName) { public static int getSubtypeNameId(final String localeString, final String keyboardLayoutName) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && isExceptionalLocale(localeString)) { return sExceptionalLocaleToWithLayoutNameIdsMap.get(localeString); Loading @@ -141,7 +143,7 @@ public final class SubtypeLocale { return nameId == null ? UNKNOWN_KEYBOARD_LAYOUT : nameId; } public static String getSubtypeLocaleDisplayName(String localeString) { public static String getSubtypeLocaleDisplayName(final String localeString) { final String exceptionalValue = sExceptionalDisplayNamesMap.get(localeString); if (exceptionalValue != null) { return exceptionalValue; Loading @@ -166,12 +168,17 @@ public final class SubtypeLocale { // en_US azerty T English (US) (AZERTY) // zz azerty T No language (AZERTY) in system locale public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) { final String replacementString = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) ? subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME) : getSubtypeLocaleDisplayName(subtype.getLocale()); private static String getReplacementString(final InputMethodSubtype subtype) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) { return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME); } else { return getSubtypeLocaleDisplayName(subtype.getLocale()); } } public static String getSubtypeDisplayName(final InputMethodSubtype subtype) { final String replacementString = getReplacementString(subtype); final int nameResId = subtype.getNameResId(); final RunInLocale<String> getSubtypeName = new RunInLocale<String>() { @Override Loading @@ -190,30 +197,30 @@ public final class SubtypeLocale { } }; final Locale locale = isNoLanguage(subtype) ? res.getConfiguration().locale : getSubtypeLocale(subtype); return getSubtypeName.runInLocale(res, locale); ? sResources.getConfiguration().locale : getSubtypeLocale(subtype); return getSubtypeName.runInLocale(sResources, locale); } public static boolean isNoLanguage(InputMethodSubtype subtype) { public static boolean isNoLanguage(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return localeString.equals(NO_LANGUAGE); } public static Locale getSubtypeLocale(InputMethodSubtype subtype) { public static Locale getSubtypeLocale(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return LocaleUtils.constructLocaleFromString(localeString); } public static String getKeyboardLayoutSetDisplayName(InputMethodSubtype subtype) { public static String getKeyboardLayoutSetDisplayName(final InputMethodSubtype subtype) { final String layoutName = getKeyboardLayoutSetName(subtype); return getKeyboardLayoutSetDisplayName(layoutName); } public static String getKeyboardLayoutSetDisplayName(String layoutName) { public static String getKeyboardLayoutSetDisplayName(final String layoutName) { return sKeyboardLayoutToDisplayNameMap.get(layoutName); } public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) { public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) { String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET); if (keyboardLayoutSet == null) { // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard Loading java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +1 −2 Original line number Diff line number Diff line Loading @@ -151,8 +151,7 @@ public final class SubtypeSwitcher { // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. public void onSubtypeChanged(final InputMethodSubtype newSubtype) { if (DBG) { Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName( newSubtype, mResources)); Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(newSubtype)); } final Locale newLocale = SubtypeLocale.getSubtypeLocale(newSubtype); Loading Loading
java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +3 −3 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype, final int width) { // Choose appropriate language name to fit into the width. final String fullText = getFullDisplayName(subtype, getResources()); final String fullText = getFullDisplayName(subtype); if (fitsTextIntoWidth(width, fullText, paint)) { return fullText; } Loading Loading @@ -1445,12 +1445,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack // zz azerty T AZERTY AZERTY // Get InputMethodSubtype's full display name in its locale. static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) { static String getFullDisplayName(final InputMethodSubtype subtype) { if (SubtypeLocale.isNoLanguage(subtype)) { return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype); } return SubtypeLocale.getSubtypeDisplayName(subtype, res); return SubtypeLocale.getSubtypeDisplayName(subtype); } // Get InputMethodSubtype's short display name in its locale. Loading
java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java +3 −4 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { if (DEBUG_SUBTYPE_ID) { android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s", subtype.getLocale(), subtype.hashCode(), subtype.hashCode(), SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources()))); SubtypeLocale.getSubtypeDisplayName(subtype))); } if (subtype.containsExtraValueKey(ASCII_CAPABLE)) { items.add(createItem(context, subtype.getLocale())); Loading Loading @@ -205,8 +205,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { setDialogTitle(R.string.add_style); setKey(KEY_NEW_SUBTYPE); } else { final String displayName = SubtypeLocale.getSubtypeDisplayName( subtype, getContext().getResources()); final String displayName = SubtypeLocale.getSubtypeDisplayName(subtype); setTitle(displayName); setDialogTitle(displayName); setKey(KEY_PREFIX + subtype.getLocale() + "_" Loading Loading @@ -498,7 +497,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment { final Context context = getActivity(); final Resources res = context.getResources(); final String message = res.getString(R.string.custom_input_style_already_exists, SubtypeLocale.getSubtypeDisplayName(subtype, res)); SubtypeLocale.getSubtypeDisplayName(subtype)); Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } Loading
java/src/com/android/inputmethod/latin/SettingsFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment final StringBuilder styles = new StringBuilder(); for (final InputMethodSubtype subtype : subtypes) { if (styles.length() > 0) styles.append(", "); styles.append(SubtypeLocale.getSubtypeDisplayName(subtype, res)); styles.append(SubtypeLocale.getSubtypeDisplayName(subtype)); } customInputStyles.setSummary(styles); } Loading
java/src/com/android/inputmethod/latin/SubtypeLocale.java +25 −18 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public final class SubtypeLocale { public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic; private static boolean sInitialized = false; private static Resources sResources; private static String[] sPredefinedKeyboardLayoutSet; // Keyboard layout to its display name map. private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = Loading Loading @@ -71,10 +72,11 @@ public final class SubtypeLocale { } // Note that this initialization method can be called multiple times. public static synchronized void init(Context context) { public static synchronized void init(final Context context) { if (sInitialized) return; final Resources res = context.getResources(); sResources = res; final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts); sPredefinedKeyboardLayoutSet = predefinedLayoutSet; Loading Loading @@ -121,15 +123,15 @@ public final class SubtypeLocale { return sPredefinedKeyboardLayoutSet; } public static boolean isExceptionalLocale(String localeString) { public static boolean isExceptionalLocale(final String localeString) { return sExceptionalLocaleToWithLayoutNameIdsMap.containsKey(localeString); } private static final String getNoLanguageLayoutKey(String keyboardLayoutName) { private static final String getNoLanguageLayoutKey(final String keyboardLayoutName) { return NO_LANGUAGE + "_" + keyboardLayoutName; } public static int getSubtypeNameId(String localeString, String keyboardLayoutName) { public static int getSubtypeNameId(final String localeString, final String keyboardLayoutName) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && isExceptionalLocale(localeString)) { return sExceptionalLocaleToWithLayoutNameIdsMap.get(localeString); Loading @@ -141,7 +143,7 @@ public final class SubtypeLocale { return nameId == null ? UNKNOWN_KEYBOARD_LAYOUT : nameId; } public static String getSubtypeLocaleDisplayName(String localeString) { public static String getSubtypeLocaleDisplayName(final String localeString) { final String exceptionalValue = sExceptionalDisplayNamesMap.get(localeString); if (exceptionalValue != null) { return exceptionalValue; Loading @@ -166,12 +168,17 @@ public final class SubtypeLocale { // en_US azerty T English (US) (AZERTY) // zz azerty T No language (AZERTY) in system locale public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) { final String replacementString = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) ? subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME) : getSubtypeLocaleDisplayName(subtype.getLocale()); private static String getReplacementString(final InputMethodSubtype subtype) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) { return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME); } else { return getSubtypeLocaleDisplayName(subtype.getLocale()); } } public static String getSubtypeDisplayName(final InputMethodSubtype subtype) { final String replacementString = getReplacementString(subtype); final int nameResId = subtype.getNameResId(); final RunInLocale<String> getSubtypeName = new RunInLocale<String>() { @Override Loading @@ -190,30 +197,30 @@ public final class SubtypeLocale { } }; final Locale locale = isNoLanguage(subtype) ? res.getConfiguration().locale : getSubtypeLocale(subtype); return getSubtypeName.runInLocale(res, locale); ? sResources.getConfiguration().locale : getSubtypeLocale(subtype); return getSubtypeName.runInLocale(sResources, locale); } public static boolean isNoLanguage(InputMethodSubtype subtype) { public static boolean isNoLanguage(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return localeString.equals(NO_LANGUAGE); } public static Locale getSubtypeLocale(InputMethodSubtype subtype) { public static Locale getSubtypeLocale(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return LocaleUtils.constructLocaleFromString(localeString); } public static String getKeyboardLayoutSetDisplayName(InputMethodSubtype subtype) { public static String getKeyboardLayoutSetDisplayName(final InputMethodSubtype subtype) { final String layoutName = getKeyboardLayoutSetName(subtype); return getKeyboardLayoutSetDisplayName(layoutName); } public static String getKeyboardLayoutSetDisplayName(String layoutName) { public static String getKeyboardLayoutSetDisplayName(final String layoutName) { return sKeyboardLayoutToDisplayNameMap.get(layoutName); } public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) { public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) { String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET); if (keyboardLayoutSet == null) { // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard Loading
java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +1 −2 Original line number Diff line number Diff line Loading @@ -151,8 +151,7 @@ public final class SubtypeSwitcher { // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. public void onSubtypeChanged(final InputMethodSubtype newSubtype) { if (DBG) { Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName( newSubtype, mResources)); Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(newSubtype)); } final Locale newLocale = SubtypeLocale.getSubtypeLocale(newSubtype); Loading