diff --git a/packages/SystemUI/res/drawable/ic_clear.xml b/packages/SystemUI/res/drawable/ic_clear.xml new file mode 100644 index 0000000000000..5ee50d8454575 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_clear.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/layout/qs_media_panel.xml b/packages/SystemUI/res/layout/qs_media_panel.xml index 34bd7035b5aea..9ef8c1dbbb957 100644 --- a/packages/SystemUI/res/layout/qs_media_panel.xml +++ b/packages/SystemUI/res/layout/qs_media_panel.xml @@ -27,163 +27,174 @@ android:background="@drawable/qs_media_background" > - + + + - - - + android:layout_height="match_parent"> + + + + - - + + + + + + + + + - - + - - - + android:paddingLeft="12dp" + android:paddingRight="12dp" + android:gravity="center" + android:id="@+id/media_seamless" + android:background="@*android:drawable/media_seamless_background" + android:layout_weight="1" + > + + + - + - + - + + + - - - - - - - - - diff --git a/packages/SystemUI/res/layout/qs_media_panel_options.xml b/packages/SystemUI/res/layout/qs_media_panel_options.xml index 0669357910702..46655e7b4daf5 100644 --- a/packages/SystemUI/res/layout/qs_media_panel_options.xml +++ b/packages/SystemUI/res/layout/qs_media_panel_options.xml @@ -19,23 +19,40 @@ android:id="@+id/qs_media_controls_options" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="horizontal" android:gravity="center" - android:layout_gravity="center" - android:padding="10dp" - > - + - + + + + + android:layout_weight="1" + android:minWidth="48dp" + android:layout_gravity="end|bottom" + android:gravity="bottom" + android:fontFamily="@*android:string/config_headlineFontFamilyMedium" + android:text="@string/cancel" /> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index cb08840d02c83..179033a30520a 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2661,4 +2661,7 @@ Loading recommendations + + + Close this media session diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java index d5e5b10d603c5..8922e146cc504 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java @@ -18,6 +18,7 @@ package com.android.systemui.qs; import android.app.Notification; import android.content.Context; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.media.session.MediaSession; @@ -25,7 +26,9 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; import com.android.settingslib.media.MediaDevice; import com.android.systemui.R; @@ -50,6 +53,8 @@ public class QSMediaPlayer extends MediaControlPanel { R.id.action4 }; + private final QSPanel mParent; + /** * Initialize quick shade version of player * @param context @@ -62,6 +67,7 @@ public class QSMediaPlayer extends MediaControlPanel { Executor foregroundExecutor, Executor backgroundExecutor) { super(context, parent, manager, R.layout.qs_media_panel, QS_ACTION_IDS, foregroundExecutor, backgroundExecutor); + mParent = (QSPanel) parent; } /** @@ -108,5 +114,45 @@ public class QSMediaPlayer extends MediaControlPanel { ImageButton thisBtn = mMediaNotifView.findViewById(QS_ACTION_IDS[i]); thisBtn.setVisibility(View.GONE); } + + // Set up long press menu + View guts = mMediaNotifView.findViewById(R.id.media_guts); + View options = mMediaNotifView.findViewById(R.id.qs_media_controls_options); + options.setMinimumHeight(guts.getHeight()); + + View clearView = options.findViewById(R.id.remove); + clearView.setOnClickListener(b -> { + mParent.removeMediaPlayer(QSMediaPlayer.this); + }); + ImageView removeIcon = options.findViewById(R.id.remove_icon); + removeIcon.setImageTintList(ColorStateList.valueOf(iconColor)); + TextView removeText = options.findViewById(R.id.remove_text); + removeText.setTextColor(iconColor); + + TextView cancelView = options.findViewById(R.id.cancel); + cancelView.setTextColor(iconColor); + cancelView.setOnClickListener(b -> { + options.setVisibility(View.GONE); + guts.setVisibility(View.VISIBLE); + }); + // ... but don't enable it yet, and make sure is reset when the session is updated + mMediaNotifView.setOnLongClickListener(null); + options.setVisibility(View.GONE); + guts.setVisibility(View.VISIBLE); + } + + @Override + public void clearControls() { + super.clearControls(); + + View guts = mMediaNotifView.findViewById(R.id.media_guts); + View options = mMediaNotifView.findViewById(R.id.qs_media_controls_options); + + mMediaNotifView.setOnLongClickListener(v -> { + // Replace player view with close/cancel view + guts.setVisibility(View.GONE); + options.setVisibility(View.VISIBLE); + return true; // consumed click + }); } }