launcher: create more space options

The grid doesn't have a constant space between cells anymore, so we need
new attributes for the different spaces in different situations.

Bug: 191879424
Test: checking cell size and extra space in dumpsys
Change-Id: I4b6aae5b3fea281490c00cd13d0cd3a25372f21b
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index ca3ce78..319c87d 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -191,7 +191,32 @@
         if not specified -->
         <attr name="twoPanelLandscapeMinCellWidthDps" format="float" />
 
-        <attr name="borderSpacingDps" format="float" />
+        <!-- These border spaces are only used if GridDisplayOption#isScalable is true -->
+        <!-- space to be used horizontally and vertically -->
+        <attr name="borderSpaceDps" format="float" />
+        <!-- space to the right of the cell, defaults to borderSpaceDps if not specified -->
+        <attr name="borderSpaceHorizontalDps" format="float" />
+        <!-- space below the cell, defaults to borderSpaceDps if not specified -->
+        <attr name="borderSpaceVerticalDps" format="float" />
+        <!-- space to be used horizontally and vertically in two panels,
+        defaults to borderSpaceDps if not specified -->
+        <attr name="twoPanelPortraitBorderSpaceDps" format="float" />
+        <!-- space to the right of the cell in two panels, defaults to
+        twoPanelPortraitBorderSpaceDps if not specified -->
+        <attr name="twoPanelPortraitBorderSpaceHorizontalDps" format="float" />
+        <!-- space below the cell in two panels, defaults to twoPanelPortraitBorderSpaceDps
+        if not specified -->
+        <attr name="twoPanelPortraitBorderSpaceVerticalDps" format="float" />
+        <!-- space to be used horizontally and vertically in two panels,
+        defaults to borderSpaceDps if not specified -->
+        <attr name="twoPanelLandscapeBorderSpaceDps" format="float" />
+        <!-- space to the right of the cell in two panels, defaults to
+        twoPanelLandscapeBorderSpaceDps if not specified -->
+        <attr name="twoPanelLandscapeBorderSpaceHorizontalDps" format="float" />
+        <!-- space below the cell in two panels, defaults to twoPanelLandscapeBorderSpaceDps
+        if not specified -->
+        <attr name="twoPanelLandscapeBorderSpaceVerticalDps" format="float" />
+
 
         <attr name="allAppsCellSpacingDps" format="float" />
 
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index fef3f8f..ebfd281 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -422,8 +422,8 @@
      */
     private void resizeWidgetIfNeeded(boolean onDismiss) {
         DeviceProfile dp = mLauncher.getDeviceProfile();
-        float xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacingPx;
-        float yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacingPx;
+        float xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacePx.x;
+        float yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacePx.y;
 
         int hSpanInc = getSpanIncrement((mDeltaX + mDeltaXAddOn) / xThreshold - mRunningHInc);
         int vSpanInc = getSpanIncrement((mDeltaY + mDeltaYAddOn) / yThreshold - mRunningVInc);
@@ -508,8 +508,8 @@
 
     private void onTouchUp() {
         DeviceProfile dp = mLauncher.getDeviceProfile();
-        int xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacingPx;
-        int yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacingPx;
+        int xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacePx.x;
+        int yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacePx.y;
 
         mDeltaXAddOn = mRunningHInc * xThreshold;
         mDeltaYAddOn = mRunningVInc * yThreshold;
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 28e3b9d..02eb1de 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -91,7 +91,7 @@
     private int mFixedCellWidth;
     private int mFixedCellHeight;
     @ViewDebug.ExportedProperty(category = "launcher")
-    private final int mBorderSpacing;
+    private final Point mBorderSpace;
 
     @ViewDebug.ExportedProperty(category = "launcher")
     private int mCountX;
@@ -236,9 +236,9 @@
         mActivity = ActivityContext.lookupContext(context);
         DeviceProfile deviceProfile = mActivity.getDeviceProfile();
 
-        mBorderSpacing = mContainerType == FOLDER
-                ? deviceProfile.folderCellLayoutBorderSpacingPx
-                : deviceProfile.cellLayoutBorderSpacingPx;
+        mBorderSpace = mContainerType == FOLDER
+                ? new Point(deviceProfile.folderCellLayoutBorderSpacePx)
+                : new Point(deviceProfile.cellLayoutBorderSpacePx);
 
         mCellWidth = mCellHeight = -1;
         mFixedCellWidth = mFixedCellHeight = -1;
@@ -308,7 +308,7 @@
 
         mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context, mContainerType);
         mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY,
-                mBorderSpacing);
+                mBorderSpace);
         addView(mShortcutsAndWidgets);
     }
 
@@ -368,7 +368,7 @@
         mFixedCellWidth = mCellWidth = width;
         mFixedCellHeight = mCellHeight = height;
         mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY,
-                mBorderSpacing);
+                mBorderSpace);
     }
 
     public void setGridSize(int x, int y) {
@@ -378,7 +378,7 @@
         mTmpOccupied = new GridOccupancy(mCountX, mCountY);
         mTempRectStack.clear();
         mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY,
-                mBorderSpacing);
+                mBorderSpace);
         requestLayout();
     }
 
@@ -541,9 +541,9 @@
         if (mVisualizeCells) {
             for (int i = 0; i < mCountX; i++) {
                 for (int j = 0; j < mCountY; j++) {
-                    int transX = i * mCellWidth + (i * mBorderSpacing) + getPaddingLeft()
+                    int transX = i * mCellWidth + (i * mBorderSpace.x) + getPaddingLeft()
                             + paddingX;
-                    int transY = j * mCellHeight + (j * mBorderSpacing) + getPaddingTop()
+                    int transY = j * mCellHeight + (j * mBorderSpace.y) + getPaddingTop()
                             + paddingY;
 
                     mVisualizeGridRect.offsetTo(transX, transY);
@@ -567,12 +567,12 @@
 
                 // TODO b/194414754 clean this up, reconcile with cellToRect
                 mVisualizeGridRect.set(paddingX, paddingY,
-                        mCellWidth * spanX + mBorderSpacing * (spanX - 1) - paddingX,
-                        mCellHeight * spanY + mBorderSpacing * (spanY - 1) - paddingY);
+                        mCellWidth * spanX + mBorderSpace.x * (spanX - 1) - paddingX,
+                        mCellHeight * spanY + mBorderSpace.y * (spanY - 1) - paddingY);
 
-                int transX = x * mCellWidth + (x * mBorderSpacing)
+                int transX = x * mCellWidth + (x * mBorderSpace.x)
                         + getPaddingLeft() + paddingX;
-                int transY = y * mCellHeight + (y * mBorderSpacing)
+                int transY = y * mCellHeight + (y * mBorderSpace.y)
                         + getPaddingTop() + paddingY;
 
                 mVisualizeGridRect.offsetTo(transX, transY);
@@ -858,15 +858,15 @@
         int childHeightSize = heightSize - (getPaddingTop() + getPaddingBottom());
 
         if (mFixedCellWidth < 0 || mFixedCellHeight < 0) {
-            int cw = DeviceProfile.calculateCellWidth(childWidthSize, mBorderSpacing,
+            int cw = DeviceProfile.calculateCellWidth(childWidthSize, mBorderSpace.x,
                     mCountX);
-            int ch = DeviceProfile.calculateCellHeight(childHeightSize, mBorderSpacing,
+            int ch = DeviceProfile.calculateCellHeight(childHeightSize, mBorderSpace.y,
                     mCountY);
             if (cw != mCellWidth || ch != mCellHeight) {
                 mCellWidth = cw;
                 mCellHeight = ch;
                 mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mCountX, mCountY,
-                        mBorderSpacing);
+                        mBorderSpace);
             }
         }
 
@@ -920,7 +920,7 @@
      */
     public int getUnusedHorizontalSpace() {
         return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth)
-                - ((mCountX - 1) * mBorderSpacing);
+                - ((mCountX - 1) * mBorderSpace.x);
     }
 
     @Override
@@ -2592,11 +2592,11 @@
                 + (int) Math.ceil(getUnusedHorizontalSpace() / 2f);
         final int vStartPadding = getPaddingTop();
 
-        int x = hStartPadding + (cellX * mBorderSpacing) + (cellX * cellWidth);
-        int y = vStartPadding + (cellY * mBorderSpacing) + (cellY * cellHeight);
+        int x = hStartPadding + (cellX * mBorderSpace.x) + (cellX * cellWidth);
+        int y = vStartPadding + (cellY * mBorderSpace.y) + (cellY * cellHeight);
 
-        int width = cellHSpan * cellWidth + ((cellHSpan - 1) * mBorderSpacing);
-        int height = cellVSpan * cellHeight + ((cellVSpan - 1) * mBorderSpacing);
+        int width = cellHSpan * cellWidth + ((cellHSpan - 1) * mBorderSpace.x);
+        int height = cellVSpan * cellHeight + ((cellVSpan - 1) * mBorderSpace.y);
 
         resultRect.set(x, y, x + width, y + height);
     }
@@ -2615,12 +2615,12 @@
 
     public int getDesiredWidth() {
         return getPaddingLeft() + getPaddingRight() + (mCountX * mCellWidth)
-                + ((mCountX - 1) * mBorderSpacing);
+                + ((mCountX - 1) * mBorderSpace.x);
     }
 
     public int getDesiredHeight()  {
         return getPaddingTop() + getPaddingBottom() + (mCountY * mCellHeight)
-                + ((mCountY - 1) * mBorderSpacing);
+                + ((mCountY - 1) * mBorderSpace.y);
     }
 
     public boolean isOccupied(int x, int y) {
@@ -2736,20 +2736,20 @@
         }
 
         public void setup(int cellWidth, int cellHeight, boolean invertHorizontally, int colCount,
-                int rowCount, int borderSpacing, @Nullable Rect inset) {
+                int rowCount, Point borderSpace, @Nullable Rect inset) {
             setup(cellWidth, cellHeight, invertHorizontally, colCount, rowCount, 1.0f, 1.0f,
-                    borderSpacing, inset);
+                    borderSpace, inset);
         }
 
         /**
-         * Use this method, as opposed to {@link #setup(int, int, boolean, int, int, int, Rect)},
+         * Use this method, as opposed to {@link #setup(int, int, boolean, int, int, Point, Rect)},
          * if the view needs to be scaled.
          *
          * ie. In multi-window mode, we setup widgets so that they are measured and laid out
          * using their full/invariant device profile sizes.
          */
         public void setup(int cellWidth, int cellHeight, boolean invertHorizontally, int colCount,
-                int rowCount, float cellScaleX, float cellScaleY, int borderSpacing,
+                int rowCount, float cellScaleX, float cellScaleY, Point borderSpace,
                 @Nullable Rect inset) {
             if (isLockedToGrid) {
                 final int myCellHSpan = cellHSpan;
@@ -2761,16 +2761,16 @@
                     myCellX = colCount - myCellX - cellHSpan;
                 }
 
-                int hBorderSpacing = (myCellHSpan - 1) * borderSpacing;
-                int vBorderSpacing = (myCellVSpan - 1) * borderSpacing;
+                int hBorderSpacing = (myCellHSpan - 1) * borderSpace.x;
+                int vBorderSpacing = (myCellVSpan - 1) * borderSpace.y;
 
                 float myCellWidth = ((myCellHSpan * cellWidth) + hBorderSpacing) / cellScaleX;
                 float myCellHeight = ((myCellVSpan * cellHeight) + vBorderSpacing) / cellScaleY;
 
                 width = Math.round(myCellWidth) - leftMargin - rightMargin;
                 height = Math.round(myCellHeight) - topMargin - bottomMargin;
-                x = leftMargin + (myCellX * cellWidth) + (myCellX * borderSpacing);
-                y = topMargin + (myCellY * cellHeight) + (myCellY * borderSpacing);
+                x = leftMargin + (myCellX * cellWidth) + (myCellX * borderSpace.x);
+                y = topMargin + (myCellY * cellHeight) + (myCellY * borderSpace.y);
 
                 if (inset != null) {
                     x -= inset.left;
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 07221fc..4e06ff9 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -99,8 +99,8 @@
     // Workspace
     public final int desiredWorkspaceHorizontalMarginOriginalPx;
     public int desiredWorkspaceHorizontalMarginPx;
-    public final int cellLayoutBorderSpacingOriginalPx;
-    public int cellLayoutBorderSpacingPx;
+    public Point cellLayoutBorderSpaceOriginalPx;
+    public Point cellLayoutBorderSpacePx;
     public final int cellLayoutPaddingLeftRightPx;
     public final int cellLayoutBottomPaddingPx;
     public final int edgeMarginPx;
@@ -137,7 +137,8 @@
     public int folderIconOffsetYPx;
 
     // Folder content
-    public int folderCellLayoutBorderSpacingPx;
+    public Point folderCellLayoutBorderSpacePx;
+    public int folderCellLayoutBorderSpaceOriginalPx;
     public int folderContentPaddingLeftRight;
     public int folderContentPaddingTop;
 
@@ -281,10 +282,12 @@
                 res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
         folderContentPaddingTop = res.getDimensionPixelSize(R.dimen.folder_content_padding_top);
 
-        setCellLayoutBorderSpacing(pxFromDp(inv.borderSpacing, mMetrics, 1f));
+        cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv);
         allAppsCellSpacingPx = pxFromDp(inv.allAppsCellSpacing, mMetrics, 1f);
-        cellLayoutBorderSpacingOriginalPx = cellLayoutBorderSpacingPx;
-        folderCellLayoutBorderSpacingPx = cellLayoutBorderSpacingPx;
+        cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
+        folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f);
+        folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
+                folderCellLayoutBorderSpaceOriginalPx);
 
         int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
                 ? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
@@ -479,8 +482,33 @@
         }
     }
 
-    private void setCellLayoutBorderSpacing(int borderSpacing) {
-        cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0;
+    private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
+        if (!isScalableGrid) {
+            return new Point(0, 0);
+        }
+
+        int horizontalSpacePx;
+        int verticalSpacePx;
+
+        if (isTwoPanels) {
+            if (isLandscape) {
+                horizontalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.x, mMetrics);
+                verticalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.y, mMetrics);
+            } else {
+                horizontalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.x, mMetrics);
+                verticalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.y, mMetrics);
+            }
+        } else {
+            horizontalSpacePx = pxFromDp(idp.borderSpace.x, mMetrics);
+            verticalSpacePx = pxFromDp(idp.borderSpace.y, mMetrics);
+        }
+
+        return new Point(horizontalSpacePx, verticalSpacePx);
+    }
+
+    private Point getCellLayoutBorderSpaceScaled(InvariantDeviceProfile idp, float scale) {
+        Point original = getCellLayoutBorderSpace(idp);
+        return new Point((int) (original.x * scale), (int) (original.y * scale));
     }
 
     public Info getDisplayInfo() {
@@ -497,10 +525,10 @@
         // Check all sides to ensure that the widget won't overlap into another cell, or into
         // status bar.
         return workspaceTopPadding > widgetPadding.top
-                && cellLayoutBorderSpacingPx > widgetPadding.left
-                && cellLayoutBorderSpacingPx > widgetPadding.top
-                && cellLayoutBorderSpacingPx > widgetPadding.right
-                && cellLayoutBorderSpacingPx > widgetPadding.bottom;
+                && cellLayoutBorderSpacePx.x > widgetPadding.left
+                && cellLayoutBorderSpacePx.y > widgetPadding.top
+                && cellLayoutBorderSpacePx.x > widgetPadding.right
+                && cellLayoutBorderSpacePx.y > widgetPadding.bottom;
     }
 
     public Builder toBuilder(Context context) {
@@ -600,7 +628,7 @@
             // devices.
             int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
             float usedWidth = (cellWidthPx * numColumns)
-                    + (cellLayoutBorderSpacingPx * (numColumns - 1))
+                    + (cellLayoutBorderSpacePx.x * (numColumns - 1))
                     + (desiredWorkspaceHorizontalMarginPx * 2);
             // We do not subtract padding here, as we also scale the workspace padding if needed.
             scaleX = availableWidthPx / usedWidth;
@@ -618,7 +646,7 @@
     }
 
     private int getCellLayoutHeight() {
-        return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacingPx * (inv.numRows - 1));
+        return (cellHeightPx * inv.numRows) + (cellLayoutBorderSpacePx.y * (inv.numRows - 1));
     }
 
     /**
@@ -658,7 +686,7 @@
         iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale);
         iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
 
-        setCellLayoutBorderSpacing((int) (cellLayoutBorderSpacingOriginalPx * scale));
+        cellLayoutBorderSpacePx = getCellLayoutBorderSpaceScaled(inv, scale);
 
         if (isScalableGrid) {
             PointF minCellHeightAndWidth = getMinCellHeightAndWidth();
@@ -757,14 +785,14 @@
 
         // Check if the icons fit within the available height.
         float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
-                + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacingPx);
+                + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx.y);
         int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderBottomPanelSize
                 - folderMargin - folderContentPaddingTop;
         float scaleY = contentMaxHeight / contentUsedHeight;
 
         // Check if the icons fit within the available width.
         float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
-                + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacingPx);
+                + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x);
         int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
                 - folderContentPaddingLeftRight * 2;
         float scaleX = contentMaxWidth / contentUsedWidth;
@@ -790,10 +818,10 @@
             folderCellWidthPx = (int) Math.max(minWidth, cellWidthPx * scale);
             folderCellHeightPx = (int) Math.max(minHeight, cellHeightPx * scale);
 
-            int borderSpacing = (int) (cellLayoutBorderSpacingOriginalPx * scale);
-            folderCellLayoutBorderSpacingPx = borderSpacing;
-            folderContentPaddingLeftRight = borderSpacing;
-            folderContentPaddingTop = borderSpacing;
+            int scaledSpace = (int) (folderCellLayoutBorderSpaceOriginalPx * scale);
+            folderCellLayoutBorderSpacePx = new Point(scaledSpace, scaledSpace);
+            folderContentPaddingLeftRight = scaledSpace;
+            folderContentPaddingTop = scaledSpace;
         } else {
             int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding)
                     * scale);
@@ -838,9 +866,9 @@
         int cellLayoutTotalPadding =
                 isTwoPanels ? 4 * cellLayoutPaddingLeftRightPx : 2 * cellLayoutPaddingLeftRightPx;
         int screenWidthPx = availableWidthPx - padding.x - cellLayoutTotalPadding;
-        result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacingPx, numColumns);
+        result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacePx.x, numColumns);
         result.y = calculateCellHeight(availableHeightPx - padding.y
-                - cellLayoutBottomPaddingPx, cellLayoutBorderSpacingPx, inv.numRows);
+                - cellLayoutBottomPaddingPx, cellLayoutBorderSpacePx.y, inv.numRows);
         return result;
     }
 
@@ -1097,11 +1125,18 @@
         writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
         writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
                 folderChildDrawablePaddingPx));
-        writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacingPx",
-                folderCellLayoutBorderSpacingPx));
+        writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpaceOriginalPx",
+                folderCellLayoutBorderSpaceOriginalPx));
+        writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx Horizontal",
+                folderCellLayoutBorderSpacePx.x));
+        writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx Vertical",
+                folderCellLayoutBorderSpacePx.y));
 
-        writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
-                cellLayoutBorderSpacingPx));
+        writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Horizontal",
+                cellLayoutBorderSpacePx.x));
+        writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
+                cellLayoutBorderSpacePx.y));
+
         writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
                 desiredWorkspaceHorizontalMarginPx));
 
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 92cc9e8..cfc14b6 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -31,6 +31,7 @@
 import android.content.res.TypedArray;
 import android.content.res.XmlResourceParser;
 import android.graphics.Point;
+import android.graphics.PointF;
 import android.graphics.Rect;
 import android.text.TextUtils;
 import android.util.AttributeSet;
@@ -117,7 +118,12 @@
     public float twoPanelPortraitMinCellWidthDps;
     public float twoPanelLandscapeMinCellHeightDps;
     public float twoPanelLandscapeMinCellWidthDps;
-    public float borderSpacing;
+
+    public PointF borderSpace;
+    public PointF twoPanelPortraitBorderSpace;
+    public PointF twoPanelLandscapeBorderSpace;
+    public float folderBorderSpace;
+
     public float horizontalMargin;
     public float twoPanelLandscapeHorizontalMargin;
     public float twoPanelPortraitHorizontalMargin;
@@ -217,15 +223,15 @@
                 .add(myDisplayOption);
         result.iconSizes[DisplayOption.INDEX_DEFAULT] =
                 defaultDisplayOption.iconSizes[DisplayOption.INDEX_DEFAULT];
-        for (int i = 1; i < DisplayOption.COUNT_TOTAL; i++) {
+        for (int i = 1; i < DisplayOption.COUNT_SIZES; i++) {
             result.iconSizes[i] = Math.min(
                     defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]);
         }
 
         result.minCellHeight = defaultDisplayOption.minCellHeight;
         result.minCellWidth = defaultDisplayOption.minCellWidth;
-        result.borderSpacing = defaultDisplayOption.borderSpacing;
-        result.allAppsCellSpacing = defaultDisplayOption.allAppsCellSpacing;
+        result.borderSpaces[DisplayOption.INDEX_ALL_APPS] =
+                defaultDisplayOption.borderSpaces[DisplayOption.INDEX_ALL_APPS];
 
         initGrid(context, myInfo, result, false);
     }
@@ -289,8 +295,14 @@
         twoPanelPortraitMinCellWidthDps = displayOption.twoPanelPortraitMinCellWidthDps;
         twoPanelLandscapeMinCellHeightDps = displayOption.twoPanelLandscapeMinCellHeightDps;
         twoPanelLandscapeMinCellWidthDps = displayOption.twoPanelLandscapeMinCellWidthDps;
-        borderSpacing = displayOption.borderSpacing;
-        allAppsCellSpacing = displayOption.allAppsCellSpacing;
+
+        borderSpace = displayOption.borderSpaces[DisplayOption.INDEX_DEFAULT];
+        twoPanelPortraitBorderSpace =
+                displayOption.borderSpaces[DisplayOption.INDEX_TWO_PANEL_PORTRAIT];
+        twoPanelLandscapeBorderSpace =
+                displayOption.borderSpaces[DisplayOption.INDEX_TWO_PANEL_LANDSCAPE];
+        allAppsCellSpacing = displayOption.borderSpaces[DisplayOption.INDEX_ALL_APPS].x;
+        folderBorderSpace = displayOption.folderBorderSpace;
 
         horizontalMargin = displayOption.horizontalMargin;
         twoPanelLandscapeHorizontalMargin = displayOption.twoPanelLandscapeHorizontalMargin;
@@ -556,7 +568,7 @@
         // predefined size to avoid cache invalidation
         out.iconSizes[DisplayOption.INDEX_DEFAULT] =
                 closestPoint.iconSizes[DisplayOption.INDEX_DEFAULT];
-        for (int i = DisplayOption.INDEX_DEFAULT + 1; i < DisplayOption.COUNT_TOTAL; i++) {
+        for (int i = DisplayOption.INDEX_DEFAULT + 1; i < DisplayOption.COUNT_SIZES; i++) {
             out.iconSizes[i] = Math.min(out.iconSizes[i],
                     out.iconSizes[DisplayOption.INDEX_DEFAULT]);
         }
@@ -712,13 +724,12 @@
     @VisibleForTesting
     static final class DisplayOption {
 
+        static final int COUNT_SIZES = 5;
         static final int INDEX_DEFAULT = 0;
         static final int INDEX_LANDSCAPE = 1;
-        static final int INDEX_ALL_APPS = 2;
-        static final int INDEX_TWO_PANEL_PORTRAIT = 3;
-        static final int INDEX_TWO_PANEL_LANDSCAPE = 4;
-
-        static final int COUNT_TOTAL = 5;
+        static final int INDEX_TWO_PANEL_PORTRAIT = 2;
+        static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
+        static final int INDEX_ALL_APPS = 4;
 
         public final GridOption grid;
 
@@ -732,15 +743,16 @@
         private float twoPanelPortraitMinCellWidthDps;
         private float twoPanelLandscapeMinCellHeightDps;
         private float twoPanelLandscapeMinCellWidthDps;
-        private float allAppsCellSpacing;
-        private float borderSpacing;
+
+        private float folderBorderSpace;
+        private final PointF[] borderSpaces = new PointF[COUNT_SIZES];
 
         private float horizontalMargin;
         private float twoPanelLandscapeHorizontalMargin;
         private float twoPanelPortraitHorizontalMargin;
 
-        private final float[] iconSizes = new float[COUNT_TOTAL];
-        private final float[] textSizes = new float[COUNT_TOTAL];
+        private final float[] iconSizes = new float[COUNT_SIZES];
+        private final float[] textSizes = new float[COUNT_SIZES];
 
         DisplayOption(GridOption grid, Context context, AttributeSet attrs, int defaultFlagValue) {
             this.grid = grid;
@@ -767,9 +779,40 @@
             twoPanelLandscapeMinCellWidthDps = a.getFloat(
                     R.styleable.ProfileDisplayOption_twoPanelLandscapeMinCellWidthDps,
                     twoPanelPortraitMinCellWidthDps);
-            borderSpacing = a.getFloat(R.styleable.ProfileDisplayOption_borderSpacingDps, 0);
-            allAppsCellSpacing = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellSpacingDps,
-                    borderSpacing);
+
+            float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceDps, 0);
+            float twoPanelPortraitBorderSpaceDps = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelPortraitBorderSpaceDps, borderSpace);
+            float twoPanelLandscapeBorderSpaceDps = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelLandscapeBorderSpaceDps, borderSpace);
+            float x;
+            float y;
+
+            x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontalDps, borderSpace);
+            y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVerticalDps, borderSpace);
+            borderSpaces[INDEX_DEFAULT] = new PointF(x, y);
+            borderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
+
+            x = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelPortraitBorderSpaceHorizontalDps,
+                    twoPanelPortraitBorderSpaceDps);
+            y = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelPortraitBorderSpaceVerticalDps,
+                    twoPanelPortraitBorderSpaceDps);
+            borderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
+
+            x = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelLandscapeBorderSpaceHorizontalDps,
+                    twoPanelLandscapeBorderSpaceDps);
+            y = a.getFloat(
+                    R.styleable.ProfileDisplayOption_twoPanelLandscapeBorderSpaceVerticalDps,
+                    twoPanelLandscapeBorderSpaceDps);
+            borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
+
+            x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsCellSpacingDps,
+                    borderSpace);
+            borderSpaces[INDEX_ALL_APPS] = new PointF(x, y);
+            folderBorderSpace = borderSpace;
 
             iconSizes[INDEX_DEFAULT] =
                     a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0);
@@ -823,13 +866,19 @@
             canBeDefault = false;
             minCellHeight = 0;
             minCellWidth = 0;
-            borderSpacing = 0;
+            for (int i = 0; i < COUNT_SIZES; i++) {
+                iconSizes[i] = 0;
+                textSizes[i] = 0;
+                borderSpaces[i] = new PointF();
+            }
         }
 
         private DisplayOption multiply(float w) {
-            for (int i = 0; i < COUNT_TOTAL; i++) {
+            for (int i = 0; i < COUNT_SIZES; i++) {
                 iconSizes[i] *= w;
                 textSizes[i] *= w;
+                borderSpaces[i].x *=  w;
+                borderSpaces[i].y *=  w;
             }
             minCellHeight *= w;
             minCellWidth *= w;
@@ -837,8 +886,9 @@
             twoPanelPortraitMinCellWidthDps *= w;
             twoPanelLandscapeMinCellHeightDps *= w;
             twoPanelLandscapeMinCellWidthDps *= w;
-            borderSpacing *= w;
-            allAppsCellSpacing *= w;
+
+            folderBorderSpace *= w;
+
             horizontalMargin *= w;
             twoPanelLandscapeHorizontalMargin *= w;
             twoPanelPortraitHorizontalMargin *= w;
@@ -846,9 +896,11 @@
         }
 
         private DisplayOption add(DisplayOption p) {
-            for (int i = 0; i < COUNT_TOTAL; i++) {
+            for (int i = 0; i < COUNT_SIZES; i++) {
                 iconSizes[i] += p.iconSizes[i];
                 textSizes[i] += p.textSizes[i];
+                borderSpaces[i].x +=  p.borderSpaces[i].x;
+                borderSpaces[i].y +=  p.borderSpaces[i].y;
             }
             minCellHeight += p.minCellHeight;
             minCellWidth += p.minCellWidth;
@@ -856,8 +908,9 @@
             twoPanelPortraitMinCellWidthDps += p.twoPanelPortraitMinCellWidthDps;
             twoPanelLandscapeMinCellHeightDps += p.twoPanelLandscapeMinCellHeightDps;
             twoPanelLandscapeMinCellWidthDps += p.twoPanelLandscapeMinCellWidthDps;
-            borderSpacing += p.borderSpacing;
-            allAppsCellSpacing += p.allAppsCellSpacing;
+
+            folderBorderSpace += p.folderBorderSpace;
+
             horizontalMargin += p.horizontalMargin;
             twoPanelLandscapeHorizontalMargin += p.twoPanelLandscapeHorizontalMargin;
             twoPanelPortraitHorizontalMargin += p.twoPanelPortraitHorizontalMargin;
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index bebbf4f..fec1d68 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -23,6 +23,7 @@
 
 import android.app.WallpaperManager;
 import android.content.Context;
+import android.graphics.Point;
 import android.graphics.Rect;
 import android.view.MotionEvent;
 import android.view.View;
@@ -48,7 +49,7 @@
 
     private int mCellWidth;
     private int mCellHeight;
-    private int mBorderSpacing;
+    private Point mBorderSpace;
 
     private int mCountX;
     private int mCountY;
@@ -64,12 +65,12 @@
     }
 
     public void setCellDimensions(int cellWidth, int cellHeight, int countX, int countY,
-            int borderSpacing) {
+            Point borderSpace) {
         mCellWidth = cellWidth;
         mCellHeight = cellHeight;
         mCountX = countX;
         mCountY = countY;
-        mBorderSpacing = borderSpacing;
+        mBorderSpace = borderSpace;
     }
 
     public View getChildAt(int cellX, int cellY) {
@@ -108,10 +109,10 @@
             DeviceProfile profile = mActivity.getDeviceProfile();
             ((NavigableAppWidgetHostView) child).getWidgetInset(profile, mTempRect);
             lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
-                    profile.appWidgetScale.x, profile.appWidgetScale.y, mBorderSpacing, mTempRect);
+                    profile.appWidgetScale.x, profile.appWidgetScale.y, mBorderSpace, mTempRect);
         } else {
             lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
-                    mBorderSpacing, null);
+                    mBorderSpace, null);
         }
     }
 
@@ -132,10 +133,10 @@
         if (child instanceof NavigableAppWidgetHostView) {
             ((NavigableAppWidgetHostView) child).getWidgetInset(dp, mTempRect);
             lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
-                    dp.appWidgetScale.x, dp.appWidgetScale.y, mBorderSpacing, mTempRect);
+                    dp.appWidgetScale.x, dp.appWidgetScale.y, mBorderSpace, mTempRect);
         } else {
             lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
-                    mBorderSpacing, null);
+                    mBorderSpace, null);
             // Center the icon/folder
             int cHeight = getCellContentHeight();
             int cellPaddingY = dp.isScalableGrid && mContainerType == WORKSPACE
@@ -143,8 +144,9 @@
                     : (int) Math.max(0, ((lp.height - cHeight) / 2f));
 
             // No need to add padding when cell layout border spacing is present.
-            boolean noPaddingX = (dp.cellLayoutBorderSpacingPx > 0 && mContainerType == WORKSPACE)
-                    || (dp.folderCellLayoutBorderSpacingPx > 0 && mContainerType == FOLDER);
+            boolean noPaddingX =
+                    (dp.cellLayoutBorderSpacePx.x > 0 && mContainerType == WORKSPACE)
+                            || (dp.folderCellLayoutBorderSpacePx.x > 0 && mContainerType == FOLDER);
             int cellPaddingX = noPaddingX
                     ? 0
                     : mContainerType == WORKSPACE
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 6ce2930..8d6476b 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -345,12 +345,12 @@
             // Add missing cellLayout border in-between panels.
             if (panelCount > 1) {
                 if (i % panelCount == leftPanelModulus) {
-                    paddingRight += grid.cellLayoutBorderSpacingPx / 2;
+                    paddingRight += grid.cellLayoutBorderSpacePx.x / 2;
                 } else if (i % panelCount == rightPanelModulus) { // right side panel
-                    paddingLeft += grid.cellLayoutBorderSpacingPx / 2;
+                    paddingLeft += grid.cellLayoutBorderSpacePx.x / 2;
                 } else { // middle panel
-                    paddingLeft += grid.cellLayoutBorderSpacingPx / 2;
-                    paddingRight += grid.cellLayoutBorderSpacingPx / 2;
+                    paddingLeft += grid.cellLayoutBorderSpacePx.x / 2;
+                    paddingRight += grid.cellLayoutBorderSpacePx.x / 2;
                 }
             }
             // SparseArrayMap doesn't keep the order
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index 2491217..4c5a9e6 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -105,8 +105,8 @@
         int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft()
                 - mAppsView.getActiveRecyclerView().getPaddingRight();
 
-        int cellWidth = DeviceProfile.calculateCellWidth(rowWidth, dp.cellLayoutBorderSpacingPx,
-                dp.numShownHotseatIcons);
+        int cellWidth = DeviceProfile.calculateCellWidth(rowWidth,
+                dp.cellLayoutBorderSpacePx.x, dp.numShownHotseatIcons);
         int iconVisibleSize = Math.round(ICON_VISIBLE_AREA_FACTOR * dp.iconSizePx);
         int iconPadding = cellWidth - iconVisibleSize;
 
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java
index cb3884d..399d142 100644
--- a/src/com/android/launcher3/folder/FolderAnimationManager.java
+++ b/src/com/android/launcher3/folder/FolderAnimationManager.java
@@ -239,9 +239,9 @@
                 mFolder, startRect, endRect, finalRadius, !mIsOpening));
 
         // Create reveal animator for the folder content (capture the top 4 icons 2x2)
-        int width = mDeviceProfile.folderCellLayoutBorderSpacingPx
+        int width = mDeviceProfile.folderCellLayoutBorderSpacePx.x
                 + mDeviceProfile.folderCellWidthPx * 2;
-        int height = mDeviceProfile.folderCellLayoutBorderSpacingPx
+        int height = mDeviceProfile.folderCellLayoutBorderSpacePx.y
                 + mDeviceProfile.folderCellHeightPx * 2;
         int page = mIsOpening ? mContent.getCurrentPage() : mContent.getDestinationPage();
         int left = mContent.getPaddingLeft() + page * lp.width;
diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
index 468cb55..73e18f4 100644
--- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
+++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
@@ -230,15 +230,16 @@
         CellLayout firstScreen = mRootView.findViewById(R.id.workspace);
         firstScreen.setPadding(mDp.workspacePadding.left + mDp.cellLayoutPaddingLeftRightPx,
                 mDp.workspacePadding.top,
-                (mDp.isTwoPanels ? mDp.cellLayoutBorderSpacingPx / 2 : mDp.workspacePadding.right)
-                        + mDp.cellLayoutPaddingLeftRightPx,
-                mDp.workspacePadding.bottom);
+                (mDp.isTwoPanels ? mDp.cellLayoutBorderSpacePx.x / 2
+                        : mDp.workspacePadding.right) + mDp.cellLayoutPaddingLeftRightPx,
+                mDp.workspacePadding.bottom
+        );
         mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
 
         if (mDp.isTwoPanels) {
             CellLayout rightPanel = mRootView.findViewById(R.id.workspace_right);
             rightPanel.setPadding(
-                    mDp.cellLayoutBorderSpacingPx / 2 + mDp.cellLayoutPaddingLeftRightPx,
+                    mDp.cellLayoutBorderSpacePx.x / 2 + mDp.cellLayoutPaddingLeftRightPx,
                     mDp.workspacePadding.top,
                     mDp.workspacePadding.right + mDp.cellLayoutPaddingLeftRightPx,
                     mDp.workspacePadding.bottom
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 8a494ba..743fd4d 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -1050,7 +1050,10 @@
             deviceProfile.getCellSize(cellSize);
             FileLog.d(TAG, "DeviceProfile available width: " + deviceProfile.availableWidthPx
                     + ", available height: " + deviceProfile.availableHeightPx
-                    + ", cellLayoutBorderSpacingPx: " + deviceProfile.cellLayoutBorderSpacingPx
+                    + ", cellLayoutBorderSpacePx Horizontal: "
+                    + deviceProfile.cellLayoutBorderSpacePx.x
+                    + ", cellLayoutBorderSpacePx Vertical: "
+                    + deviceProfile.cellLayoutBorderSpacePx.y
                     + ", cellSize: " + cellSize);
         }
 
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java
index d77d99d..bba1016 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java
@@ -121,29 +121,29 @@
                 localPadding.set(widgetPadding);
             }
             minSpanX = Math.max(minSpanX,
-                    getSpanX(localPadding, minResizeWidth, dp.cellLayoutBorderSpacingPx,
+                    getSpanX(localPadding, minResizeWidth, dp.cellLayoutBorderSpacePx.x,
                             cellSize.x));
             minSpanY = Math.max(minSpanY,
-                    getSpanY(localPadding, minResizeHeight, dp.cellLayoutBorderSpacingPx,
+                    getSpanY(localPadding, minResizeHeight, dp.cellLayoutBorderSpacePx.y,
                             cellSize.y));
 
             if (ATLEAST_S) {
                 if (maxResizeWidth > 0) {
-                    maxSpanX = Math.min(maxSpanX,
-                            getSpanX(localPadding, maxResizeWidth, dp.cellLayoutBorderSpacingPx,
-                                    cellSize.x));
+                    maxSpanX = Math.min(maxSpanX, getSpanX(localPadding, maxResizeWidth,
+                            dp.cellLayoutBorderSpacePx.x, cellSize.x));
                 }
                 if (maxResizeHeight > 0) {
-                    maxSpanY = Math.min(maxSpanY,
-                            getSpanY(localPadding, maxResizeHeight, dp.cellLayoutBorderSpacingPx,
-                                    cellSize.y));
+                    maxSpanY = Math.min(maxSpanY, getSpanY(localPadding, maxResizeHeight,
+                            dp.cellLayoutBorderSpacePx.y, cellSize.y));
                 }
             }
 
             spanX = Math.max(spanX,
-                    getSpanX(localPadding, minWidth, dp.cellLayoutBorderSpacingPx, cellSize.x));
+                    getSpanX(localPadding, minWidth, dp.cellLayoutBorderSpacePx.x,
+                            cellSize.x));
             spanY = Math.max(spanY,
-                    getSpanY(localPadding, minHeight, dp.cellLayoutBorderSpacingPx, cellSize.y));
+                    getSpanY(localPadding, minHeight, dp.cellLayoutBorderSpacePx.y,
+                            cellSize.y));
         }
 
         if (ATLEAST_S) {
diff --git a/src/com/android/launcher3/widget/util/WidgetSizes.java b/src/com/android/launcher3/widget/util/WidgetSizes.java
index b211f4c..fb2d63b 100644
--- a/src/com/android/launcher3/widget/util/WidgetSizes.java
+++ b/src/com/android/launcher3/widget/util/WidgetSizes.java
@@ -114,8 +114,8 @@
 
     private static Size getWidgetSizePx(DeviceProfile profile, int spanX, int spanY,
             @Nullable Point recycledCellSize) {
-        final int hBorderSpacing = (spanX - 1) * profile.cellLayoutBorderSpacingPx;
-        final int vBorderSpacing = (spanY - 1) * profile.cellLayoutBorderSpacingPx;
+        final int hBorderSpacing = (spanX - 1) * profile.cellLayoutBorderSpacePx.x;
+        final int vBorderSpacing = (spanY - 1) * profile.cellLayoutBorderSpacePx.y;
         if (recycledCellSize == null) {
             recycledCellSize = new Point();
         }
diff --git a/tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java b/tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java
index 24ae583..b534a41 100644
--- a/tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java
+++ b/tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java
@@ -46,6 +46,7 @@
 @RunWith(AndroidJUnit4.class)
 public final class LauncherAppWidgetProviderInfoTest {
 
+    private static final int SPACE_SIZE = 10;
     private static final int CELL_SIZE = 50;
     private static final int NUM_OF_COLS = 4;
     private static final int NUM_OF_ROWS = 5;
@@ -159,7 +160,7 @@
         AppWidgetHostView.getDefaultPaddingForWidget(mContext, null, padding);
         int maxPadding = Math.max(Math.max(padding.left, padding.right),
                 Math.max(padding.top, padding.bottom));
-        dp.cellLayoutBorderSpacingPx = maxPadding + 1;
+        dp.cellLayoutBorderSpacePx.x = dp.cellLayoutBorderSpacePx.y = maxPadding + 1;
         Mockito.when(dp.shouldInsetWidgets()).thenReturn(true);
 
         LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
@@ -182,7 +183,7 @@
         AppWidgetHostView.getDefaultPaddingForWidget(mContext, null, padding);
         int maxPadding = Math.max(Math.max(padding.left, padding.right),
                 Math.max(padding.top, padding.bottom));
-        dp.cellLayoutBorderSpacingPx = maxPadding - 1;
+        dp.cellLayoutBorderSpacePx.x = dp.cellLayoutBorderSpacePx.y = maxPadding - 1;
         Mockito.when(dp.shouldInsetWidgets()).thenReturn(false);
         LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
         info.minWidth = CELL_SIZE * 3;
@@ -262,6 +263,7 @@
             return null;
         }).when(profile).getCellSize(any(Point.class));
         Mockito.when(profile.getCellSize()).thenReturn(new Point(CELL_SIZE, CELL_SIZE));
+        profile.cellLayoutBorderSpacePx = new Point(SPACE_SIZE, SPACE_SIZE);
         Mockito.when(profile.shouldInsetWidgets()).thenReturn(true);
 
         InvariantDeviceProfile idp = new InvariantDeviceProfile();