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

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

Issue 1896543002: [Media, UI] Use 3-line style to show metadata in MediaNotification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 8 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 643cc79de0fc1bbd4aa44d8815e1195de3e30266..cc6c2561cc2b8b85e3b5f75e07b6ea8634b765c2 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
@@ -34,6 +34,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
+import org.chromium.content_public.common.MediaMetadata;
import javax.annotation.Nullable;
@@ -637,10 +638,7 @@ public class MediaNotificationManager {
}
private void setMediaStyleLayoutForNotificationBuilder(NotificationCompat.Builder builder) {
- // TODO(zqzhang): After we ship the new style, we should see how to present the
- // metadata.artist and metadata.album. See http://crbug.com/599937
- builder.setContentTitle(mMediaNotificationInfo.metadata.getTitle());
- builder.setContentText(mMediaNotificationInfo.origin);
+ setMediaStyleNotificationText(builder);
// TODO(zqzhang): Update the default icon when a new one in provided.
// See http://crbug.com/600396.
if (mMediaNotificationInfo.largeIcon != null) {
@@ -760,4 +758,26 @@ public class MediaNotificationManager {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
return bitmapDrawable.getBitmap();
}
+
+ private void setMediaStyleNotificationText(NotificationCompat.Builder builder) {
+ builder.setContentTitle(mMediaNotificationInfo.metadata.getTitle());
+ String artistAndAlbumText = getArtistAndAlbumText(mMediaNotificationInfo.metadata);
+ // TODO(zqzhang): update this when N is released.
+ if (TextUtils.equals(Build.VERSION.CODENAME, "N") || !artistAndAlbumText.isEmpty()) {
+ builder.setContentText(artistAndAlbumText);
+ builder.setSubText(mMediaNotificationInfo.origin);
+ } else {
+ // Leaving ContentText empty looks bad, so move origin up to the ContentText.
+ builder.setContentText(mMediaNotificationInfo.origin);
+ }
+ }
+
+ private String getArtistAndAlbumText(MediaMetadata metadata) {
+ String artist = (metadata.getArtist() == null) ? "" : metadata.getArtist();
+ String album = (metadata.getAlbum() == null) ? "" : metadata.getAlbum();
+ if (artist.isEmpty() || album.isEmpty()) {
+ return artist + album;
+ }
+ return artist + " - " + album;
+ }
}
« 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