diff options
author | 2011-01-14 05:25:47 -0800 | |
---|---|---|
committer | 2011-01-14 05:25:47 -0800 | |
commit | 5a88787e674a2079f964f5ffaca7ae01cf979600 (patch) | |
tree | 34c530011b6593dd3ae462244cd6697a613bc7eb /java/src | |
parent | c99c0ed939bb441a4ee7b2c3eb643620f3dbce28 (diff) | |
parent | e276d8ddaaff91d5940a71cefb5ecd94fd48ba98 (diff) | |
download | latinime-5a88787e674a2079f964f5ffaca7ae01cf979600.tar.gz latinime-5a88787e674a2079f964f5ffaca7ae01cf979600.tar.xz latinime-5a88787e674a2079f964f5ffaca7ae01cf979600.zip |
Merge "Add SubtypeLocale class" into honeycomb
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeLocale.java | 46 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 4 |
2 files changed, 49 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java new file mode 100644 index 000000000..917521c40 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin; + +import android.content.Context; +import android.content.res.Resources; + +import java.util.Locale; + +public class SubtypeLocale { + private static String[] sExceptionKeys; + private static String[] sExceptionValues; + + private SubtypeLocale() { + // Intentional empty constructor for utility class. + } + + public static void init(Context context) { + final Resources res = context.getResources(); + sExceptionKeys = res.getStringArray(R.array.subtype_locale_exception_keys); + sExceptionValues = res.getStringArray(R.array.subtype_locale_exception_values); + } + + public static String getFullDisplayName(Locale locale) { + String localeCode = locale.toString(); + for (int index = 0; index < sExceptionKeys.length; index++) { + if (sExceptionKeys[index].equals(localeCode)) + return sExceptionValues[index]; + } + return locale.getDisplayName(locale); + } +} diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 91044685e..f04f3efe7 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -83,6 +83,8 @@ public class SubtypeSwitcher { sInstance.mPrefs = prefs; sInstance.resetParams(service); sInstance.updateAllParameters(); + + SubtypeLocale.init(service); } private SubtypeSwitcher() { @@ -430,7 +432,7 @@ public class SubtypeSwitcher { public static String getFullDisplayName(Locale locale, boolean returnsNameInThisLocale) { if (returnsNameInThisLocale) { - return toTitleCase(locale.getDisplayName(locale)); + return toTitleCase(SubtypeLocale.getFullDisplayName(locale)); } else { return toTitleCase(locale.getDisplayName()); } |