merge in ics-release history after reset to master
diff --git a/res/values-xlarge-port/styles.xml b/res/values-xlarge-port/styles.xml
new file mode 100644
index 0000000..2c5f5bb
--- /dev/null
+++ b/res/values-xlarge-port/styles.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright (C) 2011 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>
+    <style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
+        <item name="android:paddingLeft">20dp</item>
+        <item name="android:paddingRight">20dp</item>
+    </style>
+</resources>
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index f195470..0f364f8 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -172,7 +172,9 @@
 
         availableHeight -= mPageLayoutPaddingTop + mPageLayoutPaddingBottom;
         availableHeight -= cellHeight; // Assume at least one row
-        availableHeight -= screenHeight * 0.16f;
+        Resources r = getContext().getResources();
+        float scaleFactor = r.getInteger(R.integer.config_appsCustomizeZoomScaleFactor) / 100f;
+        availableHeight -= screenHeight * scaleFactor;
         if (availableHeight > 0) {
             return Math.min(mMaxCellCountY,
                     1 + availableHeight / (cellHeight + mPageLayoutHeightGap));
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index f189cd5..eb92d20 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -271,54 +271,20 @@
         // We use this method from Workspace to figure out how many rows/columns Launcher should
         // have. We ignore the left/right padding on CellLayout because it turns out in our design
         // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at either
-        // edge to be rendered (half the crosshair is sticking out on either side)
         int cellWidth = r.getDimensionPixelSize(R.dimen.workspace_cell_width);
         int widthGap = r.getDimensionPixelSize(R.dimen.workspace_width_gap_port);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicWidth();
 
-        return  widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
-    }
-
-    static int widthInLandscape(Resources r, int numCells) {
-        // We use this method from Workspace to figure out how many rows/columns Launcher should
-        // have. We ignore the left/right padding on CellLayout because it turns out in our design
-        // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at either
-        // edge to be rendered (half the crosshair is sticking out on either side)
-        int cellWidth = r.getDimensionPixelSize(R.dimen.workspace_cell_width);
-        int widthGap = r.getDimensionPixelSize(R.dimen.workspace_width_gap_land);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicWidth();
-
-        return widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
-    }
-
-    static int heightInPortrait(Resources r, int numCells) {
-        // We use this method from Workspace to figure out how many rows/columns Launcher should
-        // have. We ignore the left/right padding on CellLayout because it turns out in our design
-        // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at the bottom
-        // to be rendered (half the crosshair is sticking out); we don't worry about the top
-        // crosshair since it can bleed into the action bar space
-        int cellHeight = r.getDimensionPixelSize(R.dimen.workspace_cell_height);
-        int heightGap = r.getDimensionPixelSize(R.dimen.workspace_height_gap_port);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicHeight();
-
-        return heightGap * (numCells - 1) + cellHeight * numCells + (crosshairsSize + 1) / 2;
+        return  widthGap * (numCells - 1) + cellWidth * numCells;
     }
 
     static int heightInLandscape(Resources r, int numCells) {
         // We use this method from Workspace to figure out how many rows/columns Launcher should
         // have. We ignore the left/right padding on CellLayout because it turns out in our design
         // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at the bottom
-        // to be rendered (half the crosshair is sticking out); we don't worry about the top
-        // crosshair since it can bleed into the action bar space
         int cellHeight = r.getDimensionPixelSize(R.dimen.workspace_cell_height);
         int heightGap = r.getDimensionPixelSize(R.dimen.workspace_height_gap_land);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicHeight();
 
-        return heightGap * (numCells - 1) + cellHeight * numCells + (crosshairsSize + 1) / 2;
+        return heightGap * (numCells - 1) + cellHeight * numCells;
     }
 
     public void enableHardwareLayers() {
diff --git a/src/com/android/launcher2/CustomizeTrayTabHost.java b/src/com/android/launcher2/CustomizeTrayTabHost.java
index c6a39b3..5780818 100644
--- a/src/com/android/launcher2/CustomizeTrayTabHost.java
+++ b/src/com/android/launcher2/CustomizeTrayTabHost.java
@@ -84,7 +84,7 @@
                 .setIndicator(tabView).setContent(contentFactory));
         tabView = (TextView) mInflater.inflate(
                 R.layout.customize_tab_widget_indicator, tabWidget, false);
-        tabView.setText(mContext.getString(R.string.applications_tab_label));
+        tabView.setText(mContext.getString(R.string.all_apps_tab_apps));
         addTab(newTabSpec(APPLICATIONS_TAG)
                 .setIndicator(tabView).setContent(contentFactory));
         tabView = (TextView) mInflater.inflate(
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 0ae7a59..901ac26 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -211,8 +211,6 @@
     }
 
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        // TODO: currently ignoring padding
-
         int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
         int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
 
@@ -255,10 +253,8 @@
             widthGap = heightGap = minGap;
         }
 
-        int newWidth = mPaddingLeft + mPaddingRight + (mCellCountX * cellWidth) +
-            ((mCellCountX - 1) * widthGap);
-        int newHeight = mPaddingTop + mPaddingBottom + (mCellCountY * cellHeight) +
-            ((mCellCountY - 1) * heightGap);
+        int newWidth = (mCellCountX * cellWidth) + ((mCellCountX - 1) * widthGap);
+        int newHeight = (mCellCountY * cellHeight) + ((mCellCountY - 1) * heightGap);
 
         final int count = getChildCount();
         for (int i = 0; i < count; i++) {
@@ -270,7 +266,8 @@
             child.measure(childWidthMeasureSpec, childheightMeasureSpec);
         }
 
-        setMeasuredDimension(newWidth, newHeight);
+        setMeasuredDimension(newWidth + mPaddingLeft + mPaddingRight,
+            newHeight + mPaddingTop + mPaddingBottom);
     }
 
     int getContentWidth() {
@@ -304,12 +301,8 @@
         int count = getChildCount();
         for (int i = 0; i < count; i++) {
             View child = getChildAt(i);
-            if (LauncherApplication.isScreenLarge()) {
-                child.layout(0, 0, r - l, b - t);
-            } else {
-                child.layout(mPaddingLeft, mPaddingTop, getMeasuredWidth() - mPaddingRight,
-                        getMeasuredHeight() - mPaddingBottom);
-            }
+            child.layout(mPaddingLeft, mPaddingTop,
+                r - l - mPaddingRight, b - t - mPaddingBottom);
         }
     }
 
diff --git a/src/com/android/launcher2/PagedViewCellLayoutChildren.java b/src/com/android/launcher2/PagedViewCellLayoutChildren.java
index 6333f7f..1afdd03 100644
--- a/src/com/android/launcher2/PagedViewCellLayoutChildren.java
+++ b/src/com/android/launcher2/PagedViewCellLayoutChildren.java
@@ -92,8 +92,8 @@
             PagedViewCellLayout.LayoutParams lp =
                 (PagedViewCellLayout.LayoutParams) child.getLayoutParams();
             lp.setup(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
-                    ((ViewGroup)getParent()).getPaddingLeft(),
-                    ((ViewGroup)getParent()).getPaddingTop());
+                    getPaddingLeft(),
+                    getPaddingTop());
 
             int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width,
                     MeasureSpec.EXACTLY);
@@ -111,18 +111,21 @@
         int count = getChildCount();
 
         int offsetX = 0;
-        if (mCenterContent) {
+        if (mCenterContent && count > 0) {
             // determine the max width of all the rows and center accordingly
-            int maxRowWidth = 0;
+            int maxRowX = 0;
+            int minRowX = Integer.MAX_VALUE;
             for (int i = 0; i < count; i++) {
                 View child = getChildAt(i);
                 if (child.getVisibility() != GONE) {
                     PagedViewCellLayout.LayoutParams lp =
                         (PagedViewCellLayout.LayoutParams) child.getLayoutParams();
-                    maxRowWidth = Math.max(maxRowWidth, lp.x + lp.width);
+                    minRowX = Math.min(minRowX, lp.x);
+                    maxRowX = Math.max(maxRowX, lp.x + lp.width);
                 }
             }
-            offsetX = (getMeasuredWidth() / 2) - (maxRowWidth / 2);
+            int maxRowWidth = maxRowX - minRowX;
+            offsetX = (getMeasuredWidth() - maxRowWidth) / 2;
         }
 
         for (int i = 0; i < count; i++) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7d1ee19..e0472fc 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -52,7 +52,6 @@
 import android.os.IBinder;
 import android.os.Parcelable;
 import android.util.AttributeSet;
-import android.util.DisplayMetrics;
 import android.util.Log;
 import android.util.Pair;
 import android.view.Display;
@@ -272,42 +271,28 @@
                 R.styleable.Workspace, defStyle, 0);
 
         if (LauncherApplication.isScreenLarge()) {
+            // Determine number of rows/columns dynamically
+            // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
+            // Around that ratio we should make cells the same size in portrait and
+            // landscape
             final Resources res = context.getResources();
-            final DisplayMetrics dm = res.getDisplayMetrics();
-            float widthDp = dm.widthPixels / dm.density;
-            float heightDp = dm.heightPixels / dm.density;
 
-            final float statusBarHeight = res.getDimension(R.dimen.status_bar_height);
             TypedArray actionBarSizeTypedArray =
                 context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
-            float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+            final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+            final float systemBarHeight = res.getDimension(R.dimen.status_bar_height);
+            final float smallestScreenDim = res.getConfiguration().smallestScreenWidthDp;
 
-            if (heightDp > widthDp) {
-                float temp = widthDp;
-                widthDp = heightDp;
-                heightDp = temp;
+            cellCountX = 1;
+            while (CellLayout.widthInPortrait(res, cellCountX + 1) <= smallestScreenDim) {
+                cellCountX++;
             }
-            int cellCountXLand = 1;
-            int cellCountXPort = 1;
-            while (2*mPageSpacing + CellLayout.widthInLandscape(res, cellCountXLand + 1) <= widthDp) {
-                cellCountXLand++;
-            }
-            while (CellLayout.widthInPortrait(res, cellCountXPort + 1) <= heightDp) {
-                cellCountXPort++;
-            }
-            cellCountX = Math.min(cellCountXLand, cellCountXPort);
 
-            int cellCountYLand = 1;
-            int cellCountYPort = 1;
-            while (statusBarHeight + actionBarHeight +
-                    CellLayout.heightInLandscape(res, cellCountYLand + 1) <= heightDp) {
-                cellCountYLand++;
+            cellCountY = 1;
+            while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1)
+                <= smallestScreenDim - systemBarHeight) {
+                cellCountY++;
             }
-            while (statusBarHeight + actionBarHeight +
-                    CellLayout.heightInPortrait(res, cellCountYPort + 1) <= widthDp) {
-                cellCountYPort++;
-            }
-            cellCountY = Math.min(cellCountYLand, cellCountYPort);
         }
 
         // if the value is manually specified, use that instead