Altering homescreen spacing to match design.

Change-Id: I8b859992fe843d0cf688cb84bcbaab6dbeccb6fb
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/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/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 bfab155..a84926d 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -15,8 +15,12 @@
 -->
 
 <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 -->
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/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 8631e2c..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);
@@ -734,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();
 
@@ -760,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);