Merge branch 'master' into honeycomb-release
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 0ef946f..f42d72b 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -38,7 +38,7 @@
         launcher:defaultScreen="2"
         launcher:cellCountX="8"
         launcher:cellCountY="7"
-        launcher:pageSpacing="64dip">
+        launcher:pageSpacing="32dip">
 
         <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
         <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
diff --git a/res/layout-xlarge-land/workspace_screen.xml b/res/layout-xlarge-land/workspace_screen.xml
index f358443..38dab82 100644
--- a/res/layout-xlarge-land/workspace_screen.xml
+++ b/res/layout-xlarge-land/workspace_screen.xml
@@ -24,6 +24,8 @@
 
     launcher:cellWidth="@dimen/workspace_cell_width"
     launcher:cellHeight="@dimen/workspace_cell_height"
+    launcher:widthGap="@dimen/workspace_width_gap"
+    launcher:heightGap="@dimen/workspace_height_gap"
     launcher:yAxisStartPadding="40dip"
     launcher:yAxisEndPadding="40dip"
     launcher:xAxisStartPadding="40dip"
diff --git a/res/layout-xlarge-port/customization_drawer.xml b/res/layout-xlarge-port/customization_drawer.xml
index 53d1f6f..d3ca457 100644
--- a/res/layout-xlarge-port/customization_drawer.xml
+++ b/res/layout-xlarge-port/customization_drawer.xml
@@ -19,10 +19,12 @@
 
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    launcher:widgetCellCountX="12"
+    launcher:widgetCellCountX="10"
     launcher:cellCountX="5"
-    launcher:cellCountY="4"
-    launcher:pageLayoutPaddingTop="15dp"
+    launcher:cellCountY="5"
+    launcher:pageLayoutWidthGap="36dp"
+    launcher:pageLayoutHeightGap="36dp"
+    launcher:pageLayoutPaddingTop="25dp"
     launcher:pageLayoutPaddingBottom="25dp"
-    launcher:pageLayoutPaddingLeft="15dp"
-    launcher:pageLayoutPaddingRight="15dp" />
+    launcher:pageLayoutPaddingLeft="20dp"
+    launcher:pageLayoutPaddingRight="20dp" />
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index df7abc1..20debca 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -131,7 +131,7 @@
     <TabHost
         android:id="@android:id/tabhost"
         android:layout_width="match_parent"
-        android:layout_height="550dip"
+        android:layout_height="800dip"
         android:layout_gravity="bottom">
         <LinearLayout
             android:orientation="vertical"
@@ -148,7 +148,7 @@
             <FrameLayout
                 android:id="@android:id/tabcontent"
                 android:layout_width="match_parent"
-                android:layout_height="match_parent">
+                android:layout_height="650dp">
              </FrameLayout>
           </LinearLayout>
     </TabHost>
diff --git a/res/layout-xlarge-port/workspace_screen.xml b/res/layout-xlarge-port/workspace_screen.xml
index 7314e60..406441d 100644
--- a/res/layout-xlarge-port/workspace_screen.xml
+++ b/res/layout-xlarge-port/workspace_screen.xml
@@ -24,7 +24,9 @@
 
     launcher:cellWidth="@dimen/workspace_cell_width"
     launcher:cellHeight="@dimen/workspace_cell_height"
-    launcher:yAxisStartPadding="40dip"
-    launcher:yAxisEndPadding="40dip"
-    launcher:xAxisStartPadding="40dip"
-    launcher:xAxisEndPadding="40dip"/>
+    launcher:widthGap="@dimen/workspace_width_gap"
+    launcher:heightGap="@dimen/workspace_height_gap"
+    launcher:yAxisStartPadding="25dip"
+    launcher:yAxisEndPadding="25dip"
+    launcher:xAxisStartPadding="15dip"
+    launcher:xAxisEndPadding="15dip"/>
diff --git a/res/layout-xlarge/customize_paged_view_widget.xml b/res/layout-xlarge/customize_paged_view_widget.xml
index e8f4ac9..cfc0ca0 100644
--- a/res/layout-xlarge/customize_paged_view_widget.xml
+++ b/res/layout-xlarge/customize_paged_view_widget.xml
@@ -18,10 +18,9 @@
     xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
 
     android:layout_width="wrap_content"
-    android:layout_height="match_parent"
+    android:layout_height="425dp"
     android:paddingLeft="12.5dp"
     android:paddingRight="12.5dp"
-    android:paddingTop="40dp"
     android:paddingBottom="50dp"
     android:gravity="top"
     android:orientation="vertical"
diff --git a/res/values-xlarge-land/dimens.xml b/res/values-xlarge-land/dimens.xml
index d1140c0..f8ebb3f 100644
--- a/res/values-xlarge-land/dimens.xml
+++ b/res/values-xlarge-land/dimens.xml
@@ -18,4 +18,8 @@
     <!-- the area at the edge of the screen that makes the workspace go left
          or right while you're dragging. -->
     <dimen name="scroll_zone">160dip</dimen>
+
+    <!-- Width/height gap overrides for the workspace -->
+    <dimen name="workspace_width_gap">16dp</dimen>
+    <dimen name="workspace_height_gap">0dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/res/values-xlarge-port/dimens.xml b/res/values-xlarge-port/dimens.xml
new file mode 100644
index 0000000..3117df9
--- /dev/null
+++ b/res/values-xlarge-port/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+    <!-- Width/height gap overrides for the workspace -->
+    <dimen name="workspace_width_gap">0dp</dimen>
+    <dimen name="workspace_height_gap">16dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index ecc6f3a..a84926d 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -15,16 +15,26 @@
 -->
 
 <resources>
-    <dimen name="workspace_cell_width">76dip</dimen>
-    <dimen name="workspace_cell_height">76dip</dimen>
+    <dimen name="workspace_cell_width">96dip</dimen>
+    <dimen name="workspace_cell_height">96dip</dimen>
+
+    <!-- Width/height gap overrides for the workspace -->
+    <dimen name="workspace_width_gap">0dp</dimen>
+    <dimen name="workspace_height_gap">0dp</dimen>
 
     <!-- extra horizontal spacing between mini screen thumbnails ie. in all
          apps and in customization mode -->
     <dimen name="smallScreenExtraSpacing">0dip</dimen>
 
-    <!-- vertical spacing between edge of screen and mini screen thumbnails -->
-    <dimen name="smallScreenVerticalMarginLandscape">30dip</dimen>
-    <dimen name="smallScreenVerticalMarginPortrait">60dip</dimen>
+    <!-- Vertical spacing between edge of screen and mini cell layouts when they
+         are minimized to the bottom in all apps -->
+    <dimen name="allAppsSmallScreenVerticalMarginLandscape">30dip</dimen>
+    <dimen name="allAppsSmallScreenVerticalMarginPortrait">60dip</dimen>
+
+    <!-- Vertical spacing between edge of screen and mini cell layouts when they
+         are minimized to the top when the customization drawer is showing -->
+    <dimen name="customizeSmallScreenVerticalMarginLandscape">70dip</dimen>
+    <dimen name="customizeSmallScreenVerticalMarginPortrait">180dip</dimen>
 
     <dimen name="toolbar_padding">10dip</dimen>
 
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index a0e2706..6189f1c 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -53,6 +53,12 @@
         <attr name="yAxisStartPadding" format="dimension"  />
         <!-- Padding to apply at the end of the short axis -->
         <attr name="yAxisEndPadding" format="dimension"  />
+        <!-- An override for the width and height gap to allow users to specify
+             a specific size for the page using spacing instead of resolving the
+             spacing from the width of the page -->
+        <attr name="widthGap" format="dimension" />
+        <attr name="heightGap" format="dimension" />
+
     </declare-styleable>
 
     <!-- PagedViewIcon specific attributes. These attributes are used to customize
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index c4aa98c..fe5ffd1 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -99,10 +99,11 @@
 
     public void onDragStart(DragSource source, Object info, int dragAction) {
         if (info != null) {
+            final int itemType = ((ItemInfo)info).itemType;
+            mActive = (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION);
             if (mManageVisibility) {
-                mActive = true;
                 // Only show the info icon when an application is selected
-                if (((ItemInfo)info).itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
+                if (mActive) {
                     setVisibility(VISIBLE);
                 }
                 mHandle.setVisibility(INVISIBLE);
@@ -128,10 +129,15 @@
     public void getHitRect(Rect outRect) {
         super.getHitRect(outRect);
         if (LauncherApplication.isScreenXLarge()) {
-            outRect.top -= 50;
-            outRect.left -= 50;
-            outRect.bottom += 50;
-            outRect.right += 50;
+            // TODO: This is a temporary hack. mManageVisiblity = false when you're in CAB mode.
+            // In that case, this icon is more tightly spaced next to the delete icon so we want
+            // it to have a smaller drag region. When the new drag&drop system comes in, we'll
+            // dispatch the drag/drop by calculating what target you're overlapping
+            final int dragPadding = mManageVisibility ? 50 : 10;
+            outRect.top -= dragPadding;
+            outRect.left -= dragPadding;
+            outRect.bottom += dragPadding;
+            outRect.right += dragPadding;
         }
     }
 
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index d94bacf..2da5ac3 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -144,6 +144,8 @@
 
         mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
         mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
+        mWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, -1);
+        mHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, -1);
 
         mLeftPadding =
             a.getDimensionPixelSize(R.styleable.CellLayout_xAxisStartPadding, 10);
@@ -456,6 +458,11 @@
     }
 
     public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params) {
+        return addViewToCellLayout(child, index, childId, params, true);
+    }
+
+    public boolean addViewToCellLayout(
+            View child, int index, int childId, LayoutParams params, boolean markCells) {
         final LayoutParams lp = params;
 
         // Generate an id for each view, this assumes we have at most 256x256 cells
@@ -473,7 +480,7 @@
             child.setAlpha(getAlpha());
             addView(child, index, lp);
 
-            markCellsAsOccupiedForView(child);
+            if (markCells) markCellsAsOccupiedForView(child);
 
             return true;
         }
@@ -500,6 +507,10 @@
         clearOccupiedCells();
     }
 
+    public void removeViewWithoutMarkingCells(View view) {
+        super.removeView(view);
+    }
+
     @Override
     public void removeView(View view) {
         markCellsAsUnoccupiedForView(view);
@@ -725,15 +736,17 @@
         int numWidthGaps = mCountX - 1;
         int numHeightGaps = mCountY - 1;
 
-        int vSpaceLeft = heightSpecSize - mTopPadding - mBottomPadding - (cellHeight * mCountY);
-        mHeightGap = vSpaceLeft / numHeightGaps;
+        if (mWidthGap < 0 || mHeightGap < 0) {
+            int vSpaceLeft = heightSpecSize - mTopPadding - mBottomPadding - (cellHeight * mCountY);
+            mHeightGap = vSpaceLeft / numHeightGaps;
 
-        int hSpaceLeft = widthSpecSize - mLeftPadding - mRightPadding - (cellWidth * mCountX);
-        mWidthGap = hSpaceLeft / numWidthGaps;
+            int hSpaceLeft = widthSpecSize - mLeftPadding - mRightPadding - (cellWidth * mCountX);
+            mWidthGap = hSpaceLeft / numWidthGaps;
 
-        // center it around the min gaps
-        int minGap = Math.min(mWidthGap, mHeightGap);
-        mWidthGap = mHeightGap = minGap;
+            // center it around the min gaps
+            int minGap = Math.min(mWidthGap, mHeightGap);
+            mWidthGap = mHeightGap = minGap;
+        }
 
         int count = getChildCount();
 
@@ -751,9 +764,9 @@
         }
         if (widthSpecMode == MeasureSpec.AT_MOST) {
             int newWidth = mLeftPadding + mRightPadding + (mCountX * cellWidth) +
-                ((mCountX - 1) * minGap);
+                ((mCountX - 1) * mWidthGap);
             int newHeight = mTopPadding + mBottomPadding + (mCountY * cellHeight) +
-                ((mCountY - 1) * minGap);
+                ((mCountY - 1) * mHeightGap);
             setMeasuredDimension(newWidth, newHeight);
         } else if (widthSpecMode == MeasureSpec.EXACTLY) {
             setMeasuredDimension(widthSpecSize, heightSpecSize);
@@ -1365,24 +1378,6 @@
         return false;
     }
 
-    /**
-     * Update the array of occupied cells (mOccupied), and return a flattened copy of the array.
-     */
-    boolean[] getOccupiedCellsFlattened() {
-        final int xCount = mCountX;
-        final int yCount = mCountY;
-        final boolean[][] occupied = mOccupied;
-
-        final boolean[] flat = new boolean[xCount * yCount];
-        for (int y = 0; y < yCount; y++) {
-            for (int x = 0; x < xCount; x++) {
-                flat[y * xCount + x] = occupied[x][y];
-            }
-        }
-
-        return flat;
-    }
-
     private void clearOccupiedCells() {
         for (int x = 0; x < mCountX; x++) {
             for (int y = 0; y < mCountY; y++) {
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index cc21276..a01f1c0 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -539,6 +539,7 @@
         layout.setCellCount(mCellCountX, mCellCountY);
         layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight,
                 mPageLayoutPaddingBottom);
+        layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
     }
 
     private void setupWorkspaceLayout() {
@@ -557,6 +558,8 @@
         for (int i = 0; i < numPages; ++i) {
             LinearLayout layout = new PagedViewWidgetLayout(getContext());
             layout.setGravity(Gravity.CENTER_HORIZONTAL);
+            layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
+                    mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
 
             // Temporary change to prevent the last page from being too small (and items bleeding
             // onto it).  We can remove this once we properly fix the fading algorithm
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index e8f160f..4acde1c 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -206,10 +206,15 @@
     public void getHitRect(Rect outRect) {
         super.getHitRect(outRect);
         if (LauncherApplication.isScreenXLarge()) {
-            outRect.top -= 50;
-            outRect.left -= 50;
-            outRect.bottom += 50;
-            outRect.right += 50;
+            // TODO: This is a temporary hack. mManageVisiblity = false when you're in CAB mode.
+            // In that case, this icon is more tightly spaced next to the delete icon so we want
+            // it to have a smaller drag region. When the new drag&drop system comes in, we'll
+            // dispatch the drag/drop by calculating what target you're overlapping
+            final int dragPadding = mManageVisibility ? 50 : 10;
+            outRect.top -= dragPadding;
+            outRect.left -= dragPadding;
+            outRect.bottom += dragPadding;
+            outRect.right += dragPadding;
         }
     }
 
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 2688e54..baec7e3 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -150,8 +150,8 @@
 
     // Type: int
     private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
-    // Type: boolean
-    private static final String RUNTIME_STATE_ALL_APPS_FOLDER = "launcher.all_apps_folder";
+    // Type: int
+    private static final String RUNTIME_STATE = "launcher.state";
     // Type: long
     private static final String RUNTIME_STATE_USER_FOLDERS = "launcher.user_folder";
     // Type: int
@@ -802,6 +802,22 @@
     }
 
     /**
+     * Given the integer (ordinal) value of a State enum instance, convert it to a variable of type
+     * State
+     */
+    private static State intToState(int stateOrdinal) {
+        State state = State.WORKSPACE;
+        final State[] stateValues = State.values();
+        for (int i = 0; i < stateValues.length; i++) {
+            if (stateValues[i].ordinal() == stateOrdinal) {
+                state = stateValues[i];
+                break;
+            }
+        }
+        return state;
+    }
+
+    /**
      * Restores the previous state, if it exists.
      *
      * @param savedState The previous state.
@@ -811,9 +827,12 @@
             return;
         }
 
-        final boolean allApps = savedState.getBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, false);
-        if (allApps) {
+        State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal()));
+
+        if (state == State.ALL_APPS) {
             showAllApps(false);
+        } else if (state == State.CUSTOMIZE) {
+            showCustomizationDrawer(false);
         }
 
         final int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1);
@@ -1232,10 +1251,7 @@
             super.onSaveInstanceState(outState);
         }
 
-        // TODO should not do this if the drawer is currently closing.
-        if (mState == State.ALL_APPS) {
-            outState.putBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, true);
-        }
+        outState.putInt(RUNTIME_STATE, mState.ordinal());
 
         if (mAddScreen > -1 && mWaitingForResult) {
             outState.putInt(RUNTIME_STATE_PENDING_ADD_SCREEN, mAddScreen);
@@ -1696,7 +1712,8 @@
         folder.getInfo().opened = false;
         ViewGroup parent = (ViewGroup) folder.getParent();
         if (parent != null) {
-            parent.removeView(folder);
+            CellLayout cl = (CellLayout) parent;
+            cl.removeViewWithoutMarkingCells(folder);
             if (folder instanceof DropTarget) {
                 // Live folders aren't DropTargets.
                 mDragController.removeDropTarget((DropTarget)folder);
@@ -1866,7 +1883,7 @@
     }
 
     /**
-     * Opens the user fodler described by the specified tag. The opening of the folder
+     * Opens the user folder described by the specified tag. The opening of the folder
      * is animated relative to the specified View. If the View is null, no animation
      * is played.
      *
@@ -2549,8 +2566,9 @@
     }
 
     void showAllApps(boolean animated) {
-        if (mState == State.ALL_APPS)
+        if (mState == State.ALL_APPS) {
             return;
+        }
 
         if (LauncherApplication.isScreenXLarge()) {
             if (mState == State.CUSTOMIZE) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 42a6f1b..7399a9e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -88,8 +88,6 @@
 
     private int mDefaultPage;
 
-    private boolean mWaitingToShrinkToBottom = false;
-
     private boolean mPageMoving = false;
 
     /**
@@ -136,6 +134,8 @@
     private enum ShrinkPosition {
         SHRINK_TO_TOP, SHRINK_TO_MIDDLE, SHRINK_TO_BOTTOM_HIDDEN, SHRINK_TO_BOTTOM_VISIBLE };
     private ShrinkPosition mShrunkenState;
+    private boolean mWaitingToShrink = false;
+    private ShrinkPosition mWaitingToShrinkPosition;
 
     private boolean mInScrollArea = false;
 
@@ -364,7 +364,8 @@
 
         // Get the canonical child id to uniquely represent this view in this screen
         int childId = LauncherModel.getCellLayoutChildId(-1, screen, x, y, spanX, spanY);
-        if (!group.addViewToCellLayout(child, insert ? 0 : -1, childId, lp)) {
+        boolean markCellsAsOccupied = !(child instanceof Folder);
+        if (!group.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
             // TODO: This branch occurs when the workspace is adding views
             // outside of the defined grid
             // maybe we should be deleting these items from the LauncherModel?
@@ -541,9 +542,9 @@
 
         // if shrinkToBottom() is called on initialization, it has to be deferred
         // until after the first call to onLayout so that it has the correct width
-        if (mWaitingToShrinkToBottom) {
-            shrinkToBottom(false);
-            mWaitingToShrinkToBottom = false;
+        if (mWaitingToShrink) {
+            shrink(mWaitingToShrinkPosition, false);
+            mWaitingToShrink = false;
         }
 
         if (LauncherApplication.isInPlaceRotationEnabled()) {
@@ -664,15 +665,7 @@
     }
 
     void shrinkToBottom(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
-            // Launcher is started in All Apps mode) then we need to wait for a layout call
-            // to get our width so we can layout the mini-screen views correctly
-            mWaitingToShrinkToBottom = true;
-        } else {
-            shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, animated);
-        }
+        shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, animated);
     }
 
     private float getYScaleForScreen(int screen) {
@@ -689,6 +682,15 @@
 
     // we use this to shrink the workspace for the all apps view and the customize view
     private void shrink(ShrinkPosition shrinkPosition, 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
+            // Launcher is started in All Apps mode) then we need to wait for a layout call
+            // to get our width so we can layout the mini-screen views correctly
+            mWaitingToShrink = true;
+            mWaitingToShrinkPosition = shrinkPosition;
+            return;
+        }
         mIsSmall = true;
         mShrunkenState = shrinkPosition;
 
@@ -717,8 +719,8 @@
 
         boolean isPortrait = getMeasuredHeight() > getMeasuredWidth();
         float newY = (isPortrait ?
-                getResources().getDimension(R.dimen.smallScreenVerticalMarginPortrait) :
-                getResources().getDimension(R.dimen.smallScreenVerticalMarginLandscape));
+                getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginPortrait) :
+                getResources().getDimension(R.dimen.allAppsSmallScreenVerticalMarginLandscape));
         float finalAlpha = 1.0f;
         float extraShrinkFactor = 1.0f;
         if (shrinkPosition == ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE) {
@@ -734,7 +736,9 @@
             newY = screenHeight / 2 - scaledPageHeight / 2;
             finalAlpha = 1.0f;
         } else if (shrinkPosition == ShrinkPosition.SHRINK_TO_TOP) {
-            newY = screenHeight / 10;
+            newY = (isPortrait ?
+                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginPortrait) :
+                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginLandscape));
         }
 
         // We animate all the screens to the centered position in workspace
@@ -771,9 +775,9 @@
             } else {
                 cl.setX((int)newX);
                 cl.setY((int)newY);
-                cl.setScaleX(SHRINK_FACTOR * rotationScaleX);
-                cl.setScaleY(SHRINK_FACTOR * rotationScaleY);
-                cl.setBackgroundAlpha(1.0f);
+                cl.setScaleX(SHRINK_FACTOR * rotationScaleX * extraShrinkFactor);
+                cl.setScaleY(SHRINK_FACTOR * rotationScaleY * extraShrinkFactor);
+                cl.setBackgroundAlpha(finalAlpha);
                 cl.setAlpha(finalAlpha);
                 cl.setRotationY(rotation);
             }