Do not merge. Fix the list of supported languages
Bug: 4390528 Change-Id: I5a9444d9addd6185d2633ab021702f7d0241c6b2
This commit is contained in:
parent
c741398f36
commit
795fc1a47b
1 changed files with 41 additions and 32 deletions
|
@ -36,10 +36,20 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
|
|
||||||
private String mSelectedLanguages;
|
private String mSelectedLanguages;
|
||||||
private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>();
|
private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>();
|
||||||
private static final String[] BLACKLIST_LANGUAGES = {
|
|
||||||
"ko", "ja", "zh", "el"
|
private static final String[] WHITELIST_LANGUAGES = {
|
||||||
|
"cs", "da", "de", "en_GB", "en_US", "es", "es_US", "fr", "it", "nb", "nl", "pl", "pt", "ru"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static boolean isWhitelisted(String lang) {
|
||||||
|
for (String s : WHITELIST_LANGUAGES) {
|
||||||
|
if (s.equalsIgnoreCase(lang)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static class Loc implements Comparable<Object> {
|
private static class Loc implements Comparable<Object> {
|
||||||
static Collator sCollator = Collator.getInstance();
|
static Collator sCollator = Collator.getInstance();
|
||||||
|
|
||||||
|
@ -157,13 +167,20 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
for (int i = 0 ; i < origSize; i++ ) {
|
for (int i = 0 ; i < origSize; i++ ) {
|
||||||
String s = locales[i];
|
String s = locales[i];
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
final Locale l;
|
||||||
|
final String language;
|
||||||
if (len == 5) {
|
if (len == 5) {
|
||||||
String language = s.substring(0, 2);
|
language = s.substring(0, 2);
|
||||||
String country = s.substring(3, 5);
|
String country = s.substring(3, 5);
|
||||||
Locale l = new Locale(language, country);
|
l = new Locale(language, country);
|
||||||
|
} else if (len == 2) {
|
||||||
|
language = s;
|
||||||
|
l = new Locale(language);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Exclude languages that are not relevant to LatinIME
|
// Exclude languages that are not relevant to LatinIME
|
||||||
if (arrayContains(BLACKLIST_LANGUAGES, language)) continue;
|
if (!isWhitelisted(s)) continue;
|
||||||
|
|
||||||
if (finalSize == 0) {
|
if (finalSize == 0) {
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
|
@ -189,17 +206,9 @@ public class InputLanguageSelection extends PreferenceActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (int i = 0; i < finalSize ; i++) {
|
for (int i = 0; i < finalSize ; i++) {
|
||||||
uniqueLocales.add(preprocess[i]);
|
uniqueLocales.add(preprocess[i]);
|
||||||
}
|
}
|
||||||
return uniqueLocales;
|
return uniqueLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean arrayContains(String[] array, String value) {
|
|
||||||
for (int i = 0; i < array.length; i++) {
|
|
||||||
if (array[i].equalsIgnoreCase(value)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue