Fixing some grid spacing issues. (Bug 10754537, 10754538)

- Ensuring app names don't run into each other in folders and on the workspace
- Ensuring that app names are aligned with folder names

Change-Id: Ie8d546eacd52005778d81c46011c1c84bc24118c
diff --git a/res/layout-port/apps_customize_application.xml b/res/layout-port/apps_customize_application.xml
deleted file mode 100644
index 0b7bab6..0000000
--- a/res/layout-port/apps_customize_application.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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.
--->
-
-<com.android.launcher3.PagedViewIcon
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
-
-    style="@style/WorkspaceIcon.Portrait.AppsCustomize"
-
-    android:id="@+id/application_icon"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:gravity="center_horizontal"
-
-    android:focusable="true"
-    android:background="@drawable/focusable_view_bg" />
diff --git a/res/layout-land/apps_customize_application.xml b/res/layout/apps_customize_application.xml
similarity index 91%
rename from res/layout-land/apps_customize_application.xml
rename to res/layout/apps_customize_application.xml
index bf0022d..3b0fa6f 100644
--- a/res/layout-land/apps_customize_application.xml
+++ b/res/layout/apps_customize_application.xml
@@ -18,12 +18,11 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
 
-    style="@style/WorkspaceIcon.Landscape.AppsCustomize"
+    style="@style/WorkspaceIcon.AppsCustomize"
 
     android:id="@+id/application_icon"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:gravity="center_horizontal"
-
+    
     android:focusable="true"
     android:background="@drawable/focusable_view_bg" />
diff --git a/res/layout/folder_icon.xml b/res/layout/folder_icon.xml
index 5a9a834..9c5c46b 100644
--- a/res/layout/folder_icon.xml
+++ b/res/layout/folder_icon.xml
@@ -28,6 +28,6 @@
         android:layout_height="wrap_content"
         android:src="@drawable/portal_ring_inner_holo"/>
     <com.android.launcher3.BubbleTextView
-        android:id="@+id/folder_icon_name"
-        style="@style/WorkspaceIcon"/>
+        style="@style/WorkspaceIcon"
+        android:id="@+id/folder_icon_name" />
 </com.android.launcher3.FolderIcon>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cf77b51..48b9dbc 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -82,15 +82,11 @@
     <style name="WorkspaceIcon.Landscape">
     </style>
 
-    <style name="WorkspaceIcon.Portrait.AppsCustomize">
+    <style name="WorkspaceIcon.AppsCustomize">
         <item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
         <item name="android:background">@null</item>
         <item name="android:textColor">@color/apps_customize_icon_text_color</item>
-    </style>
-    <style name="WorkspaceIcon.Landscape.AppsCustomize">
-        <item name="android:shadowRadius">0.0</item> <!-- Don't use text shadow -->
-        <item name="android:background">@null</item>
-        <item name="android:textColor">@color/apps_customize_icon_text_color</item>
+        <item name="android:drawablePadding">4dp</item>
     </style>
 
     <style name="QSBBar">
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index bb6903d..7a7a3b6 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -102,10 +102,13 @@
 
     public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
         Bitmap b = info.getIcon(iconCache);
+        LauncherAppState app = LauncherAppState.getInstance();
+        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
 
         setCompoundDrawablesWithIntrinsicBounds(null,
                 new FastBitmapDrawable(b),
                 null, null);
+        setCompoundDrawablePadding((int) ((grid.folderIconSizePx - grid.iconSizePx) / 2f));
         setText(info.title);
         setTag(info);
     }
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 70f0000..6e10175 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -207,7 +207,7 @@
 
         // Folder
         folderCellWidthPx = cellWidthPx + 3 * edgeMarginPx;
-        folderCellHeightPx = cellHeightPx + edgeMarginPx;
+        folderCellHeightPx = cellHeightPx + (int) ((3f/2f) * edgeMarginPx);
         folderBackgroundOffset = -edgeMarginPx;
         folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
     }
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index 5ce5571..b951100 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -137,7 +137,8 @@
                 // Otherwise, center the icon
                 int cHeight = mIsHotseatLayout ? grid.hotseatCellHeightPx : Math.min(getMeasuredHeight(), grid.cellHeightPx);
                 int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f));
-                child.setPadding(0, cellPaddingY, 0, 0);
+                int cellPaddingX = (int) (grid.edgeMarginPx / 2f);
+                child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
             }
         } else {
             lp.x = 0;