Merge "Prevent NotificationShelf from jump cutting notifications when appearing" into udc-dev

This commit is contained in:
Johannes Gallmann
2023-03-27 11:27:21 +00:00
committed by Android (Google) Code Review
2 changed files with 23 additions and 6 deletions

View File

@@ -98,6 +98,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private float mCornerAnimationDistance;
private NotificationShelfController mController;
private float mActualWidth = -1;
private boolean mSensitiveRevealAnimEndabled;
public NotificationShelf(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -260,7 +261,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
}
final float stackEnd = ambientState.getStackY() + ambientState.getStackHeight();
viewState.setYTranslation(stackEnd - viewState.height);
if (mSensitiveRevealAnimEndabled && viewState.hidden) {
// if the shelf is hidden, position it at the end of the stack (plus the clip
// padding), such that when it appears animated, it will smoothly move in from the
// bottom, without jump cutting any notifications
viewState.setYTranslation(stackEnd + mPaddingBetweenElements);
} else {
viewState.setYTranslation(stackEnd - viewState.height);
}
} else {
viewState.hidden = true;
viewState.location = ExpandableViewState.LOCATION_GONE;
@@ -395,7 +403,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
expandingAnimated, isLastChild, shelfClipStart);
// TODO(b/172289889) scale mPaddingBetweenElements with expansion amount
if ((isLastChild && !child.isInShelf()) || aboveShelf || backgroundForceHidden) {
if ((!mSensitiveRevealAnimEndabled && ((isLastChild && !child.isInShelf())
|| backgroundForceHidden)) || aboveShelf) {
notificationClipEnd = shelfStart + getIntrinsicHeight();
} else {
notificationClipEnd = shelfStart - mPaddingBetweenElements;
@@ -437,15 +446,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
}
if (child instanceof ActivatableNotificationView) {
ActivatableNotificationView anv =
(ActivatableNotificationView) child;
ActivatableNotificationView anv = (ActivatableNotificationView) child;
// Because we show whole notifications on the lockscreen, the bottom notification is
// always "just about to enter the shelf" by normal scrolling rules. This is fine
// if the shelf is visible, but if the shelf is hidden, it causes incorrect curling.
// notificationClipEnd handles the discrepancy between a visible and hidden shelf,
// so we use that when on the keyguard (and while animating away) to reduce curling.
final float keyguardSafeShelfStart =
mAmbientState.isOnKeyguard() ? notificationClipEnd : shelfStart;
final float keyguardSafeShelfStart = !mSensitiveRevealAnimEndabled
&& mAmbientState.isOnKeyguard() ? notificationClipEnd : shelfStart;
updateCornerRoundnessOnScroll(anv, viewStart, keyguardSafeShelfStart);
}
}
@@ -993,6 +1001,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
mIndexOfFirstViewInShelf = mHostLayoutController.indexOfChild(firstViewInShelf);
}
/**
* Set whether the sensitive reveal animation feature flag is enabled
* @param enabled true if enabled
*/
public void setSensitiveRevealAnimEndabled(boolean enabled) {
mSensitiveRevealAnimEndabled = enabled;
}
/**
* This method resets the OnScroll roundness of a view to 0f
* <p>

View File

@@ -55,6 +55,7 @@ public class NotificationShelfController {
mKeyguardBypassController = keyguardBypassController;
mStatusBarStateController = statusBarStateController;
mView.useRoundnessSourceTypes(featureFlags.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES));
mView.setSensitiveRevealAnimEndabled(featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM));
mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {