Merge "Add long press menu to remove media player" into rvc-dev am: c285c18e66 am: 53c36be46d

Change-Id: Iec8f23cf332a9546710e0fbe1b7286f5604fa680
This commit is contained in:
Beth Thibodeau
2020-03-19 19:44:31 +00:00
committed by Automerger Merge Worker
5 changed files with 251 additions and 150 deletions

View File

@@ -0,0 +1,24 @@
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12 19,6.41z"
android:fillColor="#FF000000"/>
</vector>

View File

@@ -27,6 +27,16 @@
android:background="@drawable/qs_media_background" android:background="@drawable/qs_media_background"
> >
<!-- Buttons to remove this view when no longer needed -->
<include
layout="@layout/qs_media_panel_options"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/media_guts"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Header section --> <!-- Header section -->
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
@@ -187,3 +197,4 @@
/> />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>

View File

@@ -19,23 +19,40 @@
android:id="@+id/qs_media_controls_options" android:id="@+id/qs_media_controls_options"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center" android:gravity="center"
android:layout_gravity="center" android:padding="16dp"
android:padding="10dp" android:orientation="vertical">
> <LinearLayout
<ImageButton android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_weight="1"
android:minWidth="48dp"
android:layout_gravity="start|bottom"
android:gravity="bottom"
android:id="@+id/remove" android:id="@+id/remove"
android:layout_width="48dp" android:orientation="horizontal">
android:layout_height="48dp" <ImageView
android:src="@android:drawable/ic_menu_delete" android:layout_width="18dp"
android:padding="8dp" android:layout_height="18dp"
/> android:id="@+id/remove_icon"
<ImageButton android:layout_marginEnd="16dp"
android:id="@+id/cancel" android:src="@drawable/ic_clear"/>
android:layout_width="48dp" <TextView
android:layout_height="48dp" android:layout_width="wrap_content"
android:src="@android:drawable/ic_menu_revert" android:layout_height="wrap_content"
android:padding="8dp" android:id="@+id/remove_text"
/> android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
android:singleLine="true"
android:text="@string/controls_media_close_session" />
</LinearLayout>
<TextView
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="48dp"
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" />
</LinearLayout> </LinearLayout>

View File

@@ -2661,4 +2661,7 @@
<!-- Message to tell the user to wait while systemui attempts to load a set of <!-- Message to tell the user to wait while systemui attempts to load a set of
recommended controls [CHAR_LIMIT=30] --> recommended controls [CHAR_LIMIT=30] -->
<string name="controls_seeding_in_progress">Loading recommendations</string> <string name="controls_seeding_in_progress">Loading recommendations</string>
<!-- Close the controls associated with a specific media session [CHAR_LIMIT=NONE] -->
<string name="controls_media_close_session">Close this media session</string>
</resources> </resources>

View File

@@ -18,6 +18,7 @@ package com.android.systemui.qs;
import android.app.Notification; import android.app.Notification;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
import android.media.session.MediaSession; import android.media.session.MediaSession;
@@ -25,7 +26,9 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settingslib.media.MediaDevice; import com.android.settingslib.media.MediaDevice;
import com.android.systemui.R; import com.android.systemui.R;
@@ -50,6 +53,8 @@ public class QSMediaPlayer extends MediaControlPanel {
R.id.action4 R.id.action4
}; };
private final QSPanel mParent;
/** /**
* Initialize quick shade version of player * Initialize quick shade version of player
* @param context * @param context
@@ -62,6 +67,7 @@ public class QSMediaPlayer extends MediaControlPanel {
Executor foregroundExecutor, Executor backgroundExecutor) { Executor foregroundExecutor, Executor backgroundExecutor) {
super(context, parent, manager, R.layout.qs_media_panel, QS_ACTION_IDS, foregroundExecutor, super(context, parent, manager, R.layout.qs_media_panel, QS_ACTION_IDS, foregroundExecutor,
backgroundExecutor); backgroundExecutor);
mParent = (QSPanel) parent;
} }
/** /**
@@ -108,5 +114,45 @@ public class QSMediaPlayer extends MediaControlPanel {
ImageButton thisBtn = mMediaNotifView.findViewById(QS_ACTION_IDS[i]); ImageButton thisBtn = mMediaNotifView.findViewById(QS_ACTION_IDS[i]);
thisBtn.setVisibility(View.GONE); 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
});
} }
} }