Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64cc3cbf authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

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

parents 7dfe2e90 d819efa0
Loading
Loading
Loading
Loading
+22 −6
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
    private float mCornerAnimationDistance;
    private float mCornerAnimationDistance;
    private NotificationShelfController mController;
    private NotificationShelfController mController;
    private float mActualWidth = -1;
    private float mActualWidth = -1;
    private boolean mSensitiveRevealAnimEndabled;


    public NotificationShelf(Context context, AttributeSet attrs) {
    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -260,7 +261,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
            }
            }


            final float stackEnd = ambientState.getStackY() + ambientState.getStackHeight();
            final float stackEnd = ambientState.getStackY() + ambientState.getStackHeight();
            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);
                viewState.setYTranslation(stackEnd - viewState.height);
            }
        } else {
        } else {
            viewState.hidden = true;
            viewState.hidden = true;
            viewState.location = ExpandableViewState.LOCATION_GONE;
            viewState.location = ExpandableViewState.LOCATION_GONE;
@@ -395,7 +403,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
                    expandingAnimated, isLastChild, shelfClipStart);
                    expandingAnimated, isLastChild, shelfClipStart);


            // TODO(b/172289889) scale mPaddingBetweenElements with expansion amount
            // TODO(b/172289889) scale mPaddingBetweenElements with expansion amount
            if ((isLastChild && !child.isInShelf()) || aboveShelf || backgroundForceHidden) {
            if ((!mSensitiveRevealAnimEndabled && ((isLastChild && !child.isInShelf())
                    || backgroundForceHidden)) || aboveShelf) {
                notificationClipEnd = shelfStart + getIntrinsicHeight();
                notificationClipEnd = shelfStart + getIntrinsicHeight();
            } else {
            } else {
                notificationClipEnd = shelfStart - mPaddingBetweenElements;
                notificationClipEnd = shelfStart - mPaddingBetweenElements;
@@ -437,15 +446,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
            }
            }


            if (child instanceof ActivatableNotificationView) {
            if (child instanceof ActivatableNotificationView) {
                ActivatableNotificationView anv =
                ActivatableNotificationView anv = (ActivatableNotificationView) child;
                        (ActivatableNotificationView) child;
                // Because we show whole notifications on the lockscreen, the bottom notification is
                // 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
                // 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.
                // 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,
                // 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.
                // so we use that when on the keyguard (and while animating away) to reduce curling.
                final float keyguardSafeShelfStart =
                final float keyguardSafeShelfStart = !mSensitiveRevealAnimEndabled
                        mAmbientState.isOnKeyguard() ? notificationClipEnd : shelfStart;
                        && mAmbientState.isOnKeyguard() ? notificationClipEnd : shelfStart;
                updateCornerRoundnessOnScroll(anv, viewStart, keyguardSafeShelfStart);
                updateCornerRoundnessOnScroll(anv, viewStart, keyguardSafeShelfStart);
            }
            }
        }
        }
@@ -993,6 +1001,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
        mIndexOfFirstViewInShelf = mHostLayoutController.indexOfChild(firstViewInShelf);
        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
     * This method resets the OnScroll roundness of a view to 0f
     * <p>
     * <p>
+1 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@ public class NotificationShelfController {
        mKeyguardBypassController = keyguardBypassController;
        mKeyguardBypassController = keyguardBypassController;
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController = statusBarStateController;
        mView.useRoundnessSourceTypes(featureFlags.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES));
        mView.useRoundnessSourceTypes(featureFlags.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES));
        mView.setSensitiveRevealAnimEndabled(featureFlags.isEnabled(Flags.SENSITIVE_REVEAL_ANIM));
        mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
        mOnAttachStateChangeListener = new View.OnAttachStateChangeListener() {
            @Override
            @Override
            public void onViewAttachedToWindow(View v) {
            public void onViewAttachedToWindow(View v) {