Home screen: side, top and bottom margins in dp
Settings, Home screen, Layout had Horizontal padding and Vertical padding, as percentages from 0 to 200. They scaled the grid's own margins, which on a phone are 8 dp at the sides and nothing at the top and bottom (measured on the emulator: desiredWorkspaceHorizontalMarginPx 21 px, workspace top and bottom padding 0). So the whole horizontal range moved the outer icons by a few dp and the vertical one did nothing at all, and the settings seemed broken. They are replaced by three sliders in dp (app.flexera.home.HomeMargins): Side margins (0 to 48, default 8, the grid's own), Top margin and Bottom margin (0 to 120, default 0, added to the grid's own). Rows and columns share the room that is left, so larger margins also bring the icons closer together. Rows that become too short get smaller icons, as Launcher3 already does; side margins are capped so that every column stays wider than what is seen of its icon plus 4 dp. The old factors are read as 1 from now on, so a value set with the old sliders no longer applies. Hooks: DeviceProfile (side margin where the grid's margin is set, top and bottom where the workspace padding is), PreferenceManager2 (three int preferences that reload the grid), HomeScreenPreferences (the sliders), each marked "Flexera Launcher:". Tested on the emulator: at the defaults the home screen is pixel for pixel as before (apart from clocks showing the time); 40, 48, 48 moves the columns in and the rows down and closer, with no overlap; back to 8, 0, 0 restores the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0b728199a
commit
ec5b36c482
5 files changed
+133
-18
No files matched your search
@@ -348,6 +348,10 @@ public class DeviceProfile {
|
||||
private float allAppsCellHeightMultiplier;
|
||||
private float workspacePaddingHorizontalFactor;
|
||||
private float workspacePaddingVerticalFactor;
|
||||
// Flexera Launcher: the home screen's margins in dp (app.flexera.home.HomeMargins).
|
||||
private int homeSideMarginDp;
|
||||
private int homeTopMarginDp;
|
||||
private int homeBottomMarginDp;
|
||||
private float widgetPaddingFactor;
|
||||
// Flexera Launcher: widgets lined up with the icons (app.flexera.widget.FlexeraWidgets).
|
||||
public boolean alignWidgetsWithIcons;
|
||||
@@ -369,10 +373,16 @@ public class DeviceProfile {
|
||||
.firstCached(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(PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getWorkspacePaddingHorizontalFactor()), 0f, 2f);
|
||||
workspacePaddingVerticalFactor = Utilities.boundToRange(PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getWorkspacePaddingVerticalFactor()), 0f, 2f);
|
||||
// Flexera Launcher: margins in dp take the place of these factors, which scaled margins
|
||||
// of 8 dp and nothing and so seemed to do nothing (app.flexera.home.HomeMargins).
|
||||
workspacePaddingHorizontalFactor = 1f;
|
||||
workspacePaddingVerticalFactor = 1f;
|
||||
homeSideMarginDp = PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getHomeSideMargin());
|
||||
homeTopMarginDp = PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getHomeTopMargin());
|
||||
homeBottomMarginDp = PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getHomeBottomMargin());
|
||||
widgetPaddingFactor = Utilities.boundToRange(PreferenceCacheExtensionsKt
|
||||
.firstCached(preferenceManager2.getWidgetPaddingFactor()), 0f, 2f);
|
||||
// Flexera Launcher: read with the grid, which the setting reloads when it changes.
|
||||
@@ -677,6 +687,13 @@ public class DeviceProfile {
|
||||
// width and get centered, leaving a visible side gap even at factor 0.
|
||||
desiredWorkspaceHorizontalMarginPx =
|
||||
Math.round(desiredWorkspaceHorizontalMarginPx * workspacePaddingHorizontalFactor);
|
||||
// Flexera Launcher: the owner's side margins (app.flexera.home.HomeMargins), except
|
||||
// beside a landscape phone's side bar, where the grid keeps none.
|
||||
if (!isVerticalBarLayout()) {
|
||||
desiredWorkspaceHorizontalMarginPx = app.flexera.home.HomeMargins.sidePx(
|
||||
homeSideMarginDp, mMetrics, mDeviceProperties.getAvailableWidthPx(),
|
||||
inv.numColumns, inv.iconSize[mTypeIndex]);
|
||||
}
|
||||
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
|
||||
|
||||
splitPlaceholderInset = res.getDimensionPixelSize(R.dimen.split_placeholder_inset);
|
||||
@@ -1801,6 +1818,9 @@ public class DeviceProfile {
|
||||
int bottomHotseatReserve = Math.min(hotseatBarSizePx, paddingBottom);
|
||||
paddingBottom = bottomHotseatReserve
|
||||
+ Math.round((paddingBottom - bottomHotseatReserve) * workspacePaddingVerticalFactor);
|
||||
// Flexera Launcher: the owner's top and bottom margins (app.flexera.home.HomeMargins).
|
||||
paddingTop += app.flexera.home.HomeMargins.topBottomPx(homeTopMarginDp, mMetrics);
|
||||
paddingBottom += app.flexera.home.HomeMargins.topBottomPx(homeBottomMarginDp, mMetrics);
|
||||
|
||||
padding.set(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user