Avoid overlap when fading notifications in
This CL reduces the number of awkward overlaping frames, where the scrim is partially visible on top of the app while notifications are also semi-transparent. One great benefit of this CL, as well, is that it avoids overdraw, drawing notifications after the shade window becomes opaque. Test: using jank scripts Test: manual Fixes: 189964129 Change-Id: Ie2fe23aba101bc4c4a5692f999d672e79ddf8e0a
This commit is contained in:
@@ -99,8 +99,10 @@ public class Interpolators {
|
||||
* @param forNotification If we want the alpha of the notification shade or the scrim.
|
||||
*/
|
||||
public static float getNotificationScrimAlpha(float fraction, boolean forNotification) {
|
||||
if (!forNotification) {
|
||||
fraction = MathUtils.saturate(1.7f * fraction);
|
||||
if (forNotification) {
|
||||
fraction = MathUtils.constrainedMap(0f, 1f, 0.3f, 1f, fraction);
|
||||
} else {
|
||||
fraction = MathUtils.constrainedMap(0f, 1f, 0f, 0.5f, fraction);
|
||||
}
|
||||
fraction = fraction * 1.2f - 0.2f;
|
||||
if (fraction <= 0) {
|
||||
|
||||
@@ -584,7 +584,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
));
|
||||
|
||||
// Back scrim should be visible after start dragging
|
||||
mScrimController.setPanelExpansion(0.5f);
|
||||
mScrimController.setPanelExpansion(0.3f);
|
||||
assertScrimAlpha(Map.of(
|
||||
mScrimInFront, TRANSPARENT,
|
||||
mNotificationsScrim, SEMI_TRANSPARENT,
|
||||
@@ -1046,7 +1046,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testScrimsVisible_whenShadeVisible() {
|
||||
mScrimController.transitionTo(ScrimState.UNLOCKED);
|
||||
mScrimController.setPanelExpansion(0.5f);
|
||||
mScrimController.setPanelExpansion(0.3f);
|
||||
// notifications scrim alpha change require calling setQsPosition
|
||||
mScrimController.setQsPosition(0, 300);
|
||||
finishAnimationsImmediately();
|
||||
@@ -1061,7 +1061,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
public void testScrimsVisible_whenShadeVisible_clippingQs() {
|
||||
mScrimController.setClipsQsScrim(true);
|
||||
mScrimController.transitionTo(ScrimState.UNLOCKED);
|
||||
mScrimController.setPanelExpansion(0.5f);
|
||||
mScrimController.setPanelExpansion(0.3f);
|
||||
// notifications scrim alpha change require calling setQsPosition
|
||||
mScrimController.setQsPosition(0.5f, 300);
|
||||
finishAnimationsImmediately();
|
||||
@@ -1111,7 +1111,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
mScrimController.transitionTo(ScrimState.SHADE_LOCKED);
|
||||
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.8f, /* expansion */ 0.8f);
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.2f, /* expansion */ 0.2f);
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.47f, /* expansion */ 0.2f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1119,7 +1119,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
mScrimController.transitionTo(ScrimState.KEYGUARD);
|
||||
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.2f, /* expansion */ 0.4f);
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.8f, /* expansion */ 0.2f);
|
||||
assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.52f, /* expansion */ 0.2f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user