Skip to content

Commit

Permalink
Reorganize and cleanup preference screens
Browse files Browse the repository at this point in the history
* Reorganize app drawer settings
* Reorganize home screen settings
* Use enum for search bar settings
* Reorganize dock search bar settings
* Tweak labels for app drawer folder settings
  • Loading branch information
SuperDragonXD committed Feb 16, 2025
1 parent efe8fe5 commit 0ab1dee
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 93 deletions.
10 changes: 7 additions & 3 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<string name="action_copy_link">Copy link</string>
<string name="action_copy">Copy</string>
<string name="action_paste">Paste</string>
<string name="action_done">Done</string>

<string name="loading">Loading…</string>

Expand Down Expand Up @@ -78,6 +79,7 @@

<!-- Generic styling options -->
<string name="wallpaper">Wallpaper</string>
<string name="style">Style</string>
<string name="background_opacity">Background opacity</string>

<!-- Toast text and tips -->
Expand All @@ -94,9 +96,9 @@
<string name="caddy_beta">Caddy (Beta)</string>
<string name="caddy">Caddy</string>

<string name="app_drawer_folder">App drawer folder</string>
<string name="app_drawer_folder">App drawer folders</string>
<string name="app_drawer_folder_settings">Drawer folder</string>
<string name="add_folder">Add folder</string>
<string name="add_folder">Create folder</string>
<string name="edit_folder">Edit folder</string>
<string name="add_label">Add</string>
<string name="edit_label">Edit</string>
Expand All @@ -110,13 +112,15 @@
<string name="my_folder_label">My folder</string>

<!-- A11y description -->
<string name="accessibility_service_description">To lock your phone when performing a gesture, and to open Recents via gesture, Lawnchair requires accessibility access.\n\nLawnchair doesn\'t watch any user action, though the privilege to do so is required for all accessibility services. Lawnchair discards any event sent by the system.\n\nIn order to lock your phone, or to open Recents, Lawnchair uses the performGlobalAction Accessibility service.</string>
<string name="accessibility_service_description">To perform certain actions (such as locking your phone) when performing a gesture, Lawnchair requires accessibility access.\n\nLawnchair doesn\'t watch any user action, though the privilege to do so is required for all accessibility services. Lawnchair discards any event sent by the system.\n\nIn order to lock your phone, or to open Recents, Lawnchair uses the performGlobalAction Accessibility service.</string>

<string name="iconPackPackageDefault" translatable="false">""</string>

<string name="n_percent" translatable="false">%1$d%%</string>
<string name="x_by_y">%1$d x %2$d</string>
<string name="x_and_y">%1$s &amp; %2$s</string>

<string name="advanced">Advanced</string>
<!--
Preference Dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.lawnchair.hotseat.DisabledHotseat
import app.lawnchair.hotseat.HotseatMode
import app.lawnchair.hotseat.LawnchairHotseat
import app.lawnchair.preferences.PreferenceAdapter
Expand All @@ -28,7 +29,6 @@ import app.lawnchair.ui.preferences.components.controls.ListPreference
import app.lawnchair.ui.preferences.components.controls.ListPreferenceEntry
import app.lawnchair.ui.preferences.components.controls.SliderPreference
import app.lawnchair.ui.preferences.components.controls.SwitchPreference
import app.lawnchair.ui.preferences.components.layout.DividerColumn
import app.lawnchair.ui.preferences.components.layout.ExpandAndShrink
import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
import app.lawnchair.ui.preferences.components.layout.PreferenceTemplate
Expand All @@ -50,19 +50,24 @@ fun DockSearchPreference(
val qsbAlphaAdapter = prefs.hotseatQsbAlpha.getAdapter()
val qsbHotseatStrokeWidth = prefs.hotseatQsbStrokeWidth.getAdapter()

Crossfade(isHotseatEnabled.state.value, label = "transition", modifier = modifier) {
if (it) {
Crossfade(isHotseatEnabled.state.value, label = "transition", modifier = modifier) { hotseatEnabled ->
val isLawnchairHotseat = hotseatModeAdapter.state.value == LawnchairHotseat
if (hotseatEnabled) {
Column {
DockPreferencesPreview()
PreferenceGroup(
heading = stringResource(R.string.search_bar_settings),
) {
PreferenceGroup {
HotseatModePreference(
adapter = hotseatModeAdapter,
)
ExpandAndShrink(visible = hotseatModeAdapter.state.value == LawnchairHotseat) {
DividerColumn {
val hotseatQsbProviderAdapter by preferenceManager2().hotseatQsbProvider.getAdapter()
}
ExpandAndShrink(visible = hotseatModeAdapter.state.value != DisabledHotseat) {
DockPreferencesPreview()
}
ExpandAndShrink(visible = isLawnchairHotseat) {
Column {
val hotseatQsbProviderAdapter by preferenceManager2().hotseatQsbProvider.getAdapter()
PreferenceGroup(
heading = stringResource(R.string.search_bar_settings),
) {
NavigationActionPreference(
label = stringResource(R.string.search_provider),
destination = DockRoutes.SEARCH_PROVIDER,
Expand All @@ -72,6 +77,10 @@ fun DockSearchPreference(
.name,
),
)
}
PreferenceGroup(
heading = stringResource(R.string.style),
) {
SwitchPreference(
adapter = themeQsbAdapter,
label = stringResource(id = R.string.apply_accent_color_label),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,15 @@ fun AppDrawerFolderPreferenceItem(
) {
val navController = LocalNavController.current

val onFolderSettingsClick: () -> Unit = {
navController.navigate(route = Routes.APP_DRAWER_FOLDER)
}

PreferenceGroup(
heading = stringResource(id = R.string.app_drawer_folder),
modifier = modifier,
) {
ClickablePreference(
label = stringResource(R.string.app_drawer_folder_settings),
label = stringResource(R.string.app_drawer_folder),
modifier = Modifier,
onClick = onFolderSettingsClick,
onClick = {
navController.navigate(route = Routes.APP_DRAWER_FOLDER)
},
)
}
}
Expand Down Expand Up @@ -176,7 +173,7 @@ fun AppDrawerFoldersPreference(
title = {},
description = {
Text(
text = stringResource(R.string.action_create),
text = stringResource(R.string.add_folder),
color = MaterialTheme.colorScheme.onSurface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ fun AppDrawerPreferences(
val drawerListAdapter = prefs.drawerList.getAdapter()
DrawerLayoutPreference(drawerListAdapter)
ExpandAndShrink(visible = drawerListAdapter.state.value) {
DividerColumn {
AppDrawerFolderPreferenceItem()
}
AppDrawerFolderPreferenceItem()
}
PreferenceGroup(heading = stringResource(id = R.string.general_label)) {
val hiddenApps = prefs2.hiddenApps.getAdapter().state.value
NavigationActionPreference(
label = stringResource(id = R.string.hidden_apps_label),
subtitle = resources.getQuantityString(R.plurals.apps_count, hiddenApps.size, hiddenApps.size),
destination = AppDrawerRoutes.HIDDEN_APPS,
)
SearchBarPreference(SearchRoute.DRAWER_SEARCH, showLabel = false)
SuggestionsPreference()
}
PreferenceGroup(heading = stringResource(R.string.style)) {
ColorPreference(preference = prefs2.appDrawerBackgroundColor)
SliderPreference(
label = stringResource(id = R.string.background_opacity),
Expand All @@ -88,30 +96,6 @@ fun AppDrawerPreferences(
valueRange = 0F..1F,
showAsPercentage = true,
)
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_bulk_icon_loading_title),
description = stringResource(id = R.string.pref_all_apps_bulk_icon_loading_description),
adapter = prefs.allAppBulkIconLoading.getAdapter(),
)
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_remember_position_title),
description = stringResource(id = R.string.pref_all_apps_remember_position_description),
adapter = prefs2.rememberPosition.getAdapter(),
)
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_show_scrollbar_title),
adapter = prefs2.showScrollbar.getAdapter(),
)
SuggestionsPreference()
}
SearchBarPreference(1)
PreferenceGroup(heading = stringResource(id = R.string.hidden_apps_label)) {
val hiddenApps = prefs2.hiddenApps.getAdapter().state.value
NavigationActionPreference(
label = stringResource(id = R.string.hidden_apps_label),
subtitle = resources.getQuantityString(R.plurals.apps_count, hiddenApps.size, hiddenApps.size),
destination = AppDrawerRoutes.HIDDEN_APPS,
)
}
PreferenceGroup(heading = stringResource(id = R.string.grid)) {
SliderPreference(
Expand Down Expand Up @@ -164,6 +148,22 @@ fun AppDrawerPreferences(
}
}
}
PreferenceGroup(heading = stringResource(id = R.string.advanced)) {
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_bulk_icon_loading_title),
description = stringResource(id = R.string.pref_all_apps_bulk_icon_loading_description),
adapter = prefs.allAppBulkIconLoading.getAdapter(),
)
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_remember_position_title),
description = stringResource(id = R.string.pref_all_apps_remember_position_description),
adapter = prefs2.rememberPosition.getAdapter(),
)
SwitchPreference(
label = stringResource(id = R.string.pref_all_apps_show_scrollbar_title),
adapter = prefs2.showScrollbar.getAdapter(),
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,29 @@ fun DockPreferences(modifier: Modifier = Modifier) {
backArrowVisible = !LocalIsExpandedScreen.current,
modifier = modifier,
) {
val isHotseatEnabled = prefs2.isHotseatEnabled.getAdapter()
val isHotseatBgEnabled = prefs.hotseatBG.getAdapter().state.value
val hotseatBgAdapter = prefs.hotseatBG.getAdapter()

MainSwitchPreference(adapter = isHotseatEnabled, label = stringResource(id = R.string.show_hotseat_title)) {
MainSwitchPreference(adapter = prefs2.isHotseatEnabled.getAdapter(), label = stringResource(id = R.string.show_hotseat_title)) {
DockPreferencesPreview()

PreferenceGroup(heading = stringResource(id = R.string.general_label)) {
DividerColumn {
SwitchPreference(
adapter = prefs.hotseatBG.getAdapter(),
label = stringResource(id = R.string.hotseat_background),
)
ExpandAndShrink(visible = isHotseatBgEnabled) {
HotseatBackgroundSettings(prefs, prefs2)
}
PreferenceGroup(heading = stringResource(id = R.string.style)) {
SwitchPreference(
adapter = hotseatBgAdapter,
label = stringResource(id = R.string.hotseat_background),
)
ExpandAndShrink(visible = hotseatBgAdapter.state.value) {
HotseatBackgroundSettings(prefs, prefs2)
}
}

SearchBarPreference(0)

SearchBarPreference(SearchRoute.DOCK_SEARCH)
PreferenceGroup(heading = stringResource(id = R.string.grid)) {
GridSettings(prefs, prefs2)
}
PreferenceGroup(heading = stringResource(id = R.string.icons)) {
SwitchPreference(
adapter = prefs2.enableLabelInDock.getAdapter(),
label = stringResource(id = R.string.show_labels),
)
}
}
}
}
Expand Down Expand Up @@ -134,10 +134,6 @@ fun HotseatBackgroundSettings(prefs: PreferenceManager, prefs2: PreferenceManage

@Composable
fun GridSettings(prefs: PreferenceManager, prefs2: PreferenceManager2) {
SwitchPreference(
adapter = prefs2.enableLabelInDock.getAdapter(),
label = stringResource(id = R.string.show_labels),
)
SliderPreference(
label = stringResource(id = R.string.dock_icons),
adapter = prefs.hotseatColumns.getAdapter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import app.lawnchair.ui.preferences.components.controls.ClickablePreference
import app.lawnchair.ui.preferences.components.controls.ListPreference
import app.lawnchair.ui.preferences.components.controls.SliderPreference
import app.lawnchair.ui.preferences.components.controls.SwitchPreference
import app.lawnchair.ui.preferences.components.layout.DividerColumn
import app.lawnchair.ui.preferences.components.layout.ExpandAndShrink
import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
import app.lawnchair.ui.preferences.components.layout.PreferenceLayout
Expand Down Expand Up @@ -86,7 +85,6 @@ fun HomeScreenPreferences(
adapter = prefs2.doubleTapGestureHandler.getAdapter(),
label = stringResource(id = R.string.gesture_double_tap),
)
HomeScreenTextColorPreference()
}
PreferenceGroup(heading = stringResource(id = R.string.minus_one)) {
val feedAvailable = OverlayCallbackImpl.minusOneAvailable(LocalContext.current)
Expand All @@ -101,10 +99,10 @@ fun HomeScreenPreferences(
FeedPreference()
}
}
PreferenceGroup(heading = stringResource(R.string.overlay_label)) {
val overlayAdapter = prefs2.closingAppOverlay.getAdapter()
PreferenceGroup(heading = stringResource(R.string.style)) {
HomeScreenTextColorPreference()
OverlayHandlerPreference(
adapter = overlayAdapter,
adapter = prefs2.closingAppOverlay.getAdapter(),
label = stringResource(id = R.string.app_closing_animation),
)
}
Expand Down Expand Up @@ -133,18 +131,16 @@ fun HomeScreenPreferences(
destination = HomeScreenRoutes.GRID,
subtitle = stringResource(id = R.string.x_by_y, columns, rows),
)
DividerColumn {
SwitchPreference(
adapter = lockHomeScreenAdapter,
label = stringResource(id = R.string.home_screen_lock),
description = stringResource(id = R.string.home_screen_lock_description),
)
SwitchPreference(
adapter = prefs2.enableDotPagination.getAdapter(),
label = stringResource(id = R.string.show_dot_pagination_label),
description = stringResource(id = R.string.show_dot_pagination_description),
)
}
SwitchPreference(
adapter = lockHomeScreenAdapter,
label = stringResource(id = R.string.home_screen_lock),
description = stringResource(id = R.string.home_screen_lock_description),
)
SwitchPreference(
adapter = prefs2.enableDotPagination.getAdapter(),
label = stringResource(id = R.string.show_dot_pagination_label),
description = stringResource(id = R.string.show_dot_pagination_description),
)
}
PreferenceGroup(heading = stringResource(id = R.string.popup_menu)) {
SwitchPreference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app.lawnchair.ui.preferences.destinations
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.movableContentOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand All @@ -16,21 +18,37 @@ import app.lawnchair.ui.preferences.components.search.DrawerSearchPreference
import app.lawnchair.ui.preferences.navigation.Routes
import com.android.launcher3.R

enum class SearchRoute {
DOCK_SEARCH,
DRAWER_SEARCH,
}

@Composable
fun SearchBarPreference(
id: Int,
id: SearchRoute,
modifier: Modifier = Modifier,
showLabel: Boolean = true,
) {
val navController = LocalNavController.current
PreferenceGroup(
heading = stringResource(id = R.string.search_bar_label),
) {
ClickablePreference(
label = stringResource(R.string.search_bar_settings),
modifier = modifier,
val preference = remember {
movableContentOf {
ClickablePreference(
label = stringResource(R.string.search_bar_settings),
modifier = modifier,
) {
navController.navigate(route = "${Routes.SEARCH}/${id.ordinal}")
}
}
}

if (showLabel) {
PreferenceGroup(
heading = stringResource(id = R.string.search_bar_label),
) {
navController.navigate(route = "${Routes.SEARCH}/$id")
preference()
}
} else {
preference()
}
}

Expand Down

0 comments on commit 0ab1dee

Please sign in to comment.