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

Commit 2e0f351d authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add guts to media player on long press

Adds the following:
* Button for accessing settings
* Button for dismissing player (similar path to when a package is
uninstalled)

Guts will close automatically if:
* QS is collapsed
* Media carousel changes pages

Also, flattened the view hierarchy to support animations between states.

Test: manual
Test: atest com.android.systemui.media
Bug: 156036025
Change-Id: I340e0b37393573f81a3bf12d5e453eccf5982473
Merged-In: I340e0b37393573f81a3bf12d5e453eccf5982473
(cherry picked from commit 429360fb)
parent 515db303
Loading
Loading
Loading
Loading
+94 −4
Original line number Diff line number Diff line
@@ -210,8 +210,98 @@
        android:layout_width="@dimen/qs_media_icon_size"
        android:layout_height="@dimen/qs_media_icon_size" />

    <!-- Buttons to remove this view when no longer needed -->
    <include
        layout="@layout/qs_media_panel_options"
        android:visibility="gone" />
    <!-- Constraints are set here as they are the same regardless of host -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/qs_media_panel_outer_padding"
        android:layout_marginStart="@dimen/qs_media_panel_outer_padding"
        android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
        android:id="@+id/media_text"
        android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
        android:textColor="@color/media_primary_text"
        android:text="@string/controls_media_title"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toTopOf="@id/remove_text"
        app:layout_constraintVertical_chainStyle="spread_inside"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_panel_outer_padding"
        android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
        android:id="@+id/remove_text"
        android:fontFamily="@*android:string/config_headlineFontFamily"
        android:singleLine="true"
        android:textColor="@color/media_primary_text"
        android:text="@string/controls_media_close_session"
        app:layout_constraintTop_toBottomOf="@id/media_text"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toTopOf="@id/settings"/>

    <FrameLayout
        android:id="@+id/settings"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/qs_media_panel_outer_padding"
        android:paddingBottom="@dimen/qs_media_panel_outer_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/remove_text">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
            android:textColor="@android:color/white"
            android:text="@string/controls_media_settings_button" />
    </FrameLayout>

    <FrameLayout
        android:id="@+id/cancel"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
        android:paddingBottom="@dimen/qs_media_panel_outer_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/dismiss" >

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
            android:textColor="@android:color/white"
            android:text="@string/cancel" />
    </FrameLayout>

    <FrameLayout
        android:id="@+id/dismiss"
        android:background="@drawable/qs_media_light_source"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
        android:paddingBottom="@dimen/qs_media_panel_outer_padding"
        android:minWidth="48dp"
        android:minHeight="48dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <TextView
            android:layout_gravity="bottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
            android:textColor="@android:color/white"
            android:text="@string/controls_media_dismiss_button"
        />
    </FrameLayout>
</com.android.systemui.util.animation.TransitionLayout>
+0 −61
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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
  -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/qs_media_controls_options"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:padding="16dp"
    android:orientation="vertical">
    <LinearLayout
        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:orientation="horizontal">
        <ImageView
            android:layout_width="18dp"
            android:layout_height="18dp"
            android:id="@+id/remove_icon"
            android:layout_marginEnd="16dp"
            android:tint="@color/media_primary_text"
            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:textColor="@color/media_primary_text"
            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:textColor="@android:color/white"
        android:text="@string/cancel" />
</LinearLayout>
+1 −1
Original line number Diff line number Diff line
@@ -2822,7 +2822,7 @@
    <!-- Explanation for closing controls associated with a specific media session [CHAR_LIMIT=NONE] -->
    <string name="controls_media_close_session">Hide the current session.</string>
    <!-- Label for a button that will hide media controls [CHAR_LIMIT=30] -->
    <string name="controls_media_dismiss_button">Hide</string>
    <string name="controls_media_dismiss_button">Dismiss</string>
    <!-- Label for button to resume media playback [CHAR_LIMIT=NONE] -->
    <string name="controls_media_resume">Resume</string>
    <!-- Label for button to go to media control settings screen [CHAR_LIMIT=30] -->
+7 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ class MediaCarouselController @Inject constructor(
        pageIndicator = mediaFrame.requireViewById(R.id.media_page_indicator)
        mediaCarouselScrollHandler = MediaCarouselScrollHandler(mediaCarousel, pageIndicator,
                executor, mediaManager::onSwipeToDismiss, this::updatePageIndicatorLocation,
                falsingManager)
                this::closeGuts, falsingManager)
        isRtl = context.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL
        inflateSettingsButton()
        mediaContent = mediaCarousel.requireViewById(R.id.media_carousel)
@@ -470,6 +470,12 @@ class MediaCarouselController @Inject constructor(
        }
    }

    fun closeGuts() {
        mediaPlayers.values.forEach {
            it.closeGuts(true)
        }
    }

    /**
     * Update the size of the carousel, remeasuring it if necessary.
     */
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ class MediaCarouselScrollHandler(
    private val mainExecutor: DelayableExecutor,
    private val dismissCallback: () -> Unit,
    private var translationChangedListener: () -> Unit,
    private val closeGuts: () -> Unit,
    private val falsingManager: FalsingManager
) {
    /**
@@ -452,6 +453,7 @@ class MediaCarouselScrollHandler(
        val nowScrolledIn = scrollIntoCurrentMedia != 0
        if (newIndex != activeMediaIndex || wasScrolledIn != nowScrolledIn) {
            activeMediaIndex = newIndex
            closeGuts()
            updatePlayerVisibilities()
        }
        val relativeLocation = activeMediaIndex.toFloat() + if (playerWidthPlusPadding > 0)
Loading