Merge "Added shade bottom corner radius transition for predictive back" into udc-dev

This commit is contained in:
Shawn Lee
2023-05-26 01:33:50 +00:00
committed by Android (Google) Code Review
5 changed files with 62 additions and 3 deletions

View File

@@ -203,7 +203,10 @@ public class ScrimDrawable extends Drawable {
} }
public void setBottomEdgeRadius(float radius) { public void setBottomEdgeRadius(float radius) {
mBottomEdgeRadius = radius; if (mBottomEdgeRadius != radius) {
mBottomEdgeRadius = radius;
invalidateSelf();
}
} }
@Override @Override

View File

@@ -2206,6 +2206,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
// TODO: non-linearly transform progress fraction into squish amount (ease-in, linear out) // TODO: non-linearly transform progress fraction into squish amount (ease-in, linear out)
mCurrentBackProgress = progressFraction; mCurrentBackProgress = progressFraction;
applyBackScaling(progressFraction); applyBackScaling(progressFraction);
mQsController.setClippingBounds();
} }
/** Resets back progress. */ /** Resets back progress. */

View File

@@ -114,6 +114,8 @@ import javax.inject.Inject;
public class QuickSettingsController implements Dumpable { public class QuickSettingsController implements Dumpable {
public static final String TAG = "QuickSettingsController"; public static final String TAG = "QuickSettingsController";
public static final int SHADE_BACK_ANIM_SCALE_MULTIPLIER = 100;
private QS mQs; private QS mQs;
private final Lazy<NotificationPanelViewController> mPanelViewControllerLazy; 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 * Updates scrim bounds, QS clipping, notifications clipping and keyguard status view clipping
* as well based on the bounds of the shade and QS state. * as well based on the bounds of the shade and QS state.
*/ */
private void setClippingBounds() { void setClippingBounds() {
float qsExpansionFraction = computeExpansionFraction(); float qsExpansionFraction = computeExpansionFraction();
final int qsPanelBottomY = calculateBottomPosition(qsExpansionFraction); final int qsPanelBottomY = calculateBottomPosition(qsExpansionFraction);
// Split shade has no QQS // Split shade has no QQS
@@ -1216,7 +1218,10 @@ public class QuickSettingsController implements Dumpable {
? 0 : mScreenCornerRadius; ? 0 : mScreenCornerRadius;
radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius, radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
Math.min(top / (float) mScrimCornerRadius, 1f)); Math.min(top / (float) mScrimCornerRadius, 1f));
mScrimController.setNotificationBottomRadius(radius);
float bottomRadius = mExpanded ? screenCornerRadius :
calculateBottomCornerRadius(screenCornerRadius);
mScrimController.setNotificationBottomRadius(bottomRadius);
} }
if (isQsFragmentCreated()) { if (isQsFragmentCreated()) {
float qsTranslation = 0; float qsTranslation = 0;
@@ -1279,6 +1284,28 @@ public class QuickSettingsController implements Dumpable {
nsslLeft, nsslTop, nsslRight, nsslBottom, topRadius, bottomRadius); 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) { void setDisplayInsets(int leftInset, int rightInset) {
mDisplayLeftInset = leftInset; mDisplayLeftInset = leftInset;
mDisplayRightInset = rightInset; mDisplayRightInset = rightInset;

View File

@@ -602,6 +602,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
mNotificationsScrim.setScaleY(scale); mNotificationsScrim.setScaleY(scale);
} }
public float getBackScaling() {
return mNotificationsScrim.getScaleY();
}
public void onTrackingStarted() { public void onTrackingStarted() {
mDarkenWhileDragging = !mKeyguardStateController.canDismissLockScreen(); mDarkenWhileDragging = !mKeyguardStateController.canDismissLockScreen();
if (!mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) { if (!mKeyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) {

View File

@@ -580,6 +580,30 @@ public class QuickSettingsControllerTest extends SysuiTestCase {
verify(mQs).setQsVisible(true); 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() { private void lockScreen() {
mQsController.setBarState(KEYGUARD); mQsController.setBarState(KEYGUARD);
} }