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

Commit 2d55867d authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Merge "Fix progressbar when orientation changes" into tm-qpr-dev am:...

Merge "Merge "Fix progressbar when orientation changes" into tm-qpr-dev am: e543602f" into tm-qpr-dev-plus-aosp am: 6a8d5332

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22102527



Change-Id: Ieabc1890fe3d6a50e95948ad93775adf9638a23d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a12a9db4 6a8d5332
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ constructor(
                R.id.turbulence_noise_view,
                R.id.touch_ripple_view,
            )

        // Sizing view id for recommendation card view.
        val recSizingViewId = R.id.sizing_view
    }

    /** A listener when the current dimensions of the player change */
@@ -176,7 +179,21 @@ constructor(
                        // Layout dimensions are possibly changing, so we need to update them. (at
                        // least on large screen devices)
                        lastOrientation = newOrientation
                        loadLayoutForType(type)
                        // Update the height of media controls for the expanded layout. it is needed
                        // for large screen devices.
                        if (type == TYPE.PLAYER) {
                            backgroundIds.forEach { id ->
                                expandedLayout.getConstraint(id).layout.mHeight =
                                    context.resources.getDimensionPixelSize(
                                        R.dimen.qs_media_session_height_expanded
                                    )
                            }
                        } else {
                            expandedLayout.getConstraint(recSizingViewId).layout.mHeight =
                                context.resources.getDimensionPixelSize(
                                    R.dimen.qs_media_session_height_expanded
                                )
                        }
                    }
                }
            }
+36 −8
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.View
import androidx.constraintlayout.widget.ConstraintSet
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
@@ -61,8 +60,6 @@ class MediaViewControllerTest : SysuiTestCase() {
    @Mock private lateinit var mediaSubTitleWidgetState: WidgetState
    @Mock private lateinit var mediaContainerWidgetState: WidgetState
    @Mock private lateinit var mediaFlags: MediaFlags
    @Mock private lateinit var expandedLayout: ConstraintSet
    @Mock private lateinit var collapsedLayout: ConstraintSet

    val delta = 0.1F

@@ -82,16 +79,47 @@ class MediaViewControllerTest : SysuiTestCase() {
    }

    @Test
    fun testOrientationChanged_layoutsAreLoaded() {
        mediaViewController.expandedLayout = expandedLayout
        mediaViewController.collapsedLayout = collapsedLayout
    fun testOrientationChanged_heightOfPlayerIsUpdated() {
        val newConfig = Configuration()

        mediaViewController.attach(player, MediaViewController.TYPE.PLAYER)
        // Change the height to see the effect of orientation change.
        MediaViewController.backgroundIds.forEach { id ->
            mediaViewController.expandedLayout.getConstraint(id).layout.mHeight = 10
        }
        newConfig.orientation = ORIENTATION_LANDSCAPE
        configurationController.onConfigurationChanged(newConfig)

        MediaViewController.backgroundIds.forEach { id ->
            assertTrue(
                mediaViewController.expandedLayout.getConstraint(id).layout.mHeight ==
                    context.resources.getDimensionPixelSize(
                        R.dimen.qs_media_session_height_expanded
                    )
            )
        }
    }

    @Test
    fun testOrientationChanged_heightOfRecCardIsUpdated() {
        val newConfig = Configuration()

        mediaViewController.attach(recommendation, MediaViewController.TYPE.RECOMMENDATION)
        // Change the height to see the effect of orientation change.
        mediaViewController.expandedLayout
            .getConstraint(MediaViewController.recSizingViewId)
            .layout
            .mHeight = 10
        newConfig.orientation = ORIENTATION_LANDSCAPE
        configurationController.onConfigurationChanged(newConfig)

        verify(expandedLayout).load(context, R.xml.media_session_expanded)
        verify(collapsedLayout).load(context, R.xml.media_session_collapsed)
        assertTrue(
            mediaViewController.expandedLayout
                .getConstraint(MediaViewController.recSizingViewId)
                .layout
                .mHeight ==
                context.resources.getDimensionPixelSize(R.dimen.qs_media_session_height_expanded)
        )
    }

    @Test