Fix long press after already moving off icon
When an icon is in the Hotseat and a user drags off from the icon,
but continues holding down, the icon gets a long press triggered
by the CheckLongPressHelper.
To fix this a check has been added on move events to see if the
point has moved outside the view and to cancel the long press
check callback if it has.
Bug: 13569451
Change-Id: Id175cdc220d70b5e9f8e492ed5a3cc7c3f11db10
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java
index 51a649a..f47fd13 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java
@@ -21,6 +21,7 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.RemoteViews;
@@ -36,6 +37,8 @@
private int mPreviousOrientation;
private DragLayer mDragLayer;
+ private float mSlop;
+
public LauncherAppWidgetHostView(Context context) {
super(context);
mContext = context;
@@ -90,6 +93,11 @@
case MotionEvent.ACTION_CANCEL:
mLongPressHelper.cancelLongPress();
break;
+ case MotionEvent.ACTION_MOVE:
+ if (!Utilities.pointInView(this, ev.getX(), ev.getY(), mSlop)) {
+ mLongPressHelper.cancelLongPress();
+ }
+ break;
}
// Otherwise continue letting touch events fall through to children
@@ -104,11 +112,22 @@
case MotionEvent.ACTION_CANCEL:
mLongPressHelper.cancelLongPress();
break;
+ case MotionEvent.ACTION_MOVE:
+ if (!Utilities.pointInView(this, ev.getX(), ev.getY(), mSlop)) {
+ mLongPressHelper.cancelLongPress();
+ }
+ break;
}
return false;
}
@Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ }
+
+ @Override
public void cancelLongPress() {
super.cancelLongPress();
mLongPressHelper.cancelLongPress();