Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53c36be4 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Automerger Merge Worker
Browse files

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

Change-Id: I1d94bc8c45e92619fbaeedb626eb6cedacb1be47
parents 518f6623 c285c18e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<!--
  ~ 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>
+145 −134
Original line number Diff line number Diff line
@@ -27,6 +27,16 @@
    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 -->
        <LinearLayout
            android:orientation="horizontal"
@@ -187,3 +197,4 @@
            />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
+32 −15
Original line number Diff line number Diff line
@@ -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"
    >
    <ImageButton
        android:id="@+id/remove"
        android:layout_width="48dp"
    android:padding="16dp"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:src="@android:drawable/ic_menu_delete"
        android:padding="8dp"
    />
    <ImageButton
        android:layout_weight="1"
        android:minWidth="48dp"
        android:layout_gravity="start|bottom"
        android:gravity="bottom"
        android:id="@+id/remove"
        android:orientation="horizontal">
        <ImageView
            android:layout_width="18dp"
            android:layout_height="18dp"
            android:id="@+id/remove_icon"
            android:layout_marginEnd="16dp"
            android:src="@drawable/ic_clear"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            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="48dp"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:src="@android:drawable/ic_menu_revert"
        android:padding="8dp"
    />
        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>
+3 −0
Original line number Diff line number Diff line
@@ -2661,4 +2661,7 @@
    <!-- Message to tell the user to wait while systemui attempts to load a set of
         recommended controls [CHAR_LIMIT=30] -->
    <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>
+46 −0
Original line number Diff line number Diff line
@@ -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
        });
    }
}