Added shade bottom corner radius transition for predictive back
The statically set notification scrim bottom corner radius that was added for predictive back was larger than the screen corner radius, causing elements behind the shade to be visible. This adds a smooth transition for the bottom corner radius during predictive back and fixes the visual bug. Bug: 273994446 Test: Verified that shade CUJs appear correct on both small and large screens Change-Id: Ibef677179e2d1ed0bf61d8b09ab06d2459cb6d8f
This commit is contained in:
@@ -203,7 +203,10 @@ public class ScrimDrawable extends Drawable {
|
||||
}
|
||||
|
||||
public void setBottomEdgeRadius(float radius) {
|
||||
mBottomEdgeRadius = radius;
|
||||
if (mBottomEdgeRadius != radius) {
|
||||
mBottomEdgeRadius = radius;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2206,6 +2206,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
// TODO: non-linearly transform progress fraction into squish amount (ease-in, linear out)
|
||||
mCurrentBackProgress = progressFraction;
|
||||
applyBackScaling(progressFraction);
|
||||
mQsController.setClippingBounds();
|
||||
}
|
||||
|
||||
/** Resets back progress. */
|
||||
|
||||
@@ -114,6 +114,8 @@ import javax.inject.Inject;
|
||||
public class QuickSettingsController implements Dumpable {
|
||||
public static final String TAG = "QuickSettingsController";
|
||||
|
||||
public static final int SHADE_BACK_ANIM_SCALE_MULTIPLIER = 100;
|
||||
|
||||
private QS mQs;
|
||||
private final Lazy<NotificationPanelViewController> mPanelViewControllerLazy;
|
||||
|
||||
@@ -1128,7 +1130,7 @@ public class QuickSettingsController implements Dumpable {
|
||||
* Updates scrim bounds, QS clipping, notifications clipping and keyguard status view clipping
|
||||
* as well based on the bounds of the shade and QS state.
|
||||
*/
|
||||
private void setClippingBounds() {
|
||||
void setClippingBounds() {
|
||||
float qsExpansionFraction = computeExpansionFraction();
|
||||
final int qsPanelBottomY = calculateBottomPosition(qsExpansionFraction);
|
||||
// Split shade has no QQS
|
||||
@@ -1216,7 +1218,10 @@ public class QuickSettingsController implements Dumpable {
|
||||
? 0 : mScreenCornerRadius;
|
||||
radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
|
||||
Math.min(top / (float) mScrimCornerRadius, 1f));
|
||||
mScrimController.setNotificationBottomRadius(radius);
|
||||
|
||||
float bottomRadius = mExpanded ? screenCornerRadius :
|
||||
calculateBottomCornerRadius(screenCornerRadius);
|
||||
mScrimController.setNotificationBottomRadius(bottomRadius);
|
||||
}
|
||||
if (isQsFragmentCreated()) {
|
||||
float qsTranslation = 0;
|
||||
@@ -1279,6 +1284,28 @@ public class QuickSettingsController implements Dumpable {
|
||||
nsslLeft, nsslTop, nsslRight, nsslBottom, topRadius, bottomRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bottom corner radius should follow screen corner radius unless
|
||||
* predictive back is running. We want a smooth transition from screen
|
||||
* corner radius to scrim corner radius as the notification scrim is scaled down,
|
||||
* but the transition should be brief enough to accommodate very short back gestures.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
int calculateBottomCornerRadius(float screenCornerRadius) {
|
||||
return (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
|
||||
Math.min(calculateBottomRadiusProgress(), 1f));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
float calculateBottomRadiusProgress() {
|
||||
return (1 - mScrimController.getBackScaling()) * SHADE_BACK_ANIM_SCALE_MULTIPLIER;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getScrimCornerRadius() {
|
||||
return mScrimCornerRadius;
|
||||
}
|
||||
|
||||
void setDisplayInsets(int leftInset, int rightInset) {
|
||||
mDisplayLeftInset = leftInset;
|
||||
mDisplayRightInset = rightInset;
|
||||
|
||||
@@ -602,6 +602,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
||||
mNotificationsScrim.setScaleY(scale);
|
||||
}
|
||||
|
||||
public float getBackScaling() {
|
||||
return mNotificationsScrim.getScaleY();
|
||||
}
|
||||
|
||||
public void onTrackingStarted() {
|
||||
mDarkenWhileDragging = !mKeyguardStateController.canDismissLockScreen();
|
||||
if (!mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) {
|
||||
|
||||
@@ -580,6 +580,30 @@ public class QuickSettingsControllerTest extends SysuiTestCase {
|
||||
verify(mQs).setQsVisible(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateBottomCornerRadius_scrimScaleMax() {
|
||||
when(mScrimController.getBackScaling()).thenReturn(1.0f);
|
||||
assertThat(mQsController.calculateBottomCornerRadius(0.0f)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateBottomCornerRadius_scrimScaleMin() {
|
||||
when(mScrimController.getBackScaling())
|
||||
.thenReturn(mNotificationPanelViewController.SHADE_BACK_ANIM_MIN_SCALE);
|
||||
assertThat(mQsController.calculateBottomCornerRadius(0.0f))
|
||||
.isEqualTo(mQsController.getScrimCornerRadius());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateBottomCornerRadius_scrimScaleCutoff() {
|
||||
float ratio = 1 / mQsController.calculateBottomRadiusProgress();
|
||||
float cutoffScale = 1 - mNotificationPanelViewController.SHADE_BACK_ANIM_MIN_SCALE / ratio;
|
||||
when(mScrimController.getBackScaling())
|
||||
.thenReturn(cutoffScale);
|
||||
assertThat(mQsController.calculateBottomCornerRadius(0.0f))
|
||||
.isEqualTo(mQsController.getScrimCornerRadius());
|
||||
}
|
||||
|
||||
private void lockScreen() {
|
||||
mQsController.setBarState(KEYGUARD);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user