Merge "Let TaskbarDragView scale up before switching to system drag view" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index 67ebc02..b89032e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -117,6 +117,24 @@
         dragLayerY += dragRect.top;
 
         DragOptions dragOptions = new DragOptions();
+        dragOptions.preDragCondition = new DragOptions.PreDragCondition() {
+            private DragView mDragView;
+
+            @Override
+            public boolean shouldStartDrag(double distanceDragged) {
+                return mDragView != null && mDragView.isAnimationFinished();
+            }
+
+            @Override
+            public void onPreDragStart(DropTarget.DragObject dragObject) {
+                mDragView = dragObject.dragView;
+            }
+
+            @Override
+            public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
+                mDragView = null;
+            }
+        };
         // TODO: open popup/pre-drag
         // PopupContainerWithArrow popupContainer = PopupContainerWithArrow.showForIcon(view);
         // if (popupContainer != null) {
@@ -155,6 +173,7 @@
 
         mDragObject = new DropTarget.DragObject(mActivity.getApplicationContext());
         mDragObject.originalView = originalView;
+        mDragObject.deferDragViewCleanupPostAnimation = false;
 
         mIsInPreDrag = mOptions.preDragCondition != null
                 && !mOptions.preDragCondition.shouldStartDrag(0);
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index f2ab96c..b9c9b32 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -23,6 +23,8 @@
 import static com.android.launcher3.Utilities.getBadge;
 import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
@@ -94,6 +96,8 @@
     private boolean mHasDrawn = false;
 
     final ValueAnimator mAnim;
+    // Whether mAnim has started. Unlike mAnim.isStarted(), this is true even after mAnim ends.
+    private boolean mAnimStarted;
 
     private int mLastTouchX;
     private int mLastTouchY;
@@ -171,6 +175,12 @@
                 animation.cancel();
             }
         });
+        mAnim.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+                mAnimStarted = true;
+            }
+        });
 
         setDragRegion(new Rect(0, 0, width, height));
 
@@ -396,6 +406,10 @@
         }
     }
 
+    public boolean isAnimationFinished() {
+        return mAnimStarted && !mAnim.isRunning();
+    }
+
     /**
      * Move the window containing this view.
      *