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

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

Issue 2514603002: Don't show the remaining time for offline page downloads (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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.download; 5 package org.chromium.chrome.browser.download;
6 6
7 import android.app.ActivityManager; 7 import android.app.ActivityManager;
8 import android.app.DownloadManager; 8 import android.app.DownloadManager;
9 import android.app.Notification; 9 import android.app.Notification;
10 import android.app.NotificationManager; 10 import android.app.NotificationManager;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 int percentage, long timeRemainingInMillis, long startTime, boolean isOffTheRecord, 264 int percentage, long timeRemainingInMillis, long startTime, boolean isOffTheRecord,
265 boolean canDownloadWhileMetered, boolean isOfflinePage, boolean isDo wnloadPending) { 265 boolean canDownloadWhileMetered, boolean isOfflinePage, boolean isDo wnloadPending) {
266 if (mStopPostingProgressNotifications) return; 266 if (mStopPostingProgressNotifications) return;
267 String contentText = mContext.getResources().getString(isDownloadPending 267 String contentText = mContext.getResources().getString(isDownloadPending
268 ? R.string.download_notification_pending : R.string.download_sta rted); 268 ? R.string.download_notification_pending : R.string.download_sta rted);
269 NotificationCompat.Builder builder = buildNotification( 269 NotificationCompat.Builder builder = buildNotification(
270 android.R.drawable.stat_sys_download, fileName, contentText); 270 android.R.drawable.stat_sys_download, fileName, contentText);
271 boolean indeterminate = (percentage == INVALID_DOWNLOAD_PERCENTAGE) || i sDownloadPending; 271 boolean indeterminate = (percentage == INVALID_DOWNLOAD_PERCENTAGE) || i sDownloadPending;
272 builder.setOngoing(true).setProgress(100, percentage, indeterminate); 272 builder.setOngoing(true).setProgress(100, percentage, indeterminate);
273 builder.setPriority(Notification.PRIORITY_HIGH); 273 builder.setPriority(Notification.PRIORITY_HIGH);
274 if (!indeterminate) { 274 if (!indeterminate && !isOfflinePage) {
275 String duration = formatRemainingTime(mContext, timeRemainingInMilli s); 275 String duration = formatRemainingTime(mContext, timeRemainingInMilli s);
276 if (Build.VERSION.CODENAME.equals("N") 276 if (Build.VERSION.CODENAME.equals("N")
277 || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { 277 || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
278 builder.setSubText(duration); 278 builder.setSubText(duration);
279 } else { 279 } else {
280 builder.setContentInfo(duration); 280 builder.setContentInfo(duration);
281 } 281 }
282 } 282 }
283 int notificationId = getNotificationId(downloadGuid); 283 int notificationId = getNotificationId(downloadGuid);
284 int itemType = isOfflinePage ? DownloadSharedPreferenceEntry.ITEM_TYPE_O FFLINE_PAGE 284 int itemType = isOfflinePage ? DownloadSharedPreferenceEntry.ITEM_TYPE_O FFLINE_PAGE
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 return context.getString(R.string.remaining_duration_minutes, minute s); 879 return context.getString(R.string.remaining_duration_minutes, minute s);
880 } else if (minutes > 0) { 880 } else if (minutes > 0) {
881 return context.getString(R.string.remaining_duration_one_minute); 881 return context.getString(R.string.remaining_duration_one_minute);
882 } else if (seconds == 1) { 882 } else if (seconds == 1) {
883 return context.getString(R.string.remaining_duration_one_second); 883 return context.getString(R.string.remaining_duration_one_second);
884 } else { 884 } else {
885 return context.getString(R.string.remaining_duration_seconds, second s); 885 return context.getString(R.string.remaining_duration_seconds, second s);
886 } 886 }
887 } 887 }
888 } 888 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698