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

Commit eca966cb authored by Yining Liu's avatar Yining Liu
Browse files

Fix the overlapping when a pinned auto-cancel notification is clicked

Fix the problem that when a pinned auto-cancel notification is clicked
when the Shade is opened, and the Shade collapsing is canceled. This
change added the normal dismissal animation for the clicked auto-cancel
HUNs to let them perform the animation correctly when the Shade
collapsing is aborted.
 Moving forward, we should only add transient views:
 1. In the same frame that the view is removed
 2. When the removal animation is currently running, or determined to be run
 We can also consider adding cleaning up procedures that act as
 back-ups for the removal animation end listeners.

 Bug: 297950089
 Bug: 281628358

Test: manual post a HUN with auto-cancel, open the Shade, click the
notif, and cancel the Shade collapsing. There shouldn't be overlapping
HUNs.

Change-Id: I3d5a76c5fc0e1baeb9c8caa4832fb9cce061a51b
parent 2e8f0375
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -351,12 +351,21 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

    @Override
    public long performRemoveAnimation(long duration, long delay, float translationDirection,
            boolean isHeadsUpAnimation, Runnable onFinishedRunnable,
            boolean isHeadsUpAnimation, Runnable onStartedRunnable, Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        enableAppearDrawing(true);
        mIsHeadsUpAnimation = isHeadsUpAnimation;
        if (mDrawingAppearAnimation) {
            startAppearAnimation(false /* isAppearing */, translationDirection,
                delay, duration, onFinishedRunnable, animationListener);
                    delay, duration, onStartedRunnable, onFinishedRunnable, animationListener);
        } else {
            if (onStartedRunnable != null) {
                onStartedRunnable.run();
            }
            if (onFinishedRunnable != null) {
                onFinishedRunnable.run();
            }
        }
        return 0;
    }

@@ -365,12 +374,14 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            Runnable onFinishRunnable) {
        enableAppearDrawing(true);
        mIsHeadsUpAnimation = isHeadsUpAppear;
        if (mDrawingAppearAnimation) {
            startAppearAnimation(true /* isAppearing */, isHeadsUpAppear ? 0.0f : -1.0f, delay,
                duration, null, null);
                    duration, null, null, null);
        }
    }

    private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay,
            long duration, final Runnable onFinishedRunnable,
            long duration, final Runnable onStartedRunnable, final Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        mAnimationTranslationY = translationDirection * getActualHeight();
        cancelAppearAnimation();
@@ -434,6 +445,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

            @Override
            public void onAnimationStart(Animator animation) {
                if (onStartedRunnable != null) {
                    onStartedRunnable.run();
                }
                mRunWithoutInterruptions = true;
                Configuration.Builder builder = Configuration.Builder
                        .withView(getCujType(isAppearing), ActivatableNotificationView.this);
+9 −2
Original line number Diff line number Diff line
@@ -2927,17 +2927,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            long delay,
            float translationDirection,
            boolean isHeadsUpAnimation,
            Runnable onStartedRunnable,
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        if (mMenuRow != null && mMenuRow.isMenuVisible()) {
            Animator anim = getTranslateViewAnimator(0f, null /* listener */);
            if (anim != null) {
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        if (onStartedRunnable != null) {
                            onStartedRunnable.run();
                        }
                    }
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ExpandableNotificationRow.super.performRemoveAnimation(
                                duration, delay, translationDirection, isHeadsUpAnimation,
                                onFinishedRunnable, animationListener);
                                null, onFinishedRunnable, animationListener);
                    }
                });
                anim.start();
@@ -2945,7 +2952,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            }
        }
        return super.performRemoveAnimation(duration, delay, translationDirection,
                isHeadsUpAnimation, onFinishedRunnable, animationListener);
                isHeadsUpAnimation, onStartedRunnable, onFinishedRunnable, animationListener);
    }

    @Override
+24 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
    private boolean mClipToActualHeight = true;
    private boolean mChangingPosition = false;
    private ViewGroup mTransientContainer;

    // Needs to be added as transient view when removed from parent, because it's in animation
    private boolean mInRemovalAnimation;
    private boolean mInShelf;
    private boolean mTransformingInShelf;
    protected float mContentTransformationAmount;
@@ -381,6 +384,7 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
     */
    public abstract long performRemoveAnimation(long duration,
            long delay, float translationDirection, boolean isHeadsUpAnimation,
            Runnable onStartedRunnable,
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener);

@@ -603,6 +607,25 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
        return mTransientContainer;
    }

    /**
     * Add the view to a transient container.
     */
    public void addToTransientContainer(ViewGroup container, int index) {
        container.addTransientView(this, index);
        setTransientContainer(container);
    }

    /**
     * @return If the view is in a process of removal animation.
     */
    public boolean inRemovalAnimation() {
        return mInRemovalAnimation;
    }

    public void setInRemovalAnimation(boolean inRemovalAnimation) {
        mInRemovalAnimation = inRemovalAnimation;
    }

    /**
     * @return true if the group's expansion state is changing, false otherwise.
     */
@@ -837,6 +860,7 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
                pw.println();
            }
            if (DUMP_VERBOSE) {
                pw.println("mInRemovalAnimation: " + mInRemovalAnimation);
                pw.println("mClipTopAmount: " + mClipTopAmount);
                pw.println("mClipBottomAmount " + mClipBottomAmount);
                pw.println("mClipToActualHeight: " + mClipToActualHeight);
+4 −0
Original line number Diff line number Diff line
@@ -237,9 +237,13 @@ public abstract class StackScrollerDecorView extends ExpandableView {
    @Override
    public long performRemoveAnimation(long duration, long delay,
            float translationDirection, boolean isHeadsUpAnimation,
            Runnable onStartedRunnable,
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        // TODO: Use duration
        if (onStartedRunnable != null) {
            onStartedRunnable.run();
        }
        setContentVisible(false, true /* animate */, (cancelled) -> onFinishedRunnable.run());
        return 0;
    }
+17 −14
Original line number Diff line number Diff line
@@ -25,9 +25,7 @@ import android.util.AttributeSet
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.row.ExpandableView

/**
 * Root view to insert Lock screen media controls into the notification stack.
 */
/** Root view to insert Lock screen media controls into the notification stack. */
class MediaContainerView(context: Context, attrs: AttributeSet?) : ExpandableView(context, attrs) {

    override var clipHeight = 0
@@ -46,8 +44,8 @@ class MediaContainerView(context: Context, attrs: AttributeSet?) : ExpandableVie
    }

    private fun updateResources() {
        cornerRadius = context.resources
                .getDimensionPixelSize(R.dimen.notification_corner_radius).toFloat()
        cornerRadius =
            context.resources.getDimensionPixelSize(R.dimen.notification_corner_radius).toFloat()
    }

    public override fun updateClipping() {
@@ -74,14 +72,19 @@ class MediaContainerView(context: Context, attrs: AttributeSet?) : ExpandableVie
        delay: Long,
        translationDirection: Float,
        isHeadsUpAnimation: Boolean,
        onStartedRunnable: Runnable?,
        onFinishedRunnable: Runnable?,
        animationListener: AnimatorListenerAdapter?
    ): Long {
        return 0
    }

    override fun performAddAnimation(delay: Long, duration: Long, isHeadsUpAppear: Boolean,
                                     onEnd: Runnable?) {
    override fun performAddAnimation(
        delay: Long,
        duration: Long,
        isHeadsUpAppear: Boolean,
        onEnd: Runnable?
    ) {
        // No animation, it doesn't need it, this would be local
    }
}
Loading