Adding ability to add to hotseat from spring loaded mode (5064141).

- Fixing regression where folder items had no text in tablet ui and assets
- Fixing spring loaded frame sizing (5067335)
- Making the cells 80x80 for testing again on the phone ui (5085986)

Change-Id: I52a0f5eaf2dcf4adaf57c5a71da3903892c490a8
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index c2d1341..b6bc5dc 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -183,7 +183,9 @@
                     anim.addListener(new AnimatorListenerAdapter() {
                         @Override
                         public void onAnimationEnd(android.animation.Animator animation) {
-                            mAppsCustomizePane.flashScrollingIndicator();
+                            if (!LauncherApplication.isScreenLarge()) {
+                                mAppsCustomizePane.flashScrollingIndicator();
+                            }
                         }
                     });
                     anim.start();
@@ -250,7 +252,7 @@
             setLayerType(LAYER_TYPE_NONE, null);
         }
 
-        if (!toWorkspace) {
+        if (!toWorkspace && !LauncherApplication.isScreenLarge()) {
             mAppsCustomizePane.flashScrollingIndicator();
         }
     }
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 518c79f..9440b89 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -906,11 +906,6 @@
             int vFreeSpace = vSpace - (mCountY * mOriginalCellHeight);
             mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
             mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
-            int remainingHSpace = hFreeSpace - (numWidthGaps * mWidthGap);
-            int remainingVSpace = vFreeSpace - (numHeightGaps * mHeightGap);
-            mCellWidth = mOriginalCellWidth + remainingHSpace / mCountX;
-            mCellHeight = mOriginalCellHeight + remainingVSpace / mCountY;
-
             mChildren.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
         } else {
             mWidthGap = mOriginalWidthGap;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index cd62ee1..400c881 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2040,6 +2040,7 @@
 
         // Shrink workspaces away if going to AppsCustomize from workspace
         mWorkspace.shrink(Workspace.State.SMALL, animated);
+        hideHotseat(animated);
 
         if (animated) {
             final ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
@@ -2141,6 +2142,7 @@
         if (!springLoaded) {
             mWorkspace.unshrink(animated);
         }
+        showHotseat(animated);
         if (animated) {
             if (mStateAnimation != null) mStateAnimation.cancel();
             mStateAnimation = new AnimatorSet();
@@ -2297,7 +2299,6 @@
 
         // Hide the search bar and hotseat
         mSearchDeleteBar.hideSearchBar(animated);
-        hideHotseat(animated);
 
         // Change the state *after* we've called all the transition code
         mState = State.APPS_CUSTOMIZE;
@@ -2357,7 +2358,6 @@
 
             // Show the search bar and hotseat
             mSearchDeleteBar.showSearchBar(animated);
-            showHotseat(animated);
 
             // Set focus to the AppsCustomize button
             if (mAllAppsButton != null) {
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 94163ac..9b24587 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -19,6 +19,7 @@
 import android.app.Application;
 import android.app.SearchManager;
 import android.content.ContentResolver;
+import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Configuration;
@@ -116,6 +117,11 @@
         return sIsScreenLarge;
     }
 
+    public static boolean isScreenLandscape(Context context) {
+        return context.getResources().getConfiguration().orientation ==
+            Configuration.ORIENTATION_LANDSCAPE;
+    }
+
     public static float getScreenDensity() {
         return sScreenDensity;
     }
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 292ccd7..48360fe 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -578,9 +578,9 @@
     protected void updateAdjacentPagesAlpha() {
         if (mFadeInAdjacentScreens) {
             if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) {
-                int screenWidth = getMeasuredWidth();
+                int screenWidth = getMeasuredWidth() - mPaddingLeft - mPaddingRight;
                 int halfScreenSize = screenWidth / 2;
-                int screenCenter = mScrollX + halfScreenSize;
+                int screenCenter = mScrollX + halfScreenSize + mPaddingLeft;
                 final int childCount = getChildCount();
                 for (int i = 0; i < childCount; ++i) {
                     View layout = (View) getChildAt(i);
@@ -1265,11 +1265,13 @@
     }
 
     protected int getRelativeChildOffset(int index) {
-        return (getMeasuredWidth() - getChildWidth(index)) / 2;
+        int padding = mPaddingLeft + mPaddingRight;
+        return mPaddingLeft + (getMeasuredWidth() - padding - getChildWidth(index)) / 2;
     }
-
     protected int getScaledRelativeChildOffset(int index) {
-        return (getMeasuredWidth() - getScaledMeasuredWidth(getChildAt(index))) / 2;
+        int padding = mPaddingLeft + mPaddingRight;
+        return mPaddingLeft + (getMeasuredWidth() - padding -
+                getScaledMeasuredWidth(getChildAt(index))) / 2;
     }
 
     protected int getChildOffset(int index) {
@@ -1762,7 +1764,7 @@
 
         int numPages = getChildCount();
         int pageWidth = getMeasuredWidth();
-        int maxPageWidth = (numPages * getMeasuredWidth()) + ((numPages - 1) * mPageSpacing);
+        int maxPageWidth = (numPages * getChildWidth(0)) + ((numPages - 1) * mPageSpacing);
         int trackWidth = pageWidth - mScrollIndicatorPaddingLeft - mScrollIndicatorPaddingRight;
         int indicatorWidth = mScrollIndicator.getMeasuredWidth() -
                 mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 10b218a..ecc5483 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -261,7 +261,10 @@
         setDataIsReady();
 
         if (!LauncherApplication.isScreenLarge()) {
-            mFadeInAdjacentScreens = false;
+            mCenterPagesVertically = false;
+            if (!LauncherApplication.isScreenLandscape(context)) {
+                mFadeInAdjacentScreens = false;
+            }
         }
 
         mWallpaperManager = WallpaperManager.getInstance(context);
@@ -1335,7 +1338,7 @@
     }
 
     // we use this to shrink the workspace for the all apps view and the customize view
-    public void shrink(State shrinkState, boolean animated) {
+    public void shrink(final State shrinkState, boolean animated) {
         if (mFirstLayout) {
             // (mFirstLayout == "first layout has not happened yet")
             // if we get a call to shrink() as part of our initialization (for example, if
@@ -1527,6 +1530,14 @@
                         cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
                         cl.setFastRotationY(a * mOldRotationYs[i] + b * mNewRotationYs[i]);
                     }
+
+                    // Shrink the hotset the same amount we are shrinking the screens
+                    if (shrinkState == State.SPRING_LOADED && mLauncher.getHotseat() != null) {
+                        View hotseat = mLauncher.getHotseat().getLayout();
+                        hotseat.fastInvalidate();
+                        hotseat.setFastScaleX(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+                        hotseat.setFastScaleY(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+                    }
                 }
             });
             mAnimator.playTogether(animWithInterpolator);
@@ -1705,7 +1716,7 @@
         mNewRotationYs = new float[childCount];
     }
 
-    void unshrink(boolean animated, boolean springLoaded) {
+    void unshrink(boolean animated, final boolean springLoaded) {
         if (mFirstLayout) {
             // (mFirstLayout == "first layout has not happened yet")
             // cancel any pending shrinks that were set earlier
@@ -1742,18 +1753,22 @@
                 final CellLayout cl = (CellLayout)getChildAt(i);
                 float finalAlphaValue = 0f;
                 float rotation = 0f;
-                if (LauncherApplication.isScreenLarge()) {
-                    finalAlphaValue = (i == mCurrentPage) ? 1.0f : 0.0f;
 
+                // Set the final alpha depending on whether we are fading side pages.  On phone ui,
+                // we don't do any of the rotation, or the fading alpha in portrait.  See the
+                // ctor and screenScrolled().
+                if (mFadeInAdjacentScreens) {
+                    finalAlphaValue = (i == mCurrentPage) ? 1f : 0f;
+                } else {
+                    finalAlphaValue = 1f;
+                }
+
+                if (LauncherApplication.isScreenLarge()) {
                     if (i < mCurrentPage) {
                         rotation = WORKSPACE_ROTATION;
                     } else if (i > mCurrentPage) {
                         rotation = -WORKSPACE_ROTATION;
                     }
-                } else {
-                    // Don't hide the side panes on the phone if we don't also update the side pages
-                    // alpha.  See screenScrolled().
-                    finalAlphaValue = 1f;
                 }
                 float finalAlphaMultiplierValue = 1f;
 
@@ -1864,6 +1879,14 @@
                                     b * mNewBackgroundAlphaMultipliers[i]);
                             cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
                         }
+
+                        // Unshrink the hotset the same amount we are unshrinking the screens
+                        if (mLauncher.getHotseat() != null) {
+                            View hotseat = mLauncher.getHotseat().getLayout();
+                            hotseat.fastInvalidate();
+                            hotseat.setFastScaleX(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+                            hotseat.setFastScaleY(a * mOldScaleXs[0] + b * mNewScaleXs[0]);
+                        }
                     }
                 });
 
@@ -2259,7 +2282,8 @@
         // new current/default screen, so any subsequent taps add items to that screen
         if (!mLauncher.isAllAppsVisible()) {
             int dragTargetIndex = indexOfChild(mDragTargetLayout);
-            if (mCurrentPage != dragTargetIndex && (isSmall() || mIsSwitchingState)) {
+            if (dragTargetIndex > -1 && mCurrentPage != dragTargetIndex &&
+                    (isSmall() || mIsSwitchingState)) {
                 scrollToNewPageWithoutMovingPages(dragTargetIndex);
             }
         }
@@ -2767,19 +2791,27 @@
         if (mInScrollArea) return;
         if (mIsSwitchingState) return;
 
+        Rect r = new Rect();
         CellLayout layout = null;
         ItemInfo item = (ItemInfo) d.dragInfo;
 
         // Ensure that we have proper spans for the item that we are dropping
         if (item.spanX < 0 || item.spanY < 0) throw new RuntimeException("Improper spans found");
-
         mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset,
-                d.dragView, mDragViewVisualCenter);
+            d.dragView, mDragViewVisualCenter);
 
         // Identify whether we have dragged over a side page
         if (isSmall()) {
-            layout = findMatchingPageForDragOver(d.dragView, mDragViewVisualCenter[0],
+            if (mLauncher.getHotseat() != null) {
+                mLauncher.getHotseat().getHitRect(r);
+                if (r.contains(d.x, d.y)) {
+                    layout = mLauncher.getHotseat().getLayout();
+                }
+            }
+            if (layout == null) {
+                layout = findMatchingPageForDragOver(d.dragView, mDragViewVisualCenter[0],
                     mDragViewVisualCenter[1], true);
+            }
             if (layout != mDragTargetLayout) {
                 // Cancel all intermediate folder states
                 cleanupFolderCreation(d);
@@ -2798,12 +2830,15 @@
 
                 boolean isInSpringLoadedMode = (mState == State.SPRING_LOADED);
                 if (isInSpringLoadedMode) {
-                    mSpringLoadedDragController.setAlarm(mDragTargetLayout);
+                    if (mLauncher.isHotseatLayout(layout)) {
+                        mSpringLoadedDragController.cancel();
+                    } else {
+                        mSpringLoadedDragController.setAlarm(mDragTargetLayout);
+                    }
                 }
             }
         } else {
             // Test to see if we are over the hotseat otherwise just use the current page
-            Rect r = new Rect();
             if (mLauncher.getHotseat() != null) {
                 mLauncher.getHotseat().getHitRect(r);
                 if (r.contains(d.x, d.y)) {