diff options
author | 2011-05-12 19:19:20 +0900 | |
---|---|---|
committer | 2011-05-13 16:21:27 +0900 | |
commit | 795fc1a47befa7e9cfe87b8ff1fe31152c182654 (patch) | |
tree | ae4457424396c09ddd96305b837452a1cbabdbf1 /java/src | |
parent | c741398f36db3cf1c32d4189f270ad5ce9233725 (diff) | |
download | latinime-795fc1a47befa7e9cfe87b8ff1fe31152c182654.tar.gz latinime-795fc1a47befa7e9cfe87b8ff1fe31152c182654.tar.xz latinime-795fc1a47befa7e9cfe87b8ff1fe31152c182654.zip |
Do not merge. Fix the list of supported languages
Bug: 4390528
Change-Id: I5a9444d9addd6185d2633ab021702f7d0241c6b2
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/InputLanguageSelection.java | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java index e811a2cdd..c32713983 100644 --- a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java +++ b/java/src/com/android/inputmethod/latin/InputLanguageSelection.java @@ -36,10 +36,20 @@ public class InputLanguageSelection extends PreferenceActivity { private String mSelectedLanguages; 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> { static Collator sCollator = Collator.getInstance(); @@ -157,35 +167,41 @@ public class InputLanguageSelection extends PreferenceActivity { for (int i = 0 ; i < origSize; i++ ) { String s = locales[i]; int len = s.length(); + final Locale l; + final String language; if (len == 5) { - String language = s.substring(0, 2); + language = s.substring(0, 2); String country = s.substring(3, 5); - Locale l = new Locale(language, country); - - // Exclude languages that are not relevant to LatinIME - if (arrayContains(BLACKLIST_LANGUAGES, language)) continue; - - if (finalSize == 0) { + 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 + if (!isWhitelisted(s)) continue; + + if (finalSize == 0) { + preprocess[finalSize++] = + new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName(l)), l); + } else { + // check previous entry: + // same lang and a country -> upgrade to full name and + // insert ours with full name + // diff lang -> insert ours with lang-only name + if (preprocess[finalSize-1].locale.getLanguage().equals( + language)) { + preprocess[finalSize-1].label = LanguageSwitcher.toTitleCase( + preprocess[finalSize-1].locale.getDisplayName()); preprocess[finalSize++] = - new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName(l)), l); + new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName()), l); } else { - // check previous entry: - // same lang and a country -> upgrade to full name and - // insert ours with full name - // diff lang -> insert ours with lang-only name - if (preprocess[finalSize-1].locale.getLanguage().equals( - language)) { - preprocess[finalSize-1].label = LanguageSwitcher.toTitleCase( - preprocess[finalSize-1].locale.getDisplayName()); - preprocess[finalSize++] = - new Loc(LanguageSwitcher.toTitleCase(l.getDisplayName()), l); + String displayName; + if (s.equals("zz_ZZ")) { } else { - String displayName; - if (s.equals("zz_ZZ")) { - } else { - displayName = LanguageSwitcher.toTitleCase(l.getDisplayName(l)); - preprocess[finalSize++] = new Loc(displayName, l); - } + displayName = LanguageSwitcher.toTitleCase(l.getDisplayName(l)); + preprocess[finalSize++] = new Loc(displayName, l); } } } @@ -195,11 +211,4 @@ public class InputLanguageSelection extends PreferenceActivity { } 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; - } } |