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

Commit bc078c2d authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix some touch issues

ag/6525933 & ag/6627783 didn't play super well together!

* mExpandedAnimationController.updateYPosition shouldn't be called
  while an expansion is happening -- this will clear out the end listeners
  from the expansion animation
* We also shouldn't have to adjust insets while the expansion is changing
  anyways

The other issue (from ag/6627783) is that in applyCurrentState updateView
was getting called while the expanded view animation might still be
running; this would result in incorrect ActivityView onLocationChanged
call. This is fixed by adding updateView after the expand animation has
been called.

Fixes: 129300945
Test: manual D: D:
Change-Id: I73b846d8428a7a1b4e02f52c120a2f21e03a1742
parent 14152272
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public class BubbleStackView extends FrameLayout {
    private BubbleExpandedView.OnBubbleBlockedListener mBlockedListener;

    private boolean mViewUpdatedRequested = false;
    private boolean mIsAnimating = false;
    private boolean mIsExpansionAnimating = false;

    private LayoutInflater mInflater;

@@ -233,6 +233,11 @@ public class BubbleStackView extends FrameLayout {
                new SpringForce()
                        .setStiffness(SpringForce.STIFFNESS_LOW)
                        .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY));
        mExpandedViewYAnim.addEndListener((anim, cancelled, value, velocity) -> {
            if (mIsExpanded && mExpandedBubble != null) {
                mExpandedBubble.expandedView.updateView();
            }
        });

        setClipChildren(false);
        setFocusable(true);
@@ -241,7 +246,7 @@ public class BubbleStackView extends FrameLayout {
        setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> {
            final int keyboardHeight = insets.getSystemWindowInsetBottom()
                    - insets.getStableInsetBottom();
            if (!mIsExpanded) {
            if (!mIsExpanded || mIsExpansionAnimating) {
                return view.onApplyWindowInsets(insets);
            }
            mImeVisible = keyboardHeight != 0;
@@ -620,24 +625,23 @@ public class BubbleStackView extends FrameLayout {
            updateExpandedBubble();
            applyCurrentState();

            mIsAnimating = true;
            mIsExpansionAnimating = true;

            Runnable updateAfter = () -> {
                applyCurrentState();
                mIsAnimating = false;
                mIsExpansionAnimating = false;
                requestUpdate();
            };

            if (shouldExpand) {
                mBubbleContainer.setController(mExpandedAnimationController);
                mExpandedAnimationController.expandFromStack(
                        /* collapseTo */
                        mStackAnimationController.getStackPositionAlongNearestHorizontalEdge(),
                        /* after */
                        mStackAnimationController.getStackPositionAlongNearestHorizontalEdge()
                        /* collapseTo */,
                        () -> {
                            updatePointerPosition();
                            updateAfter.run();
                        });
                        } /* after */);
            } else {
                mBubbleContainer.cancelAllAnimations();
                mExpandedAnimationController.collapseBackToStack(
@@ -702,7 +706,7 @@ public class BubbleStackView extends FrameLayout {

    /** Called with the coordinates to which an individual bubble has been dragged. */
    public void onBubbleDragged(View bubble, float x, float y) {
        if (!mIsExpanded || mIsAnimating) {
        if (!mIsExpanded || mIsExpansionAnimating) {
            return;
        }

@@ -712,7 +716,7 @@ public class BubbleStackView extends FrameLayout {
    /** Called when a drag operation on an individual bubble has finished. */
    public void onBubbleDragFinish(
            View bubble, float x, float y, float velX, float velY, boolean dismissed) {
        if (!mIsExpanded || mIsAnimating) {
        if (!mIsExpanded || mIsExpansionAnimating) {
            return;
        }

@@ -724,7 +728,7 @@ public class BubbleStackView extends FrameLayout {
    }

    void onDragStart() {
        if (mIsExpanded || mIsAnimating) {
        if (mIsExpanded || mIsExpansionAnimating) {
            return;
        }

@@ -733,7 +737,7 @@ public class BubbleStackView extends FrameLayout {
    }

    void onDragged(float x, float y) {
        if (mIsExpanded || mIsAnimating) {
        if (mIsExpanded || mIsExpansionAnimating) {
            return;
        }

@@ -743,7 +747,7 @@ public class BubbleStackView extends FrameLayout {
    void onDragFinish(float x, float y, float velX, float velY) {
        // TODO: Add fling to bottom to dismiss.

        if (mIsExpanded || mIsAnimating) {
        if (mIsExpanded || mIsExpansionAnimating) {
            return;
        }

@@ -832,7 +836,7 @@ public class BubbleStackView extends FrameLayout {
    }

    private void requestUpdate() {
        if (mViewUpdatedRequested || mIsAnimating) {
        if (mViewUpdatedRequested || mIsExpansionAnimating) {
            return;
        }
        mViewUpdatedRequested = true;
@@ -862,11 +866,12 @@ public class BubbleStackView extends FrameLayout {
            if (!mExpandedViewYAnim.isRunning()) {
                // We're not animating so set the value
                mExpandedViewContainer.setTranslationY(y);
                mExpandedBubble.expandedView.updateView();
            } else {
                // We are animating so update the value
                // We are animating so update the value; there is an end listener on the animator
                // that will ensure expandedeView.updateView gets called.
                mExpandedViewYAnim.animateToFinalPosition(y);
            }
            mExpandedBubble.expandedView.updateView();
        }

        int bubbsCount = mBubbleContainer.getChildCount();