From dcc26fc69362c8b7a29dab75fc5df767d6edbf31 Mon Sep 17 00:00:00 2001 From: Mario Bertschler Date: Wed, 21 Dec 2016 11:48:48 -0800 Subject: [PATCH] Fixes a bug where the user ends in freescroll state even for regular workspace mode. The bug happened while reordering pages in overview mode and clicking the back button. The fix is to check the precodition in enableFreeScroll if we are in a valid state for enabling freescroll (currently only overview mode). Bug: 33347786 Change-Id: Icc3005fd431569e2b9e3f52d2249de8ba8d13eab --- src/com/android/launcher3/PagedView.java | 22 ++++++++++------------ src/com/android/launcher3/Workspace.java | 10 ++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index ee7f9f805c..3180f27225 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1372,8 +1372,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc dampedOverScroll(amount); } - public void enableFreeScroll() { + /** + * return true if freescroll has been enabled, false otherwise + */ + public boolean enableFreeScroll() { setEnableFreeScroll(true); + return true; } public void disableFreeScroll() { @@ -2074,20 +2078,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc 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 43a1a2252a..8280ea5aac 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -4115,6 +4115,16 @@ public class Workspace extends PagedView } } + @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.