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

Commit d80ebdfd authored by Tony Wickham's avatar Tony Wickham
Browse files

Intercept touches in DeepShortcutContainer after moving beyond touch slop

Otherwise it's possible for a long press to trigger when swiping
on a shortcut, which causes it to drag far away from the finger.

Bug: 32309824
Change-Id: I40bd5c1daac49d6edb59744083a1e23dcf4f0ce6
parent 37e4df17
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.ShapeDrawable;
import android.os.Build;
@@ -38,6 +39,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
@@ -89,6 +91,7 @@ public class DeepShortcutsContainer extends AbstractFloatingView

    private BubbleTextView mOriginalIcon;
    private final Rect mTempRect = new Rect();
    private PointF mInterceptTouchDown = new PointF();
    private Point mIconLastTouchPos = new Point();
    private boolean mIsLeftAligned;
    private boolean mIsAboveIcon;
@@ -413,6 +416,17 @@ public class DeepShortcutsContainer extends AbstractFloatingView
        };
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mInterceptTouchDown.set(ev.getX(), ev.getY());
            return false;
        }
        // Stop sending touch events to deep shortcut views if user moved beyond touch slop.
        return Math.hypot(mInterceptTouchDown.x - ev.getX(), mInterceptTouchDown.y - ev.getY())
                > ViewConfiguration.get(getContext()).getScaledTouchSlop();
    }

    /**
     * We need to handle touch events to prevent them from falling through to the workspace below.
     */