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

Commit d62d358c authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[flexiglass] Adjust stack alpha during bouncer transition

Make notifs fade out at the same rate as other lockscreen content, while
swiping up to go to the bouncer. Made sure that both LOCKSCREEN->BOUNCER
and BOUNCER->LOCKSCREEN behave correctly.

This emulates the fade(end = 0.2f) behavior from STL.

This also fixes a bug where the stack would flash when pressing a
pulsing notification on AOD. This is because that triggers an
AOD->LOCKSCREEN transition that gets cancelled, followed by a
LOCKSCREEN->BOUNCER transition.

Fix: 438924860
Fix: 438901526
Test: manual with all types of shade
Flag: com.android.systemui.scene_container
Change-Id: Ied4c12708af9acd5da2cb8b4efc72a1a74706806
parent ddb9efea
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -68,11 +68,21 @@ constructor(private val blurConfig: BlurConfig, animationFlow: KeyguardTransitio
            onFinish = { 0f },
        )

    val lockscreenAlpha: Flow<Float> = shortcutsAlpha
    val lockscreenAlpha: Flow<Float> =
        if (SceneContainerFlag.isEnabled) {
            // Lockscreen -> Bouncer is a scene transition in Flexiglass.
            // SharedNotificationContainerViewModel#alphaForShadeAndQsExpansion might be relevant
            // instead.
            emptyFlow()
        } else {
            shortcutsAlpha
        }

    val notificationAlpha: Flow<Float> =
        if (SceneContainerFlag.isEnabled) {
            // Lockscreen -> Bouncer is a scene transition in Flexiglass.
            // SharedNotificationContainerViewModel#alphaForShadeAndQsExpansion might be relevant
            // instead.
            emptyFlow()
        } else if (Flags.bouncerUiRevamp()) {
            transitionAnimation.sharedFlowWithShade(
+15 −6
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@ import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow
import com.android.systemui.keyguard.ui.transitions.BlurConfig
import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition
import com.android.systemui.keyguard.ui.transitions.PrimaryBouncerTransition
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Overlays
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow

/**
 * Breaks down PRIMARY BOUNCER->LOCKSCREEN transition into discrete steps for corresponding views to
@@ -58,6 +60,12 @@ constructor(private val blurConfig: BlurConfig, animationFlow: KeyguardTransitio
        )

    fun lockscreenAlpha(viewState: ViewStateAccessor): Flow<Float> {
        if (SceneContainerFlag.isEnabled) {
            // Lockscreen -> Bouncer is a scene transition in Flexiglass.
            // SharedNotificationContainerViewModel#alphaForShadeAndQsExpansion might be relevant
            // instead.
            return emptyFlow()
        } else {
            var currentAlpha = 0f
            return transitionAnimation.sharedFlow(
                duration = 250.milliseconds,
@@ -65,6 +73,7 @@ constructor(private val blurConfig: BlurConfig, animationFlow: KeyguardTransitio
                onStep = { MathUtils.lerp(currentAlpha, 1f, it) },
            )
        }
    }

    val deviceEntryBackgroundViewAlpha: Flow<Float> =
        transitionAnimation.immediatelyTransitionTo(1f)
+12 −9
Original line number Diff line number Diff line
@@ -559,10 +559,8 @@ constructor(
                                shadeInteractor.qsExpansion,
                                bouncerInteractor.bouncerExpansion,
                            ) { shadeExpansion, qsExpansion, bouncerExpansion ->
                                if (bouncerExpansion == 1f) {
                                    emit(0f)
                                } else if (bouncerExpansion > 0f) {
                                    emit(1 - bouncerExpansion)
                                if (bouncerExpansion > 0f) {
                                    emit(alphaForBouncerExpansion(bouncerExpansion))
                                } else if (qsExpansion == 1f) {
                                    // Ensure HUNs will be visible in QS shade (at least while
                                    // unlocked)
@@ -576,10 +574,8 @@ constructor(
                            combineTransform(isAnyExpanded, bouncerInteractor.bouncerExpansion) {
                                isAnyExpanded,
                                bouncerExpansion ->
                                if (bouncerExpansion == 1f) {
                                    emit(0f)
                                } else if (bouncerExpansion > 0f) {
                                    emit(1 - bouncerExpansion)
                                if (bouncerExpansion > 0f) {
                                    emit(alphaForBouncerExpansion(bouncerExpansion))
                                } else if (isAnyExpanded) {
                                    emit(1f)
                                }
@@ -596,7 +592,7 @@ constructor(
                                qsExpansion,
                                bouncerExpansion ->
                                if (bouncerExpansion > 0f) {
                                    emit(1 - bouncerExpansion)
                                    emit(alphaForBouncerExpansion(bouncerExpansion))
                                } else if (isHeadsUpOrAnimatingAway) {
                                    // Ensure HUNs will be visible in QS shade (at least while
                                    // unlocked)
@@ -653,6 +649,13 @@ constructor(
            .onStart { emit(1f) }
            .dumpWhileCollecting("alphaForShadeAndQsExpansion")

    private fun alphaForBouncerExpansion(bouncerExpansion: Float): Float {
        // The shade content fades out faster than the bouncer comes in.
        // See lockscreenToOverlayTransition for the definition of how
        // the rest of the content behaves during the transition.
        return maxOf(0f, 1f - bouncerExpansion * 5f)
    }

    val panelAlpha = keyguardInteractor.panelAlpha

    private fun bouncerToGoneNotificationAlpha(viewState: ViewStateAccessor): Flow<Float> =