Merge "Fixes a bug where the user ends in freescroll state even for regular workspace mode." into ub-launcher3-master
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 7ce33c6..7aed155 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1370,8 +1370,12 @@
         dampedOverScroll(amount);
     }
 
-    public void enableFreeScroll() {
+    /**
+     * return true if freescroll has been enabled, false otherwise
+     */
+    public boolean enableFreeScroll() {
         setEnableFreeScroll(true);
+        return true;
     }
 
     public void disableFreeScroll() {
@@ -2072,20 +2076,14 @@
         if (!mReorderingStarted) return;
         mReorderingStarted = false;
 
-        // If we haven't flung-to-delete the current child, then we just animate the drag view
-        // back into position
-        final Runnable onCompleteRunnable = new Runnable() {
-            @Override
-            public void run() {
-                onEndReordering();
-            }
-        };
-
         mPostReorderingPreZoomInRunnable = new Runnable() {
             public void run() {
-                onCompleteRunnable.run();
+                // If we haven't flung-to-delete the current child,
+                // then we just animate the drag view back into position
+                onEndReordering();
+
                 enableFreeScroll();
-            };
+            }
         };
 
         mPostReorderingPreZoomInRemainingAnimationCount =
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index bf774e6..fccff6c 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -4103,6 +4103,16 @@
         }
     }
 
+    @Override
+    public boolean enableFreeScroll() {
+        if (getState() == State.OVERVIEW) {
+            return super.enableFreeScroll();
+        } else {
+            Log.w(TAG, "enableFreeScroll called but not in overview: state=" + getState());
+            return false;
+        }
+    }
+
     /**
      * Used as a workaround to ensure that the AppWidgetService receives the
      * PACKAGE_ADDED broadcast before updating widgets.