Loading packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt +17 −1 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ class MediaViewHolder constructor(itemView: View) { val expandedBottomActionIds = setOf( R.id.media_progress_bar, R.id.actionPrev, R.id.actionNext, R.id.action0, Loading @@ -155,7 +156,22 @@ class MediaViewHolder constructor(itemView: View) { R.id.action3, R.id.action4, R.id.media_scrubbing_elapsed_time, R.id.media_scrubbing_total_time R.id.media_scrubbing_total_time, ) val detailIds = setOf( R.id.header_title, R.id.header_artist, R.id.media_explicit_indicator, R.id.actionPlayPause, ) val backgroundIds = setOf( R.id.album_art, R.id.turbulence_noise_view, R.id.touch_ripple_view, ) } } packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt +2 −0 Original line number Diff line number Diff line Loading @@ -180,5 +180,7 @@ class RecommendationViewHolder private constructor(itemView: View, updatedView: R.id.media_cover2_container, R.id.media_cover3_container ) val backgroundId = R.id.sizing_view } } packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +11 −43 Original line number Diff line number Diff line Loading @@ -61,37 +61,6 @@ constructor( companion object { @JvmField val GUTS_ANIMATION_DURATION = 500L val controlIds = setOf( R.id.media_progress_bar, R.id.actionNext, R.id.actionPrev, R.id.action0, R.id.action1, R.id.action2, R.id.action3, R.id.action4, R.id.media_scrubbing_elapsed_time, R.id.media_scrubbing_total_time ) val detailIds = setOf( R.id.header_title, R.id.header_artist, R.id.media_explicit_indicator, R.id.actionPlayPause, ) val backgroundIds = setOf( R.id.album_art, 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 @@ -182,19 +151,18 @@ constructor( lastOrientation = newOrientation // Update the height of media controls for the expanded layout. it is needed // for large screen devices. val backgroundIds = if (type == TYPE.PLAYER) { MediaViewHolder.backgroundIds } else { setOf(RecommendationViewHolder.backgroundId) } 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 ) } } if (this@MediaViewController::configurationChangeListener.isInitialized) { configurationChangeListener.invoke() Loading Loading @@ -338,19 +306,19 @@ constructor( squishedViewState.height = squishedHeight // We are not overriding the squishedViewStates height but only the children to avoid // them remeasuring the whole view. Instead it just remains as the original size backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> squishedViewState.widgetStates.get(id)?.let { state -> state.height = squishedHeight } } // media player calculateWidgetGroupAlphaForSquishiness( controlIds, MediaViewHolder.expandedBottomActionIds, squishedViewState.measureHeight.toFloat(), squishedViewState, squishFraction ) calculateWidgetGroupAlphaForSquishiness( detailIds, MediaViewHolder.detailIds, squishedViewState.measureHeight.toFloat(), squishedViewState, squishFraction Loading Loading @@ -660,7 +628,7 @@ constructor( result.height = result.measureHeight result.width = result.measureWidth // Make sure all background views are also resized such that their size is correct backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> result.widgetStates.get(id)?.let { state -> state.height = result.height state.width = result.width Loading packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.view.View import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.media.controls.models.player.MediaViewHolder import com.android.systemui.media.controls.models.recommendation.RecommendationViewHolder import com.android.systemui.media.controls.util.MediaFlags import com.android.systemui.util.animation.MeasurementInput import com.android.systemui.util.animation.TransitionLayout Loading Loading @@ -55,13 +57,12 @@ class MediaViewControllerTest : SysuiTestCase() { @Mock private lateinit var mockCopiedState: TransitionViewState @Mock private lateinit var detailWidgetState: WidgetState @Mock private lateinit var controlWidgetState: WidgetState @Mock private lateinit var bgWidgetState: WidgetState @Mock private lateinit var mediaTitleWidgetState: WidgetState @Mock private lateinit var mediaSubTitleWidgetState: WidgetState @Mock private lateinit var mediaContainerWidgetState: WidgetState @Mock private lateinit var mediaFlags: MediaFlags val delta = 0.1F private val delta = 0.1F private lateinit var mediaViewController: MediaViewController Loading @@ -84,13 +85,13 @@ class MediaViewControllerTest : SysuiTestCase() { mediaViewController.attach(player, MediaViewController.TYPE.PLAYER) // Change the height to see the effect of orientation change. MediaViewController.backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> mediaViewController.expandedLayout.getConstraint(id).layout.mHeight = 10 } newConfig.orientation = ORIENTATION_LANDSCAPE configurationController.onConfigurationChanged(newConfig) MediaViewController.backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> assertTrue( mediaViewController.expandedLayout.getConstraint(id).layout.mHeight == context.resources.getDimensionPixelSize( Loading @@ -107,7 +108,7 @@ class MediaViewControllerTest : SysuiTestCase() { mediaViewController.attach(recommendation, MediaViewController.TYPE.RECOMMENDATION) // Change the height to see the effect of orientation change. mediaViewController.expandedLayout .getConstraint(MediaViewController.recSizingViewId) .getConstraint(RecommendationViewHolder.backgroundId) .layout .mHeight = 10 newConfig.orientation = ORIENTATION_LANDSCAPE Loading @@ -115,7 +116,7 @@ class MediaViewControllerTest : SysuiTestCase() { assertTrue( mediaViewController.expandedLayout .getConstraint(MediaViewController.recSizingViewId) .getConstraint(RecommendationViewHolder.backgroundId) .layout .mHeight == context.resources.getDimensionPixelSize(R.dimen.qs_media_session_height_expanded) Loading Loading
packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt +17 −1 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ class MediaViewHolder constructor(itemView: View) { val expandedBottomActionIds = setOf( R.id.media_progress_bar, R.id.actionPrev, R.id.actionNext, R.id.action0, Loading @@ -155,7 +156,22 @@ class MediaViewHolder constructor(itemView: View) { R.id.action3, R.id.action4, R.id.media_scrubbing_elapsed_time, R.id.media_scrubbing_total_time R.id.media_scrubbing_total_time, ) val detailIds = setOf( R.id.header_title, R.id.header_artist, R.id.media_explicit_indicator, R.id.actionPlayPause, ) val backgroundIds = setOf( R.id.album_art, R.id.turbulence_noise_view, R.id.touch_ripple_view, ) } }
packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt +2 −0 Original line number Diff line number Diff line Loading @@ -180,5 +180,7 @@ class RecommendationViewHolder private constructor(itemView: View, updatedView: R.id.media_cover2_container, R.id.media_cover3_container ) val backgroundId = R.id.sizing_view } }
packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +11 −43 Original line number Diff line number Diff line Loading @@ -61,37 +61,6 @@ constructor( companion object { @JvmField val GUTS_ANIMATION_DURATION = 500L val controlIds = setOf( R.id.media_progress_bar, R.id.actionNext, R.id.actionPrev, R.id.action0, R.id.action1, R.id.action2, R.id.action3, R.id.action4, R.id.media_scrubbing_elapsed_time, R.id.media_scrubbing_total_time ) val detailIds = setOf( R.id.header_title, R.id.header_artist, R.id.media_explicit_indicator, R.id.actionPlayPause, ) val backgroundIds = setOf( R.id.album_art, 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 @@ -182,19 +151,18 @@ constructor( lastOrientation = newOrientation // Update the height of media controls for the expanded layout. it is needed // for large screen devices. val backgroundIds = if (type == TYPE.PLAYER) { MediaViewHolder.backgroundIds } else { setOf(RecommendationViewHolder.backgroundId) } 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 ) } } if (this@MediaViewController::configurationChangeListener.isInitialized) { configurationChangeListener.invoke() Loading Loading @@ -338,19 +306,19 @@ constructor( squishedViewState.height = squishedHeight // We are not overriding the squishedViewStates height but only the children to avoid // them remeasuring the whole view. Instead it just remains as the original size backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> squishedViewState.widgetStates.get(id)?.let { state -> state.height = squishedHeight } } // media player calculateWidgetGroupAlphaForSquishiness( controlIds, MediaViewHolder.expandedBottomActionIds, squishedViewState.measureHeight.toFloat(), squishedViewState, squishFraction ) calculateWidgetGroupAlphaForSquishiness( detailIds, MediaViewHolder.detailIds, squishedViewState.measureHeight.toFloat(), squishedViewState, squishFraction Loading Loading @@ -660,7 +628,7 @@ constructor( result.height = result.measureHeight result.width = result.measureWidth // Make sure all background views are also resized such that their size is correct backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> result.widgetStates.get(id)?.let { state -> state.height = result.height state.width = result.width Loading
packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaViewControllerTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.view.View import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.media.controls.models.player.MediaViewHolder import com.android.systemui.media.controls.models.recommendation.RecommendationViewHolder import com.android.systemui.media.controls.util.MediaFlags import com.android.systemui.util.animation.MeasurementInput import com.android.systemui.util.animation.TransitionLayout Loading Loading @@ -55,13 +57,12 @@ class MediaViewControllerTest : SysuiTestCase() { @Mock private lateinit var mockCopiedState: TransitionViewState @Mock private lateinit var detailWidgetState: WidgetState @Mock private lateinit var controlWidgetState: WidgetState @Mock private lateinit var bgWidgetState: WidgetState @Mock private lateinit var mediaTitleWidgetState: WidgetState @Mock private lateinit var mediaSubTitleWidgetState: WidgetState @Mock private lateinit var mediaContainerWidgetState: WidgetState @Mock private lateinit var mediaFlags: MediaFlags val delta = 0.1F private val delta = 0.1F private lateinit var mediaViewController: MediaViewController Loading @@ -84,13 +85,13 @@ class MediaViewControllerTest : SysuiTestCase() { mediaViewController.attach(player, MediaViewController.TYPE.PLAYER) // Change the height to see the effect of orientation change. MediaViewController.backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> mediaViewController.expandedLayout.getConstraint(id).layout.mHeight = 10 } newConfig.orientation = ORIENTATION_LANDSCAPE configurationController.onConfigurationChanged(newConfig) MediaViewController.backgroundIds.forEach { id -> MediaViewHolder.backgroundIds.forEach { id -> assertTrue( mediaViewController.expandedLayout.getConstraint(id).layout.mHeight == context.resources.getDimensionPixelSize( Loading @@ -107,7 +108,7 @@ class MediaViewControllerTest : SysuiTestCase() { mediaViewController.attach(recommendation, MediaViewController.TYPE.RECOMMENDATION) // Change the height to see the effect of orientation change. mediaViewController.expandedLayout .getConstraint(MediaViewController.recSizingViewId) .getConstraint(RecommendationViewHolder.backgroundId) .layout .mHeight = 10 newConfig.orientation = ORIENTATION_LANDSCAPE Loading @@ -115,7 +116,7 @@ class MediaViewControllerTest : SysuiTestCase() { assertTrue( mediaViewController.expandedLayout .getConstraint(MediaViewController.recSizingViewId) .getConstraint(RecommendationViewHolder.backgroundId) .layout .mHeight == context.resources.getDimensionPixelSize(R.dimen.qs_media_session_height_expanded) Loading