Merge "Swipe from nav bar to enter overview in landscape" into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index 7077185..43a01a7 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -328,5 +328,9 @@
 
     private void onAnimationToLauncherComplete() {
         mDragView.close(false);
+        View currentRecentsPage = mRecentsView.getPageAt(mRecentsView.getCurrentPage());
+        if (currentRecentsPage instanceof TaskView) {
+            ((TaskView) currentRecentsPage).animateIconToScale(1f);
+        }
     }
 }
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index a107343..fd9010d 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -146,6 +146,9 @@
     public void update(RecentsTaskLoadPlan loadPlan) {
         final RecentsTaskLoader loader = TouchInteractionService.getRecentsTaskLoader();
         setCurrentPage(0);
+        if (getPageAt(mCurrentPage) instanceof TaskView) {
+            ((TaskView) getPageAt(mCurrentPage)).setIconScale(0);
+        }
         TaskStack stack = loadPlan != null ? loadPlan.getTaskStack() : null;
         if (stack == null) {
             removeAllViews();
diff --git a/quickstep/src/com/android/quickstep/TaskView.java b/quickstep/src/com/android/quickstep/TaskView.java
index a0ad618..d834881 100644
--- a/quickstep/src/com/android/quickstep/TaskView.java
+++ b/quickstep/src/com/android/quickstep/TaskView.java
@@ -59,6 +59,8 @@
      */
     private static final float SWIPE_DISTANCE_HEIGHT_PERCENTAGE = 0.38f;
 
+    private static final long SCALE_ICON_DURATION = 120;
+
     private static final Property<TaskView, Float> PROPERTY_SWIPE_PROGRESS =
             new Property<TaskView, Float>(Float.class, "swipe_progress") {
 
@@ -73,6 +75,19 @@
                 }
             };
 
+    private static final Property<TaskView, Float> SCALE_ICON_PROPERTY =
+            new Property<TaskView, Float>(Float.TYPE, "scale_icon") {
+                @Override
+                public Float get(TaskView taskView) {
+                    return taskView.mIconScale;
+                }
+
+                @Override
+                public void set(TaskView taskView, Float iconScale) {
+                    taskView.setIconScale(iconScale);
+                }
+            };
+
     private Task mTask;
     private TaskThumbnailView mSnapshotView;
     private ImageView mIconView;
@@ -81,6 +96,7 @@
     private float mSwipeProgress;
     private Interpolator mAlphaInterpolator;
     private Interpolator mSwipeAnimInterpolator;
+    private float mIconScale = 1f;
 
     public TaskView(Context context) {
         this(context, null);
@@ -259,4 +275,17 @@
         swipeAnimator.setInterpolator(mSwipeAnimInterpolator);
         swipeAnimator.start();
     }
+
+    public void animateIconToScale(float scale) {
+        ObjectAnimator.ofFloat(this, SCALE_ICON_PROPERTY, scale)
+                .setDuration(SCALE_ICON_DURATION).start();
+    }
+
+    protected void setIconScale(float iconScale) {
+        mIconScale = iconScale;
+        if (mIconView != null) {
+            mIconView.setScaleX(mIconScale);
+            mIconView.setScaleY(mIconScale);
+        }
+    }
 }
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 7b89c5c..b98d852 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -495,6 +495,7 @@
             public void onPageSelected(int pos) {
                 tabs.updateTabTextColor(pos);
                 mHeader.setMainActive(pos == 0);
+                reset();
                 applyTouchDelegate();
                 if (mAH[pos].recyclerView != null) {
                     mAH[pos].recyclerView.bindFastScrollbar();
@@ -674,8 +675,9 @@
                 recyclerView.setPadding(padding.left, paddingTop, padding.right, padding.bottom);
             }
             if (isHeaderVisible()) {
-                mHeader.getPredictionRow()
-                        .setPadding(padding.left, 0 , padding.right, 0);
+                PredictionRowView prv = mHeader.getPredictionRow();
+                prv.setPadding(padding.left, prv.getPaddingTop() , padding.right,
+                        prv.getPaddingBottom());
             }
         }
 
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index dc3afb5..409985c 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -107,6 +107,7 @@
         mWorkRV = setupRV(mWorkRV, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView);
         mParent = (ViewGroup) mMainRV.getParent();
         setMainActive(true);
+        reset();
         setupDivider();
     }
 
@@ -130,8 +131,6 @@
 
     public void setMainActive(boolean active) {
         mCurrentRV = active ? mMainRV : mWorkRV;
-        mSnappedScrolledY = mCurrentRV.getCurrentScrollY() - mMaxTranslation;
-        setExpanded(true);
     }
 
     public PredictionRowView getPredictionRow() {
@@ -142,10 +141,6 @@
         return mDivider;
     }
 
-    public void reset() {
-        setExpanded(true);
-    }
-
     private boolean canSnapAt(int currentScrollY) {
         return Math.abs(currentScrollY) <= mPredictionRow.getHeight();
     }
@@ -194,16 +189,14 @@
         }
     }
 
-    private void setExpanded(boolean expand) {
-        int translateTo = expand ? 0 : -mMaxTranslation;
+    public void reset() {
+        int translateTo = 0;
         mAnimator.setIntValues(mTranslationY, translateTo);
         mAnimator.addUpdateListener(this);
         mAnimator.setDuration(150);
         mAnimator.start();
-        mHeaderCollapsed = !expand;
-        mSnappedScrolledY = expand
-                ? mCurrentRV.getCurrentScrollY() - mMaxTranslation
-                : mCurrentRV.getCurrentScrollY();
+        mHeaderCollapsed = false;
+        mSnappedScrolledY = -mMaxTranslation;
     }
 
     public boolean isExpanded() {