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
This commit is contained in:
Justin Weir
2023-05-04 14:00:45 -04:00
parent ba26bf97c5
commit fb416ecf31
2 changed files with 10 additions and 2 deletions

View File

@@ -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")
}

View File

@@ -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)