summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt19
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt44
2 files changed, 54 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
index b4724ddebb9a..1a85a0f47749 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt
@@ -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
+ )
+ }
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt
index 0fac3db2dc1f..4565762929d7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt
@@ -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