Skip to content

Commit

Permalink
feat : Adjust page-indicator height to space workspace and hotseat
Browse files Browse the repository at this point in the history
closes : #4836
  • Loading branch information
MrSluffy committed Jan 3, 2025
1 parent 24ba475 commit 38934f8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions lawnchair/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<item name="config_default_drawer_icon_size_factor" type="dimen" format="float">1.0</item>
<item name="config_default_home_icon_label_size_factor" type="dimen" format="float">1.0</item>
<item name="config_default_home_icon_label_folder_size_factor" type="dimen" format="float">1.0</item>
<item name="page_indicator_height_factor" type="dimen" format="float">1.0</item>
<item name="config_default_drawer_icon_label_size_factor" type="dimen" format="float">1.0</item>
<item name="config_default_drawer_cell_height_factor" type="dimen" format="float">1.0</item>
<item name="config_default_drawer_left_right_factor" type="dimen" format="float">0.1</item>
Expand Down
1 change: 1 addition & 0 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@

<string name="dock_icons">Dock icons</string>
<string name="hotseat_bottom_space_label">Bottom padding</string>
<string name="page_indicator_height">Page indicator height</string>

<!-- Search providers -->
<string name="search_provider_app_search">App search</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ class PreferenceManager2 private constructor(private val context: Context) : Pre
onSet = { reloadHelper.reloadGrid() },
)

val pageIndicatorHeightFactor = preference(
key = floatPreferencesKey(name = "page_indicator_height_factor"),
defaultValue = resourceProvider.getFloat(R.dimen.page_indicator_height_factor),
onSet = { reloadHelper.reloadGrid() },
)

val drawerIconLabelSizeFactor = preference(
key = floatPreferencesKey(name = "drawer_icon_label_size_factor"),
defaultValue = resourceProvider.getFloat(R.dimen.config_default_drawer_icon_label_size_factor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fun DockPreferences(
val hotseatBgVerticalInsetTopAdapter = prefs.hotseatBGVerticalInsetTop.getAdapter()
val hotseatBgHorizontalInsetRightAdapter = prefs.hotseatBGHorizontalInsetRight.getAdapter()
val hotseatBgVerticalInsetBottomAdapter = prefs.hotseatBGVerticalInsetBottom.getAdapter()
val pageIndicatorHeightFactorAdapter = prefs2.pageIndicatorHeightFactor.getAdapter()

MainSwitchPreference(adapter = isHotseatEnabled, label = stringResource(id = R.string.show_hotseat_title)) {
if (isPortrait) {
Expand Down Expand Up @@ -115,6 +116,7 @@ fun DockPreferences(
hotseatBgHorizontalInsetRightAdapter.state.value,
hotseatBgVerticalInsetBottomAdapter.state.value,
hotseatBottomFactorAdapter.state.value,
pageIndicatorHeightFactorAdapter.state.value,
) {
DummyLauncherLayout(
idp = createPreviewIdp { copy(numHotseatColumns = prefs.hotseatColumns.get()) },
Expand Down Expand Up @@ -226,6 +228,13 @@ fun DockPreferences(
step = 0.1F,
showAsPercentage = true,
)
SliderPreference(
adapter = pageIndicatorHeightFactorAdapter,
label = stringResource(id = R.string.page_indicator_height),
valueRange = 0.0F..1.0F,
step = 0.1F,
showAsPercentage = true,
)
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/com/android/launcher3/DeviceProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public class DeviceProfile {
public int workspaceBottomPadding;

// Workspace page indicator
public final int workspacePageIndicatorHeight;
public int workspacePageIndicatorHeight;
private final int mWorkspacePageIndicatorOverlapWorkspace;

// Workspace icons
Expand Down Expand Up @@ -523,6 +523,10 @@ public class DeviceProfile {

workspacePageIndicatorHeight = res.getDimensionPixelSize(
R.dimen.workspace_page_indicator_height);
float pageIndicatorHeightFactor = PreferenceExtensionsKt
.firstBlocking(preferenceManager2.getPageIndicatorHeightFactor());

workspacePageIndicatorHeight *= (int) pageIndicatorHeightFactor;
mWorkspacePageIndicatorOverlapWorkspace = res
.getDimensionPixelSize(R.dimen.workspace_page_indicator_overlap_workspace);

Expand Down

0 comments on commit 38934f8

Please sign in to comment.