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

Commit fb416ecf authored by Justin Weir's avatar Justin Weir
Browse files

Add method for adding expansion listener without firing event

The current method immediately sends a change event to the listener,
which causes the AuthDialogPanelInteractionDetector dialog to
immediately cancel itself upon adding the listener. Adding a new
method that doesn't fire the event and calling that instead fixes
the problem.

Test: manually verified
Test: atest SystemUITests SystemUIGoogleTests
Fixes: 278455611
Change-Id: Id94bba0ab10890fd3c380d69cf6409c614c7e84c
parent ba26bf97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ constructor(
    fun enable(onPanelInteraction: Runnable) {
        if (action == null) {
            action = Action(onPanelInteraction)
            shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged)
            shadeExpansionStateManager.addShadeExpansionListener(this::onPanelExpansionChanged)
        } else {
            Log.e(TAG, "Already enabled")
        }
+9 −1
Original line number Diff line number Diff line
@@ -54,12 +54,20 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
     * Listener will also be immediately notified with the current values.
     */
    fun addExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.add(listener)
        addShadeExpansionListener(listener)
        listener.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount)
        )
    }

    /**
     * Adds a listener that will be notified when the panel expansion fraction has changed.
     * @see #addExpansionListener
     */
    fun addShadeExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.add(listener)
    }

    /** Removes an expansion listener. */
    fun removeExpansionListener(listener: ShadeExpansionListener) {
        expansionListeners.remove(listener)