diff options
4 files changed, 37 insertions, 50 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt index 1c8bfd1fc468..8b7426336b80 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/models/player/MediaViewHolder.kt @@ -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, @@ -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, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt index 70f2dee006ed..0b33904829d5 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/models/recommendation/RecommendationViewHolder.kt @@ -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 } } 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 cd51d92062bc..4bca778b77c5 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 @@ -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 */ @@ -182,15 +151,14 @@ constructor( lastOrientation = newOrientation // 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 - ) + val backgroundIds = + if (type == TYPE.PLAYER) { + MediaViewHolder.backgroundIds + } else { + setOf(RecommendationViewHolder.backgroundId) } - } else { - expandedLayout.getConstraint(recSizingViewId).layout.mHeight = + backgroundIds.forEach { id -> + expandedLayout.getConstraint(id).layout.mHeight = context.resources.getDimensionPixelSize( R.dimen.qs_media_session_height_expanded ) @@ -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 @@ -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 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 4565762929d7..c9956f36dbeb 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 @@ -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 @@ -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 @@ -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( @@ -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 @@ -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) |