Use grid border spacing as widget padding if possible.
Widget padding is added by the system to create reliable consistency
between widgets.
Now that we have added border spacing between cells on the launcher
grid, we have significantly decreased the available space for widgets
on home screens: widget padding is 8dp on all sides, border spacing is
currently spec'd to be 16dp.
We can inset the widget padding added by the system, and instead rely
on the border spacing between cells to create reliable consistency
between widgets.
Bug: 175329686
Test: manual
turn CellLayout#VISUALIZE_GRID debug flag on
test drag and drop, resizing using drag handles
view measurements in go/web-hv
Change-Id: Iabb9f45e82e4ae039f55d7fd27fbd0d23be60191
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 7a9f852..7beea74 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -331,6 +331,19 @@
}
}
+ /**
+ * We inset the widget padding added by the system and instead rely on the border spacing
+ * between cells to create reliable consistency between widgets
+ */
+ public boolean shouldInsetWidgets() {
+ Rect widgetPadding = inv.defaultWidgetPadding;
+
+ // Check all sides to ensure that the widget won't overlap into another cell.
+ return cellLayoutBorderSpacingPx > widgetPadding.left
+ && cellLayoutBorderSpacingPx > widgetPadding.top
+ && cellLayoutBorderSpacingPx > widgetPadding.right
+ && cellLayoutBorderSpacingPx > widgetPadding.bottom;
+ }
public Builder toBuilder(Context context) {
Point size = new Point(availableWidthPx, availableHeightPx);