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

Commit bd6890b9 authored by burakov's avatar burakov Committed by Danny Burakov
Browse files

[bc25] Reset ShadeSessionStorage when Dual Shade is visible.

Bonus 1: This also slightly improves the definition of a "session" for the existing shade as well: not only when it's idle or transitioning out
(previous definition), but also when it's transitioning in.

Bonus 2: Refactor OverlayShade's combinePaddings() to be more readable
(albeit less concise).

Bug: 356596436
Flag: com.android.systemui.scene_container
Flag: com.android.systemui.dual_shade
Test: Existing unit tests still pass.
Change-Id: I068e8d92742f769f494376956462ec083477d02a
parent 99e12a24
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -152,15 +152,18 @@ private fun Modifier.panelPadding(): Modifier {
/** Creates a union of [paddingValues] by using the max padding of each edge. */
@Composable
private fun combinePaddings(vararg paddingValues: PaddingValues): PaddingValues {
    return if (paddingValues.isEmpty()) {
        PaddingValues(0.dp)
    } else {
        val layoutDirection = LocalLayoutDirection.current

    return PaddingValues(
        start = paddingValues.maxOfOrNull { it.calculateStartPadding(layoutDirection) } ?: 0.dp,
        top = paddingValues.maxOfOrNull { it.calculateTopPadding() } ?: 0.dp,
        end = paddingValues.maxOfOrNull { it.calculateEndPadding(layoutDirection) } ?: 0.dp,
        bottom = paddingValues.maxOfOrNull { it.calculateBottomPadding() } ?: 0.dp,
        PaddingValues(
            start = paddingValues.maxOf { it.calculateStartPadding(layoutDirection) },
            top = paddingValues.maxOf { it.calculateTopPadding() },
            end = paddingValues.maxOf { it.calculateEndPadding(layoutDirection) },
            bottom = paddingValues.maxOf { it.calculateBottomPadding() },
        )
    }
}

object OverlayShade {
    object Elements {
+6 −12
Original line number Diff line number Diff line
@@ -193,22 +193,16 @@ constructor(
                        // We are in a session if either Shade or QuickSettings is on the back stack
                        .map { backStack ->
                            backStack.asIterable().any {
                                // TODO(b/356596436): Include overlays in the back stack as well.
                                it == Scenes.Shade || it == Scenes.QuickSettings
                            }
                        }
                        .distinctUntilChanged(),
                    sceneInteractor.transitionState
                        .mapNotNull { state ->
                            // We are also in a session if either Shade or QuickSettings is the
                            // current scene
                            when (state) {
                                is ObservableTransitionState.Idle -> state.currentScene
                                is ObservableTransitionState.Transition -> state.fromContent
                            }.let { it == Scenes.Shade || it == Scenes.QuickSettings }
                        }
                        .distinctUntilChanged(),
                ) { inBackStack, isCurrentScene ->
                    inBackStack || isCurrentScene
                    // We are also in a session if either Notifications Shade or QuickSettings Shade
                    // is currently shown (whether idle or animating).
                    shadeInteractor.isAnyExpanded,
                ) { inBackStack, isShadeShown ->
                    inBackStack || isShadeShown
                }
                // Once a session has ended, clear the session storage.
                .filter { inSession -> !inSession }