Fixing missed events during motion interaction

> Only ignoring touch events during the start of the motion events
> Handling action_cancel

Bug: 30291280
Change-Id: I4aa791b30c65ebaff90bb2f232d77de62ab6a033
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index 8091825..c9eee81 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -388,6 +388,8 @@
                     break;
                 }
             }
+        } else if (action == MotionEvent.ACTION_CANCEL) {
+            cleanupDeferredDrag();
         }
         return true;
     }
diff --git a/src/com/android/launcher3/shortcuts/ShortcutsContainerListener.java b/src/com/android/launcher3/shortcuts/ShortcutsContainerListener.java
index 962fbac..f3b0d04 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutsContainerListener.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutsContainerListener.java
@@ -56,6 +56,9 @@
     private final int[] mTouchDown;
     private boolean mHasMappedTouchDownToContainerCoord;
 
+    /** If true, the gesture is not handled. The value is reset when next gesture starts. */
+    private boolean mIgnoreCurrentGesture;
+
     public ShortcutsContainerListener(BubbleTextView icon) {
         mSrcIcon = icon;
         mScaledTouchSlop = ViewConfiguration.get(icon.getContext()).getScaledTouchSlop();
@@ -72,18 +75,22 @@
 
     @Override
     public boolean onTouch(View v, MotionEvent event) {
-        if (mLauncher.getShortcutIdsForItem((ItemInfo) v.getTag()).isEmpty()) {
-            // There are no shortcuts associated with this item, so return to normal touch handling.
-            return false;
-        }
-
         if (event.getAction() == MotionEvent.ACTION_DOWN) {
+            // There are no shortcuts associated with this item,
+            // so return to normal touch handling.
+            mIgnoreCurrentGesture =
+                    (mLauncher.getShortcutIdsForItem((ItemInfo) v.getTag())).isEmpty();
+
             mTouchDown[0] = (int) event.getX();
             mTouchDown[1] = (int) event.getY();
             mDragLayer.getDescendantCoordRelativeToSelf(mSrcIcon, mTouchDown);
             mHasMappedTouchDownToContainerCoord = false;
         }
 
+        if (mIgnoreCurrentGesture) {
+            return false;
+        }
+
         final boolean wasForwarding = mForwarding;
         final boolean forwarding;
         if (wasForwarding) {