Ensuring that we give a widget the full space requested

Change-Id: I03ca7be47e427373f1efdad3f97d18db9bd3b913
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index b26e3ac..489f3fb 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1048,7 +1048,17 @@
 
         // Calculate the grid spans needed to fit this widget
         CellLayout layout = (CellLayout) mWorkspace.getChildAt(screen);
-        int[] spanXY = layout.rectToCell(appWidgetInfo.minWidth, appWidgetInfo.minHeight, null);
+
+        // We want to account for the extra amount of padding that we are adding to the widget
+        // to ensure that it gets the full amount of space that it has requested
+        Resources r = getResources();
+        int requiredWidth = appWidgetInfo.minWidth +
+                r.getDimensionPixelSize(R.dimen.app_widget_padding_left) +
+                r.getDimensionPixelSize(R.dimen.app_widget_padding_right);
+        int requiredHeight = appWidgetInfo.minHeight + 
+                r.getDimensionPixelSize(R.dimen.app_widget_padding_top) +
+                r.getDimensionPixelSize(R.dimen.app_widget_padding_bottom);
+        int[] spanXY = layout.rectToCell(requiredWidth, requiredHeight, null);
 
         // Try finding open space on Launcher screen
         // We have saved the position to which the widget was dragged-- this really only matters