From 6a7110ec970d14e2fcc81c01e1e95a9b0fcfd840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Go=CC=88llner?= Date: Wed, 18 Jan 2023 13:52:13 +0100 Subject: [PATCH] Large screens: fully fade in behind scrim before anything else on shade Before, elements of the shade were starting to fade in, before the behind scrim was fully faded in. This made it possible to see the launcher and notifications at the same time for example. The fix is to fully fade in the behind earlier. Test: ScrimControllerTest.java Test: Manually on-device. See videos. Fixes: 247119667 Fixes: 265402313 Change-Id: I54475061d530d076a0b2f11a7e23e689e3cccb5e --- .../statusbar/phone/ScrimController.java | 26 ++++++++++++------- .../statusbar/phone/ScrimControllerTest.java | 12 +++++++-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index ee8b86160f515..2d3f8f4217f17 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -790,20 +790,28 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump if (!mScreenOffAnimationController.shouldExpandNotifications() && !mAnimatingPanelExpansionOnUnlock && !occluding) { - float behindFraction = getInterpolatedFraction(); - behindFraction = (float) Math.pow(behindFraction, 0.8f); if (mClipsQsScrim) { + float behindFraction = getInterpolatedFraction(); + behindFraction = (float) Math.pow(behindFraction, 0.8f); mBehindAlpha = mTransparentScrimBackground ? 0 : 1; mNotificationsAlpha = mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha; } else { - mBehindAlpha = - mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha; - // Delay fade-in of notification scrim a bit further, to coincide with the - // view fade in. Otherwise the empty panel can be quite jarring. - mNotificationsAlpha = mTransparentScrimBackground - ? 0 : MathUtils.constrainedMap(0f, 1f, 0.3f, 0.75f, - mPanelExpansionFraction); + if (mTransparentScrimBackground) { + mBehindAlpha = 0; + mNotificationsAlpha = 0; + } else { + // Behind scrim will finish fading in at 30% expansion. + float behindFraction = MathUtils + .constrainedMap(0f, 1f, 0f, 0.3f, mPanelExpansionFraction); + mBehindAlpha = behindFraction * mDefaultScrimAlpha; + // Delay fade-in of notification scrim a bit further, to coincide with the + // behind scrim finishing fading in. + // Also to coincide with the view starting to fade in, otherwise the empty + // panel can be quite jarring. + mNotificationsAlpha = MathUtils + .constrainedMap(0f, 1f, 0.3f, 0.75f, mPanelExpansionFraction); + } } mBehindTint = mState.getBehindTint(); mInFrontAlpha = 0; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index e4759057a59ca..3fee183d9b56d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -629,6 +629,7 @@ public class ScrimControllerTest extends SysuiTestCase { @Test public void transitionToUnlocked() { + mScrimController.setClipsQsScrim(false); mScrimController.setRawPanelExpansionFraction(0f); mScrimController.transitionTo(ScrimState.UNLOCKED); finishAnimationsImmediately(); @@ -644,14 +645,21 @@ public class ScrimControllerTest extends SysuiTestCase { )); // Back scrim should be visible after start dragging - mScrimController.setRawPanelExpansionFraction(0.3f); + mScrimController.setRawPanelExpansionFraction(0.29f); assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, SEMI_TRANSPARENT)); + // Back scrim should be opaque at 30% + mScrimController.setRawPanelExpansionFraction(0.3f); + assertScrimAlpha(Map.of( + mScrimInFront, TRANSPARENT, + mNotificationsScrim, TRANSPARENT, + mScrimBehind, OPAQUE)); + // Then, notification scrim should fade in - mScrimController.setRawPanelExpansionFraction(0.7f); + mScrimController.setRawPanelExpansionFraction(0.31f); assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, SEMI_TRANSPARENT,