diff options
3 files changed, 32 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt index 5a39a6272c94..32a8b355c7b0 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt @@ -254,6 +254,7 @@ constructor( expandedMatchesParentHeight = true showsOnlyActiveMedia = false falsingProtectionNeeded = false + disablePagination = true init(MediaHierarchyManager.LOCATION_COMMUNAL_HUB) } } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt index 8fd578e99b33..f5a7966b7c1e 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt @@ -166,6 +166,9 @@ constructor( /** Is the player currently visible (at the end of the transformation */ private var playersVisible: Boolean = false + /** Are we currently disabling pagination only allowing one media session to show */ + private var currentlyDisablePagination: Boolean = false + /** * The desired location where we'll be at the end of the transformation. Usually this matches * the end location, except when we're still waiting on a state update call. @@ -1355,14 +1358,20 @@ constructor( val endShowsActive = hostStates[currentEndLocation]?.showsOnlyActiveMedia ?: true val startShowsActive = hostStates[currentStartLocation]?.showsOnlyActiveMedia ?: endShowsActive + val startDisablePagination = hostStates[currentStartLocation]?.disablePagination ?: false + val endDisablePagination = hostStates[currentEndLocation]?.disablePagination ?: false + if ( currentlyShowingOnlyActive != endShowsActive || + currentlyDisablePagination != endDisablePagination || ((currentTransitionProgress != 1.0f && currentTransitionProgress != 0.0f) && - startShowsActive != endShowsActive) + (startShowsActive != endShowsActive || + startDisablePagination != endDisablePagination)) ) { // Whenever we're transitioning from between differing states or the endstate differs // we reset the translation currentlyShowingOnlyActive = endShowsActive + currentlyDisablePagination = endDisablePagination mediaCarouselScrollHandler.resetTranslation(animate = true) } } diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/view/MediaHost.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/view/MediaHost.kt index 91050c8bfab3..09a618110f21 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/view/MediaHost.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/view/MediaHost.kt @@ -44,6 +44,7 @@ class MediaHost( lateinit var hostView: UniqueObjectHostView var location: Int = -1 private set + private var visibleChangedListeners: ArraySet<(Boolean) -> Unit> = ArraySet() private val tmpLocationOnScreen: IntArray = intArrayOf(0, 0) @@ -287,6 +288,15 @@ class MediaHost( changedListener?.invoke() } + override var disablePagination: Boolean = false + set(value) { + if (field == value) { + return + } + field = value + changedListener?.invoke() + } + private var lastDisappearHash = disappearParameters.hashCode() /** A listener for all changes. This won't be copied over when invoking [copy] */ @@ -303,6 +313,7 @@ class MediaHost( mediaHostState.visible = visible mediaHostState.disappearParameters = disappearParameters.deepCopy() mediaHostState.falsingProtectionNeeded = falsingProtectionNeeded + mediaHostState.disablePagination = disablePagination return mediaHostState } @@ -331,6 +342,9 @@ class MediaHost( if (!disappearParameters.equals(other.disappearParameters)) { return false } + if (disablePagination != other.disablePagination) { + return false + } return true } @@ -342,6 +356,7 @@ class MediaHost( result = 31 * result + showsOnlyActiveMedia.hashCode() result = 31 * result + if (visible) 1 else 2 result = 31 * result + disappearParameters.hashCode() + result = 31 * result + disablePagination.hashCode() return result } } @@ -400,6 +415,12 @@ interface MediaHostState { */ var disappearParameters: DisappearParameters + /** + * Whether pagination should be disabled for this host, meaning that when there are multiple + * media sessions, only the first one will appear. + */ + var disablePagination: Boolean + /** Get a copy of this view state, deepcopying all appropriate members */ fun copy(): MediaHostState } |