Clear fields that do not have metadata
Returning early when there is no metadata available means that fields could potentially contain stale info, especially apparent in QQS. We should be clearing those fields instead. Fixes: 153606598 Test: manual - play from app with metadata, then switch to app without (e.g. Recorder), observe QQS does not have first app's title showing Change-Id: Ie280c10f67550ab0b3c680f72eeaef3f723ecb12
This commit is contained in:
@@ -315,11 +315,8 @@ public class MediaControlPanel {
|
||||
appName.setTextColor(mForegroundColor);
|
||||
}
|
||||
|
||||
// Can be null!
|
||||
MediaMetadata mediaMetadata = mController.getMetadata();
|
||||
if (mediaMetadata == null) {
|
||||
Log.e(TAG, "Media metadata was null");
|
||||
return;
|
||||
}
|
||||
|
||||
ImageView albumView = mMediaNotifView.findViewById(R.id.album_art);
|
||||
if (albumView != null) {
|
||||
@@ -329,14 +326,20 @@ public class MediaControlPanel {
|
||||
|
||||
// Song name
|
||||
TextView titleText = mMediaNotifView.findViewById(R.id.header_title);
|
||||
String songName = mediaMetadata.getString(MediaMetadata.METADATA_KEY_TITLE);
|
||||
String songName = "";
|
||||
if (mediaMetadata != null) {
|
||||
songName = mediaMetadata.getString(MediaMetadata.METADATA_KEY_TITLE);
|
||||
}
|
||||
titleText.setText(songName);
|
||||
titleText.setTextColor(mForegroundColor);
|
||||
|
||||
// Artist name (not in mini player)
|
||||
TextView artistText = mMediaNotifView.findViewById(R.id.header_artist);
|
||||
if (artistText != null) {
|
||||
String artistName = mediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
|
||||
String artistName = "";
|
||||
if (mediaMetadata != null) {
|
||||
artistName = mediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
|
||||
}
|
||||
artistText.setText(artistName);
|
||||
artistText.setTextColor(mForegroundColor);
|
||||
}
|
||||
@@ -439,21 +442,23 @@ public class MediaControlPanel {
|
||||
private void processAlbumArt(MediaMetadata metadata, Icon largeIcon, ImageView albumView) {
|
||||
Bitmap albumArt = null;
|
||||
|
||||
// First look in URI fields
|
||||
for (String field : ART_URIS) {
|
||||
String uriString = metadata.getString(field);
|
||||
if (!TextUtils.isEmpty(uriString)) {
|
||||
albumArt = loadBitmapFromUri(Uri.parse(uriString));
|
||||
if (albumArt != null) {
|
||||
Log.d(TAG, "loaded art from " + field);
|
||||
break;
|
||||
if (metadata != null) {
|
||||
// First look in URI fields
|
||||
for (String field : ART_URIS) {
|
||||
String uriString = metadata.getString(field);
|
||||
if (!TextUtils.isEmpty(uriString)) {
|
||||
albumArt = loadBitmapFromUri(Uri.parse(uriString));
|
||||
if (albumArt != null) {
|
||||
Log.d(TAG, "loaded art from " + field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then check bitmap field
|
||||
if (albumArt == null) {
|
||||
albumArt = metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);
|
||||
// Then check bitmap field
|
||||
if (albumArt == null) {
|
||||
albumArt = metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally try the notification's largeIcon
|
||||
|
||||
Reference in New Issue
Block a user