diff options
author | 2014-10-02 09:20:04 +0000 | |
---|---|---|
committer | 2014-10-02 09:20:04 +0000 | |
commit | 371d76ff070ab962c9ab58588839965db36fdf13 (patch) | |
tree | 1e0efe8aef1a463a9a7a64bb408940fc66ab097c /java/src/com/android/inputmethod/latin/DictionaryFacilitator.java | |
parent | 7e5614520a581afa79a51677e973a9ff6dc29162 (diff) | |
parent | 1c0876dc49eee44170cb86ba3d78e759d5bbd573 (diff) | |
download | latinime-371d76ff070ab962c9ab58588839965db36fdf13.tar.gz latinime-371d76ff070ab962c9ab58588839965db36fdf13.tar.xz latinime-371d76ff070ab962c9ab58588839965db36fdf13.zip |
Merge "[ML12] Add a getPrimaryLocale function and some refactoring"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/DictionaryFacilitator.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/DictionaryFacilitator.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java index 6dc1e8273..1f0317288 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java @@ -99,6 +99,30 @@ public class DictionaryFacilitator { DICT_TYPES_ORDERED_TO_GET_SUGGESTIONS.length); /** + * Returns whether this facilitator is exactly for this list of locales. + * @param locales the list of locales to test against + * @return true if this facilitator handles exactly this list of locales, false otherwise + */ + public boolean isForLocales(final Locale[] locales) { + if (locales.length != mDictionaryGroups.length) { + return false; + } + for (final Locale locale : locales) { + boolean found = false; + for (final DictionaryGroup group : mDictionaryGroups) { + if (locale.equals(group.mLocale)) { + found = true; + break; + } + } + if (!found) { + return false; + } + } + return true; + } + + /** * A group of dictionaries that work together for a single language. */ private static class DictionaryGroup { @@ -199,6 +223,18 @@ public class DictionaryFacilitator { return mDictionaryGroups[0].mLocale; } + /** + * Returns the primary locale among all currently active locales. BE CAREFUL using this. + * + * DO NOT USE THIS just because it's convenient. Use it when it's correct, for example when + * choosing what dictionary to put a word in, or when changing the capitalization of a typed + * string. + * @return the primary active locale + */ + public Locale getPrimaryLocale() { + return mDictionaryGroups[0].mLocale; + } + private static ExpandableBinaryDictionary getSubDict(final String dictType, final Context context, final Locale locale, final File dictFile, final String dictNamePrefix) { |