Merge "Initialize SubtypeLocale from Settings"
This commit is contained in:
commit
92d2f7e03b
2 changed files with 11 additions and 1 deletions
|
@ -111,6 +111,10 @@ public class Settings extends InputMethodSettingsFragment
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
|
||||||
|
// When we are called from the Settings application but we are not already running, the
|
||||||
|
// {@link SubtypeLocale} class may not have been initialized. It is safe to call
|
||||||
|
// {@link SubtypeLocale#init(Context)} multiple times.
|
||||||
|
SubtypeLocale.init(context);
|
||||||
mVoicePreference = (ListPreference) findPreference(PREF_VOICE_MODE);
|
mVoicePreference = (ListPreference) findPreference(PREF_VOICE_MODE);
|
||||||
mShowCorrectionSuggestionsPreference =
|
mShowCorrectionSuggestionsPreference =
|
||||||
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
|
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class SubtypeLocale {
|
||||||
public static final String QWERTY = "qwerty";
|
public static final String QWERTY = "qwerty";
|
||||||
public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic;
|
public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic;
|
||||||
|
|
||||||
|
private static boolean sInitialized = false;
|
||||||
private static String[] sPredefinedKeyboardLayoutSet;
|
private static String[] sPredefinedKeyboardLayoutSet;
|
||||||
// Keyboard layout to its display name map.
|
// Keyboard layout to its display name map.
|
||||||
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
|
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
|
||||||
|
@ -69,7 +70,10 @@ public class SubtypeLocale {
|
||||||
// Intentional empty constructor for utility class.
|
// Intentional empty constructor for utility class.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
// Note that this initialization method can be called multiple times.
|
||||||
|
public static synchronized void init(Context context) {
|
||||||
|
if (sInitialized) return;
|
||||||
|
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
|
|
||||||
final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts);
|
final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts);
|
||||||
|
@ -109,6 +113,8 @@ public class SubtypeLocale {
|
||||||
final String keyboardLayoutSet = keyboardLayoutSetMap[i + 1];
|
final String keyboardLayoutSet = keyboardLayoutSetMap[i + 1];
|
||||||
sLocaleAndExtraValueToKeyboardLayoutSetMap.put(key, keyboardLayoutSet);
|
sLocaleAndExtraValueToKeyboardLayoutSetMap.put(key, keyboardLayoutSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getPredefinedKeyboardLayoutSet() {
|
public static String[] getPredefinedKeyboardLayoutSet() {
|
||||||
|
|
Loading…
Reference in a new issue