Merge "AssistContentRequester move binder call to background thread." into sc-dev
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index c85d3dc..60eeaff 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -45,8 +45,9 @@
 
     <!-- These speeds are in dp/s -->
     <dimen name="max_task_dismiss_drag_velocity">2.25dp</dimen>
-    <dimen name="default_task_dismiss_drag_velocity">1.75dp</dimen>
-    <dimen name="default_task_dismiss_drag_velocity_grid">0.75dp</dimen>
+    <dimen name="default_task_dismiss_drag_velocity">1.5dp</dimen>
+    <dimen name="default_task_dismiss_drag_velocity_grid">1dp</dimen>
+    <dimen name="default_task_dismiss_drag_velocity_grid_focus_task">5dp</dimen>
 
     <dimen name="recents_page_spacing">16dp</dimen>
     <dimen name="recents_clear_all_deadzone_vertical_margin">70dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index c6ea953..180af0b 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -21,6 +21,7 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
+import android.os.SystemClock;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.animation.Interpolator;
@@ -72,6 +73,7 @@
     private float mProgressMultiplier;
     private float mEndDisplacement;
     private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck();
+    private Float mOverrideVelocity = null;
 
     private TaskView mTaskBeingDragged;
 
@@ -268,6 +270,7 @@
             mCurrentAnimation.pause();
         }
         mFlingBlockCheck.unblockFling();
+        mOverrideVelocity = null;
     }
 
     @Override
@@ -283,19 +286,36 @@
             mFlingBlockCheck.onEvent();
         }
 
-        // Once halfway through task dismissal interpolation, switch from reversible dragging-task
-        // animation to playing the remaining task translation animations
-        if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
-            // Halve the value as we are animating the drag across the full length for only the
-            // first half of the progress
-            mCurrentAnimation.setPlayFraction(
-                    Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1));
+        if (isGoingUp) {
+            if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
+                // Halve the value when dismissing, as we are animating the drag across the full
+                // length for only the first half of the progress
+                mCurrentAnimation.setPlayFraction(
+                        Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1));
+            } else {
+                // Set mOverrideVelocity to control task dismiss velocity in onDragEnd
+                int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
+                if (mRecentsView.showAsGrid()) {
+                    if (mTaskBeingDragged.isFocusedTask()) {
+                        velocityDimenId =
+                                R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
+                    } else {
+                        velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid;
+                    }
+                }
+                mOverrideVelocity = -mTaskBeingDragged.getResources().getDimension(velocityDimenId);
+
+                // Once halfway through task dismissal interpolation, switch from reversible
+                // dragging-task animation to playing the remaining task translation animations
+                final long now = SystemClock.uptimeMillis();
+                MotionEvent upAction = MotionEvent.obtain(now, now,
+                        MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
+                mDetector.onTouchEvent(upAction);
+                upAction.recycle();
+            }
         } else {
-            float dragVelocity = -mTaskBeingDragged.getResources().getDimension(
-                    mRecentsView.showAsGrid() ? R.dimen.default_task_dismiss_drag_velocity_grid
-                            : R.dimen.default_task_dismiss_drag_velocity);
-            onDragEnd(dragVelocity);
-            return true;
+            mCurrentAnimation.setPlayFraction(
+                    Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
         }
 
         return true;
@@ -303,6 +323,10 @@
 
     @Override
     public void onDragEnd(float velocity) {
+        if (mOverrideVelocity != null) {
+            velocity = mOverrideVelocity;
+            mOverrideVelocity = null;
+        }
         // Limit velocity, as very large scalar values make animations play too quickly
         float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension(
                 R.dimen.max_task_dismiss_drag_velocity);