Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +55 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ import java.util.Optional import javax.inject.Inject import kotlin.math.max import kotlin.math.sign import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch /** * Responsible for blurring the notification shade window, and applying a zoom effect to the Loading Loading @@ -92,6 +94,7 @@ constructor( private const val MIN_VELOCITY = -MAX_VELOCITY private const val INTERACTION_BLUR_FRACTION = 0.8f private const val ANIMATION_BLUR_FRACTION = 1f - INTERACTION_BLUR_FRACTION private const val TRANSITION_THRESHOLD = 0.98f private const val TAG = "DepthController" } Loading Loading @@ -156,6 +159,9 @@ constructor( /** * When launching an app from the shade, the animations progress should affect how blurry the * shade is, overriding the expansion amount. * * TODO(b/399617511): remove this once [Flags.notificationShadeBlur] is launched and the Shade * closing is actually instantaneous. */ var blursDisabledForAppLaunch: Boolean = false set(value) { Loading Loading @@ -185,9 +191,13 @@ constructor( return } if (Flags.notificationShadeBlur()) { shadeAnimation.skipTo(0) } else { shadeAnimation.animateTo(0) shadeAnimation.finishIfRunning() } } @Deprecated( message = "This might get reset to false before shade expansion is fully done, " + Loading Loading @@ -487,6 +497,22 @@ constructor( scheduleUpdate() } fun onTransitionAnimationProgress(progress: Float) { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return // Because the Shade takes a few frames to actually trigger the unblur after a transition // has ended, we need to disable it manually, or the opening window itself will be blurred // for a few frames due to relative ordering. We do this towards the end, so that the // window is already covering the background and the unblur is not visible. if (progress >= TRANSITION_THRESHOLD && shadeAnimation.radius > 0) { blursDisabledForAppLaunch = true } } fun onTransitionAnimationEnd() { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return blursDisabledForAppLaunch = false } private fun updateShadeAnimationBlur( expansion: Float, tracking: Boolean, Loading Loading @@ -631,6 +657,20 @@ constructor( springAnimation.addEndListener { _, _, _, _ -> pendingRadius = -1 } } /** * Starts an animation to [newRadius], or updates the current one if already ongoing. * IMPORTANT: do NOT use this method + [finishIfRunning] to instantaneously change the value * of the animation. The change will NOT be instantaneous. Use [skipTo] instead. * * Explanation: * 1. If idle, [SpringAnimation.animateToFinalPosition] requests a start to the animation. * 2. On the first frame after an idle animation is requested to start, the animation simply * acquires the starting value and does nothing else. * 3. [SpringAnimation.skipToEnd] requests a fast-forward to the end value, but this happens * during calculation of the next animation value. Because on the first frame no such * calculation happens (point #2), there is one lagging frame where we still see the old * value. */ fun animateTo(newRadius: Int) { if (pendingRadius == newRadius) { return Loading @@ -639,6 +679,19 @@ constructor( springAnimation.animateToFinalPosition(newRadius.toFloat()) } /** * Instantaneously set a new blur radius to this animation. Always use this instead of * [animateTo] and [finishIfRunning] to make sure that the change takes effect in the next * frame. See the doc for [animateTo] for an explanation. */ fun skipTo(newRadius: Int) { if (pendingRadius == newRadius) return pendingRadius = newRadius springAnimation.cancel() springAnimation.setStartValue(newRadius.toFloat()) springAnimation.animateToFinalPosition(newRadius.toFloat()) } fun finishIfRunning() { if (springAnimation.isRunning) { springAnimation.skipToEnd() Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +18 −2 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ import com.android.systemui.AutoReinflateContainer; import com.android.systemui.CoreStartable; import com.android.systemui.DejankUtils; import com.android.systemui.EventLogTags; import com.android.systemui.Flags; import com.android.systemui.InitController; import com.android.systemui.Prefs; import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; Loading Loading @@ -3183,13 +3184,28 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { new ActivityTransitionAnimator.Listener() { @Override public void onTransitionAnimationStart() { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) { mKeyguardViewMediator.setBlursDisabledForAppLaunch(true); } } @Override public void onTransitionAnimationProgress(float linearProgress) { if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) { mNotificationShadeDepthControllerLazy.get() .onTransitionAnimationProgress(linearProgress); } } @Override public void onTransitionAnimationEnd() { if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) { mNotificationShadeDepthControllerLazy.get() .onTransitionAnimationEnd(); } else { mKeyguardViewMediator.setBlursDisabledForAppLaunch(false); } } }; private final DemoMode mDemoModeCallback = new DemoMode() { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +55 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ import java.util.Optional import javax.inject.Inject import kotlin.math.max import kotlin.math.sign import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch /** * Responsible for blurring the notification shade window, and applying a zoom effect to the Loading Loading @@ -92,6 +94,7 @@ constructor( private const val MIN_VELOCITY = -MAX_VELOCITY private const val INTERACTION_BLUR_FRACTION = 0.8f private const val ANIMATION_BLUR_FRACTION = 1f - INTERACTION_BLUR_FRACTION private const val TRANSITION_THRESHOLD = 0.98f private const val TAG = "DepthController" } Loading Loading @@ -156,6 +159,9 @@ constructor( /** * When launching an app from the shade, the animations progress should affect how blurry the * shade is, overriding the expansion amount. * * TODO(b/399617511): remove this once [Flags.notificationShadeBlur] is launched and the Shade * closing is actually instantaneous. */ var blursDisabledForAppLaunch: Boolean = false set(value) { Loading Loading @@ -185,9 +191,13 @@ constructor( return } if (Flags.notificationShadeBlur()) { shadeAnimation.skipTo(0) } else { shadeAnimation.animateTo(0) shadeAnimation.finishIfRunning() } } @Deprecated( message = "This might get reset to false before shade expansion is fully done, " + Loading Loading @@ -487,6 +497,22 @@ constructor( scheduleUpdate() } fun onTransitionAnimationProgress(progress: Float) { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return // Because the Shade takes a few frames to actually trigger the unblur after a transition // has ended, we need to disable it manually, or the opening window itself will be blurred // for a few frames due to relative ordering. We do this towards the end, so that the // window is already covering the background and the unblur is not visible. if (progress >= TRANSITION_THRESHOLD && shadeAnimation.radius > 0) { blursDisabledForAppLaunch = true } } fun onTransitionAnimationEnd() { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) return blursDisabledForAppLaunch = false } private fun updateShadeAnimationBlur( expansion: Float, tracking: Boolean, Loading Loading @@ -631,6 +657,20 @@ constructor( springAnimation.addEndListener { _, _, _, _ -> pendingRadius = -1 } } /** * Starts an animation to [newRadius], or updates the current one if already ongoing. * IMPORTANT: do NOT use this method + [finishIfRunning] to instantaneously change the value * of the animation. The change will NOT be instantaneous. Use [skipTo] instead. * * Explanation: * 1. If idle, [SpringAnimation.animateToFinalPosition] requests a start to the animation. * 2. On the first frame after an idle animation is requested to start, the animation simply * acquires the starting value and does nothing else. * 3. [SpringAnimation.skipToEnd] requests a fast-forward to the end value, but this happens * during calculation of the next animation value. Because on the first frame no such * calculation happens (point #2), there is one lagging frame where we still see the old * value. */ fun animateTo(newRadius: Int) { if (pendingRadius == newRadius) { return Loading @@ -639,6 +679,19 @@ constructor( springAnimation.animateToFinalPosition(newRadius.toFloat()) } /** * Instantaneously set a new blur radius to this animation. Always use this instead of * [animateTo] and [finishIfRunning] to make sure that the change takes effect in the next * frame. See the doc for [animateTo] for an explanation. */ fun skipTo(newRadius: Int) { if (pendingRadius == newRadius) return pendingRadius = newRadius springAnimation.cancel() springAnimation.setStartValue(newRadius.toFloat()) springAnimation.animateToFinalPosition(newRadius.toFloat()) } fun finishIfRunning() { if (springAnimation.isRunning) { springAnimation.skipToEnd() Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +18 −2 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ import com.android.systemui.AutoReinflateContainer; import com.android.systemui.CoreStartable; import com.android.systemui.DejankUtils; import com.android.systemui.EventLogTags; import com.android.systemui.Flags; import com.android.systemui.InitController; import com.android.systemui.Prefs; import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController; Loading Loading @@ -3183,13 +3184,28 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { new ActivityTransitionAnimator.Listener() { @Override public void onTransitionAnimationStart() { if (!Flags.notificationShadeBlur() || !Flags.moveTransitionAnimationLayer()) { mKeyguardViewMediator.setBlursDisabledForAppLaunch(true); } } @Override public void onTransitionAnimationProgress(float linearProgress) { if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) { mNotificationShadeDepthControllerLazy.get() .onTransitionAnimationProgress(linearProgress); } } @Override public void onTransitionAnimationEnd() { if (Flags.notificationShadeBlur() && Flags.moveTransitionAnimationLayer()) { mNotificationShadeDepthControllerLazy.get() .onTransitionAnimationEnd(); } else { mKeyguardViewMediator.setBlursDisabledForAppLaunch(false); } } }; private final DemoMode mDemoModeCallback = new DemoMode() { Loading