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

Commit 03905757 authored by András Kurucz's avatar András Kurucz
Browse files

[flexiglass] Reset NSSL stack bounds from the unoccluded GONE scene

NSSL can display some content on the GONE scene (HUNs), and therefore
we'd like to have some consistent values for the stack bounds to be set.
However we only want these values if the GONE scene is NOT occluded by
the shade.

Fixes: 383321837
Test: open dual shade over gone -> notifications are positioned correctly
Flag: com.android.systemui.scene_container
Change-Id: I37a7e9880c47d20d051900df95d76fcfb4d12690
parent 91edaf64
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.notifications.ui.composable.SnoozeableHeadsUpNotific
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaLandscapeTopOffset
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaOffset.Default
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.viewmodel.GoneUserActionsViewModel
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView
@@ -70,18 +71,22 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {

        val isIdle by remember {
            derivedStateOf { layoutState.transitionState is TransitionState.Idle }
        val isIdleAndNotOccluded by remember {
            derivedStateOf {
                layoutState.transitionState is TransitionState.Idle &&
                    Overlays.NotificationsShade !in layoutState.transitionState.currentOverlays
            }
        }

        LaunchedEffect(isIdle) {
        LaunchedEffect(isIdleAndNotOccluded) {
            // Wait for being Idle on this Scene, otherwise LaunchedEffect would fire too soon,
            // and another transition could override the NSSL stack bounds.
            if (isIdle) {
            if (isIdleAndNotOccluded) {
                // Reset the stack bounds to avoid caching these values from the previous Scenes,
                // and not to confuse the StackScrollAlgorithm when it displays a HUN over GONE.
                notificationStackScrolLView.get().apply {
                    setStackTop(0f)
                    // use -headsUpInset to allow HUN translation outside bounds for snoozing
                    setStackTop(-getHeadsUpInset().toFloat())
                    setStackCutoff(0f)
                }
            }
+0 −5
Original line number Diff line number Diff line
@@ -108,11 +108,6 @@ constructor(
                    view.setPulsing(isPulsing, viewModel.shouldAnimatePulse.value)
                }
            }
            launch {
                viewModel.shouldResetStackTop
                    .filter { it }
                    .collectTraced { view.setStackTop(-(view.getHeadsUpInset().toFloat())) }
            }
            launch {
                viewModel.shouldCloseGuts
                    .filter { it }
+0 −6
Original line number Diff line number Diff line
@@ -192,12 +192,6 @@ constructor(
    /** Whether we should close any open notification guts. */
    val shouldCloseGuts: Flow<Boolean> = stackAppearanceInteractor.shouldCloseGuts

    val shouldResetStackTop: Flow<Boolean> =
        sceneInteractor.transitionState
            .mapNotNull { state -> state is Idle && state.currentScene == Scenes.Gone }
            .distinctUntilChanged()
            .dumpWhileCollecting("shouldResetStackTop")

    /** Whether the Notification Stack is visibly on the lockscreen scene. */
    val isShowingStackOnLockscreen: Flow<Boolean> =
        sceneInteractor.transitionState