summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt20
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt25
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt12
3 files changed, 41 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt
index cf747c81769a..6ad4bc54be2b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractor.kt
@@ -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
@@ -96,16 +97,19 @@ constructor(
/** Limit the max alpha for the scrim to allow for some transparency */
val maxAlpha: Flow<Float> =
- transitionInteractor
- .isInTransition(
- edge = Edge.create(Scenes.Gone, KeyguardState.AOD),
- edgeWithoutSceneContainer = Edge.create(KeyguardState.GONE, KeyguardState.AOD),
+ 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 {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt
index 32757ce82c69..741cc02ffb6b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt
@@ -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
@@ -43,14 +44,24 @@ object LightRevealScrimViewBinder {
}
}
launch("$TAG#viewModel.maxAlpha") {
- viewModel.maxAlpha.collect { alpha ->
+ var animator: ValueAnimator? = null
+ viewModel.maxAlpha.collect { (alpha, animate) ->
if (alpha != revealScrim.alpha) {
- ValueAnimator.ofFloat(revealScrim.alpha, alpha).apply {
- duration = 400
- addUpdateListener { animation ->
- revealScrim.alpha = animation.getAnimatedValue() as Float
- }
- start()
+ animator?.cancel()
+ if (!animate) {
+ revealScrim.alpha = alpha
+ } else {
+ animator =
+ ValueAnimator.ofFloat(revealScrim.alpha, alpha).apply {
+ startDelay = 333
+ duration = 733
+ interpolator = ALPHA_IN
+ addUpdateListener { animation ->
+ revealScrim.alpha =
+ animation.getAnimatedValue() as Float
+ }
+ start()
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt
index af6cd166479a..6d1aefe813c3 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LightRevealScrimViewModel.kt
@@ -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
@@ -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)