am 0ab1c664: Avoid Resources
* commit '0ab1c664c138b3bc10730c89b2d8efdacee6b15b': Avoid Resources$NotFoundExceptionmain
commit
a278bca57e
|
@ -66,6 +66,7 @@ public class ImfUtils {
|
|||
public static boolean checkIfSubtypeBelongsToThisIme(Context context, InputMethodSubtype ims) {
|
||||
final InputMethodInfo myImi = getInputMethodInfoOfThisIme(context);
|
||||
final InputMethodManager imm = getInputMethodManager(context);
|
||||
// TODO: Cache all subtypes of this IME for optimization
|
||||
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(myImi, true);
|
||||
for (final InputMethodSubtype subtype : subtypes) {
|
||||
if (subtype.equals(ims)) {
|
||||
|
|
|
@ -33,11 +33,10 @@ public class SubtypeLocale {
|
|||
|
||||
// Special language code to represent "no language".
|
||||
public static final String NO_LANGUAGE = "zz";
|
||||
|
||||
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<String, String> sKeyboardKayoutToDisplayNameMap =
|
||||
|
@ -58,6 +57,7 @@ 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);
|
||||
|
@ -128,6 +128,9 @@ public class SubtypeLocale {
|
|||
// zz azerty T No language (AZERTY)
|
||||
|
||||
public static String getSubtypeDisplayName(InputMethodSubtype subtype, Resources res) {
|
||||
// TODO: Remove this check when InputMethodManager.getLastInputMethodSubtype is
|
||||
// fixed.
|
||||
if (!ImfUtils.checkIfSubtypeBelongsToThisIme(sContext, subtype)) return "";
|
||||
final String language = getSubtypeLocaleDisplayName(subtype.getLocale());
|
||||
return res.getString(subtype.getNameResId(), language);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue