Merge "Fix notification launch animation for split shade" into tm-qpr-dev

This commit is contained in:
Johannes Gallmann
2022-12-15 09:36:44 +00:00
committed by Android (Google) Code Review
4 changed files with 32 additions and 17 deletions

View File

@@ -27,8 +27,10 @@ class LaunchAnimationParameters(
/** /**
* The top position of the notification at the start of the animation. This is needed in order * The top position of the notification at the start of the animation. This is needed in order
* to keep the notification at its place when launching a notification that is clipped rounded. * to keep the notification at its place when launching a notification that is clipped rounded.
* This value is in absolute screen coordinates.
*/ */
var startNotificationTop = 0f var startNotificationTop = 0
var notificationParentTop = 0
var startClipTopAmount = 0 var startClipTopAmount = 0
var parentStartClipTopAmount = 0 var parentStartClipTopAmount = 0
var progress = 0f var progress = 0f

View File

@@ -92,11 +92,12 @@ class NotificationLaunchAnimatorController(
) )
params.startTranslationZ = notification.translationZ params.startTranslationZ = notification.translationZ
params.startNotificationTop = notification.translationY params.startNotificationTop = location[1]
params.notificationParentTop = notificationListContainer
.getViewParentForNotification(notificationEntry).locationOnScreen[1]
params.startRoundedTopClipping = roundedTopClipping params.startRoundedTopClipping = roundedTopClipping
params.startClipTopAmount = notification.clipTopAmount params.startClipTopAmount = notification.clipTopAmount
if (notification.isChildInGroup) { if (notification.isChildInGroup) {
params.startNotificationTop += notification.notificationParent.translationY
val locationOnScreen = notification.notificationParent.locationOnScreen[1] val locationOnScreen = notification.notificationParent.locationOnScreen[1]
val parentRoundedClip = (clipStartLocation - locationOnScreen).coerceAtLeast(0) val parentRoundedClip = (clipStartLocation - locationOnScreen).coerceAtLeast(0)
params.parentStartRoundedTopClipping = parentRoundedClip params.parentStartRoundedTopClipping = parentRoundedClip

View File

@@ -2223,6 +2223,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
if (mNotificationParent != null) { if (mNotificationParent != null) {
mNotificationParent.setClipTopAmount(0); mNotificationParent.setClipTopAmount(0);
} }
setTranslationX(0);
return; return;
} }
@@ -2241,6 +2242,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
setTranslationZ(translationZ); setTranslationZ(translationZ);
float extraWidthForClipping = params.getWidth() - getWidth(); float extraWidthForClipping = params.getWidth() - getWidth();
setExtraWidthForClipping(extraWidthForClipping); setExtraWidthForClipping(extraWidthForClipping);
int top; int top;
if (params.getStartRoundedTopClipping() > 0) { if (params.getStartRoundedTopClipping() > 0) {
// If we were clipping initially, let's interpolate from the start position to the // If we were clipping initially, let's interpolate from the start position to the
@@ -2248,20 +2250,22 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
float expandProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation( float expandProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(
params.getProgress(0, params.getProgress(0,
NotificationLaunchAnimatorController.ANIMATION_DURATION_TOP_ROUNDING)); NotificationLaunchAnimatorController.ANIMATION_DURATION_TOP_ROUNDING));
float startTop = params.getStartNotificationTop(); int startTop = params.getStartNotificationTop();
top = (int) Math.min(MathUtils.lerp(startTop, top = (int) Math.min(MathUtils.lerp(startTop, params.getTop(), expandProgress),
params.getTop(), expandProgress),
startTop); startTop);
} else { } else {
top = params.getTop(); top = params.getTop();
} }
int actualHeight = params.getBottom() - top; int actualHeight = params.getBottom() - top;
setActualHeight(actualHeight); setActualHeight(actualHeight);
int notificationStackTop = params.getNotificationParentTop();
top -= notificationStackTop;
int startClipTopAmount = params.getStartClipTopAmount(); int startClipTopAmount = params.getStartClipTopAmount();
int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, params.getProgress()); int clipTopAmount = (int) MathUtils.lerp(startClipTopAmount, 0, params.getProgress());
if (mNotificationParent != null) { if (mNotificationParent != null) {
float parentY = mNotificationParent.getTranslationY(); float parentTranslationY = mNotificationParent.getTranslationY();
top -= parentY; top -= parentTranslationY;
mNotificationParent.setTranslationZ(translationZ); mNotificationParent.setTranslationZ(translationZ);
// When the expanding notification is below its parent, the parent must be clipped // When the expanding notification is below its parent, the parent must be clipped
@@ -2270,15 +2274,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
// pixels to show the expanding notification, while still taking the decreasing // pixels to show the expanding notification, while still taking the decreasing
// notification clipTopAmount into consideration, so 'top + clipTopAmount'. // notification clipTopAmount into consideration, so 'top + clipTopAmount'.
int parentStartClipTopAmount = params.getParentStartClipTopAmount(); int parentStartClipTopAmount = params.getParentStartClipTopAmount();
int parentClipTopAmount = Math.min(parentStartClipTopAmount, int parentClipTopAmount = Math.min(parentStartClipTopAmount, top + clipTopAmount);
top + clipTopAmount);
mNotificationParent.setClipTopAmount(parentClipTopAmount); mNotificationParent.setClipTopAmount(parentClipTopAmount);
mNotificationParent.setExtraWidthForClipping(extraWidthForClipping); mNotificationParent.setExtraWidthForClipping(extraWidthForClipping);
float clipBottom = Math.max(params.getBottom(), float clipBottom = Math.max(params.getBottom() - notificationStackTop,
parentY + mNotificationParent.getActualHeight() parentTranslationY + mNotificationParent.getActualHeight()
- mNotificationParent.getClipBottomAmount()); - mNotificationParent.getClipBottomAmount());
float clipTop = Math.min(params.getTop(), parentY); float clipTop = Math.min(params.getTop() - notificationStackTop, parentTranslationY);
int minimumHeightForClipping = (int) (clipBottom - clipTop); int minimumHeightForClipping = (int) (clipBottom - clipTop);
mNotificationParent.setMinimumHeightForClipping(minimumHeightForClipping); mNotificationParent.setMinimumHeightForClipping(minimumHeightForClipping);
} else if (startClipTopAmount != 0) { } else if (startClipTopAmount != 0) {
@@ -2286,6 +2289,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
} }
setTranslationY(top); setTranslationY(top);
float absoluteCenterX = getLocationOnScreen()[0] + getWidth() / 2f - getTranslationX();
setTranslationX(params.getCenterX() - absoluteCenterX);
final float maxRadius = getMaxRadius(); final float maxRadius = getMaxRadius();
mTopRoundnessDuringLaunchAnimation = params.getTopCornerRadius() / maxRadius; mTopRoundnessDuringLaunchAnimation = params.getTopCornerRadius() / maxRadius;
mBottomRoundnessDuringLaunchAnimation = params.getBottomCornerRadius() / maxRadius; mBottomRoundnessDuringLaunchAnimation = params.getBottomCornerRadius() / maxRadius;

View File

@@ -5772,14 +5772,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|| mExpandingNotificationRow == null) { || mExpandingNotificationRow == null) {
return; return;
} }
int left = Math.min(mLaunchAnimationParams.getLeft(), mRoundedRectClippingLeft); int[] absoluteCoords = new int[2];
int right = Math.max(mLaunchAnimationParams.getRight(), mRoundedRectClippingRight); getLocationOnScreen(absoluteCoords);
int bottom = Math.max(mLaunchAnimationParams.getBottom(), mRoundedRectClippingBottom);
int left = Math.min(mLaunchAnimationParams.getLeft() - absoluteCoords[0],
mRoundedRectClippingLeft);
int right = Math.max(mLaunchAnimationParams.getRight() - absoluteCoords[0],
mRoundedRectClippingRight);
int bottom = Math.max(mLaunchAnimationParams.getBottom() - absoluteCoords[1],
mRoundedRectClippingBottom);
float expandProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation( float expandProgress = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(
mLaunchAnimationParams.getProgress(0, mLaunchAnimationParams.getProgress(0,
NotificationLaunchAnimatorController.ANIMATION_DURATION_TOP_ROUNDING)); NotificationLaunchAnimatorController.ANIMATION_DURATION_TOP_ROUNDING));
int top = (int) Math.min(MathUtils.lerp(mRoundedRectClippingTop, int top = (int) Math.min(MathUtils.lerp(mRoundedRectClippingTop,
mLaunchAnimationParams.getTop(), expandProgress), mLaunchAnimationParams.getTop() - absoluteCoords[1], expandProgress),
mRoundedRectClippingTop); mRoundedRectClippingTop);
float topRadius = mLaunchAnimationParams.getTopCornerRadius(); float topRadius = mLaunchAnimationParams.getTopCornerRadius();
float bottomRadius = mLaunchAnimationParams.getBottomCornerRadius(); float bottomRadius = mLaunchAnimationParams.getBottomCornerRadius();