Merge change 1099 into donut

* changes:
  Fix Phone-based locale selection to never choose a lang-only locale.
This commit is contained in:
Android (Google) Code Review
2009-05-06 14:06:08 -07:00

View File

@@ -490,7 +490,7 @@ public abstract class PhoneBase implements Phone {
if (null == language) { if (null == language) {
return; // no match possible return; // no match possible
} }
language.toLowerCase(); language = language.toLowerCase();
if (null == country) { if (null == country) {
country = ""; country = "";
} }
@@ -503,13 +503,12 @@ public abstract class PhoneBase implements Phone {
final int N = locales.length; final int N = locales.length;
String bestMatch = null; String bestMatch = null;
for(int i = 0; i < N; i++) { for(int i = 0; i < N; i++) {
if (locales[i]!=null && locales[i].length() >= 2 && // only match full (lang + country) locales
if (locales[i]!=null && locales[i].length() >= 5 &&
locales[i].substring(0,2).equals(language)) { locales[i].substring(0,2).equals(language)) {
if (locales[i].length() >= 5) { if (locales[i].substring(3,5).equals(country)) {
if (locales[i].substring(3,5).equals(country)) { bestMatch = locales[i];
bestMatch = locales[i]; break;
break;
}
} else if (null == bestMatch) { } else if (null == bestMatch) {
bestMatch = locales[i]; bestMatch = locales[i];
} }
@@ -518,12 +517,8 @@ public abstract class PhoneBase implements Phone {
if (null != bestMatch) { if (null != bestMatch) {
IActivityManager am = ActivityManagerNative.getDefault(); IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration(); Configuration config = am.getConfiguration();
if (bestMatch.length() >= 5) { config.locale = new Locale(bestMatch.substring(0,2),
config.locale = new Locale(bestMatch.substring(0,2), bestMatch.substring(3,5));
bestMatch.substring(3,5));
} else {
config.locale = new Locale(bestMatch.substring(0,2));
}
config.userSetLocale = true; config.userSetLocale = true;
am.updateConfiguration(config); am.updateConfiguration(config);
} }