Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +18 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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 ) } } } } Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +36 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +18 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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 ) } } } } Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +36 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading