Ignore touches on launcher while quick scrub is enabled

Bug: 72189689
Change-Id: Ic4564719a35442670226a021ae2c8799a884b201
diff --git a/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
new file mode 100644
index 0000000..92aa1fd
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.uioverrides;
+
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.util.TouchController;
+import com.android.quickstep.QuickScrubController;
+import com.android.quickstep.RecentsView;
+
+/**
+ * Consumes touches when quick scrub is enabled.
+ */
+public class IgnoreTouchesInQuickScrub implements TouchController {
+
+    private QuickScrubController mQuickScrubController;
+
+    public IgnoreTouchesInQuickScrub(Launcher l) {
+        mQuickScrubController = ((RecentsView) l.getOverviewPanel()).getQuickScrubController();
+    }
+
+    @Override
+    public boolean onControllerTouchEvent(MotionEvent ev) {
+        return true;
+    }
+
+    @Override
+    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+        return mQuickScrubController.isQuickScrubEnabled();
+    }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index a55c6e4..a05304b 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -35,7 +35,6 @@
 import com.android.launcher3.widget.WidgetsFullSheet;
 import com.android.quickstep.RecentsView;
 import com.android.systemui.shared.recents.view.RecentsTransition;
-import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
 
 public class UiFactory {
 
@@ -43,12 +42,14 @@
 
     public static TouchController[] createTouchControllers(Launcher launcher) {
         if (FeatureFlags.ENABLE_TWO_SWIPE_TARGETS) {
-            return new TouchController[]{
+            return new TouchController[] {
+                    new IgnoreTouchesInQuickScrub(launcher),
                     new EdgeSwipeController(launcher),
                     new TwoStepSwipeController(launcher),
                     new OverviewSwipeController(launcher)};
         } else {
-            return new TouchController[]{
+            return new TouchController[] {
+                    new IgnoreTouchesInQuickScrub(launcher),
                     new TwoStepSwipeController(launcher),
                     new OverviewSwipeController(launcher)};
         }
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index f4c2055..d656f8a 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -40,6 +40,7 @@
 
     private int mQuickScrubSection;
     private int mStartPage;
+    private boolean mQuickScrubEnabled;
 
     public QuickScrubController(Launcher launcher) {
         mLauncher = launcher;
@@ -51,11 +52,14 @@
         mRecentsView = mLauncher.getOverviewPanel();
         mStartPage = startingFromHome ? 0 : mRecentsView.getFirstTaskIndex();
         mQuickScrubSection = 0;
+        mQuickScrubEnabled = true;
     }
 
     public void onQuickScrubEnd() {
         mAutoAdvanceAlarm.cancelAlarm();
-        if (mRecentsView != null) {
+        if (mRecentsView == null) {
+            mQuickScrubEnabled = false;
+        } else {
             int page = mRecentsView.getNextPage();
             // Settle on the page then launch it.
             int snapDuration = Math.abs(page - mRecentsView.getPageNearestToCenterOfScreen())
@@ -67,10 +71,15 @@
                 } else {
                     ((TaskView) mRecentsView.getPageAt(page)).launchTask(true);
                 }
+                mQuickScrubEnabled = false;
             }, snapDuration);
         }
     }
 
+    public boolean isQuickScrubEnabled() {
+        return mQuickScrubEnabled;
+    }
+
     public void onQuickScrubProgress(float progress) {
         int quickScrubSection = Math.round(progress * NUM_QUICK_SCRUB_SECTIONS);
         if (quickScrubSection != mQuickScrubSection) {