OSDN Git Service

Lower the transition threshold for dropping on Workspace.
authorTony Wickham <twickham@google.com>
Sat, 3 Dec 2016 02:54:32 +0000 (18:54 -0800)
committerTony Wickham <twickham@google.com>
Mon, 12 Dec 2016 21:56:36 +0000 (13:56 -0800)
Old threshold: 0.5f
New threshold: 0.25f

The threshold is used when dragging to Workspace from any
drag source other than Workspace, including Hotseat. This
lowered threshold is more forgiving for faster drags.

Bug: 33210055
Change-Id: Ic121fb4b7caa3ea66abb48a8a3f3bd36f3365749

src/com/android/launcher3/Workspace.java

index 10680b4..2d4af52 100644 (file)
@@ -100,6 +100,14 @@ public class Workspace extends PagedView
         Insettable, DropTargetSource {
     private static final String TAG = "Launcher.Workspace";
 
+    /** The value that {@link #mTransitionProgress} must be greater than for
+     * {@link #transitionStateShouldAllowDrop()} to return true. */
+    private static final float ALLOW_DROP_TRANSITION_PROGRESS = 0.25f;
+
+    /** The value that {@link #mTransitionProgress} must be greater than for
+     * {@link #isFinishedSwitchingState()} ()} to return true. */
+    private static final float FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS = 0.5f;
+
     private static boolean ENFORCE_DRAG_EVENT_ORDER = false;
 
     private static final int SNAP_OFF_EMPTY_SCREEN_DURATION = 400;
@@ -1171,7 +1179,8 @@ public class Workspace extends PagedView
     /** This differs from isSwitchingState in that we take into account how far the transition
      *  has completed. */
     public boolean isFinishedSwitchingState() {
-        return !mIsSwitchingState || (mTransitionProgress > 0.5f);
+        return !mIsSwitchingState
+                || (mTransitionProgress > FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS);
     }
 
     protected void onWindowVisibilityChanged (int visibility) {
@@ -2273,8 +2282,8 @@ public class Workspace extends PagedView
         return dv;
     }
 
-    public boolean transitionStateShouldAllowDrop() {
-        return ((!isSwitchingState() || mTransitionProgress > 0.5f) &&
+    private boolean transitionStateShouldAllowDrop() {
+        return ((!isSwitchingState() || mTransitionProgress > ALLOW_DROP_TRANSITION_PROGRESS) &&
                 (mState == State.NORMAL || mState == State.SPRING_LOADED));
     }