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

Commit a1bd4e8b authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge "Reset umo settings cog when disable pagination changes" into main

parents e3475620 84af6d2f
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
@@ -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)
        }
    }
+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
}