Merge "Always draw the background color in the task views" into ub-launcher3-edmonton
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 82e64ab..079e256 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -130,10 +130,12 @@
             "STATE_QUICK_SCRUB_END"
     };
 
-    private static final long MAX_SWIPE_DURATION = 200;
+    private static final long MAX_SWIPE_DURATION = 350;
     private static final long MIN_SWIPE_DURATION = 80;
 
     private static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
+    private static final float SWIPE_DURATION_MULTIPLIER =
+            Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
 
     private final ClipAnimationHelper mClipAnimationHelper = new ClipAnimationHelper();
 
@@ -559,12 +561,15 @@
     public void onGestureEnded(float endVelocity) {
         Resources res = mContext.getResources();
         float flingThreshold = res.getDimension(R.dimen.quickstep_fling_threshold_velocity);
-        boolean isFling = Math.abs(endVelocity) > flingThreshold;
+        boolean isFling = mGestureStarted && Math.abs(endVelocity) > flingThreshold;
 
         long duration = MAX_SWIPE_DURATION;
         final float endShift;
         if (!isFling) {
-            endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW ? 1 : 0;
+            endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted ? 1 : 0;
+            long expectedDuration = Math.abs(Math.round((endShift - mCurrentShift.value)
+                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
+            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
             mLogAction = Touch.SWIPE;
         } else {
             endShift = endVelocity < 0 ? 1 : 0;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
index cd4a6ff..fe668c6 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
@@ -1,5 +1,7 @@
 package com.android.quickstep.views;
 
+import static com.android.quickstep.views.RecentsView.DEBUG_SHOW_CLEAR_ALL_BUTTON;
+
 import android.content.Context;
 import android.graphics.Rect;
 import android.util.AttributeSet;
@@ -50,6 +52,8 @@
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
         super.onLayout(changed, left, top, right, bottom);
 
+        if (!changed || !DEBUG_SHOW_CLEAR_ALL_BUTTON) return;
+
         mRecentsView.getTaskSize(mTempRect);
 
         mClearAllButton.setTranslationX(
@@ -57,7 +61,7 @@
                         R.dimen.clear_all_container_width)) / 2);
         mClearAllButton.setTranslationY(
                 mTempRect.top + (mTempRect.height() - mClearAllButton.getMeasuredHeight()) / 2
-                        - mClearAllButton.getY());
+                        - mClearAllButton.getTop());
     }
 
     @Override