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

Commit 6e6c85ba authored by Chandru S's avatar Chandru S
Browse files

Move old implementation to a separate method to make reviews easier.

Other changes:
 - formatting

Bug: 405368373
Flag: EXEMPT minor refactoring
Test: NA

Change-Id: I0c8ef75a1fe12a634dae4225f14b0412800d0421
parent 206f61e7
Loading
Loading
Loading
Loading
+36 −28
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ constructor(
            createScrimAlphaFlow(
                duration,
                fromState,
                primaryBouncerInteractor::willRunDismissFromKeyguard
                primaryBouncerInteractor::willRunDismissFromKeyguard,
            )
        }
    }
@@ -79,11 +79,9 @@ constructor(
                        Edge.INVALID
                    } else {
                        Edge.create(from = from, to = Scenes.Gone)
                    }
            )
            .setupWithoutSceneContainer(
                edge = Edge.create(from = from, to = GONE),
                    },
            )
            .setupWithoutSceneContainer(edge = Edge.create(from = from, to = GONE))
            .sharedFlow(
                duration = duration,
                onStart = { leaveShadeOpen = statusBarStateController.leaveOpenOnKeyguardHide() },
@@ -98,7 +96,7 @@ constructor(
    private fun createScrimAlphaFlow(
        duration: Duration,
        fromState: KeyguardState,
        willRunAnimationOnKeyguard: () -> Boolean
        willRunAnimationOnKeyguard: () -> Boolean,
    ): Flow<ScrimAlpha> {
        var isShadeExpanded = false
        var leaveShadeOpen: Boolean = false
@@ -112,11 +110,9 @@ constructor(
                            Edge.INVALID
                        } else {
                            Edge.create(from = fromState, to = Scenes.Gone)
                        }
                )
                .setupWithoutSceneContainer(
                    edge = Edge.create(from = fromState, to = GONE),
                        },
                )
                .setupWithoutSceneContainer(edge = Edge.create(from = fromState, to = GONE))

        return shadeInteractor.anyExpansion
            .map { it > 0f }
@@ -131,27 +127,39 @@ constructor(
                            willRunDismissFromKeyguard = willRunAnimationOnKeyguard()
                            isShadeExpanded = isAnyExpanded
                        },
                        onStep = { 1f - it },
                        onStep = { it },
                    )
                    .map {
                        if (willRunDismissFromKeyguard) {
                        mapToScrimAlphas(
                            it,
                            willRunDismissFromKeyguard,
                            isShadeExpanded,
                            leaveShadeOpen
                        )
                    }
            }
    }

    private fun mapToScrimAlphas(
        transitionProgress: Float,
        willRunDismissFromKeyguard: Boolean,
        isShadeExpanded: Boolean,
        leaveShadeOpen: Boolean,
    ): ScrimAlpha {
        val invertedTransitionProgress = 1 - transitionProgress
        return if (willRunDismissFromKeyguard) {
            if (isShadeExpanded) {
                ScrimAlpha(
                                    behindAlpha = it,
                                    notificationsAlpha = it,
                    behindAlpha = invertedTransitionProgress,
                    notificationsAlpha = invertedTransitionProgress,
                )
            } else {
                ScrimAlpha()
            }
        } else if (leaveShadeOpen) {
                            ScrimAlpha(
                                behindAlpha = 1f,
                                notificationsAlpha = 1f,
                            )
            ScrimAlpha(behindAlpha = 1f, notificationsAlpha = 1f)
        } else {
                            ScrimAlpha(behindAlpha = it)
                        }
                    }
            ScrimAlpha(behindAlpha = invertedTransitionProgress)
        }
    }
}