Chromium Code Reviews| 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 c0430c98c3ebc7aad88e5c9cc61c99238c5f9f20..e0e755c03d4982922f035b3957479ff6a3227fd7 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 |
| @@ -24,7 +24,6 @@ import android.graphics.drawable.shapes.OvalShape; |
| import android.os.Binder; |
| import android.os.Build; |
| import android.os.IBinder; |
| -import android.support.v4.app.NotificationCompat; |
| import android.text.TextUtils; |
| import org.chromium.base.ApiCompatibilityUtils; |
| @@ -37,6 +36,7 @@ import org.chromium.chrome.browser.ChromeApplication; |
| import org.chromium.chrome.browser.init.BrowserParts; |
| import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
| import org.chromium.chrome.browser.init.EmptyBrowserParts; |
| +import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; |
| import org.chromium.chrome.browser.notifications.NotificationConstants; |
| import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadBridge; |
| import org.chromium.chrome.browser.util.IntentUtils; |
| @@ -298,7 +298,7 @@ public class DownloadNotificationService extends Service { |
| } |
| int resId = isDownloadPending ? R.drawable.ic_download_pending |
| : android.R.drawable.stat_sys_download; |
| - NotificationCompat.Builder builder = buildNotification(resId, fileName, contentText); |
| + ChromeNotificationBuilder builder = buildNotification(resId, fileName, contentText); |
| builder.setOngoing(true); |
| builder.setPriority(Notification.PRIORITY_HIGH); |
| @@ -401,8 +401,8 @@ public class DownloadNotificationService extends Service { |
| String contentText = mContext.getResources().getString( |
| R.string.download_notification_paused); |
| - NotificationCompat.Builder builder = buildNotification( |
| - R.drawable.ic_download_pause, entry.fileName, contentText); |
| + ChromeNotificationBuilder builder = |
| + buildNotification(R.drawable.ic_download_pause, entry.fileName, contentText); |
| // Clicking on an in-progress download sends the user to see all their downloads. |
| Intent downloadHomeIntent = buildActionIntent( |
| @@ -453,8 +453,7 @@ public class DownloadNotificationService extends Service { |
| String downloadGuid, String filePath, String fileName, long systemDownloadId, |
| boolean isOfflinePage, boolean isSupportedMimeType) { |
| int notificationId = getNotificationId(downloadGuid); |
| - NotificationCompat.Builder builder = buildNotification( |
| - R.drawable.offline_pin, fileName, |
| + ChromeNotificationBuilder builder = buildNotification(R.drawable.offline_pin, fileName, |
| mContext.getResources().getString(R.string.download_notification_completed)); |
| ComponentName component = new ComponentName( |
| mContext.getPackageName(), DownloadBroadcastReceiver.class.getName()); |
| @@ -500,9 +499,9 @@ public class DownloadNotificationService extends Service { |
| } |
| int notificationId = getNotificationId(downloadGuid); |
| - NotificationCompat.Builder builder = buildNotification( |
| - android.R.drawable.stat_sys_download_done, fileName, |
| - mContext.getResources().getString(R.string.download_notification_failed)); |
| + ChromeNotificationBuilder builder = |
| + buildNotification(android.R.drawable.stat_sys_download_done, fileName, |
| + mContext.getResources().getString(R.string.download_notification_failed)); |
| updateNotification(notificationId, builder.build()); |
| mDownloadSharedPreferenceHelper.removeSharedPreferenceEntry(downloadGuid); |
| mDownloadsInProgress.remove(downloadGuid); |
| @@ -570,15 +569,19 @@ public class DownloadNotificationService extends Service { |
| * @param contentText Notification content text to be displayed. |
| * @return notification builder that builds the notification to be displayed |
| */ |
| - private NotificationCompat.Builder buildNotification( |
| + private ChromeNotificationBuilder buildNotification( |
| int iconId, String title, String contentText) { |
| - NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) |
| - .setContentTitle(DownloadUtils.getAbbreviatedFileName(title, MAX_FILE_NAME_LENGTH)) |
| - .setSmallIcon(iconId) |
| - .setLocalOnly(true) |
| - .setAutoCancel(true) |
| - .setContentText(contentText) |
| - .setGroup(NotificationConstants.GROUP_DOWNLOADS); |
| + ChromeNotificationBuilder builder = |
| + ((ChromeApplication) mContext) |
| + .getChromeNotificationBuilder(true, NotificationConstants.TYPE_ID_GENERAL, |
|
Peter Beverloo
2017/02/20 01:06:45
nit: true -> true /* preferCompat */ (elsewhere to
awdf
2017/02/24 00:38:46
Done.
|
| + NotificationConstants.TYPE_NAME_GENERAL) |
| + .setContentTitle( |
| + DownloadUtils.getAbbreviatedFileName(title, MAX_FILE_NAME_LENGTH)) |
| + .setSmallIcon(iconId) |
| + .setLocalOnly(true) |
| + .setAutoCancel(true) |
| + .setContentText(contentText) |
| + .setGroup(NotificationConstants.GROUP_DOWNLOADS); |
| return builder; |
| } |