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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java

Issue 1424793006: [Media, Android] Always explicitly set the notification play/pause button visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5815eb81fd8516f23cb43a55ba3629c92e5a1ed..0cd447e1f09781e7634cea19f75d19523fc74ef6 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
@@ -397,6 +397,36 @@ public class MediaNotificationManager {
contentView.setOnClickPendingIntent(R.id.stop,
mService.getPendingIntent(ListenerService.ACTION_STOP));
}
+
+ contentView.setTextViewText(R.id.title, mMediaNotificationInfo.title);
+ contentView.setTextViewText(R.id.status, mMediaNotificationInfo.origin);
+ if (mNotificationIcon != null) {
+ contentView.setImageViewBitmap(R.id.icon, mNotificationIcon);
+ } else {
+ contentView.setImageViewResource(R.id.icon, mMediaNotificationInfo.icon);
+ }
+
+ if (mMediaNotificationInfo.supportsPlayPause()) {
+ if (mMediaNotificationInfo.isPaused) {
+ contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_play);
+ contentView.setContentDescription(R.id.playpause, mPlayDescription);
+ contentView.setOnClickPendingIntent(R.id.playpause,
+ mService.getPendingIntent(ListenerService.ACTION_PLAY));
+ } else {
+ // If we're here, the notification supports play/pause button and is playing.
+ contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_pause);
+ contentView.setContentDescription(R.id.playpause, mPauseDescription);
+ contentView.setOnClickPendingIntent(R.id.playpause,
+ mService.getPendingIntent(ListenerService.ACTION_PAUSE));
+ }
+
+ // Even though we create the new view everytime, Android seems to remember the last
+ // visibility state rather than use the default one. So set it explicitly.
+ contentView.setViewVisibility(R.id.playpause, View.VISIBLE);
+ } else {
+ contentView.setViewVisibility(R.id.playpause, View.GONE);
+ }
+
return contentView;
}
@@ -457,31 +487,7 @@ public class MediaNotificationManager {
.setContentIntent(PendingIntent.getActivity(mContext, tabId, tabIntent, 0));
}
- RemoteViews contentView = createContentView();
- contentView.setTextViewText(R.id.title, mMediaNotificationInfo.title);
- contentView.setTextViewText(R.id.status, mMediaNotificationInfo.origin);
- if (mNotificationIcon != null) {
- contentView.setImageViewBitmap(R.id.icon, mNotificationIcon);
- } else {
- contentView.setImageViewResource(R.id.icon, mMediaNotificationInfo.icon);
- }
-
- if (!mMediaNotificationInfo.supportsPlayPause()) {
- contentView.setViewVisibility(R.id.playpause, View.GONE);
- } else if (mMediaNotificationInfo.isPaused) {
- contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_play);
- contentView.setContentDescription(R.id.playpause, mPlayDescription);
- contentView.setOnClickPendingIntent(R.id.playpause,
- mService.getPendingIntent(ListenerService.ACTION_PLAY));
- } else {
- // If we're here, the notification supports play/pause button and is playing.
- contentView.setImageViewResource(R.id.playpause, R.drawable.ic_vidcontrol_pause);
- contentView.setContentDescription(R.id.playpause, mPauseDescription);
- contentView.setOnClickPendingIntent(R.id.playpause,
- mService.getPendingIntent(ListenerService.ACTION_PAUSE));
- }
-
- mNotificationBuilder.setContent(contentView);
+ mNotificationBuilder.setContent(createContentView());
mNotificationBuilder.setVisibility(
mMediaNotificationInfo.isPrivate ? NotificationCompat.VISIBILITY_PRIVATE
: NotificationCompat.VISIBILITY_PUBLIC);
« 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