Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2921)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java

Issue 2489143002: Use new download notification strings (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
index ffda922ec24d691f382fd8672f41dbe3d2f51619..12852c57605b572c4687777d2dfc0fd8cb4dfefa 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadNotificationService.java
@@ -40,12 +40,10 @@ import org.chromium.chrome.browser.init.EmptyBrowserParts;
import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge;
import org.chromium.chrome.browser.util.IntentUtils;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
/**
@@ -231,20 +229,19 @@ public class DownloadNotificationService extends Service {
boolean canDownloadWhileMetered, boolean isOfflinePage) {
if (mStopPostingProgressNotifications) return;
boolean indeterminate = percentage == INVALID_DOWNLOAD_PERCENTAGE;
+ String contentText = mContext.getResources().getString(
+ indeterminate ? R.string.download_notification_pending : R.string.download_started);
NotificationCompat.Builder builder = buildNotification(
- android.R.drawable.stat_sys_download, fileName, null);
+ android.R.drawable.stat_sys_download, fileName, contentText);
builder.setOngoing(true).setProgress(100, percentage, indeterminate);
builder.setPriority(Notification.PRIORITY_HIGH);
if (!indeterminate) {
- NumberFormat formatter = NumberFormat.getPercentInstance(Locale.getDefault());
- String percentText = formatter.format(percentage / 100.0);
String duration = formatRemainingTime(mContext, timeRemainingInMillis);
- builder.setContentText(duration);
if (Build.VERSION.CODENAME.equals("N")
|| Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
- builder.setSubText(percentText);
+ builder.setSubText(duration);
} else {
- builder.setContentInfo(percentText);
+ builder.setContentInfo(duration);
}
}
int notificationId = getNotificationId(downloadGuid);
@@ -305,9 +302,10 @@ public class DownloadNotificationService extends Service {
notifyDownloadFailed(downloadGuid, entry.fileName);
return;
}
+ String contentText = mContext.getResources().getString(isAutoResumable
+ ? R.string.download_notification_waiting : R.string.download_notification_paused);
NotificationCompat.Builder builder = buildNotification(
- android.R.drawable.ic_media_pause, entry.fileName,
- mContext.getResources().getString(R.string.download_notification_paused));
+ android.R.drawable.ic_media_pause, entry.fileName, contentText);
Intent cancelIntent = buildActionIntent(
ACTION_DOWNLOAD_CANCEL, entry.notificationId, entry.downloadGuid, entry.fileName,
entry.isOfflinePage());

Powered by Google App Engine
This is Rietveld 408576698