Collapse carousel if no media active, null checks
Bug: 143245284
Test: manual
Change-Id: I6a61c532592edef4cd8e534af39adc8335fae24c
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
index af418f6..6949640 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
@@ -33,6 +33,7 @@
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
+import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -50,7 +51,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.statusbar.MediaTransferManager;
/**
* Single media player for carousel in QSPanel
@@ -101,6 +101,12 @@
mToken = token;
mController = new MediaController(mContext, token);
MediaMetadata mMediaMetadata = mController.getMetadata();
+
+ if (mMediaMetadata == null) {
+ Log.e(TAG, "Media metadata was null");
+ return;
+ }
+
Notification.Builder builder = Notification.Builder.recoverBuilder(mContext, notif);
// Album art
@@ -151,18 +157,17 @@
// Album name
TextView albumName = headerView.findViewById(com.android.internal.R.id.header_text);
String albumString = mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ALBUM);
- if (!albumString.isEmpty()) {
+ if (TextUtils.isEmpty(albumString)) {
+ albumName.setVisibility(View.GONE);
+ separator.setVisibility(View.GONE);
+ } else {
albumName.setText(albumString);
albumName.setTextColor(iconColor);
albumName.setVisibility(View.VISIBLE);
separator.setVisibility(View.VISIBLE);
- } else {
- albumName.setVisibility(View.GONE);
- separator.setVisibility(View.GONE);
}
// Transfer chip
- MediaTransferManager mediaTransferManager = new MediaTransferManager(mContext);
View transferBackgroundView = headerView.findViewById(
com.android.internal.R.id.media_seamless);
LinearLayout viewLayout = (LinearLayout) transferBackgroundView;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 2060059..b48814b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -166,6 +166,7 @@
mMediaCarousel = new LinearLayout(mContext);
mMediaCarousel.setOrientation(LinearLayout.HORIZONTAL);
mediaScrollView.addView(mMediaCarousel, lpCarousel);
+ mediaScrollView.setVisibility(View.GONE);
} else {
mMediaCarousel = null;
}
@@ -239,6 +240,7 @@
} else {
mMediaCarousel.addView(player.getView(), lp); // add at end
}
+ mMediaPlayers.add(player);
} else if (player.isPlaying()) {
// move it to the front
mMediaCarousel.removeView(player.getView());
@@ -248,7 +250,10 @@
Log.d(TAG, "setting player session");
player.setMediaSession(token, icon, iconColor, bgColor, actionsContainer,
notif.getNotification());
- mMediaPlayers.add(player);
+
+ if (mMediaPlayers.size() > 0) {
+ ((View) mMediaCarousel.getParent()).setVisibility(View.VISIBLE);
+ }
}
protected View getMediaPanel() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
index ae66cd5..3ec71ac 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
@@ -84,6 +84,11 @@
mController = new MediaController(mContext, token);
MediaMetadata mMediaMetadata = mController.getMetadata();
+ if (mMediaMetadata == null) {
+ Log.e(TAG, "Media metadata was null");
+ return;
+ }
+
// Album art
addAlbumArtBackground(mMediaMetadata, bgColor);