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

Commit f9fbfa42 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure only distinct light reveal alpha gets processed" into main

parents 30dd7b34 ece8a4fc
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ object LightRevealScrimViewBinder {
                    launch("$TAG#viewModel.maxAlpha") {
                        var animator: ValueAnimator? = null
                        viewModel.maxAlpha.collect { (alpha, animate) ->
                            if (alpha != revealScrim.alpha) {
                            animator?.cancel()
                            if (!animate) {
                                revealScrim.alpha = alpha
@@ -65,7 +64,6 @@ object LightRevealScrimViewBinder {
                        }
                    }
                }
                }

                launch("$TAG#viewModel.revealAmount") {
                    viewModel.revealAmount.collect { revealScrim.revealAmount = it }
+10 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.systemui.keyguard.domain.interactor.LightRevealScrimInteracto
import com.android.systemui.statusbar.LightRevealEffect
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map

/**
@@ -34,13 +35,15 @@ constructor(private val interactor: LightRevealScrimInteractor) {

    /** Max alpha for the scrim + whether to animate the change */
    val maxAlpha: Flow<Pair<Float, Boolean>> =
        interactor.maxAlpha.map { alpha ->
        interactor.maxAlpha
            .map { alpha ->
                Pair(
                    alpha,
                    // Darken immediately if going to be fully opaque
                    if (alpha == 1f) false else true,
                )
            }
            .distinctUntilChanged()

    fun setWallpaperSupportsAmbientMode(supportsAmbientMode: Boolean) {
        interactor.setWallpaperSupportsAmbientMode(supportsAmbientMode)