Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java |
| index a83e0f314b87724a7d4bf8f4b308e0871d9bb403..7b845fe28ebfc9477dfa1fc47c6967f34d5fe817 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java |
| @@ -36,6 +36,8 @@ import org.chromium.base.SysUtils; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.blink.mojom.MediaSessionAction; |
| import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.ChromeApplication; |
| +import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; |
| import org.chromium.chrome.browser.notifications.NotificationConstants; |
| import org.chromium.content_public.common.MediaMetadata; |
| @@ -84,7 +86,7 @@ public class MediaNotificationManager { |
| private SparseArray<MediaButtonInfo> mActionToButtonInfo; |
| - private NotificationCompat.Builder mNotificationBuilder; |
| + private ChromeNotificationBuilder mNotificationBuilder; |
| private Bitmap mDefaultNotificationLargeIcon; |
| @@ -538,8 +540,7 @@ public class MediaNotificationManager { |
| @VisibleForTesting |
| @Nullable |
| - static NotificationCompat.Builder getNotificationBuilderForTesting( |
| - int notificationId) { |
| + static ChromeNotificationBuilder getNotificationBuilderForTesting(int notificationId) { |
| MediaNotificationManager manager = getManager(notificationId); |
| if (manager == null) return null; |
| @@ -716,7 +717,11 @@ public class MediaNotificationManager { |
| updateMediaSession(); |
| - mNotificationBuilder = new NotificationCompat.Builder(mContext); |
| + mNotificationBuilder = |
| + ((ChromeApplication) mContext) |
|
nyquist
2017/02/28 07:33:17
I think you need to do mContext.getApplicationCont
mlamouri (slow - plz ping)
2017/02/28 15:23:11
+1. The context you are getting here is probably n
awdf
2017/02/28 18:09:05
Done.
|
| + .createChromeNotificationBuilder(true, |
| + NotificationConstants.CATEGORY_ID_GENERAL, |
|
mlamouri (slow - plz ping)
2017/02/28 15:23:11
Should this be media?
awdf
2017/02/28 18:09:05
As discussed, we're going with GENERAL for now.
|
| + mContext.getString(R.string.notification_category_general)); |
| setMediaStyleLayoutForNotificationBuilder(mNotificationBuilder); |
| mNotificationBuilder.setSmallIcon(mMediaNotificationInfo.notificationSmallIcon); |
| @@ -848,7 +853,7 @@ public class MediaNotificationManager { |
| mMediaSession.setActive(true); |
| } |
| - private void setMediaStyleLayoutForNotificationBuilder(NotificationCompat.Builder builder) { |
| + private void setMediaStyleLayoutForNotificationBuilder(ChromeNotificationBuilder builder) { |
| setMediaStyleNotificationText(builder); |
| if (!mMediaNotificationInfo.supportsPlayPause()) { |
| builder.setLargeIcon(null); |
| @@ -871,7 +876,7 @@ public class MediaNotificationManager { |
| addNotificationButtons(builder); |
| } |
| - private void addNotificationButtons(NotificationCompat.Builder builder) { |
| + private void addNotificationButtons(ChromeNotificationBuilder builder) { |
| Set<Integer> actions = new HashSet<>(); |
| // TODO(zqzhang): handle other actions when play/pause is not supported? See |
| @@ -902,15 +907,8 @@ public class MediaNotificationManager { |
| // Only apply MediaStyle when NotificationInfo supports play/pause. |
| if (mMediaNotificationInfo.supportsPlayPause()) { |
| - NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle(); |
| - style.setMediaSession(mMediaSession.getSessionToken()); |
| - |
| - int[] compactViewActionIndices = computeCompactViewActionIndices(bigViewActions); |
| - |
| - style.setShowActionsInCompactView(compactViewActionIndices); |
| - style.setCancelButtonIntent(createPendingIntent(ListenerService.ACTION_CANCEL)); |
| - style.setShowCancelButton(true); |
| - builder.setStyle(style); |
| + builder.setMediaStyle(mMediaSession, computeCompactViewActionIndices(bigViewActions), |
| + createPendingIntent(ListenerService.ACTION_CANCEL), true); |
| } |
| } |
| @@ -921,7 +919,7 @@ public class MediaNotificationManager { |
| return bitmapDrawable.getBitmap(); |
| } |
| - private void setMediaStyleNotificationText(NotificationCompat.Builder builder) { |
| + private void setMediaStyleNotificationText(ChromeNotificationBuilder builder) { |
| builder.setContentTitle(mMediaNotificationInfo.metadata.getTitle()); |
| String artistAndAlbumText = getArtistAndAlbumText(mMediaNotificationInfo.metadata); |
| if (isRunningN() || !artistAndAlbumText.isEmpty()) { |