From ca934420269e18c843181c0dc98cd61cce67dd19 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sat, 5 May 2012 16:33:51 +0900 Subject: Fix newly created custom input style display name This will revert I4263632e Bug: 6443665 Bug: 6410653 Change-Id: Id9ad1a204ed9802488abfc2c536a95d62d55afe0 --- .../android/inputmethod/latin/SubtypeLocale.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java index 7694b56fc..b7e488410 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java +++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java @@ -20,6 +20,7 @@ import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOAR import android.content.Context; import android.content.res.Resources; +import android.util.Log; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.latin.LocaleUtils.RunInLocale; @@ -28,7 +29,7 @@ import java.util.HashMap; import java.util.Locale; public class SubtypeLocale { - private static final String TAG = SubtypeLocale.class.getSimpleName(); + static final String TAG = SubtypeLocale.class.getSimpleName(); // This class must be located in the same package as LatinIME.java. private static final String RESOURCE_PACKAGE_NAME = DictionaryFactory.class.getPackage().getName(); @@ -38,7 +39,6 @@ public class SubtypeLocale { public static final String QWERTY = "qwerty"; public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic; - private static Context sContext; private static String[] sPredefinedKeyboardLayoutSet; // Keyboard layout to its display name map. private static final HashMap sKeyboardKayoutToDisplayNameMap = @@ -59,7 +59,6 @@ public class SubtypeLocale { } public static void init(Context context) { - sContext = context; final Resources res = context.getResources(); final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts); @@ -129,16 +128,23 @@ public class SubtypeLocale { // en_US azerty T English (US) (AZERTY) // zz azerty T No language (AZERTY) in system locale - public static String getSubtypeDisplayName(InputMethodSubtype subtype, Resources res) { - // TODO: Remove this check when InputMethodManager.getLastInputMethodSubtype is - // fixed. - if (!ImfUtils.checkIfSubtypeBelongsToThisIme(sContext, subtype)) return ""; + public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) { final String language = getSubtypeLocaleDisplayName(subtype.getLocale()); final int nameResId = subtype.getNameResId(); final RunInLocale getSubtypeName = new RunInLocale() { @Override protected String job(Resources res) { - return res.getString(nameResId, language); + try { + return res.getString(nameResId, language); + } catch (Resources.NotFoundException e) { + // TODO: Remove this catch when InputMethodManager.getCurrentInputMethodSubtype + // is fixed. + Log.w(TAG, "Unknown subtype: mode=" + subtype.getMode() + + " locale=" + subtype.getLocale() + + " extra=" + subtype.getExtraValue() + + "\n" + Utils.getStackTrace()); + return ""; + } } }; final Locale locale = isNoLanguage(subtype) -- cgit v1.2.3-83-g751a