Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt +0 −8 Original line number Diff line number Diff line Loading @@ -197,7 +197,6 @@ constructor( private val configListener = object : ConfigurationController.ConfigurationListener { var lastOrientation = -1 override fun onDensityOrFontScaleChanged() { // System font changes should only happen when UMO is offscreen or a flicker may Loading @@ -214,13 +213,6 @@ constructor( override fun onConfigChanged(newConfig: Configuration?) { if (newConfig == null) return isRtl = newConfig.layoutDirection == View.LAYOUT_DIRECTION_RTL val newOrientation = newConfig.orientation if (lastOrientation != newOrientation) { // The players actually depend on the orientation possibly, so we have to // recreate them (at least on large screen devices) lastOrientation = newOrientation updatePlayers(recreateMedia = true) } } override fun onUiModeChanged() { Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +16 −6 Original line number Diff line number Diff line Loading @@ -154,9 +154,11 @@ constructor( return transitionLayout?.translationY ?: 0.0f } /** A callback for RTL config changes */ /** A callback for config changes */ private val configurationListener = object : ConfigurationController.ConfigurationListener { var lastOrientation = -1 override fun onConfigChanged(newConfig: Configuration?) { // Because the TransitionLayout is not always attached (and calculates/caches layout // results regardless of attach state), we have to force the layoutDirection of the Loading @@ -169,6 +171,13 @@ constructor( transitionLayout?.layoutDirection = layoutDirection refreshState() } val newOrientation = newConfig.orientation if (lastOrientation != newOrientation) { // Layout dimensions are possibly changing, so we need to update them. (at // least on large screen devices) lastOrientation = newOrientation loadLayoutForType(type) } } } } Loading @@ -195,13 +204,14 @@ constructor( * The expanded constraint set used to render a expanded player. If it is modified, make sure to * call [refreshState] */ val collapsedLayout = ConstraintSet() var collapsedLayout = ConstraintSet() @VisibleForTesting set /** * The expanded constraint set used to render a collapsed player. If it is modified, make sure * to call [refreshState] */ val expandedLayout = ConstraintSet() var expandedLayout = ConstraintSet() @VisibleForTesting set /** Whether the guts are visible for the associated player. */ var isGutsVisible = false Loading Loading @@ -483,7 +493,7 @@ constructor( */ fun attach(transitionLayout: TransitionLayout, type: TYPE) = traceSection("MediaViewController#attach") { updateMediaViewControllerType(type) loadLayoutForType(type) logger.logMediaLocation("attach $type", currentStartLocation, currentEndLocation) this.transitionLayout = transitionLayout layoutController.attach(transitionLayout) Loading Loading @@ -641,7 +651,7 @@ constructor( return result } private fun updateMediaViewControllerType(type: TYPE) { private fun loadLayoutForType(type: TYPE) { this.type = type // These XML resources contain ConstraintSets that will apply to this player type's layout Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt +0 −41 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.systemui.media.controls.ui import android.app.PendingIntent import android.content.res.ColorStateList import android.content.res.Configuration import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.util.MathUtils.abs Loading Loading @@ -684,46 +683,6 @@ class MediaCarouselControllerTest : SysuiTestCase() { verify(pageIndicator).alpha = floatThat { abs(it - 1.0F) < delta } } @Test fun testOnConfigChanged_playersAreAddedBack() { mediaCarouselController.pageIndicator = pageIndicator listener.value.onMediaDataLoaded( "playing local", null, DATA.copy( active = true, isPlaying = true, playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = false ) ) listener.value.onMediaDataLoaded( "paused local", null, DATA.copy( active = true, isPlaying = false, playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = false ) ) runAllReady() val playersSize = MediaPlayerData.players().size configListener.value.onConfigChanged(Configuration()) runAllReady() verify(pageIndicator).tintList = ColorStateList.valueOf(context.getColor(R.color.media_paging_indicator)) assertEquals(playersSize, MediaPlayerData.players().size) assertEquals( MediaPlayerData.getMediaPlayerIndex("playing local"), mediaCarouselController.mediaCarouselScrollHandler.visibleMediaIndex ) } @Test fun testOnUiModeChanged_playersAreAddedBack() { mediaCarouselController.pageIndicator = pageIndicator Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.systemui.media.controls.ui import android.content.res.Configuration 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 @@ -58,6 +61,8 @@ 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 @@ -76,6 +81,19 @@ class MediaViewControllerTest : SysuiTestCase() { ) } @Test fun testOrientationChanged_layoutsAreLoaded() { mediaViewController.expandedLayout = expandedLayout mediaViewController.collapsedLayout = collapsedLayout val newConfig = Configuration() 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) } @Test fun testObtainViewState_applySquishFraction_toPlayerTransitionViewState_height() { mediaViewController.attach(player, MediaViewController.TYPE.PLAYER) Loading Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt +0 −8 Original line number Diff line number Diff line Loading @@ -197,7 +197,6 @@ constructor( private val configListener = object : ConfigurationController.ConfigurationListener { var lastOrientation = -1 override fun onDensityOrFontScaleChanged() { // System font changes should only happen when UMO is offscreen or a flicker may Loading @@ -214,13 +213,6 @@ constructor( override fun onConfigChanged(newConfig: Configuration?) { if (newConfig == null) return isRtl = newConfig.layoutDirection == View.LAYOUT_DIRECTION_RTL val newOrientation = newConfig.orientation if (lastOrientation != newOrientation) { // The players actually depend on the orientation possibly, so we have to // recreate them (at least on large screen devices) lastOrientation = newOrientation updatePlayers(recreateMedia = true) } } override fun onUiModeChanged() { Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +16 −6 Original line number Diff line number Diff line Loading @@ -154,9 +154,11 @@ constructor( return transitionLayout?.translationY ?: 0.0f } /** A callback for RTL config changes */ /** A callback for config changes */ private val configurationListener = object : ConfigurationController.ConfigurationListener { var lastOrientation = -1 override fun onConfigChanged(newConfig: Configuration?) { // Because the TransitionLayout is not always attached (and calculates/caches layout // results regardless of attach state), we have to force the layoutDirection of the Loading @@ -169,6 +171,13 @@ constructor( transitionLayout?.layoutDirection = layoutDirection refreshState() } val newOrientation = newConfig.orientation if (lastOrientation != newOrientation) { // Layout dimensions are possibly changing, so we need to update them. (at // least on large screen devices) lastOrientation = newOrientation loadLayoutForType(type) } } } } Loading @@ -195,13 +204,14 @@ constructor( * The expanded constraint set used to render a expanded player. If it is modified, make sure to * call [refreshState] */ val collapsedLayout = ConstraintSet() var collapsedLayout = ConstraintSet() @VisibleForTesting set /** * The expanded constraint set used to render a collapsed player. If it is modified, make sure * to call [refreshState] */ val expandedLayout = ConstraintSet() var expandedLayout = ConstraintSet() @VisibleForTesting set /** Whether the guts are visible for the associated player. */ var isGutsVisible = false Loading Loading @@ -483,7 +493,7 @@ constructor( */ fun attach(transitionLayout: TransitionLayout, type: TYPE) = traceSection("MediaViewController#attach") { updateMediaViewControllerType(type) loadLayoutForType(type) logger.logMediaLocation("attach $type", currentStartLocation, currentEndLocation) this.transitionLayout = transitionLayout layoutController.attach(transitionLayout) Loading Loading @@ -641,7 +651,7 @@ constructor( return result } private fun updateMediaViewControllerType(type: TYPE) { private fun loadLayoutForType(type: TYPE) { this.type = type // These XML resources contain ConstraintSets that will apply to this player type's layout Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt +0 −41 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.systemui.media.controls.ui import android.app.PendingIntent import android.content.res.ColorStateList import android.content.res.Configuration import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.util.MathUtils.abs Loading Loading @@ -684,46 +683,6 @@ class MediaCarouselControllerTest : SysuiTestCase() { verify(pageIndicator).alpha = floatThat { abs(it - 1.0F) < delta } } @Test fun testOnConfigChanged_playersAreAddedBack() { mediaCarouselController.pageIndicator = pageIndicator listener.value.onMediaDataLoaded( "playing local", null, DATA.copy( active = true, isPlaying = true, playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = false ) ) listener.value.onMediaDataLoaded( "paused local", null, DATA.copy( active = true, isPlaying = false, playbackLocation = MediaData.PLAYBACK_LOCAL, resumption = false ) ) runAllReady() val playersSize = MediaPlayerData.players().size configListener.value.onConfigChanged(Configuration()) runAllReady() verify(pageIndicator).tintList = ColorStateList.valueOf(context.getColor(R.color.media_paging_indicator)) assertEquals(playersSize, MediaPlayerData.players().size) assertEquals( MediaPlayerData.getMediaPlayerIndex("playing local"), mediaCarouselController.mediaCarouselScrollHandler.visibleMediaIndex ) } @Test fun testOnUiModeChanged_playersAreAddedBack() { mediaCarouselController.pageIndicator = pageIndicator Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.systemui.media.controls.ui import android.content.res.Configuration 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 @@ -58,6 +61,8 @@ 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 @@ -76,6 +81,19 @@ class MediaViewControllerTest : SysuiTestCase() { ) } @Test fun testOrientationChanged_layoutsAreLoaded() { mediaViewController.expandedLayout = expandedLayout mediaViewController.collapsedLayout = collapsedLayout val newConfig = Configuration() 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) } @Test fun testObtainViewState_applySquishFraction_toPlayerTransitionViewState_height() { mediaViewController.attach(player, MediaViewController.TYPE.PLAYER) Loading