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

Commit 9c2c4963 authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix dismiss all clipping for tablet / landscape

Shouldn't animate the whole view, use the translatable views so that
they get clipped on tablet / landscape.

Additionally this changes the behavior in the case where the gear
might be showing, previously that would hide prior to the dismiss
all animation, UX prefers this to just have the notification cover
the gear and slide away or the gear fade away depending on the side
it's showing.

Bug: 28006639
Change-Id: I43027cb29410496de5b6e09c4a0c57a69484295c
parent 43cd4b70
Loading
Loading
Loading
Loading
+13 −8
Original line number Original line Diff line number Diff line
@@ -329,7 +329,7 @@ public class SwipeHelper implements Gefingerpoken {
     */
     */
    public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) {
    public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) {
        dismissChild(view, velocity, null /* endAction */, 0 /* delay */,
        dismissChild(view, velocity, null /* endAction */, 0 /* delay */,
                useAccelerateInterpolator, 0 /* fixedDuration */);
                useAccelerateInterpolator, 0 /* fixedDuration */, false /* isDismissAll */);
    }
    }


    /**
    /**
@@ -341,17 +341,22 @@ public class SwipeHelper implements Gefingerpoken {
     * @param fixedDuration If not 0, this exact duration will be taken
     * @param fixedDuration If not 0, this exact duration will be taken
     */
     */
    public void dismissChild(final View animView, float velocity, final Runnable endAction,
    public void dismissChild(final View animView, float velocity, final Runnable endAction,
            long delay, boolean useAccelerateInterpolator, long fixedDuration) {
            long delay, boolean useAccelerateInterpolator, long fixedDuration,
            boolean isDismissAll) {
        final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
        final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
        float newPos;
        float newPos;
        boolean isLayoutRtl = animView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        boolean isLayoutRtl = animView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;


        if (velocity < 0
                || (velocity == 0 && getTranslation(animView) < 0)
        // if we use the Menu to dismiss an item in landscape, animate up
        // if we use the Menu to dismiss an item in landscape, animate up
                || (velocity == 0 && getTranslation(animView) == 0 && mSwipeDirection == Y)
        boolean animateUpForMenu = velocity == 0 && (getTranslation(animView) == 0 || isDismissAll)
                && mSwipeDirection == Y;
        // if the language is rtl we prefer swiping to the left
        // if the language is rtl we prefer swiping to the left
                || (velocity == 0 && getTranslation(animView) == 0 && isLayoutRtl)) {
        boolean animateLeftForRtl = velocity == 0 && (getTranslation(animView) == 0 || isDismissAll)
                && isLayoutRtl;
        boolean animateLeft = velocity < 0
                || (velocity == 0 && getTranslation(animView) < 0 && !isDismissAll);

        if (animateLeft || animateLeftForRtl || animateUpForMenu) {
            newPos = -getSize(animView);
            newPos = -getSize(animView);
        } else {
        } else {
            newPos = getSize(animView);
            newPos = getSize(animView);
+5 −20
Original line number Original line Diff line number Diff line
@@ -986,7 +986,8 @@ public class NotificationStackScrollLayout extends ViewGroup
    }
    }


    public void dismissViewAnimated(View child, Runnable endRunnable, int delay, long duration) {
    public void dismissViewAnimated(View child, Runnable endRunnable, int delay, long duration) {
        mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration);
        mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration,
                true /* isDismissAll */);
    }
    }


    public void snapViewIfNeeded(View child) {
    public void snapViewIfNeeded(View child) {
@@ -3194,9 +3195,6 @@ public class NotificationStackScrollLayout extends ViewGroup
            disableClipOptimization();
            disableClipOptimization();
        }
        }
        handleDismissAllClipping();
        handleDismissAllClipping();
        if (mCurrIconRow != null && mCurrIconRow.isVisible()) {
            mCurrIconRow.getNotificationParent().animateTranslateNotification(0 /* left target */);
        }
    }
    }


    private void handleDismissAllClipping() {
    private void handleDismissAllClipping() {
@@ -3639,10 +3637,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        @Override
        @Override
        public Animator getViewTranslationAnimator(View v, float target,
        public Animator getViewTranslationAnimator(View v, float target,
                AnimatorUpdateListener listener) {
                AnimatorUpdateListener listener) {
            if (mDismissAllInProgress) {
            if (v instanceof ExpandableNotificationRow) {
                // When dismissing all, we translate the entire view instead.
                return super.getViewTranslationAnimator(v, target, listener);
            } else if (v instanceof ExpandableNotificationRow) {
                return ((ExpandableNotificationRow) v).getTranslateViewAnimator(target, listener);
                return ((ExpandableNotificationRow) v).getTranslateViewAnimator(target, listener);
            } else {
            } else {
                return super.getViewTranslationAnimator(v, target, listener);
                return super.getViewTranslationAnimator(v, target, listener);
@@ -3651,23 +3646,13 @@ public class NotificationStackScrollLayout extends ViewGroup


        @Override
        @Override
        public void setTranslation(View v, float translate) {
        public void setTranslation(View v, float translate) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                super.setTranslation(v, translate);
            } else {
            ((ExpandableView) v).setTranslation(translate);
            ((ExpandableView) v).setTranslation(translate);
        }
        }
        }


        @Override
        @Override
        public float getTranslation(View v) {
        public float getTranslation(View v) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                return super.getTranslation(v);
            } else {
            return ((ExpandableView) v).getTranslation();
            return ((ExpandableView) v).getTranslation();
        }
        }
        }


        public void closeControlsIfOutsideTouch(MotionEvent ev) {
        public void closeControlsIfOutsideTouch(MotionEvent ev) {
            NotificationGuts guts = mPhoneStatusBar.getExposedGuts();
            NotificationGuts guts = mPhoneStatusBar.getExposedGuts();