Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d23dd597 authored by Dan Zivkovic's avatar Dan Zivkovic
Browse files

Don't prompt before downloading.

We don't pay attention to the answer, so don't ask.

Bug 22069694.

Change-Id: Ic048d5570e68fbc9438c6577e27e6c7f68428606
parent 5e4c0caa
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -243,14 +243,8 @@ 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, mayPrompt);
                        getDictionaryWordListsForLocale(clientId, locale);
                // TODO: pass clientId to the following function
                DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext());
                if (null != dictFiles && dictFiles.size() > 0) {
@@ -343,11 +337,10 @@ 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 boolean mayPrompt) {
            final String locale) {
        final Context context = getContext();
        final Cursor results =
                MetadataDbHelper.queryInstalledOrDeletingOrAvailableDictionaryMetadata(context,
@@ -412,8 +405,7 @@ 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,
                                mayPrompt);
                        UpdateHandler.installIfNeverRequested(context, clientId, wordListId);
                        continue;
                    }
                    final WordListInfo currentBestMatch = dicts.get(wordListCategory);
+1 −2
Original line number Diff line number Diff line
@@ -80,8 +80,7 @@ public final class DownloadOverMeteredDialog extends Activity {
    @SuppressWarnings("unused")
    public void onClickAllow(final View v) {
        UpdateHandler.setDownloadOverMeteredSetting(this, true);
        UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload,
                false /* mayPrompt */);
        UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload);
        finish();
    }
}
+8 −21
Original line number Diff line number Diff line
@@ -907,9 +907,9 @@ public final class UpdateHandler {
    // list because it may only install the latest version we know about for this specific
    // word list ID / client ID combination.
    public static void installIfNeverRequested(final Context context, final String clientId,
            final String wordlistId, final boolean mayPrompt) {
            final String wordlistId) {
        Log.i(TAG, "installIfNeverRequested() : ClientId = " + clientId
                + " : WordListId = " + wordlistId + " : MayPrompt = " + mayPrompt);
                + " : WordListId = " + wordlistId);
        final String[] idArray = wordlistId.split(DictionaryProvider.ID_CATEGORY_SEPARATOR);
        // If we have a new-format dictionary id (category:manual_id), then use the
        // specified category. Otherwise, it is a main dictionary, so force the
@@ -942,17 +942,6 @@ public final class UpdateHandler {
            return;
        }

        if (mayPrompt
                && DOWNLOAD_OVER_METERED_SETTING_UNKNOWN
                        == getDownloadOverMeteredSetting(context)) {
            final ConnectivityManager cm =
                    (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            if (ConnectivityManagerCompatUtils.isActiveNetworkMetered(cm)) {
                showDictionaryAvailableNotification(context, clientId, installCandidate);
                return;
            }
        }

        // We decided against prompting the user for a decision. This may be because we were
        // explicitly asked not to, or because we are currently on wi-fi anyway, or because we
        // already know the answer to the question. We'll enqueue a request ; StartDownloadAction
@@ -969,14 +958,12 @@ public final class UpdateHandler {
        final String localeString = installCandidate.getAsString(MetadataDbHelper.LOCALE_COLUMN);
        // We are in a content provider: we can't do any UI at all. We have to defer the displaying
        // itself to the service. Also, we only display this when the user does not have a
        // dictionary for this language already: we know that from the mayPrompt argument.
        if (mayPrompt) {
        // dictionary for this language already.
        final Intent intent = new Intent();
        intent.setClass(context, DictionaryService.class);
        intent.setAction(DictionaryService.SHOW_DOWNLOAD_TOAST_INTENT_ACTION);
        intent.putExtra(DictionaryService.LOCALE_INTENT_ARGUMENT, localeString);
        context.startService(intent);
        }
        Log.i(TAG, "installIfNeverRequested() : StartDownloadAction for " + metadata);
        actions.execute(context, new LogProblemReporter(TAG));
    }