aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-07-05 02:04:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-05 02:04:35 -0700
commit92d2f7e03b9fb0487c64cb3b7b958768066640f6 (patch)
tree95661659d3652287b2c3dfb40c83a19fc44779ab /java/src
parent792e7ddc2493f700852f8a37dd81cdb0157c136b (diff)
parentd6ac0443f0250281872fd889c81d8cbd71e72736 (diff)
downloadlatinime-92d2f7e03b9fb0487c64cb3b7b958768066640f6.tar.gz
latinime-92d2f7e03b9fb0487c64cb3b7b958768066640f6.tar.xz
latinime-92d2f7e03b9fb0487c64cb3b7b958768066640f6.zip
Merge "Initialize SubtypeLocale from Settings"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java8
2 files changed, 11 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 4c89a6e91..70acdc771 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -111,6 +111,10 @@ public class Settings extends InputMethodSettingsFragment
final Resources res = getResources();
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);
mShowCorrectionSuggestionsPreference =
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index acc17ef3f..21c9c0d1e 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -41,6 +41,7 @@ public class SubtypeLocale {
public static final String QWERTY = "qwerty";
public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic;
+ private static boolean sInitialized = false;
private static String[] sPredefinedKeyboardLayoutSet;
// Keyboard layout to its display name map.
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
@@ -69,7 +70,10 @@ public class SubtypeLocale {
// 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 String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts);
@@ -109,6 +113,8 @@ public class SubtypeLocale {
final String keyboardLayoutSet = keyboardLayoutSetMap[i + 1];
sLocaleAndExtraValueToKeyboardLayoutSetMap.put(key, keyboardLayoutSet);
}
+
+ sInitialized = true;
}
public static String[] getPredefinedKeyboardLayoutSet() {