diff options
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java index 308b123e1..659fe5c51 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryProvider.java @@ -243,8 +243,14 @@ public final class DictionaryProvider extends ContentProvider { // Fall through case DICTIONARY_V1_DICT_INFO: final String locale = uri.getLastPathSegment(); + // If LatinIME does not have a dictionary for this locale at all, it will + // send us true for this value. In this case, we may prompt the user for + // a decision about downloading a dictionary even over a metered connection. + final String mayPromptValue = + uri.getQueryParameter(QUERY_PARAMETER_MAY_PROMPT_USER); + final boolean mayPrompt = QUERY_PARAMETER_TRUE.equals(mayPromptValue); final Collection<WordListInfo> dictFiles = - getDictionaryWordListsForLocale(clientId, locale); + getDictionaryWordListsForLocale(clientId, locale, mayPrompt); // TODO: pass clientId to the following function DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext()); if (null != dictFiles && dictFiles.size() > 0) { @@ -337,10 +343,11 @@ public final class DictionaryProvider extends ContentProvider { * * @param clientId the ID of the client requesting the list * @param locale the locale for which we want the list, as a String + * @param mayPrompt true if we are allowed to prompt the user for arbitration via notification * @return a collection of ids. It is guaranteed to be non-null, but may be empty. */ private Collection<WordListInfo> getDictionaryWordListsForLocale(final String clientId, - final String locale) { + final String locale, final boolean mayPrompt) { final Context context = getContext(); final Cursor results = MetadataDbHelper.queryInstalledOrDeletingOrAvailableDictionaryMetadata(context, @@ -405,7 +412,8 @@ public final class DictionaryProvider extends ContentProvider { } } else if (MetadataDbHelper.STATUS_AVAILABLE == wordListStatus) { // The locale is the id for the main dictionary. - UpdateHandler.installIfNeverRequested(context, clientId, wordListId); + UpdateHandler.installIfNeverRequested(context, clientId, wordListId, + mayPrompt); continue; } final WordListInfo currentBestMatch = dicts.get(wordListCategory); |