diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/AppDrawerPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/AppDrawerPreferences.kt index 351cb94401..c5b70724d5 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/AppDrawerPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/AppDrawerPreferences.kt @@ -150,22 +150,26 @@ fun AppDrawerPreferences( label = stringResource(id = R.string.show_labels), ) } - if (showDrawerLabels.state.value) { - item { - SliderPreference( - label = stringResource(id = R.string.label_size), - adapter = prefs2.drawerIconLabelSizeFactor.getAdapter(), - step = 0.1F, - valueRange = 0.5F..1.5F, - showAsPercentage = true, - ) - } - item { - SwitchPreference( - adapter = prefs2.twoLineAllApps.getAdapter(), - label = stringResource(R.string.twoline_label), - ) - } + item( + "drawer_icon_label_size", + showDrawerLabels.state.value + ) { + SliderPreference( + label = stringResource(id = R.string.label_size), + adapter = prefs2.drawerIconLabelSizeFactor.getAdapter(), + step = 0.1F, + valueRange = 0.5F..1.5F, + showAsPercentage = true, + ) + } + item( + "drawer_label_twoline", + showDrawerLabels.state.value + ) { + SwitchPreference( + adapter = prefs2.twoLineAllApps.getAdapter(), + label = stringResource(R.string.twoline_label), + ) } } PreferenceGroup(heading = stringResource(id = R.string.advanced)) { diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FolderPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FolderPreferences.kt index 4196b600b1..cf1cde43f5 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FolderPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FolderPreferences.kt @@ -89,16 +89,17 @@ fun FolderPreferences( label = stringResource(id = R.string.show_labels), ) } - if (homeScreenLabelsAdapter.state.value) { - item { - SliderPreference( - label = stringResource(id = R.string.label_size), - adapter = prefs2.homeIconLabelFolderSizeFactor.getAdapter(), - step = 0.1f, - valueRange = 0.5F..1.5F, - showAsPercentage = true, - ) - } + item( + "label_size", + homeScreenLabelsAdapter.state.value + ) { + SliderPreference( + label = stringResource(id = R.string.label_size), + adapter = prefs2.homeIconLabelFolderSizeFactor.getAdapter(), + step = 0.1f, + valueRange = 0.5F..1.5F, + showAsPercentage = true, + ) } } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt index 516cb0ca1e..69b54b057e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt @@ -145,14 +145,15 @@ fun GeneralPreferences() { subtitle = iconStyleSubtitle, ) } - if (themedIconsEnabled) { - item { - SwitchPreference( - adapter = prefs.transparentIconBackground.getAdapter(), - label = stringResource(id = R.string.transparent_background_icons_label), - description = stringResource(id = R.string.transparent_background_icons_description), - ) - } + item( + "themed_icon", + themedIconsEnabled + ) { + SwitchPreference( + adapter = prefs.transparentIconBackground.getAdapter(), + label = stringResource(id = R.string.transparent_background_icons_label), + description = stringResource(id = R.string.transparent_background_icons_description), + ) } item { NavigationActionPreference( @@ -177,16 +178,17 @@ fun GeneralPreferences() { label = stringResource(id = R.string.shadow_bg_icons_label), ) } - if (wrapAdaptiveIcons.state.value) { - item { - SliderPreference( - label = stringResource(id = R.string.background_lightness_label), - adapter = prefs.coloredBackgroundLightness.getAdapter(), - valueRange = 0F..1F, - step = 0.1f, - showAsPercentage = true, - ) - } + item( + "wrap_adaptive_icons", + wrapAdaptiveIcons.state.value + ) { + SliderPreference( + label = stringResource(id = R.string.background_lightness_label), + adapter = prefs.coloredBackgroundLightness.getAdapter(), + valueRange = 0F..1F, + step = 0.1f, + showAsPercentage = true, + ) } } @@ -197,9 +199,10 @@ fun GeneralPreferences() { PreferenceGroup(heading = stringResource(id = R.string.colors)) { item { ThemePreference() } item { ColorPreference(preference = prefs2.accentColor) } - if (showColorStyle) { - item { ColorStylePreference(prefs2.colorStyle.getAdapter()) } - } + item( + "color_style", + showColorStyle + ) { ColorStylePreference(prefs2.colorStyle.getAdapter()) } } val notificationEnabled by remember { notificationDotsEnabled(context) }.collectAsStateWithLifecycle(initialValue = false) @@ -211,23 +214,32 @@ fun GeneralPreferences() { PreferenceGroup(heading = stringResource(id = R.string.notification_dots)) { item { NotificationDotsPreference(enabled = notificationEnabled, serviceEnabled = serviceEnabled) } - if (notificationEnabled && serviceEnabled) { - item { ColorPreference(preference = prefs2.notificationDotColor) } - item { - SwitchPreference( - adapter = showNotificationCountAdapter, - label = stringResource(id = R.string.show_notification_count), - ) - } - if (showNotificationCount) { - item { ColorPreference(preference = prefs2.notificationDotTextColor) } - item { - NotificationDotColorContrastWarnings( - dotColor = dotColor, - dotTextColor = dotTextColor, - ) - } - } + val canDisplayNotificationDot = notificationEnabled && serviceEnabled + item( + "notification_dot_color", + canDisplayNotificationDot + ) { ColorPreference(preference = prefs2.notificationDotColor) } + item( + "notification_dot_counter_toggle", + canDisplayNotificationDot + ) { + SwitchPreference( + adapter = showNotificationCountAdapter, + label = stringResource(id = R.string.show_notification_count), + ) + } + item( + "notification_dot_text_color", + canDisplayNotificationDot && showNotificationCount + ) { ColorPreference(preference = prefs2.notificationDotTextColor) } + item( + "notification_dot_color_contrast_warning", + canDisplayNotificationDot && showNotificationCount + ) { + NotificationDotColorContrastWarnings( + dotColor = dotColor, + dotTextColor = dotTextColor, + ) } } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/HomeScreenPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/HomeScreenPreferences.kt index b90ac5475f..84fc7465da 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/HomeScreenPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/HomeScreenPreferences.kt @@ -75,16 +75,17 @@ fun HomeScreenPreferences( PreferenceGroup(heading = stringResource(id = R.string.general_label)) { val addIconToHomeAdapter = prefs.addIconToHome.getAdapter() val isDeckLayoutAdapter = prefs2.deckLayout.getAdapter() - if (!isDeckLayoutAdapter.state.value) { - item { - SwitchPreference( - checked = (!lockHomeScreenAdapter.state.value && addIconToHomeAdapter.state.value) || isDeckLayoutAdapter.state.value, - onCheckedChange = addIconToHomeAdapter::onChange, - label = stringResource(id = R.string.auto_add_shortcuts_label), - description = if (lockHomeScreenAdapter.state.value) stringResource(id = R.string.home_screen_locked) else null, - enabled = lockHomeScreenAdapter.state.value.not(), - ) - } + item( + "add_icon_to_home", + !isDeckLayoutAdapter.state.value + ) { + SwitchPreference( + checked = (!lockHomeScreenAdapter.state.value && addIconToHomeAdapter.state.value) || isDeckLayoutAdapter.state.value, + onCheckedChange = addIconToHomeAdapter::onChange, + label = stringResource(id = R.string.auto_add_shortcuts_label), + description = if (lockHomeScreenAdapter.state.value) stringResource(id = R.string.home_screen_locked) else null, + enabled = lockHomeScreenAdapter.state.value.not(), + ) } item { GestureHandlerPreference( @@ -134,14 +135,15 @@ fun HomeScreenPreferences( label = stringResource(id = R.string.wallpaper_scrolling_label), ) } - if (Utilities.ATLEAST_R) { - item { - SwitchPreference( - prefs2.wallpaperDepthEffect.getAdapter(), - label = stringResource(id = R.string.wallpaper_depth_effect_label), - description = stringResource(id = R.string.wallpaper_depth_effect_description), - ) - } + item( + "wallpaper_depth_effect", + Utilities.ATLEAST_R + ) { + SwitchPreference( + prefs2.wallpaperDepthEffect.getAdapter(), + label = stringResource(id = R.string.wallpaper_depth_effect_label), + description = stringResource(id = R.string.wallpaper_depth_effect_description), + ) } item { SwitchPreference( @@ -179,22 +181,24 @@ fun HomeScreenPreferences( label = stringResource(id = R.string.show_status_bar), ) } - if (showStatusBarAdapter.state.value) { - item { - SwitchPreference( - adapter = prefs2.darkStatusBar.getAdapter(), - label = stringResource(id = R.string.dark_status_bar_label), - ) - } + item( + "dark_status_bar", + showStatusBarAdapter.state.value + ) { + SwitchPreference( + adapter = prefs2.darkStatusBar.getAdapter(), + label = stringResource(id = R.string.dark_status_bar_label), + ) } - if (showStatusBarAdapter.state.value && LawnchairApp.isRecentsEnabled) { - item { - SwitchPreference( - adapter = prefs2.statusBarClock.getAdapter(), - label = stringResource(id = R.string.status_bar_clock_label), - description = stringResource(id = R.string.status_bar_clock_description), - ) - } + item( + "status_bar_clock", + showStatusBarAdapter.state.value && LawnchairApp.isRecentsEnabled + ) { + SwitchPreference( + adapter = prefs2.statusBarClock.getAdapter(), + label = stringResource(id = R.string.status_bar_clock_label), + description = stringResource(id = R.string.status_bar_clock_description), + ) } } val homeScreenLabelsAdapter = prefs2.showIconLabelsOnHomeScreen.getAdapter() @@ -214,16 +218,17 @@ fun HomeScreenPreferences( label = stringResource(id = R.string.show_labels), ) } - if (homeScreenLabelsAdapter.state.value) { - item { - SliderPreference( - label = stringResource(id = R.string.label_size), - adapter = prefs2.homeIconLabelSizeFactor.getAdapter(), - step = 0.1f, - valueRange = 0.5F..1.5F, - showAsPercentage = true, - ) - } + item( + "workspace_label_size", + homeScreenLabelsAdapter.state.value + ) { + SliderPreference( + label = stringResource(id = R.string.label_size), + adapter = prefs2.homeIconLabelSizeFactor.getAdapter(), + step = 0.1f, + valueRange = 0.5F..1.5F, + showAsPercentage = true, + ) } } val overrideRepo = IconOverrideRepository.INSTANCE.get(LocalContext.current) diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt index 67b2e80c6d..6b37614326 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/PreferencesDashboard.kt @@ -164,18 +164,19 @@ fun PreferencesDashboard( ) } - if (!deckLayout.state.value) { - item { - PreferenceCategory( - label = stringResource(R.string.app_drawer_label), - description = stringResource(R.string.app_drawer_description), - iconResource = R.drawable.ic_app_drawer, - onNavigate = { onNavigate(AppDrawer) }, - isSelected = currentRoute is AppDrawer, - isFirst = it.isFirst, - isLast = it.isLast, - ) - } + item( + key = "app_drawer", + visible = !deckLayout.state.value + ) { + PreferenceCategory( + label = stringResource(R.string.app_drawer_label), + description = stringResource(R.string.app_drawer_description), + iconResource = R.drawable.ic_app_drawer, + onNavigate = { onNavigate(AppDrawer) }, + isSelected = currentRoute is AppDrawer, + isFirst = it.isFirst, + isLast = it.isLast, + ) } item { @@ -213,19 +214,19 @@ fun PreferencesDashboard( isLast = it.isLast, ) } - - if (LawnchairApp.isRecentsEnabled || BuildConfig.DEBUG) { - item { - PreferenceCategory( - label = stringResource(id = R.string.quickstep_label), - description = stringResource(id = R.string.quickstep_description), - iconResource = R.drawable.ic_quickstep, - onNavigate = { onNavigate(Quickstep) }, - isSelected = currentRoute is Quickstep, - isFirst = it.isFirst, - isLast = it.isLast, - ) - } + item( + "quickstep", + LawnchairApp.isRecentsEnabled || BuildConfig.DEBUG + ) { + PreferenceCategory( + label = stringResource(id = R.string.quickstep_label), + description = stringResource(id = R.string.quickstep_description), + iconResource = R.drawable.ic_quickstep, + onNavigate = { onNavigate(Quickstep) }, + isSelected = currentRoute is Quickstep, + isFirst = it.isFirst, + isLast = it.isLast, + ) } item { diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/QuickstepPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/QuickstepPreferences.kt index f2371162dc..76b0456b83 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/QuickstepPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/QuickstepPreferences.kt @@ -80,16 +80,17 @@ fun QuickstepPreferences( label = stringResource(id = R.string.translucent_background), ) } - if (recentsTranslucentBackground) { - item { - SliderPreference( - adapter = prefs.recentsTranslucentBackgroundAlpha.getAdapter(), - label = stringResource(id = R.string.translucent_background_alpha), - step = 0.05f, - valueRange = 0f..0.95f, - showAsPercentage = true, - ) - } + item( + key = "recents_translucent_background_alpha", + visible = recentsTranslucentBackground, + ) { + SliderPreference( + adapter = prefs.recentsTranslucentBackgroundAlpha.getAdapter(), + label = stringResource(id = R.string.translucent_background_alpha), + step = 0.05f, + valueRange = 0f..0.95f, + showAsPercentage = true, + ) } } @@ -110,15 +111,16 @@ fun QuickstepPreferences( label = stringResource(id = R.string.override_window_corner_radius_label), ) } - if (overrideWindowCornerRadius) { - item { - SliderPreference( - label = stringResource(id = R.string.window_corner_radius_label), - adapter = prefs.windowCornerRadius.getAdapter(), - step = 0, - valueRange = 70..150, - ) - } + item( + "window_corner_radius", + overrideWindowCornerRadius, + ) { + SliderPreference( + label = stringResource(id = R.string.window_corner_radius_label), + adapter = prefs.windowCornerRadius.getAdapter(), + step = 0, + valueRange = 70..150, + ) } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt index 0731aa8c2c..1191a3bc0e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt @@ -205,28 +205,35 @@ fun SmartspaceDateAndTimePreferences( heading = stringResource(id = R.string.smartspace_date_and_time), modifier = modifier.padding(top = 8.dp), ) { - if (calendar.formatCustomizationSupport) { - item { - SwitchPreference( - adapter = showDateAdapter, - label = stringResource(id = R.string.smartspace_date), - enabled = if (showDateAdapter.state.value) !calendarHasMinimumContent else true, - ) - } - if (showDateAdapter.state.value) { - item { SmartspaceCalendarPreference() } - } - item { - SwitchPreference( - adapter = showTimeAdapter, - label = stringResource(id = R.string.smartspace_time), - enabled = if (showTimeAdapter.state.value) !calendarHasMinimumContent else true, - ) - } - if (showTimeAdapter.state.value) { - item { SmartspaceTimeFormatPreference() } - } + val supportCustomizationFormat = calendar.formatCustomizationSupport + item( + key = "smartspace_date", + visible = supportCustomizationFormat, + ) { + SwitchPreference( + adapter = showDateAdapter, + label = stringResource(id = R.string.smartspace_date), + enabled = if (showDateAdapter.state.value) !calendarHasMinimumContent else true, + ) } + item( + "smartspace_calendar", + supportCustomizationFormat && showDateAdapter.state.value, + ) { SmartspaceCalendarPreference() } + item( + "smartspace_time", + supportCustomizationFormat, + ) { + SwitchPreference( + adapter = showTimeAdapter, + label = stringResource(id = R.string.smartspace_time), + enabled = if (showTimeAdapter.state.value) !calendarHasMinimumContent else true, + ) + } + item( + "smartspace_time_format", + supportCustomizationFormat && showTimeAdapter.state.value, + ) { SmartspaceTimeFormatPreference() } } }