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

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

Fix user education placement

We were only showing the user education on click, so
you could drag the bubble then click on it, then the
user education would appear. However, the bubble wouldn't
be in the spot we'd expect due to the initial drag so the
user education would be misplaced.

This change fixes the issue by showing the user education
in the touchlistener onDown(*). Subsequent actions in
that gesture won't do anything. A small issue is that the
clickListener could be triggered in this state and then
immediately hide the education, to work around this I
added a flag to indicate if the education showed from the
touchListener & skip hiding in that case.

(*) Ideally this would occur in a proper down/up action
rather than onDown but there's a lot going on in the
touch handling and I think this is simplest.


Test: manual - (reset device) check that tapping the
               bubble shows the education
             - (reset device) check that dragging the
                bubble shows the education and the bubble
                doesn't move on the drag
             - education shouldn't show more than once
             - bubble should be draggable after the edu
               goes away
Bug: 200151972
Change-Id: I0bdb8d165641b5cad234b3053eb73e0575916102
parent 35185d54
Loading
Loading
Loading
Loading
+30 −9
Original line number Diff line number Diff line
@@ -529,9 +529,10 @@ public class BubbleStackView extends FrameLayout
                // Otherwise, we either tapped the stack (which means we're collapsed
                // and should expand) or the currently selected bubble (we're expanded
                // and should collapse).
                if (!maybeShowStackEdu()) {
                if (!maybeShowStackEdu() && !mShowedUserEducationInTouchListenerActive) {
                    mBubbleData.setExpanded(!mBubbleData.isExpanded());
                }
                mShowedUserEducationInTouchListenerActive = false;
            }
        }
    };
@@ -549,6 +550,14 @@ public class BubbleStackView extends FrameLayout
                return true;
            }

            mShowedUserEducationInTouchListenerActive = false;
            if (maybeShowStackEdu()) {
                mShowedUserEducationInTouchListenerActive = true;
                return true;
            } else if (isStackEduShowing()) {
                mStackEduView.hide(false /* fromExpansion */);
            }

            // If the manage menu is visible, just hide it.
            if (mShowingManage) {
                showManageMenu(false /* show */);
@@ -607,7 +616,8 @@ public class BubbleStackView extends FrameLayout
            // If we're expanding or collapsing, ignore all touch events.
            if (mIsExpansionAnimating
                    // Also ignore events if we shouldn't be draggable.
                    || (mPositioner.showingInTaskbar() && !mIsExpanded)) {
                    || (mPositioner.showingInTaskbar() && !mIsExpanded)
                    || mShowedUserEducationInTouchListenerActive) {
                return;
            }

@@ -628,7 +638,7 @@ public class BubbleStackView extends FrameLayout
                    mExpandedAnimationController.dragBubbleOut(
                            v, viewInitialX + dx, viewInitialY + dy);
                } else {
                    if (mStackEduView != null) {
                    if (isStackEduShowing()) {
                        mStackEduView.hide(false /* fromExpansion */);
                    }
                    mStackAnimationController.moveStackFromTouch(
@@ -646,6 +656,10 @@ public class BubbleStackView extends FrameLayout
                    || (mPositioner.showingInTaskbar() && !mIsExpanded)) {
                return;
            }
            if (mShowedUserEducationInTouchListenerActive) {
                mShowedUserEducationInTouchListenerActive = false;
                return;
            }

            // First, see if the magnetized object consumes the event - if so, the bubble was
            // released in the target or flung out of it, and we should ignore the event.
@@ -738,6 +752,7 @@ public class BubbleStackView extends FrameLayout
    private ImageView mManageSettingsIcon;
    private TextView mManageSettingsText;
    private boolean mShowingManage = false;
    private boolean mShowedUserEducationInTouchListenerActive = false;
    private PhysicsAnimator.SpringConfig mManageSpringConfig = new PhysicsAnimator.SpringConfig(
            SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_LOW_BOUNCY);
    private BubblePositioner mPositioner;
@@ -929,10 +944,12 @@ public class BubbleStackView extends FrameLayout
                showManageMenu(false /* show */);
            } else if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) {
                mManageEduView.hide();
            } else if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) {
            } else if (isStackEduShowing()) {
                mStackEduView.hide(false /* isExpanding */);
            } else if (mBubbleData.isExpanded()) {
                mBubbleData.setExpanded(false);
            } else {
                maybeShowStackEdu();
            }
        });

@@ -1157,7 +1174,7 @@ public class BubbleStackView extends FrameLayout
     * @return true if education view for collapsed stack should show and was not showing before.
     */
    private boolean maybeShowStackEdu() {
        if (!shouldShowStackEdu()) {
        if (!shouldShowStackEdu() || isExpanded()) {
            return false;
        }
        if (mStackEduView == null) {
@@ -1168,9 +1185,13 @@ public class BubbleStackView extends FrameLayout
        return mStackEduView.show(mPositioner.getDefaultStartPosition());
    }

    private boolean isStackEduShowing() {
        return mStackEduView != null && mStackEduView.getVisibility() == VISIBLE;
    }

    // Recreates & shows the education views. Call when a theme/config change happens.
    private void updateUserEdu() {
        if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) {
        if (isStackEduShowing()) {
            removeView(mStackEduView);
            mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController);
            addView(mStackEduView);
@@ -1852,7 +1873,7 @@ public class BubbleStackView extends FrameLayout
        cancelDelayedExpandCollapseSwitchAnimations();
        final boolean showVertically = mPositioner.showBubblesVertically();
        mIsExpanded = true;
        if (mStackEduView != null) {
        if (isStackEduShowing()) {
            mStackEduView.hide(true /* fromExpansion */);
        }
        beforeExpandedViewAnimation();
@@ -2390,7 +2411,7 @@ public class BubbleStackView extends FrameLayout
        if (flyoutMessage == null
                || flyoutMessage.message == null
                || !bubble.showFlyout()
                || (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE)
                || isStackEduShowing()
                || isExpanded()
                || mIsExpansionAnimating
                || mIsGestureInProgress
@@ -2512,7 +2533,7 @@ public class BubbleStackView extends FrameLayout
     * them.
     */
    public void getTouchableRegion(Rect outRect) {
        if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) {
        if (isStackEduShowing()) {
            // When user education shows then capture all touches
            outRect.set(0, 0, getWidth(), getHeight());
            return;
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ class StackEducationView constructor(
     * @return true if user education was shown, false otherwise.
     */
    fun show(stackPosition: PointF): Boolean {
        isHiding = false
        if (visibility == VISIBLE) return false

        controller.updateWindowFlagsForBackpress(true /* interceptBack */)
@@ -164,6 +165,7 @@ class StackEducationView constructor(
     */
    fun hide(isExpanding: Boolean) {
        if (visibility != VISIBLE || isHiding) return
        isHiding = true

        controller.updateWindowFlagsForBackpress(false /* interceptBack */)
        animate()