diff options
author | 2011-08-18 20:09:35 +0900 | |
---|---|---|
committer | 2011-08-18 20:09:35 +0900 | |
commit | ee7daefd972979898d91974ea0d92fcc9f3ca169 (patch) | |
tree | abcb282c77e9b24f428ecaa61dfcf5117ba64504 /java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java | |
parent | 89fdb827532f43a7121b200dc9a7c72815fb45fd (diff) | |
download | latinime-ee7daefd972979898d91974ea0d92fcc9f3ca169.tar.gz latinime-ee7daefd972979898d91974ea0d92fcc9f3ca169.tar.xz latinime-ee7daefd972979898d91974ea0d92fcc9f3ca169.zip |
Check the main dict id to be able to fallback.
Bug: 5095140
Change-Id: I02032923ca2a65bd8fbabc0abbe6a476f7542187
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index 18df797f0..5d2dab0a9 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -214,6 +214,13 @@ class BinaryDictionaryGetter { } /** + * Returns the id of the main dict for a specified locale. + */ + private static String getMainDictId(final Locale locale) { + return locale.toString(); + } + + /** * Returns a list of file addresses for a given locale, trying relevant methods in order. * * Tries to get binary dictionaries from various sources, in order: @@ -234,12 +241,18 @@ class BinaryDictionaryGetter { BinaryDictionaryFileDumper.cacheDictionariesFromContentProvider(locale, context); final File[] cachedDictionaryList = getCachedDictionaryList(locale, context); + final String mainDictId = getMainDictId(locale); + final DictPackSettings dictPackSettings = new DictPackSettings(context); + boolean foundMainDict = false; final ArrayList<AssetFileAddress> fileList = new ArrayList<AssetFileAddress>(); // cachedDictionaryList may not be null, see doc for getCachedDictionaryList for (final File f : cachedDictionaryList) { final String wordListId = getWordListIdFromFileName(f.getName()); + if (wordListId.equals(mainDictId)) { + foundMainDict = true; + } if (!dictPackSettings.isWordListActive(wordListId)) continue; if (f.canRead()) { fileList.add(AssetFileAddress.makeFromFileName(f.getPath())); @@ -248,14 +261,14 @@ class BinaryDictionaryGetter { } } - if (!fileList.isEmpty()) { - return fileList; + if (!foundMainDict && dictPackSettings.isWordListActive(mainDictId)) { + final AssetFileAddress fallbackAsset = loadFallbackResource(context, fallbackResId, + locale); + if (null != fallbackAsset) { + fileList.add(fallbackAsset); + } } - // If the list is empty, fall through and return the fallback - final AssetFileAddress fallbackAsset = loadFallbackResource(context, fallbackResId, - locale); - if (null == fallbackAsset) return null; - return Arrays.asList(fallbackAsset); + return fileList; } } |