diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 0bb8cbfb96..c499beeb37 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -594,18 +594,31 @@ public class Workspace extends PagedView } // Add the first page CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0); - final VerticalFlingDetector detector = new VerticalFlingDetector(mLauncher){ - @Override - public boolean onTouch(View v, MotionEvent ev) { - if (shouldConsumeTouch(v)) return true; - if (super.onTouch(v, ev)) { - mLauncher.startSearch("", false, null, false); + if (FeatureFlags.PULLDOWN_SEARCH) { + firstPage.setOnTouchListener(new VerticalFlingDetector(mLauncher) { + // detect fling when touch started from empty space + @Override + public boolean onTouch(View v, MotionEvent ev) { + if (workspaceInModalState()) return false; + if (shouldConsumeTouch(v)) return true; + if (super.onTouch(v, ev)) { + mLauncher.startSearch("", false, null, false); + } + return false; } - return false; - } - }; - firstPage.setOnTouchListener(detector); - firstPage.setOnInterceptTouchListener(detector); + }); + firstPage.setOnInterceptTouchListener(new VerticalFlingDetector(mLauncher) { + // detect fling when touch started from on top of the icons + @Override + public boolean onTouch(View v, MotionEvent ev) { + if (shouldConsumeTouch(v)) return true; + if (super.onTouch(v, ev)) { + mLauncher.startSearch("", false, null, false); + } + return false; + } + }); + } // Always add a QSB on the first screen. if (qsb == null) { // In transposed layout, we add the QSB in the Grid. As workspace does not touch the diff --git a/src/com/android/launcher3/util/VerticalFlingDetector.java b/src/com/android/launcher3/util/VerticalFlingDetector.java index 5f2b3f3aca..7236c2d1bb 100644 --- a/src/com/android/launcher3/util/VerticalFlingDetector.java +++ b/src/com/android/launcher3/util/VerticalFlingDetector.java @@ -79,6 +79,9 @@ public class VerticalFlingDetector implements View.OnTouchListener { } private void cleanUp() { + if (mVelocityTracker == null) { + return; + } mVelocityTracker.recycle(); mVelocityTracker = null; } diff --git a/src_config/com/android/launcher3/config/FeatureFlags.java b/src_config/com/android/launcher3/config/FeatureFlags.java index 81fa3370ff..13acc4ae38 100644 --- a/src_config/com/android/launcher3/config/FeatureFlags.java +++ b/src_config/com/android/launcher3/config/FeatureFlags.java @@ -31,8 +31,10 @@ public final class FeatureFlags { public static boolean LAUNCHER3_DISABLE_PINCH_TO_OVERVIEW = false; public static boolean LAUNCHER3_ALL_APPS_PULL_UP = true; - // Feature flag to enable moving the QSB on the 0th screen of the workspace + // Feature flag to enable moving the QSB on the 0th screen of the workspace. public static final boolean QSB_ON_FIRST_SCREEN = true; // When enabled the all-apps icon is not added to the hotseat. public static final boolean NO_ALL_APPS_ICON = true; + // When enabled fling down gesture on the first workspace triggers search. + public static final boolean PULLDOWN_SEARCH = true; }