Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84af6d2f authored by Darrell Shi's avatar Darrell Shi
Browse files

Reset umo settings cog when disable pagination changes

This change fixes an issue where if the umo is swiped to show settings
cog in the shade, this state does not get reset when going from shade to
communal, causing the umo only appear paritally in the communal grid.

Fix: 361090914
Bug: 341319629
Test: manually verified umo gets reset when going from shade to communal
Flag: com.android.systemui.communal_hub
Change-Id: Ie24eadc25ef004dab91ca6ea5a34c8aa3efc5754
parent 88f1c7e6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ constructor(
            expandedMatchesParentHeight = true
            showsOnlyActiveMedia = false
            falsingProtectionNeeded = false
            disablePagination = true
            init(MediaHierarchyManager.LOCATION_COMMUNAL_HUB)
        }
    }
+10 −1
Original line number Diff line number Diff line
@@ -164,6 +164,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.
@@ -1347,14 +1350,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)
        }
    }
+21 −0
Original line number Diff line number Diff line
@@ -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
}