feat: Nova-style padding controls (#6872)

Adds user-configurable spacing controls (similar to Nova Launcher):

- Workspace padding: horizontal & vertical sliders (Home screen > Layout).
  Horizontal factor is applied to the source margin so cells fill the
  freed space; vertical factor preserves the dock reservation so the last
  row never overlaps the hotseat.
- Widget padding: slider (Home screen > Widgets), 0% removes the forced
  padding, up to 200%.
- App drawer top padding slider (App drawer > Grid).
- Widget resize: respect the overridden resize mode so force/unlimited
  resize shows handles even for widgets whose provider limits resizing.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
x-JOCandClaude Opus 4.8 authored and GitHub committed 2026-06-20 01:51:23 +08:00
1 parent 5d55b09657
commit 5de4bb09fa
7 files changed
+112 -2

No files matched your search

@@ -338,6 +338,10 @@ public class DeviceProfile {
private final TextFactors mTextFactors;
private float allAppsCellHeightMultiplier;
private float workspacePaddingHorizontalFactor;
private float workspacePaddingVerticalFactor;
private float widgetPaddingFactor;
private float drawerPaddingTopFactor;
private PreferenceManager2 preferenceManager2 = null;
/** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */
@@ -353,6 +357,16 @@ public class DeviceProfile {
preferenceManager2 = PreferenceManager2.INSTANCE.get(context);
allAppsCellHeightMultiplier = PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getDrawerCellHeightFactor());
// Lawnchair: clamp the user padding factors to their slider ranges so a restored or
// manually edited preference can't feed out-of-range values into the layout math.
workspacePaddingHorizontalFactor = Utilities.boundToRange(PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getWorkspacePaddingHorizontalFactor()), 0f, 2f);
workspacePaddingVerticalFactor = Utilities.boundToRange(PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getWorkspacePaddingVerticalFactor()), 0f, 2f);
widgetPaddingFactor = Utilities.boundToRange(PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getWidgetPaddingFactor()), 0f, 2f);
drawerPaddingTopFactor = Utilities.boundToRange(PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getDrawerPaddingTopFactor()), 1f, 2f);
this.inv = inv;
mDeviceProperties = DeviceProperties.Factory.createDeviceProperties(
@@ -636,6 +650,11 @@ public class DeviceProfile {
}
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
// Lawnchair: scale the horizontal workspace margin at the source so the cell layout
// width calculation uses the scaled value too. Otherwise cells keep their original
// width and get centered, leaving a visible side gap even at factor 0.
desiredWorkspaceHorizontalMarginPx =
Math.round(desiredWorkspaceHorizontalMarginPx * workspacePaddingHorizontalFactor);
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
splitPlaceholderInset = res.getDimensionPixelSize(R.dimen.split_placeholder_inset);
@@ -684,6 +703,9 @@ public class DeviceProfile {
allAppsShiftRange =
res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
}
// Lawnchair: extra user-configurable app drawer top padding. The factor is additive
// and slider-ranged 100%-200% (default 100%), so subtract 1f to keep 100% as no change.
allAppsPadding.top += Math.round(iconSizePx * (drawerPaddingTopFactor - 1f));
allAppsOpenDuration = res.getInteger(R.integer.config_allAppsOpenDuration);
allAppsCloseDuration = res.getInteger(R.integer.config_allAppsCloseDuration);
@@ -1350,6 +1372,11 @@ public class DeviceProfile {
} else {
widgetPadding.setEmpty();
}
// Lawnchair: scale widget padding by user factor (0 = remove, 1 = default).
widgetPadding.left = Math.round(widgetPadding.left * widgetPaddingFactor);
widgetPadding.right = Math.round(widgetPadding.right * widgetPaddingFactor);
widgetPadding.top = Math.round(widgetPadding.top * widgetPaddingFactor);
widgetPadding.bottom = Math.round(widgetPadding.bottom * widgetPaddingFactor);
}
/**
@@ -1718,6 +1745,16 @@ public class DeviceProfile {
paddingLeft = isSeascape() ? desiredWorkspaceHorizontalMarginPx : 0;
paddingRight = isSeascape() ? 0 : desiredWorkspaceHorizontalMarginPx;
}
// Lawnchair: scale vertical workspace padding by user factor.
// (Horizontal is applied at the source margin so the cells fill the freed space.)
// The dock (hotseatBarSizePx) reservation in the bottom padding must be preserved,
// otherwise reducing the factor pulls the last row into the dock and clips it.
paddingTop = Math.round(paddingTop * workspacePaddingVerticalFactor);
int bottomHotseatReserve = Math.min(hotseatBarSizePx, paddingBottom);
paddingBottom = bottomHotseatReserve
+ Math.round((paddingBottom - bottomHotseatReserve) * workspacePaddingVerticalFactor);
padding.set(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
insetPadding(workspacePadding, cellLayoutPaddingPx);