UI fixes to All apps pull up work

b/28917826
- nav bar change to light when top of the all apps container
passes y mid point of the status bar
- apps search edit box change when top of the all apps passes
the bottom of nav bar
- Restrict pull up to work only if the ACTION_DOWN event started
from the hotseat.
- Landscape: reverted old padding and margin. Only the interaction
is different.
- Tuning of the motion spec
- Animation duration respects fling speed more agressively.
- and many more small bugs...

Change-Id: Icde4093c41eeab8c9c6d9dc8b7d57adc3b171349
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java
index a9ef43d..7c7cb0b 100644
--- a/src/com/android/launcher3/BaseContainerView.java
+++ b/src/com/android/launcher3/BaseContainerView.java
@@ -51,7 +51,9 @@
         super(context, attrs, defStyleAttr);
 
         int width = ((Launcher) context).getDeviceProfile().availableWidthPx;
-        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && (this instanceof AllAppsContainerView)) {
+        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP &&
+                this instanceof AllAppsContainerView &&
+                !((Launcher) context).getDeviceProfile().isLandscape) {
             mHorizontalPadding = 0;
         } else {
             mHorizontalPadding = DeviceProfile.getContainerPadding(context, width);
diff --git a/src/com/android/launcher3/InsettableFrameLayout.java b/src/com/android/launcher3/InsettableFrameLayout.java
index 61edc0f..db4d855 100644
--- a/src/com/android/launcher3/InsettableFrameLayout.java
+++ b/src/com/android/launcher3/InsettableFrameLayout.java
@@ -18,6 +18,10 @@
     @ViewDebug.ExportedProperty(category = "launcher")
     protected Rect mInsets = new Rect();
 
+    public Rect getInsets() {
+        return mInsets;
+    }
+
     public InsettableFrameLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
         setOnHierarchyChangeListener(this);
@@ -34,9 +38,6 @@
             lp.rightMargin += (newInsets.right - oldInsets.right);
             lp.bottomMargin += (newInsets.bottom - oldInsets.bottom);
         }
-        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && child instanceof AllAppsContainerView) {
-            lp.setMargins(0, 0, 0, lp.bottomMargin);
-        }
         child.setLayoutParams(lp);
     }
 
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 87ac67d..91014a6 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3447,7 +3447,7 @@
      * Updates the set of predicted apps if it hasn't been updated since the last time Launcher was
      * resumed.
      */
-    private void tryAndUpdatePredictedApps() {
+    public void tryAndUpdatePredictedApps() {
         if (mLauncherCallbacks != null) {
             List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps();
             if (apps != null) {
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index d62c629..bdd026d 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -249,10 +249,9 @@
         cancelAnimation();
 
         final View contentView = toView.getContentView();
-
+        playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+                animated, initialized, animation, revealDuration, layerViews);
         if (!animated || !initialized) {
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
 
             toView.setTranslationX(0.0f);
             toView.setTranslationY(0.0f);
@@ -276,9 +275,6 @@
             return null;
         }
         if (animType == CIRCULAR_REVEAL) {
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
-
             // Setup the reveal view animation
             final View revealView = toView.getRevealView();
 
@@ -425,8 +421,6 @@
                   }
             });
             mAllAppsController.animateToAllApps(animation, revealDuration);
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
 
             dispatchOnLauncherTransitionPrepare(fromView, animated, false);
             dispatchOnLauncherTransitionPrepare(toView, animated, false);
@@ -675,9 +669,9 @@
 
         boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages;
 
+        playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
+                animated, initialized, animation, revealDuration, layerViews);
         if (!animated || !initialized) {
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
             if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
                 mAllAppsController.finishPullDown();
             }
@@ -694,12 +688,9 @@
             if (onCompleteRunnable != null) {
                 onCompleteRunnable.run();
             }
-
             return null;
         }
         if (animType == CIRCULAR_REVEAL) {
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
             final View revealView = fromView.getRevealView();
             final View contentView = fromView.getContentView();
 
@@ -880,8 +871,6 @@
 
             });
             mAllAppsController.animateToWorkspace(animation, revealDuration);
-            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
-                    animated, initialized, animation, revealDuration, layerViews);
 
             // Dispatch the prepare transition signal
             dispatchOnLauncherTransitionPrepare(fromView, animated, false);
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 0f437c1..d59058b 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -490,7 +490,8 @@
 
         final DragLayer dragLayer = mLauncher.getDragLayer();
         final float startAlpha = dragLayer.getBackgroundAlpha();
-        float finalAlpha = states.stateIsNormal ? 0 : mWorkspaceScrimAlpha;
+        float finalAlpha = states.stateIsNormal || states.stateIsNormalHidden ?
+                0 : mWorkspaceScrimAlpha;
 
         if (finalAlpha != startAlpha) {
             if (animated) {
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a74c4c5..b5dc0c0 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -185,7 +185,8 @@
         mApps.setAdapter(mAdapter);
         mLayoutManager = mAdapter.getLayoutManager();
         mItemDecoration = mAdapter.getItemDecoration();
-        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
+        DeviceProfile grid = mLauncher.getDeviceProfile();
+        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && !grid.isLandscape) {
             mRecyclerViewTopBottomPadding = 0;
             setPadding(0, 0, 0, 0);
         } else {
@@ -350,7 +351,12 @@
         mAppsRecyclerView.setPremeasuredIconHeights(predIcon.getMeasuredHeight(),
                 icon.getMeasuredHeight());
 
-        updatePaddingsAndMargins();
+        // TODO(hyunyoungs): clean up setting the content and the reveal view.
+        if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
+            getContentView().setBackground(null);
+            getRevealView().setVisibility(View.VISIBLE);
+            getRevealView().setAlpha(AllAppsTransitionController.ALL_APPS_FINAL_ALPHA);
+        }
     }
 
     @Override
@@ -358,6 +364,7 @@
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        updatePaddingsAndMargins();
         mContentBounds.set(mHorizontalPadding, 0,
                 MeasureSpec.getSize(widthMeasureSpec) - mHorizontalPadding,
                 MeasureSpec.getSize(heightMeasureSpec));
@@ -366,6 +373,7 @@
         int availableWidth = (!mContentBounds.isEmpty() ? mContentBounds.width() :
                 MeasureSpec.getSize(widthMeasureSpec))
                 - 2 * mAppsRecyclerView.getMaxScrollbarWidth();
+        grid.updateAppsViewNumCols(getResources(), availableWidth);
         if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
             if (mNumAppsPerRow != grid.inv.numColumns ||
                     mNumPredictedAppsPerRow != grid.inv.numColumns) {
@@ -378,6 +386,7 @@
                 if (mNumAppsPerRow > 0) {
                     int iconSize = availableWidth / mNumAppsPerRow;
                     int iconSpacing = (iconSize - grid.allAppsIconSizePx) / 2;
+                    mSearchInput.setPaddingRelative(iconSpacing, 0, iconSpacing, 0);
                 }
             }
             super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -450,23 +459,25 @@
         lp.leftMargin = bgPadding.left;
         lp.rightMargin = bgPadding.right;
 
+        DeviceProfile grid = mLauncher.getDeviceProfile();
         if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
-            MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();
+            if (!grid.isLandscape) {
+                MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();
 
-            int navBarHeight = 84; /* replace with mInset.height() in dragLayer */
-            DeviceProfile grid = mLauncher.getDeviceProfile();
-            int height = navBarHeight + grid.hotseatCellHeightPx;
+                int navBarHeight = mLauncher.getDragLayer().getInsets().top;
+                int height = navBarHeight + grid.hotseatCellHeightPx;
 
-            mlp.topMargin = height;
-            mAppsRecyclerView.setLayoutParams(mlp);
+                mlp.topMargin = height;
+                mAppsRecyclerView.setLayoutParams(mlp);
 
-            LinearLayout.LayoutParams llp =
-                    (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
-            llp.topMargin = navBarHeight;
-            mSearchInput.setLayoutParams(llp);
+                LinearLayout.LayoutParams llp =
+                        (LinearLayout.LayoutParams) mSearchInput.getLayoutParams();
+                llp.topMargin = navBarHeight;
+                mSearchInput.setLayoutParams(llp);
 
-            lp.height = height;
-            mSearchContainer.setBackground(null);
+                lp.height = height;
+            }
+            mSearchContainer.getBackground().setAlpha(0);
         }
         mSearchContainer.setLayoutParams(lp);
     }
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 7f047d5..c443b1e 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -8,10 +8,13 @@
 import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.animation.AccelerateDecelerateInterpolator;
 import android.view.animation.AccelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
 import android.view.animation.Interpolator;
 
 import com.android.launcher3.CellLayout;
+import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Hotseat;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherAnimUtils;
@@ -34,16 +37,21 @@
     private static final String TAG = "AllAppsTrans";
     private static final boolean DBG = false;
 
-     private final Interpolator mAccelInterpolator = new AccelerateInterpolator(1f);
+    private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
+    private final Interpolator mDecelInterpolator = new DecelerateInterpolator(1f);
+    private final Interpolator mAccelDecelInterpolator = new AccelerateDecelerateInterpolator();
 
     private static final float ANIMATION_DURATION = 2000;
-    private static final float FINAL_ALPHA = .65f;
+    public static final float ALL_APPS_FINAL_ALPHA = .8f;
+
+    private static final float PARALLAX_COEFFICIENT = .125f;
 
     private AllAppsContainerView mAppsView;
     private Workspace mWorkspace;
     private Hotseat mHotseat;
     private Drawable mHotseatBackground;
     private float mHotseatAlpha;
+    private float mStatusBarHeight;
 
     private final Launcher mLauncher;
     private final VerticalPullDetector mDetector;
@@ -56,12 +64,21 @@
 
     private static final float RECATCH_REJECTION_FRACTION = .0875f;
 
+    // Used in landscape.
+    private static final float BAZEL_PULL_UP_HEIGHT = 60;
+
     private long mAnimationDuration;
     private float mCurY;
 
     private AnimatorSet mCurrentAnimation;
     private boolean mNoIntercept;
 
+    private boolean mLightStatusBar;
+
+    // At the end of scroll settling, this class also sets the state of the launcher.
+    // If it's already set,do not call the #mLauncher.setXXX method.
+    private boolean mStateAlreadyChanged;
+
     public AllAppsTransitionController(Launcher launcher) {
         mLauncher = launcher;
         mDetector = new VerticalPullDetector(launcher);
@@ -78,6 +95,8 @@
             } else if (mLauncher.isAllAppsVisible() &&
                     !mAppsView.shouldContainerScroll(ev.getX(), ev.getY())) {
                 mNoIntercept = true;
+            } else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) {
+                mNoIntercept = true;
             } else {
                 mDetector.setDetectableScrollConditions(mLauncher.isAllAppsVisible() /* down */,
                         isInDisallowRecatchTopZone(), isInDisallowRecatchBottomZone());
@@ -90,6 +109,22 @@
         return mDetector.shouldIntercept();
     }
 
+    private boolean shouldPossiblyIntercept(MotionEvent ev) {
+        DeviceProfile grid = mLauncher.getDeviceProfile();
+        if (mDetector.isRestingState()) {
+            if (mLauncher.getDragLayer().isEventOverHotseat(ev) && !grid.isLandscape) {
+                return true;
+            }
+            if (ev.getY() > mLauncher.getDeviceProfile().heightPx - BAZEL_PULL_UP_HEIGHT &&
+                    grid.isLandscape) {
+                return true;
+            }
+            return false;
+        } else {
+            return true;
+        }
+    }
+
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
         return mDetector.onTouchEvent(ev);
@@ -111,6 +146,7 @@
         mHotseat = mLauncher.getHotseat();
         mWorkspace = mLauncher.getWorkspace();
 
+        mStatusBarHeight = mLauncher.getDragLayer().getInsets().height();
         if (mHotseatBackground == null) {
             mHotseatBackground = mHotseat.getBackground();
             mHotseatAlpha = mHotseatBackground.getAlpha() / 255f;
@@ -119,6 +155,7 @@
 
     @Override
     public void onScrollStart(boolean start) {
+        init();
         cancelAnimation();
         mCurrentAnimation = LauncherAnimUtils.createAnimatorSet();
         preparePull(start);
@@ -133,18 +170,21 @@
         mHotseat.bringToFront();
         if (start) {
             if (!mLauncher.isAllAppsVisible()) {
+                mLauncher.tryAndUpdatePredictedApps();
                 mHotseat.setBackground(null);
                 mAppsView.setVisibility(View.VISIBLE);
                 mAppsView.getContentView().setVisibility(View.VISIBLE);
                 mAppsView.getContentView().setBackground(null);
                 mAppsView.getRevealView().setVisibility(View.VISIBLE);
                 mAppsView.getRevealView().setAlpha(mHotseatAlpha);
-                mAppsView.setSearchBarVisible(false);
 
-                if (mTranslation < 0) {
+                DeviceProfile grid= mLauncher.getDeviceProfile();
+                if (!grid.isLandscape) {
                     mTranslation = mHotseat.getTop();
-                    setProgress(mTranslation);
+                } else {
+                    mTranslation = mHotseat.getBottom();
                 }
+                setProgress(mTranslation);
             } else {
                 // TODO: get rid of this workaround to override state change by workspace transition
                 mWorkspace.onLauncherTransitionPrepare(mLauncher, false, false);
@@ -152,14 +192,16 @@
                         .getShortcutsAndWidgets();
                 child.setVisibility(View.VISIBLE);
                 child.setAlpha(1f);
-
-                mAppsView.setSearchBarVisible(false);
-                setLightStatusBar(false);
             }
         }
     }
 
-    private void setLightStatusBar(boolean enable) {
+    private void updateLightStatusBar(float progress) {
+        boolean enable = (progress < mStatusBarHeight / 2);
+        // Already set correctly
+        if (mLightStatusBar == enable) {
+            return;
+        }
         int systemUiFlags = mLauncher.getWindow().getDecorView().getSystemUiVisibility();
         if (enable) {
             mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags
@@ -170,6 +212,7 @@
                     & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
 
         }
+        mLightStatusBar = enable;
     }
 
     @Override
@@ -187,17 +230,20 @@
      * @param progress y value of the border between hotseat and all apps
      */
     public void setProgress(float progress) {
+        updateLightStatusBar(progress);
         mProgressTransY = progress;
         float alpha = calcAlphaAllApps(progress);
         float workspaceHotseatAlpha = 1 - alpha;
 
-        mAppsView.getRevealView().setAlpha(Math.min(FINAL_ALPHA, Math.max(mHotseatAlpha, alpha)));
+        mAppsView.getRevealView().setAlpha(Math.min(ALL_APPS_FINAL_ALPHA, Math.max(mHotseatAlpha,
+                mDecelInterpolator.getInterpolation(alpha))));
         mAppsView.getContentView().setAlpha(alpha);
         mAppsView.setTranslationY(progress);
-        mWorkspace.setWorkspaceTranslation(View.TRANSLATION_Y, -mTranslation + progress,
+        mWorkspace.setWorkspaceTranslation(View.TRANSLATION_Y,
+                PARALLAX_COEFFICIENT *(-mTranslation + progress),
                 mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
-        mWorkspace.setHotseatTranslation(
-                View.TRANSLATION_Y, -mTranslation + progress, workspaceHotseatAlpha);
+        mWorkspace.setHotseatTranslation(View.TRANSLATION_Y, -mTranslation + progress,
+                mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
     }
 
     public float getProgress() {
@@ -217,26 +263,27 @@
         if (fling) {
             if (velocity < 0) {
                 calculateDuration(velocity, mAppsView.getTranslationY());
-                showAppsView(); // Flinging in UP direction
+                animateToAllApps(mCurrentAnimation, mAnimationDuration);
             } else {
                 calculateDuration(velocity, Math.abs(mTranslation - mAppsView.getTranslationY()));
-                showWorkspace(); // Flinging in DOWN direction
+                animateToWorkspace(mCurrentAnimation, mAnimationDuration);
             }
             // snap to top or bottom using the release velocity
         } else {
             if (mAppsView.getTranslationY() > mTranslation / 2) {
                 calculateDuration(velocity, Math.abs(mTranslation - mAppsView.getTranslationY()));
-                showWorkspace(); // Released in the bottom half
+                animateToWorkspace(mCurrentAnimation, mAnimationDuration);
             } else {
                 calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
-                showAppsView(); // Released in the top half
+                animateToAllApps(mCurrentAnimation, mAnimationDuration);
             }
         }
+        mCurrentAnimation.start();
     }
 
     private void calculateDuration(float velocity, float disp) {
         // TODO: make these values constants after tuning.
-        float velocityDivisor = Math.max(1.5f, Math.abs(0.25f * velocity));
+        float velocityDivisor = Math.max(1.5f, Math.abs(0.5f * velocity));
         float travelDistance = Math.max(0.2f, disp / mTranslation);
         mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
         if (DBG) {
@@ -244,35 +291,6 @@
         }
     }
 
-    /**
-     * Depending on the current state of the launcher, either just
-     * 1) animate
-     * 2) animate and do all the state updates.
-     */
-    private void showAppsView() {
-        if (mLauncher.isAllAppsVisible()) {
-            animateToAllApps(mCurrentAnimation, mAnimationDuration);
-            mCurrentAnimation.start();
-        } else {
-            mLauncher.showAppsView(true /* animated */, true /* resetListToTop */,
-                    true /* updatePredictedApps */, false /* focusSearchBar */);
-        }
-    }
-
-    /**
-     * Depending on the current state of the launcher, either just
-     * 1) animate
-     * 2) animate and do all the state updates.
-     */
-    private void showWorkspace() {
-        if (mLauncher.isAllAppsVisible()) {
-            mLauncher.showWorkspace(true /* animated */);
-        } else {
-            animateToWorkspace(mCurrentAnimation, mAnimationDuration);
-            mCurrentAnimation.start();
-        }
-    }
-
     public void animateToAllApps(AnimatorSet animationOut, long duration) {
         if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
             return;
@@ -280,6 +298,7 @@
         if (mDetector.isRestingState()) {
             preparePull(true);
             mAnimationDuration = duration;
+            mStateAlreadyChanged = true;
         }
         mCurY = mAppsView.getTranslationY();
         final float fromAllAppsTop = mAppsView.getTranslationY();
@@ -310,13 +329,6 @@
         mCurrentAnimation = animationOut;
     }
 
-    private void finishPullUp() {
-        mAppsView.setSearchBarVisible(true);
-        mHotseat.setVisibility(View.INVISIBLE);
-        setProgress(0f);
-        setLightStatusBar(true);
-    }
-
     public void animateToWorkspace(AnimatorSet animationOut, long duration) {
         if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
             return;
@@ -324,6 +336,7 @@
         if(mDetector.isRestingState()) {
             preparePull(true);
             mAnimationDuration = duration;
+            mStateAlreadyChanged = true;
         }
         final float fromAllAppsTop = mAppsView.getTranslationY();
         final float toAllAppsTop = mTranslation;
@@ -354,12 +367,28 @@
         mCurrentAnimation = animationOut;
     }
 
+    private void finishPullUp() {
+        mHotseat.setVisibility(View.INVISIBLE);
+        setProgress(0f);
+        if (!mStateAlreadyChanged) {
+            mLauncher.showAppsView(false /* animated */, true /* resetListToTop */,
+                    false /* updatePredictedApps */, false /* focusSearchBar */);
+        }
+        mStateAlreadyChanged = false;
+    }
+
     public void finishPullDown() {
+        if (mHotseat.getBackground() != null) {
+            return;
+        }
         mAppsView.setVisibility(View.INVISIBLE);
         mHotseat.setBackground(mHotseatBackground);
         mHotseat.setVisibility(View.VISIBLE);
         setProgress(mTranslation);
-        setLightStatusBar(false);
+        if (!mStateAlreadyChanged) {
+            mLauncher.showWorkspace(false);
+        }
+        mStateAlreadyChanged = false;
     }
 
     private void cancelAnimation() {
diff --git a/src/com/android/launcher3/allapps/VerticalPullDetector.java b/src/com/android/launcher3/allapps/VerticalPullDetector.java
index 7df63e0..9304aac 100644
--- a/src/com/android/launcher3/allapps/VerticalPullDetector.java
+++ b/src/com/android/launcher3/allapps/VerticalPullDetector.java
@@ -135,7 +135,7 @@
                 mDisplacementY = ev.getY() - mDownY;
                 mVelocity = computeVelocity(ev, mVelocity);
 
-                if (mState == State.SCROLLING && shouldRecatchScrollStart()){
+                if (mState == State.SCROLLING && Math.abs(mDisplacementY) > mTouchSlop ){
                     setState(State.DRAG);
                     reportScrollStart(true /* recatch */);
                 }
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 5d212d8..c62353d 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -187,6 +187,11 @@
         removeView(mOverlayView);
     }
 
+    public boolean isEventOverHotseat(MotionEvent ev) {
+        getDescendantRectRelativeToSelf(mLauncher.getHotseat(), mHitRect);
+        return mHitRect.contains((int) ev.getX(), (int) ev.getY());
+    }
+
     private boolean isEventOverFolderTextRegion(Folder folder, MotionEvent ev) {
         getDescendantRectRelativeToSelf(folder.getEditTextRegion(), mHitRect);
         return mHitRect.contains((int) ev.getX(), (int) ev.getY());