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

Commit 4721ef7c authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge changes from topic "notif_smooth_dismissal" into sc-dev

* changes:
  Animating when the qs boundary changes due to notification interactions
  When swiping notifications it doesn't clip early anymore
  Modified the way the notifications clip to the boundary
parents 0ecbcfd0 982d5430
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -396,10 +396,6 @@
    <!-- Whether or not the notifications should always fade as they are dismissed. -->
    <bool name="config_fadeNotificationsOnDismiss">false</bool>

    <!-- Whether or not the parent of the notification row itself is being translated when swiped or
         its children views. If true, then the contents are translated and vice versa. -->
    <bool name="config_translateNotificationContentsOnSwipe">true</bool>

    <!-- Whether or not the fade on the notification is based on the amount that it has been swiped
         off-screen. -->
    <bool name="config_fadeDependingOnAmountSwiped">false</bool>
+11 −2
Original line number Diff line number Diff line
@@ -391,9 +391,9 @@ public class SwipeHelper implements Gefingerpoken {
        boolean animateLeft = (Math.abs(velocity) > getEscapeVelocity() && velocity < 0) ||
                (getTranslation(animView) < 0 && !isDismissAll);
        if (animateLeft || animateLeftForRtl || animateUpForMenu) {
            newPos = -getSize(animView);
            newPos = -getTotalTranslationLength(animView);
        } else {
            newPos = getSize(animView);
            newPos = getTotalTranslationLength(animView);
        }
        long duration;
        if (fixedDuration == 0) {
@@ -469,6 +469,15 @@ public class SwipeHelper implements Gefingerpoken {
        anim.start();
    }

    /**
     * Get the total translation length where we want to swipe to when dismissing the view. By
     * default this is the size of the view, but can also be larger.
     * @param animView the view to ask about
     */
    protected float getTotalTranslationLength(View animView) {
        return getSize(animView);
    }

    /**
     * Called to update the dismiss animation.
     */
+2 −2
Original line number Diff line number Diff line
@@ -71,11 +71,11 @@ public final class NotificationClicker implements View.OnClickListener {
        // Check if the notification is displaying the menu, if so slide notification back
        if (isMenuVisible(row)) {
            mLogger.logMenuVisible(entry);
            row.animateTranslateNotification(0);
            row.animateResetTranslation();
            return;
        } else if (row.isChildInGroup() && isMenuVisible(row.getNotificationParent())) {
            mLogger.logParentMenuVisible(entry);
            row.getNotificationParent().animateTranslateNotification(0);
            row.getNotificationParent().animateResetTranslation();
            return;
        } else if (row.isSummaryWithChildren() && row.areChildrenExpanded()) {
            // We never want to open the app directly if the user clicks in between
+0 −24
Original line number Diff line number Diff line
@@ -330,30 +330,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        }
    }

    @Override
    public void setDistanceToTopRoundness(float distanceToTopRoundness) {
        super.setDistanceToTopRoundness(distanceToTopRoundness);
        mBackgroundNormal.setDistanceToTopRoundness(distanceToTopRoundness);
    }

    /** Sets whether this view is the last notification in a section. */
    @Override
    public void setLastInSection(boolean lastInSection) {
        if (lastInSection != mLastInSection) {
            super.setLastInSection(lastInSection);
            mBackgroundNormal.setLastInSection(lastInSection);
        }
    }

    /** Sets whether this view is the first notification in a section. */
    @Override
    public void setFirstInSection(boolean firstInSection) {
        if (firstInSection != mFirstInSection) {
            super.setFirstInSection(firstInSection);
            mBackgroundNormal.setFirstInSection(firstInSection);
        }
    }

    /**
     * Set an override tint color that is used for the background.
     *
+43 −39
Original line number Diff line number Diff line
@@ -846,8 +846,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        updateClickAndFocus();
        if (mNotificationParent != null) {
            setOverrideTintColor(NO_COLOR, 0.0f);
            // Let's reset the distance to top roundness, as this isn't applied to group children
            setDistanceToTopRoundness(NO_ROUNDNESS);
            mNotificationParent.updateBackgroundForGroupState();
        }
        updateBackgroundClipping();
@@ -876,7 +874,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    @Override
    protected boolean handleSlideBack() {
        if (mMenuRow != null && mMenuRow.isMenuVisible()) {
            animateTranslateNotification(0 /* targetLeft */);
            animateResetTranslation();
            return true;
        }
        return false;
@@ -1713,12 +1711,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
            mChildrenContainer.onNotificationUpdated();

            if (mShouldTranslateContents) {
            mTranslateableViews.add(mChildrenContainer);
            }
        });

        if (mShouldTranslateContents) {
        // Add the views that we translate to reveal the menu
        mTranslateableViews = new ArrayList<>();
        for (int i = 0; i < getChildCount(); i++) {
@@ -1728,7 +1723,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mTranslateableViews.remove(mChildrenContainerStub);
        mTranslateableViews.remove(mGutsStub);
    }
    }

    private void doLongClickCallback() {
        doLongClickCallback(getWidth() / 2, getHeight() / 2);
@@ -1805,7 +1799,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mTranslateAnim.cancel();
        }

        if (!mShouldTranslateContents) {
        if (mDismissUsingRowTranslationX) {
            setTranslationX(0);
        } else if (mTranslateableViews != null) {
            for (int i = 0; i < mTranslateableViews.size(); i++) {
@@ -1867,23 +1861,47 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return mPrivateLayout.getActiveRemoteInputText();
    }

    public void animateTranslateNotification(final float leftTarget) {
    /**
     * Reset the translation with an animation.
     */
    public void animateResetTranslation() {
        if (mTranslateAnim != null) {
            mTranslateAnim.cancel();
        }
        mTranslateAnim = getTranslateViewAnimator(leftTarget, null /* updateListener */);
        mTranslateAnim = getTranslateViewAnimator(0, null /* updateListener */);
        if (mTranslateAnim != null) {
            mTranslateAnim.start();
        }
    }

    /**
     * Set the dismiss behavior of the view.
     * @param usingRowTranslationX {@code true} if the view should translate using regular
     *                                          translationX, otherwise the contents will be
     *                                          translated.
     */
    @Override
    public void setDismissUsingRowTranslationX(boolean usingRowTranslationX) {
        if (usingRowTranslationX != mDismissUsingRowTranslationX) {
            // In case we were already transitioning, let's switch over!
            float previousTranslation = getTranslation();
            if (previousTranslation != 0) {
                setTranslation(0);
            }
            super.setDismissUsingRowTranslationX(usingRowTranslationX);
            if (previousTranslation != 0) {
                setTranslation(previousTranslation);
            }
        }
    }

    @Override
    public void setTranslation(float translationX) {
        invalidate();
        if (isBlockingHelperShowingAndTranslationFinished()) {
            mGuts.setTranslationX(translationX);
            return;
        } else if (!mShouldTranslateContents) {
        } else if (mDismissUsingRowTranslationX) {
            setTranslationX(translationX);
        } else if (mTranslateableViews != null) {
            // Translate the group of views
@@ -1907,7 +1925,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    public float getTranslation() {
        if (!mShouldTranslateContents) {
        if (mDismissUsingRowTranslationX) {
            return getTranslationX();
        }

@@ -2898,7 +2916,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        float y = event.getY();
        NotificationViewWrapper wrapper = getVisibleNotificationViewWrapper();
        NotificationHeaderView header = wrapper == null ? null : wrapper.getNotificationHeader();
        if (header != null && header.isInTouchRect(x - getTranslation(), y)) {
        // the extra translation only needs to be added, if we're translating the notification
        // contents, otherwise the motionEvent is already at the right place due to the
        // touch event system.
        float translation = !mDismissUsingRowTranslationX ? getTranslation() : 0;
        if (header != null && header.isInTouchRect(x - translation, y)) {
            return true;
        }
        if ((!mIsSummaryWithChildren || shouldShowPublic())
@@ -3036,24 +3058,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                || mExpandAnimationRunning || mChildIsExpanding));
    }

    @Override
    public boolean topAmountNeedsClipping() {
        if (isGroupExpanded()) {
            return true;
        }
        if (isGroupExpansionChanging()) {
            return true;
        }
        if (getShowingLayout().shouldClipToRounding(true /* topRounded */,
                false /* bottomRounded */)) {
            return true;
        }
        if (mGuts != null && mGuts.getAlpha() != 0.0f) {
            return true;
        }
        return false;
    }

    @Override
    protected boolean childNeedsClipping(View child) {
        if (child instanceof NotificationContentView) {
Loading