Don't prompt before downloading.
We don't pay attention to the answer, so don't ask. Bug 22069694. Change-Id: Ic048d5570e68fbc9438c6577e27e6c7f68428606
This commit is contained in:
parent
5e4c0caac3
commit
d23dd5978d
3 changed files with 12 additions and 34 deletions
|
@ -243,14 +243,8 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
// Fall through
|
// Fall through
|
||||||
case DICTIONARY_V1_DICT_INFO:
|
case DICTIONARY_V1_DICT_INFO:
|
||||||
final String locale = uri.getLastPathSegment();
|
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 =
|
final Collection<WordListInfo> dictFiles =
|
||||||
getDictionaryWordListsForLocale(clientId, locale, mayPrompt);
|
getDictionaryWordListsForLocale(clientId, locale);
|
||||||
// TODO: pass clientId to the following function
|
// TODO: pass clientId to the following function
|
||||||
DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext());
|
DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext());
|
||||||
if (null != dictFiles && dictFiles.size() > 0) {
|
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 clientId the ID of the client requesting the list
|
||||||
* @param locale the locale for which we want the list, as a String
|
* @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.
|
* @return a collection of ids. It is guaranteed to be non-null, but may be empty.
|
||||||
*/
|
*/
|
||||||
private Collection<WordListInfo> getDictionaryWordListsForLocale(final String clientId,
|
private Collection<WordListInfo> getDictionaryWordListsForLocale(final String clientId,
|
||||||
final String locale, final boolean mayPrompt) {
|
final String locale) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final Cursor results =
|
final Cursor results =
|
||||||
MetadataDbHelper.queryInstalledOrDeletingOrAvailableDictionaryMetadata(context,
|
MetadataDbHelper.queryInstalledOrDeletingOrAvailableDictionaryMetadata(context,
|
||||||
|
@ -412,8 +405,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
}
|
}
|
||||||
} else if (MetadataDbHelper.STATUS_AVAILABLE == wordListStatus) {
|
} else if (MetadataDbHelper.STATUS_AVAILABLE == wordListStatus) {
|
||||||
// The locale is the id for the main dictionary.
|
// The locale is the id for the main dictionary.
|
||||||
UpdateHandler.installIfNeverRequested(context, clientId, wordListId,
|
UpdateHandler.installIfNeverRequested(context, clientId, wordListId);
|
||||||
mayPrompt);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final WordListInfo currentBestMatch = dicts.get(wordListCategory);
|
final WordListInfo currentBestMatch = dicts.get(wordListCategory);
|
||||||
|
|
|
@ -80,8 +80,7 @@ public final class DownloadOverMeteredDialog extends Activity {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void onClickAllow(final View v) {
|
public void onClickAllow(final View v) {
|
||||||
UpdateHandler.setDownloadOverMeteredSetting(this, true);
|
UpdateHandler.setDownloadOverMeteredSetting(this, true);
|
||||||
UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload,
|
UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload);
|
||||||
false /* mayPrompt */);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -907,9 +907,9 @@ public final class UpdateHandler {
|
||||||
// list because it may only install the latest version we know about for this specific
|
// list because it may only install the latest version we know about for this specific
|
||||||
// word list ID / client ID combination.
|
// word list ID / client ID combination.
|
||||||
public static void installIfNeverRequested(final Context context, final String clientId,
|
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
|
Log.i(TAG, "installIfNeverRequested() : ClientId = " + clientId
|
||||||
+ " : WordListId = " + wordlistId + " : MayPrompt = " + mayPrompt);
|
+ " : WordListId = " + wordlistId);
|
||||||
final String[] idArray = wordlistId.split(DictionaryProvider.ID_CATEGORY_SEPARATOR);
|
final String[] idArray = wordlistId.split(DictionaryProvider.ID_CATEGORY_SEPARATOR);
|
||||||
// If we have a new-format dictionary id (category:manual_id), then use the
|
// 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
|
// specified category. Otherwise, it is a main dictionary, so force the
|
||||||
|
@ -942,17 +942,6 @@ public final class UpdateHandler {
|
||||||
return;
|
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
|
// 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
|
// 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
|
// 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);
|
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
|
// 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
|
// 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.
|
// dictionary for this language already.
|
||||||
if (mayPrompt) {
|
final Intent intent = new Intent();
|
||||||
final Intent intent = new Intent();
|
intent.setClass(context, DictionaryService.class);
|
||||||
intent.setClass(context, DictionaryService.class);
|
intent.setAction(DictionaryService.SHOW_DOWNLOAD_TOAST_INTENT_ACTION);
|
||||||
intent.setAction(DictionaryService.SHOW_DOWNLOAD_TOAST_INTENT_ACTION);
|
intent.putExtra(DictionaryService.LOCALE_INTENT_ARGUMENT, localeString);
|
||||||
intent.putExtra(DictionaryService.LOCALE_INTENT_ARGUMENT, localeString);
|
context.startService(intent);
|
||||||
context.startService(intent);
|
|
||||||
}
|
|
||||||
Log.i(TAG, "installIfNeverRequested() : StartDownloadAction for " + metadata);
|
Log.i(TAG, "installIfNeverRequested() : StartDownloadAction for " + metadata);
|
||||||
actions.execute(context, new LogProblemReporter(TAG));
|
actions.execute(context, new LogProblemReporter(TAG));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue