From db6c43f2390f398553bd178e0d7bde606cb1b779 Mon Sep 17 00:00:00 2001 From: Patryk Michalik Date: Wed, 3 Nov 2021 14:00:03 +0100 Subject: [PATCH] Add ability to change height of rows in App Drawer --- lawnchair/res/values/strings.xml | 1 + .../src/app/lawnchair/preferences/PreferenceManager.kt | 1 + .../lawnchair/ui/preferences/AppDrawerPreferences.kt | 7 +++++++ src/com/android/launcher3/DeviceProfile.java | 10 +++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml index 7d5050872a..90cdfa6e9a 100644 --- a/lawnchair/res/values/strings.xml +++ b/lawnchair/res/values/strings.xml @@ -197,4 +197,5 @@ Show Shortcuts for Apps and People Shortcuts Pixel Tips + Row Height diff --git a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt index fe482415b1..a796e64ebf 100644 --- a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt +++ b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt @@ -126,6 +126,7 @@ class PreferenceManager private constructor(private val context: Context) : Base val themedIcons = BoolPref("themed_icons", false) val hotseatQsbCornerRadius = FloatPref("pref_hotseatQsbCornerRadius", 1F, recreate) val themedHotseatQsb = BoolPref("pref_themedHotseatQsb", false) + val allAppsCellHeightMultiplier = FloatPref("pref_allAppsCellHeightMultiplier", 1F, reloadGrid) init { sp.registerOnSharedPreferenceChangeListener(this) diff --git a/lawnchair/src/app/lawnchair/ui/preferences/AppDrawerPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/AppDrawerPreferences.kt index 787a7a5679..86bc462c63 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/AppDrawerPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/AppDrawerPreferences.kt @@ -118,6 +118,13 @@ fun AppDrawerPreferences() { step = 1, valueRange = 3..10, ) + SliderPreference( + label = stringResource(id = R.string.row_height_label), + adapter = prefs.allAppsCellHeightMultiplier.getAdapter(), + valueRange = 0.7F..1.5F, + step = 0.1F, + showAsPercentage = true + ) } PreferenceGroup(heading = stringResource(id = R.string.icons)) { SliderPreference( diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index b7fe20689d..be43e855b4 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -179,6 +179,7 @@ public class DeviceProfile { public int allAppsIconDrawablePaddingPx; public final int numShownAllAppsColumns; public float allAppsIconTextSizePx; + private float allAppsCellHeightMultiplier; // Overview public int overviewTaskMarginPx; @@ -222,6 +223,9 @@ public class DeviceProfile { boolean useTwoPanels) { mContext = context; + PreferenceManager pm = PreferenceManager.INSTANCE.get(context); + allAppsCellHeightMultiplier = pm.getAllAppsCellHeightMultiplier().get(); + this.inv = inv; this.isLandscape = windowBounds.isLandscape(); this.isMultiWindowMode = isMultiWindowMode; @@ -538,12 +542,12 @@ public class DeviceProfile { public void autoResizeAllAppsCells() { int textHeight = Utilities.calculateTextHeight(allAppsIconTextSizePx); int topBottomPadding = textHeight; - allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx - + textHeight + (topBottomPadding * 2); + int baseCellHeight = allAppsIconSizePx + allAppsIconDrawablePaddingPx + textHeight + (topBottomPadding * 2); + allAppsCellHeightPx = (int) (baseCellHeight * allAppsCellHeightMultiplier); if (allAppsIconTextSizePx == 0) { int leftRightPadding = desiredWorkspaceLeftRightMarginPx + cellLayoutPaddingLeftRightPx; int drawerWidth = availableWidthPx - leftRightPadding * 2; - allAppsCellHeightPx = drawerWidth / inv.numAllAppsColumns; + allAppsCellHeightPx = (int) (drawerWidth / inv.numAllAppsColumns * allAppsCellHeightMultiplier); allAppsIconDrawablePaddingPx = 0; } }