diff options
author | 2014-10-16 09:23:16 +0000 | |
---|---|---|
committer | 2014-10-16 09:23:16 +0000 | |
commit | ffe2c54cc51274bf5b363fd9a38ff8854a5484b4 (patch) | |
tree | 4237c01dbc73f4943ea0963cd5106fab5441de13 /java | |
parent | 31b7b4c889df0fd863a83e4f9b5d9978ba000526 (diff) | |
parent | 544da4a2ea4ce9dbad24f8ed55c29276033d47b2 (diff) | |
download | latinime-ffe2c54cc51274bf5b363fd9a38ff8854a5484b4.tar.gz latinime-ffe2c54cc51274bf5b363fd9a38ff8854a5484b4.tar.xz latinime-ffe2c54cc51274bf5b363fd9a38ff8854a5484b4.zip |
am 544da4a2: Merge "[ML25] Add an hasDict method."
* commit '544da4a2ea4ce9dbad24f8ed55c29276033d47b2':
[ML25] Add an hasDict method.
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputMethodManager.java | 6 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java index b0c0725bb..e6df35bea 100644 --- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java +++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java @@ -52,7 +52,7 @@ public class RichInputMethodManager { private static final RichInputMethodManager sInstance = new RichInputMethodManager(); - private Resources mResources; + private Context mContext; private InputMethodManagerCompatWrapper mImmWrapper; private InputMethodInfoCache mInputMethodInfoCache; final HashMap<InputMethodInfo, List<InputMethodSubtype>> @@ -86,7 +86,7 @@ public class RichInputMethodManager { return; } mImmWrapper = new InputMethodManagerCompatWrapper(context); - mResources = context.getResources(); + mContext = context; mInputMethodInfoCache = new InputMethodInfoCache( mImmWrapper.mImm, context.getPackageName()); @@ -309,7 +309,7 @@ public class RichInputMethodManager { public RichInputMethodSubtype createCurrentRichInputMethodSubtype( final InputMethodSubtype rawSubtype) { return AdditionalFeaturesSettingUtils.createRichInputMethodSubtype(this, rawSubtype, - mResources); + mContext); } public boolean hasMultipleEnabledIMEsOrSubtypes(final boolean shouldIncludeAuxiliarySubtypes) { diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index 249478785..e29aabacd 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -230,6 +230,7 @@ public class DictionaryInfoUtils { /** * Helper method to return a dictionary res id for a locale, or 0 if none. + * @param res resources for the app * @param locale dictionary locale * @return main dictionary resource id */ @@ -258,6 +259,7 @@ public class DictionaryInfoUtils { /** * Returns a main dictionary resource id + * @param res resources for the app * @param locale dictionary locale * @return main dictionary resource id */ @@ -283,6 +285,25 @@ public class DictionaryInfoUtils { BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR + locale.getLanguage().toString(); } + /** + * Returns whether a main dictionary is readily available for this locale. + * + * This does not query the content provider. + * + * @param context context to open files upon + * @param locale dictionary locale + * @return true if a dictionary is available right away, false otherwise + */ + public static boolean hasReadilyAvailableMainDictionaryForLocale(final Context context, + final Locale locale) { + final Resources res = context.getResources(); + if (0 != getMainDictionaryResourceIdIfAvailableForLocale(res, locale)) { + return true; + } + final String fileName = getCacheFileName(getMainDictId(locale), locale.toString(), context); + return new File(fileName).exists(); + } + public static DictionaryHeader getDictionaryFileHeaderOrNull(final File file) { return getDictionaryFileHeaderOrNull(file, 0, file.length()); } |