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

Commit 736d38b3 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Fade bubbles when dismissing the last bubble

When the stack is expanded and the last bubble is being dismissed,
the bubbles now fade out as part of the collapse animation.

Demo: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/fl3WS1vhKAwKFJDu05uQ6V

Fixes: 311485533
Test: Manual
      - Add a bubble and expand the stack
      - Dismiss the bubble either from the manage menu or by dradding it
      - Observe that bubbles fade out during the collapse animation
Change-Id: Ieecfbfe27bddde72355aaf54b14eb9abeb1e5e06
parent 6ea41f31
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2456,6 +2456,7 @@ public class BubbleStackView extends FrameLayout
        final Runnable collapseBackToStack = () ->
                mExpandedAnimationController.collapseBackToStack(
                        mStackAnimationController.getStackPositionAlongNearestHorizontalEdge(),
                        /* fadeBubblesDuringCollapse= */ mRemovingLastBubbleWhileExpanded,
                        () -> {
                            mBubbleContainer.setActiveController(mStackAnimationController);
                            updateOverflowVisibility();
+6 −2
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class ExpandedAnimationController
    private Runnable mAfterExpand;
    private Runnable mAfterCollapse;
    private PointF mCollapsePoint;
    private boolean mFadeBubblesDuringCollapse = false;

    /**
     * Whether the dragged out bubble is springing towards the touch point, rather than using the
@@ -201,12 +202,14 @@ public class ExpandedAnimationController
    }

    /** Animate collapsing the bubbles back to their stacked position. */
    public void collapseBackToStack(PointF collapsePoint, Runnable after) {
    public void collapseBackToStack(PointF collapsePoint, boolean fadeBubblesDuringCollapse,
            Runnable after) {
        mAnimatingExpand = false;
        mPreparingToCollapse = false;
        mAnimatingCollapse = true;
        mAfterCollapse = after;
        mCollapsePoint = collapsePoint;
        mFadeBubblesDuringCollapse = fadeBubblesDuringCollapse;

        startOrUpdatePathAnimation(false /* expanding */);
    }
@@ -253,6 +256,7 @@ public class ExpandedAnimationController
                }

                mAfterCollapse = null;
                mFadeBubblesDuringCollapse = false;
            };
        }

@@ -262,7 +266,7 @@ public class ExpandedAnimationController
                        == LAYOUT_DIRECTION_RTL;

        // Animate each bubble individually, since each path will end in a different spot.
        animationsForChildrenFromIndex(0, (index, animation) -> {
        animationsForChildrenFromIndex(0, mFadeBubblesDuringCollapse, (index, animation) -> {
            final View bubble = mLayout.getChildAt(index);

            // Start a path at the bubble's current position.
+11 −2
Original line number Diff line number Diff line
@@ -204,6 +204,13 @@ public class PhysicsAnimationLayout extends FrameLayout {
            return animationForChild(mLayout.getChildAt(index));
        }


        protected MultiAnimationStarter animationsForChildrenFromIndex(
                int startIndex, ChildAnimationConfigurator configurator) {
            return animationsForChildrenFromIndex(startIndex, /* fadeChildren= */ false,
                    configurator);
        }

        /**
         * Returns a {@link MultiAnimationStarter} whose startAll method will start the physics
         * animations for all children from startIndex onward. The provided configurator will be
@@ -211,14 +218,16 @@ public class PhysicsAnimationLayout extends FrameLayout {
         * animation appropriately.
         */
        protected MultiAnimationStarter animationsForChildrenFromIndex(
                int startIndex, ChildAnimationConfigurator configurator) {
                int startIndex, boolean fadeChildren, ChildAnimationConfigurator configurator) {
            final Set<DynamicAnimation.ViewProperty> allAnimatedProperties = new HashSet<>();
            final List<PhysicsPropertyAnimator> allChildAnims = new ArrayList<>();

            // Retrieve the animator for each child, ask the configurator to configure it, then save
            // it and the properties it chose to animate.
            for (int i = startIndex; i < mLayout.getChildCount(); i++) {
                final PhysicsPropertyAnimator anim = animationForChildAtIndex(i);
                final PhysicsPropertyAnimator anim = fadeChildren
                        ? animationForChildAtIndex(i).alpha(0)
                        : animationForChildAtIndex(i);
                configurator.configureAnimationForChildAtIndex(i, anim);
                allAnimatedProperties.addAll(anim.getAnimatedProperties());
                allChildAnims.add(anim);
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class ExpandedAnimationControllerTest extends PhysicsAnimationLayoutTestC
        verify(afterExpand).run();

        Runnable afterCollapse = mock(Runnable.class);
        mExpandedController.collapseBackToStack(mExpansionPoint, afterCollapse);
        mExpandedController.collapseBackToStack(mExpansionPoint, false, afterCollapse);
        waitForPropertyAnimations(DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);

        testStackedAtPosition(mExpansionPoint.x, mExpansionPoint.y, -1);