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

Commit e1d07010 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Update long press layout for large display sizes" into sc-dev

parents 268e44c5 5b7117f0
Loading
Loading
Loading
Loading
+36 −24
Original line number Diff line number Diff line
@@ -125,36 +125,43 @@

    <!-- Long press menu -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/qs_media_padding"
        android:layout_marginTop="20dp"
        android:layout_marginStart="@dimen/qs_media_padding"
        android:layout_marginEnd="@dimen/qs_media_padding"
        android:id="@+id/remove_text"
        android:fontFamily="@*android:string/config_headlineFontFamily"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:text="@string/controls_media_close_session"
        android:gravity="center_horizontal|top"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toTopOf="@id/settings"/>
        app:layout_constraintBottom_toTopOf="@id/cancel"/>

    <FrameLayout
        android:id="@+id/settings"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_padding"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginEnd="@dimen/qs_media_info_spacing"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/cancel"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:id="@+id/settings_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
@@ -164,18 +171,21 @@
    <FrameLayout
        android:id="@+id/cancel"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginStart="@dimen/qs_media_info_spacing"
        android:layout_marginEnd="@dimen/qs_media_info_spacing"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintStart_toEndOf="@id/settings"
        app:layout_constraintEnd_toStartOf="@id/dismiss"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
@@ -185,23 +195,25 @@
    <FrameLayout
        android:id="@+id/dismiss"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_info_spacing"
        android:layout_marginEnd="@dimen/qs_media_padding"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintStart_toEndOf="@id/cancel"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
            android:text="@string/controls_media_dismiss_button"
        />
    </FrameLayout>

</com.android.systemui.util.animation.TransitionLayout>
 No newline at end of file
+35 −22
Original line number Diff line number Diff line
@@ -213,36 +213,43 @@

    <!-- Long press menu -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/qs_media_padding"
        android:layout_marginTop="20dp"
        android:layout_marginStart="@dimen/qs_media_padding"
        android:layout_marginEnd="@dimen/qs_media_padding"
        android:id="@+id/remove_text"
        android:fontFamily="@*android:string/config_headlineFontFamily"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:text="@string/controls_media_close_session"
        android:gravity="center_horizontal|top"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toTopOf="@id/settings"/>
        app:layout_constraintBottom_toTopOf="@id/cancel"/>

    <FrameLayout
        android:id="@+id/settings"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_padding"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginEnd="@dimen/qs_media_info_spacing"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/cancel"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:id="@+id/settings_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
@@ -252,18 +259,21 @@
    <FrameLayout
        android:id="@+id/cancel"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginStart="@dimen/qs_media_info_spacing"
        android:layout_marginEnd="@dimen/qs_media_info_spacing"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintStart_toEndOf="@id/settings"
        app:layout_constraintEnd_toStartOf="@id/dismiss"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
@@ -273,18 +283,21 @@
    <FrameLayout
        android:id="@+id/dismiss"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_info_spacing"
        android:layout_marginEnd="@dimen/qs_media_padding"
        android:paddingBottom="@dimen/qs_media_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="@dimen/qs_media_padding"
        android:layout_marginTop="6dp"
        app:layout_constrainedWidth="true"
        app:layout_constraintWidth_min="48dp"
        app:layout_constraintHeight_min="48dp"
        app:layout_constraintStart_toEndOf="@id/cancel"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MediaPlayer.OutlineButton"
+2 −0
Original line number Diff line number Diff line
@@ -651,6 +651,8 @@
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:backgroundTint">@color/media_player_outline_button_bg</item>
        <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:singleLine">true</item>
    </style>

    <style name="MediaPlayer.SolidButton">
+35 −3
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.text.Layout;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
@@ -220,7 +221,7 @@ public class MediaControlPanel {

        mPlayerViewHolder.getPlayer().setOnLongClickListener(v -> {
            if (!mMediaViewController.isGutsVisible()) {
                mMediaViewController.openGuts();
                openGuts();
                return true;
            } else {
                closeGuts();
@@ -244,7 +245,7 @@ public class MediaControlPanel {

        mRecommendationViewHolder.getRecommendations().setOnLongClickListener(v -> {
            if (!mMediaViewController.isGutsVisible()) {
                mMediaViewController.openGuts();
                openGuts();
                return true;
            } else {
                return false;
@@ -433,7 +434,7 @@ public class MediaControlPanel {

        // Guts label
        boolean isDismissible = data.isClearable();
        mPlayerViewHolder.getSettingsText().setText(isDismissible
        mPlayerViewHolder.getLongPressText().setText(isDismissible
                ? R.string.controls_media_close_session
                : R.string.controls_media_active_session);

@@ -592,6 +593,11 @@ public class MediaControlPanel {
     * @param immediate {@code true} if it should be closed without animation
     */
    public void closeGuts(boolean immediate) {
        if (mPlayerViewHolder != null) {
            mPlayerViewHolder.marquee(false, mMediaViewController.GUTS_ANIMATION_DURATION);
        } else if (mRecommendationViewHolder != null) {
            mRecommendationViewHolder.marquee(false, mMediaViewController.GUTS_ANIMATION_DURATION);
        }
        mMediaViewController.closeGuts(immediate);
    }

@@ -599,6 +605,32 @@ public class MediaControlPanel {
        closeGuts(false);
    }

    private void openGuts() {
        ConstraintSet expandedSet = mMediaViewController.getExpandedLayout();
        ConstraintSet collapsedSet = mMediaViewController.getCollapsedLayout();

        boolean wasTruncated = false;
        Layout l = null;
        if (mPlayerViewHolder != null) {
            mPlayerViewHolder.marquee(true, mMediaViewController.GUTS_ANIMATION_DURATION);
            l = mPlayerViewHolder.getSettingsText().getLayout();
        } else if (mRecommendationViewHolder != null) {
            mRecommendationViewHolder.marquee(true, mMediaViewController.GUTS_ANIMATION_DURATION);
            l = mRecommendationViewHolder.getSettingsText().getLayout();
        }
        if (l != null) {
            wasTruncated = l.getEllipsisCount(0) > 0;
        }
        mMediaViewController.setShouldHideGutsSettings(wasTruncated);
        if (wasTruncated) {
            // not enough room for the settings button to show fully, let's hide it
            expandedSet.constrainMaxWidth(R.id.settings, 0);
            collapsedSet.constrainMaxWidth(R.id.settings, 0);
        }

        mMediaViewController.openGuts();
    }

    @UiThread
    private Drawable scaleDrawable(Icon icon) {
        if (icon == null) {
+8 −0
Original line number Diff line number Diff line
@@ -185,6 +185,11 @@ class MediaViewController @Inject constructor(
    var isGutsVisible = false
        private set

    /**
     * Whether the settings button in the guts should be visible
     */
    var shouldHideGutsSettings = false

    init {
        mediaHostStatesManager.addController(this)
        layoutController.sizeChangedListener = { width: Int, height: Int ->
@@ -277,6 +282,9 @@ class MediaViewController @Inject constructor(
                viewState.widgetStates.get(id)?.gone = !isGutsVisible
            }
        }
        if (shouldHideGutsSettings) {
            viewState.widgetStates.get(R.id.settings)?.gone = true
        }
    }

    /**
Loading