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

Commit 91ceef85 authored by András Kurucz's avatar András Kurucz
Browse files

Fix missing HUN disappear animation

Make the StackStateAnimator.startAnimationForEvents check if the
AnimationEvents have produced any custom animations, before its
executing the onFinish runnables.

We need this, because since ag/20789485 the ExpandableNotificationRow
starts its HUN appear and disappear animations async.

Fixes: 289495907
Test: Post a HUNning notification, cancel it with clicking its action,
observe the animation

Change-Id: I7146c9bcc6c17a1650675886b83ac27549a09979
parent 1962eee4
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ public class StackStateAnimator {
            ArrayList<NotificationStackScrollLayout.AnimationEvent> mAnimationEvents,
            long additionalDelay) {

        processAnimationEvents(mAnimationEvents);
        // Animation events might generate custom animations, which are started async
        boolean anyCustomAnimationCreated = processAnimationEvents(mAnimationEvents);

        int childCount = mHostLayout.getChildCount();
        mAnimationFilter.applyCombination(mNewEvents);
@@ -150,8 +151,8 @@ public class StackStateAnimator {
            initAnimationProperties(child, viewState, animationStaggerCount);
            viewState.animateTo(child, mAnimationProperties);
        }
        if (!isRunning()) {
            // no child has preformed any animation, lets finish
        if (!isRunning() && !anyCustomAnimationCreated) {
            // no child has performed any animation or is about to animate, lets finish
            onAnimationFinished();
        }
        mHeadsUpAppearChildren.clear();
@@ -335,12 +336,15 @@ public class StackStateAnimator {
    }

    /**
     * Process the animationEvents for a new animation
     * Process the animationEvents for a new animation. Here is the place to do something custom,
     * like to modify the ViewState or to create a custom animation for an event.
     *
     *  @param animationEvents the animation events for the animation to perform
     * @return true if any custom animation was created
     */
    private void processAnimationEvents(
    private boolean processAnimationEvents(
            ArrayList<NotificationStackScrollLayout.AnimationEvent> animationEvents) {
        boolean needsCustomAnimation = false;
        for (NotificationStackScrollLayout.AnimationEvent event : animationEvents) {
            final ExpandableView changingView = (ExpandableView) event.mChangingView;
            boolean loggable = false;
@@ -425,7 +429,8 @@ public class StackStateAnimator {
                }
                changingView.performRemoveAnimation(ANIMATION_DURATION_APPEAR_DISAPPEAR,
                        0 /* delay */, translationDirection, false /* isHeadsUpAppear */,
                        postAnimation, null);
                        postAnimation, getGlobalAnimationFinishedListener());
                needsCustomAnimation = true;
            } else if (event.animationType ==
                NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE_SWIPED_OUT) {
                if (mHostLayout.isFullySwipedOut(changingView)) {
@@ -479,7 +484,6 @@ public class StackStateAnimator {
                        needsAnimation = false;
                    }
                }

                if (needsAnimation) {
                    // We need to add the global animation listener, since once no animations are
                    // running anymore, the panel will instantly hide itself. We need to wait until
@@ -503,9 +507,11 @@ public class StackStateAnimator {
                } else if (endRunnable != null) {
                    endRunnable.run();
                }
                needsCustomAnimation |= needsAnimation;
            }
            mNewEvents.add(event);
        }
        return needsCustomAnimation;
    }

    public void animateOverScrollToAmount(float targetAmount, final boolean onTop,