Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt +12 −8 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.power.shared.model.ScreenPowerState import com.android.systemui.power.shared.model.WakeSleepReason import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.LightRevealEffect import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.sample import dagger.Lazy import javax.inject.Inject Loading Loading @@ -96,16 +97,19 @@ constructor( /** Limit the max alpha for the scrim to allow for some transparency */ val maxAlpha: Flow<Float> = transitionInteractor .isInTransition( anyOf( transitionInteractor.isInTransition( edge = Edge.create(Scenes.Gone, KeyguardState.AOD), edgeWithoutSceneContainer = Edge.create(KeyguardState.GONE, KeyguardState.AOD), ), transitionInteractor.isInTransition( Edge.create(KeyguardState.OCCLUDED, KeyguardState.AOD) ), ) .flatMapLatest { isInTransition -> // During GONE->AOD transitions, the home screen and wallpaper are still visible // until // WM is told to hide them, which occurs at the end of the animation. Use an opaque // scrim until this transition is complete // During transitions like GONE->AOD, surfaces like the launcher may be visible // until WM is told to hide them, which occurs at the end of the animation. Use an // opaque scrim until this transition is complete. if (isInTransition) { flowOf(1f) } else { Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt +18 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.binder import android.animation.ValueAnimator import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.app.animation.Interpolators.ALPHA_IN import com.android.app.tracing.coroutines.launchTraced as launch import com.android.systemui.keyguard.ui.viewmodel.LightRevealScrimViewModel import com.android.systemui.lifecycle.repeatWhenAttached Loading @@ -43,12 +44,21 @@ object LightRevealScrimViewBinder { } } launch("$TAG#viewModel.maxAlpha") { viewModel.maxAlpha.collect { alpha -> var animator: ValueAnimator? = null viewModel.maxAlpha.collect { (alpha, animate) -> if (alpha != revealScrim.alpha) { animator?.cancel() if (!animate) { revealScrim.alpha = alpha } else { animator = ValueAnimator.ofFloat(revealScrim.alpha, alpha).apply { duration = 400 startDelay = 333 duration = 733 interpolator = ALPHA_IN addUpdateListener { animation -> revealScrim.alpha = animation.getAnimatedValue() as Float revealScrim.alpha = animation.getAnimatedValue() as Float } start() } Loading @@ -56,6 +66,7 @@ object LightRevealScrimViewBinder { } } } } launch("$TAG#viewModel.revealAmount") { viewModel.revealAmount.collect { revealScrim.revealAmount = it } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt +11 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.systemui.statusbar.LightRevealEffect import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map /** * Models UI state for the light reveal scrim, which is used during screen on and off animations to Loading @@ -32,7 +33,16 @@ class LightRevealScrimViewModel constructor(private val interactor: LightRevealScrimInteractor) { val lightRevealEffect: Flow<LightRevealEffect> = interactor.lightRevealEffect val revealAmount: Flow<Float> = interactor.revealAmount val maxAlpha: Flow<Float> = interactor.maxAlpha /** Max alpha for the scrim + whether to animate the change */ val maxAlpha: Flow<Pair<Float, Boolean>> = interactor.maxAlpha.map { alpha -> Pair( alpha, // Darken immediately if going to be fully opaque if (alpha == 1f) false else true, ) } fun setWallpaperSupportsAmbientMode(supportsAmbientMode: Boolean) { interactor.setWallpaperSupportsAmbientMode(supportsAmbientMode) Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt +12 −8 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.power.shared.model.ScreenPowerState import com.android.systemui.power.shared.model.WakeSleepReason import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.LightRevealEffect import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf import com.android.systemui.util.kotlin.sample import dagger.Lazy import javax.inject.Inject Loading Loading @@ -96,16 +97,19 @@ constructor( /** Limit the max alpha for the scrim to allow for some transparency */ val maxAlpha: Flow<Float> = transitionInteractor .isInTransition( anyOf( transitionInteractor.isInTransition( edge = Edge.create(Scenes.Gone, KeyguardState.AOD), edgeWithoutSceneContainer = Edge.create(KeyguardState.GONE, KeyguardState.AOD), ), transitionInteractor.isInTransition( Edge.create(KeyguardState.OCCLUDED, KeyguardState.AOD) ), ) .flatMapLatest { isInTransition -> // During GONE->AOD transitions, the home screen and wallpaper are still visible // until // WM is told to hide them, which occurs at the end of the animation. Use an opaque // scrim until this transition is complete // During transitions like GONE->AOD, surfaces like the launcher may be visible // until WM is told to hide them, which occurs at the end of the animation. Use an // opaque scrim until this transition is complete. if (isInTransition) { flowOf(1f) } else { Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt +18 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.binder import android.animation.ValueAnimator import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.app.animation.Interpolators.ALPHA_IN import com.android.app.tracing.coroutines.launchTraced as launch import com.android.systemui.keyguard.ui.viewmodel.LightRevealScrimViewModel import com.android.systemui.lifecycle.repeatWhenAttached Loading @@ -43,12 +44,21 @@ object LightRevealScrimViewBinder { } } launch("$TAG#viewModel.maxAlpha") { viewModel.maxAlpha.collect { alpha -> var animator: ValueAnimator? = null viewModel.maxAlpha.collect { (alpha, animate) -> if (alpha != revealScrim.alpha) { animator?.cancel() if (!animate) { revealScrim.alpha = alpha } else { animator = ValueAnimator.ofFloat(revealScrim.alpha, alpha).apply { duration = 400 startDelay = 333 duration = 733 interpolator = ALPHA_IN addUpdateListener { animation -> revealScrim.alpha = animation.getAnimatedValue() as Float revealScrim.alpha = animation.getAnimatedValue() as Float } start() } Loading @@ -56,6 +66,7 @@ object LightRevealScrimViewBinder { } } } } launch("$TAG#viewModel.revealAmount") { viewModel.revealAmount.collect { revealScrim.revealAmount = it } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt +11 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.systemui.statusbar.LightRevealEffect import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map /** * Models UI state for the light reveal scrim, which is used during screen on and off animations to Loading @@ -32,7 +33,16 @@ class LightRevealScrimViewModel constructor(private val interactor: LightRevealScrimInteractor) { val lightRevealEffect: Flow<LightRevealEffect> = interactor.lightRevealEffect val revealAmount: Flow<Float> = interactor.revealAmount val maxAlpha: Flow<Float> = interactor.maxAlpha /** Max alpha for the scrim + whether to animate the change */ val maxAlpha: Flow<Pair<Float, Boolean>> = interactor.maxAlpha.map { alpha -> Pair( alpha, // Darken immediately if going to be fully opaque if (alpha == 1f) false else true, ) } fun setWallpaperSupportsAmbientMode(supportsAmbientMode: Boolean) { interactor.setWallpaperSupportsAmbientMode(supportsAmbientMode) Loading