Loading packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt +1 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,7 @@ class MediaCarouselController @Inject constructor( if (numPages == 1) { pageIndicator.setLocation(0f) } updatePageIndicatorAlpha() } /** Loading packages/SystemUI/src/com/android/systemui/media/MediaHost.kt +1 −2 Original line number Diff line number Diff line package com.android.systemui.media import android.graphics.PointF import android.graphics.Rect import android.util.ArraySet import android.view.View Loading Loading @@ -101,7 +100,7 @@ class MediaHost @Inject constructor( } // This will trigger a state change that ensures that we now have a state available state.measurementInput = input return mediaHostStatesManager.getPlayerDimensions(state) return mediaHostStatesManager.updateCarouselDimensions(location, state) } } Loading packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt +12 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ class MediaHostStatesManager @Inject constructor() { private val callbacks: MutableSet<Callback> = mutableSetOf() private val controllers: MutableSet<MediaViewController> = mutableSetOf() /** * The overall sizes of the carousel. This is needed to make sure all players in the carousel * have equal size. */ val carouselSizes: MutableMap<Int, MeasurementOutput> = mutableMapOf() /** * A map with all media states of all locations. */ Loading @@ -45,6 +51,7 @@ class MediaHostStatesManager @Inject constructor() { if (!hostState.equals(currentState)) { val newState = hostState.copy() mediaHostStates.put(location, newState) updateCarouselDimensions(location, hostState) // First update all the controllers to ensure they get the chance to measure for (controller in controllers) { controller.stateCallback.onHostStateChanged(location, newState) Loading @@ -61,7 +68,10 @@ class MediaHostStatesManager @Inject constructor() { * Get the dimensions of all players combined, which determines the overall height of the * media carousel and the media hosts. */ fun getPlayerDimensions(hostState: MediaHostState): MeasurementOutput { fun updateCarouselDimensions( @MediaLocation location: Int, hostState: MediaHostState ): MeasurementOutput { val result = MeasurementOutput(0, 0) for (controller in controllers) { val measurement = controller.getMeasurementsForState(hostState) Loading @@ -74,6 +84,7 @@ class MediaHostStatesManager @Inject constructor() { } } } carouselSizes[location] = result return result } Loading packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt +30 −3 Original line number Diff line number Diff line Loading @@ -78,6 +78,16 @@ class MediaViewController @Inject constructor( */ private val tmpState = TransitionViewState() /** * A temporary state used to store intermediate measurements. */ private val tmpState2 = TransitionViewState() /** * A temporary state used to store intermediate measurements. */ private val tmpState3 = TransitionViewState() /** * A temporary cache key to be used to look up cache entries */ Loading Loading @@ -304,8 +314,8 @@ class MediaViewController @Inject constructor( // Obtain the view state that we'd want to be at the end // The view might not be bound yet or has never been measured and in that case will be // reset once the state is fully available val endViewState = obtainViewState(endHostState) ?: return var endViewState = obtainViewState(endHostState) ?: return endViewState = updateViewStateToCarouselSize(endViewState, endLocation, tmpState2)!! layoutController.setMeasureState(endViewState) // If the view isn't bound, we can drop the animation, otherwise we'll execute it Loading @@ -315,7 +325,8 @@ class MediaViewController @Inject constructor( } val result: TransitionViewState val startViewState = obtainViewState(startHostState) var startViewState = obtainViewState(startHostState) startViewState = updateViewStateToCarouselSize(startViewState, startLocation, tmpState3) if (!endHostState.visible) { // Let's handle the case where the end is gone first. In this case we take the Loading Loading @@ -350,6 +361,22 @@ class MediaViewController @Inject constructor( animationDelay) } private fun updateViewStateToCarouselSize( viewState: TransitionViewState?, location: Int, outState: TransitionViewState ) : TransitionViewState? { val result = viewState?.copy(outState) ?: return null val overrideSize = mediaHostStatesManager.carouselSizes[location] overrideSize?.let { // To be safe we're using a maximum here. The override size should always be set // properly though. result.height = Math.max(it.measuredHeight, result.height) result.width = Math.max(it.measuredWidth, result.width) } return result } /** * Retrieves the [TransitionViewState] and [MediaHostState] of a [@MediaLocation]. * In the event of [location] not being visible, [locationWhenHidden] will be used instead. Loading Loading
packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt +1 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,7 @@ class MediaCarouselController @Inject constructor( if (numPages == 1) { pageIndicator.setLocation(0f) } updatePageIndicatorAlpha() } /** Loading
packages/SystemUI/src/com/android/systemui/media/MediaHost.kt +1 −2 Original line number Diff line number Diff line package com.android.systemui.media import android.graphics.PointF import android.graphics.Rect import android.util.ArraySet import android.view.View Loading Loading @@ -101,7 +100,7 @@ class MediaHost @Inject constructor( } // This will trigger a state change that ensures that we now have a state available state.measurementInput = input return mediaHostStatesManager.getPlayerDimensions(state) return mediaHostStatesManager.updateCarouselDimensions(location, state) } } Loading
packages/SystemUI/src/com/android/systemui/media/MediaHostStatesManager.kt +12 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ class MediaHostStatesManager @Inject constructor() { private val callbacks: MutableSet<Callback> = mutableSetOf() private val controllers: MutableSet<MediaViewController> = mutableSetOf() /** * The overall sizes of the carousel. This is needed to make sure all players in the carousel * have equal size. */ val carouselSizes: MutableMap<Int, MeasurementOutput> = mutableMapOf() /** * A map with all media states of all locations. */ Loading @@ -45,6 +51,7 @@ class MediaHostStatesManager @Inject constructor() { if (!hostState.equals(currentState)) { val newState = hostState.copy() mediaHostStates.put(location, newState) updateCarouselDimensions(location, hostState) // First update all the controllers to ensure they get the chance to measure for (controller in controllers) { controller.stateCallback.onHostStateChanged(location, newState) Loading @@ -61,7 +68,10 @@ class MediaHostStatesManager @Inject constructor() { * Get the dimensions of all players combined, which determines the overall height of the * media carousel and the media hosts. */ fun getPlayerDimensions(hostState: MediaHostState): MeasurementOutput { fun updateCarouselDimensions( @MediaLocation location: Int, hostState: MediaHostState ): MeasurementOutput { val result = MeasurementOutput(0, 0) for (controller in controllers) { val measurement = controller.getMeasurementsForState(hostState) Loading @@ -74,6 +84,7 @@ class MediaHostStatesManager @Inject constructor() { } } } carouselSizes[location] = result return result } Loading
packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt +30 −3 Original line number Diff line number Diff line Loading @@ -78,6 +78,16 @@ class MediaViewController @Inject constructor( */ private val tmpState = TransitionViewState() /** * A temporary state used to store intermediate measurements. */ private val tmpState2 = TransitionViewState() /** * A temporary state used to store intermediate measurements. */ private val tmpState3 = TransitionViewState() /** * A temporary cache key to be used to look up cache entries */ Loading Loading @@ -304,8 +314,8 @@ class MediaViewController @Inject constructor( // Obtain the view state that we'd want to be at the end // The view might not be bound yet or has never been measured and in that case will be // reset once the state is fully available val endViewState = obtainViewState(endHostState) ?: return var endViewState = obtainViewState(endHostState) ?: return endViewState = updateViewStateToCarouselSize(endViewState, endLocation, tmpState2)!! layoutController.setMeasureState(endViewState) // If the view isn't bound, we can drop the animation, otherwise we'll execute it Loading @@ -315,7 +325,8 @@ class MediaViewController @Inject constructor( } val result: TransitionViewState val startViewState = obtainViewState(startHostState) var startViewState = obtainViewState(startHostState) startViewState = updateViewStateToCarouselSize(startViewState, startLocation, tmpState3) if (!endHostState.visible) { // Let's handle the case where the end is gone first. In this case we take the Loading Loading @@ -350,6 +361,22 @@ class MediaViewController @Inject constructor( animationDelay) } private fun updateViewStateToCarouselSize( viewState: TransitionViewState?, location: Int, outState: TransitionViewState ) : TransitionViewState? { val result = viewState?.copy(outState) ?: return null val overrideSize = mediaHostStatesManager.carouselSizes[location] overrideSize?.let { // To be safe we're using a maximum here. The override size should always be set // properly though. result.height = Math.max(it.measuredHeight, result.height) result.width = Math.max(it.measuredWidth, result.width) } return result } /** * Retrieves the [TransitionViewState] and [MediaHostState] of a [@MediaLocation]. * In the event of [location] not being visible, [locationWhenHidden] will be used instead. Loading