summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/inputmethod
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-06-13 15:24:12 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-13 15:24:12 -0700
commite5147e4933e61c762f63b115e41c5aa8a2e37bd4 (patch)
treeb318fc199af25063bdef878ffca6b3b888c2a2fe /src/com/android/settings/inputmethod
parent5b97798cbd2cad3448a9adec8f4cc249e95e5de7 (diff)
parent5b7a8204d875c901782ff482b68fde8da7a0081f (diff)
downloadpackages_apps_settings-e5147e4933e61c762f63b115e41c5aa8a2e37bd4.zip
packages_apps_settings-e5147e4933e61c762f63b115e41c5aa8a2e37bd4.tar.gz
packages_apps_settings-e5147e4933e61c762f63b115e41c5aa8a2e37bd4.tar.bz2
am 5b7a8204: Merge "Show only the language if there\'s only one locale for the language." into jb-dev
* commit '5b7a8204d875c901782ff482b68fde8da7a0081f': Show only the language if there's only one locale for the language.
Diffstat (limited to 'src/com/android/settings/inputmethod')
-rw-r--r--src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index 5459275..c2ff0d9 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -29,6 +29,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
@@ -230,10 +231,23 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
if (!mIsOnlyImeSettings) {
if (mLanguagePref != null) {
Configuration conf = getResources().getConfiguration();
- String locale = conf.locale.getDisplayName(conf.locale);
- if (locale != null && locale.length() > 1) {
- locale = Character.toUpperCase(locale.charAt(0)) + locale.substring(1);
- mLanguagePref.setSummary(locale);
+ String language = conf.locale.getLanguage();
+ String localeString;
+ // TODO: This is not an accurate way to display the locale, as it is
+ // just working around the fact that we support limited dialects
+ // and want to pretend that the language is valid for all locales.
+ // We need a way to support languages that aren't tied to a particular
+ // locale instead of hiding the locale qualifier.
+ if (hasOnlyOneLanguageInstance(language,
+ Resources.getSystem().getAssets().getLocales())) {
+ localeString = conf.locale.getDisplayLanguage(conf.locale);
+ } else {
+ localeString = conf.locale.getDisplayName(conf.locale);
+ }
+ if (localeString.length() > 1) {
+ localeString = Character.toUpperCase(localeString.charAt(0))
+ + localeString.substring(1);
+ mLanguagePref.setSummary(localeString);
}
}
@@ -324,6 +338,20 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
+ private boolean hasOnlyOneLanguageInstance(String languageCode, String[] locales) {
+ int count = 0;
+ for (String localeCode : locales) {
+ if (localeCode.length() > 2
+ && localeCode.startsWith(languageCode)) {
+ count++;
+ if (count > 1) {
+ return false;
+ }
+ }
+ }
+ return count == 1;
+ }
+
private void saveInputMethodSelectorVisibility(String value) {
try {
int intValue = Integer.valueOf(value);