@@ -12,6 +12,7 @@ import androidx.compose.material.icons.twotone.ColorLens
1212import androidx.compose.material.icons.twotone.Contrast
1313import androidx.compose.material.icons.twotone.DarkMode
1414import androidx.compose.material.icons.twotone.Lock
15+ import androidx.compose.material.icons.twotone.Speed
1516import androidx.compose.material3.FilledTonalButton
1617import androidx.compose.material3.Icon
1718import androidx.compose.material3.IconButton
@@ -59,6 +60,7 @@ fun GeneralSettingsScreenHost() {
5960 val themeColor by vm.themeColor.collectAsState(initial = ThemeColor .BLUE )
6061 val isDynamicColorActive = LocalIsDynamicColorActive .current
6162 val isPro by vm.isPro.collectAsState()
63+ val ipcParallelisation by vm.ipcParallelisation.collectAsState(initial = 0 )
6264
6365 GeneralSettingsScreen (
6466 onBack = { navCtrl?.up() },
@@ -67,14 +69,16 @@ fun GeneralSettingsScreenHost() {
6769 themeColor = themeColor,
6870 isDynamicColorActive = isDynamicColorActive,
6971 isPro = isPro,
72+ ipcParallelisation = ipcParallelisation,
7073 onThemeModeSelected = { vm.setThemeMode(it) },
7174 onThemeStyleSelected = { vm.setThemeStyle(it) },
7275 onThemeColorSelected = { vm.setThemeColor(it) },
76+ onIpcParallelisationSelected = { vm.setIpcParallelisation(it) },
7377 onUpgrade = { vm.onUpgrade() },
7478 )
7579}
7680
77- private enum class ThemeDialog { MODE , STYLE , COLOR }
81+ private enum class SettingsDialog { THEME_MODE , THEME_STYLE , THEME_COLOR , SCAN_SPEED }
7882
7983@Composable
8084fun GeneralSettingsScreen (
@@ -84,12 +88,14 @@ fun GeneralSettingsScreen(
8488 themeColor : ThemeColor = ThemeColor .BLUE ,
8589 isDynamicColorActive : Boolean = false,
8690 isPro : Boolean = true,
91+ ipcParallelisation : Int = 0,
8792 onThemeModeSelected : (ThemeMode ) -> Unit = {},
8893 onThemeStyleSelected : (ThemeStyle ) -> Unit = {},
8994 onThemeColorSelected : (ThemeColor ) -> Unit = {},
95+ onIpcParallelisationSelected : (Int ) -> Unit = {},
9096 onUpgrade : () -> Unit = {},
9197) {
92- var openDialog by remember { mutableStateOf<ThemeDialog ?>(null ) }
98+ var openDialog by remember { mutableStateOf<SettingsDialog ?>(null ) }
9399
94100 Scaffold (
95101 topBar = {
@@ -132,15 +138,15 @@ fun GeneralSettingsScreen(
132138 subtitle = stringResource(themeMode.labelRes),
133139 icon = Icons .TwoTone .DarkMode ,
134140 enabled = isPro,
135- onClick = { openDialog = ThemeDialog . MODE },
141+ onClick = { openDialog = SettingsDialog . THEME_MODE },
136142 )
137143 SettingsDivider ()
138144 SettingsBaseItem (
139145 title = stringResource(R .string.ui_theme_style_label),
140146 subtitle = stringResource(themeStyle.labelRes),
141147 icon = Icons .TwoTone .Contrast ,
142148 enabled = isPro,
143- onClick = { openDialog = ThemeDialog . STYLE },
149+ onClick = { openDialog = SettingsDialog . THEME_STYLE },
144150 )
145151 SettingsDivider ()
146152
@@ -154,13 +160,45 @@ fun GeneralSettingsScreen(
154160 },
155161 icon = Icons .TwoTone .ColorLens ,
156162 enabled = colorEnabled,
157- onClick = { openDialog = ThemeDialog .COLOR },
163+ onClick = { openDialog = SettingsDialog .THEME_COLOR },
164+ )
165+
166+ SettingsCategoryHeader (
167+ text = stringResource(R .string.settings_category_advanced_label),
168+ action = if (! isPro) {{
169+ FilledTonalButton (onClick = onUpgrade) {
170+ Icon (
171+ Icons .TwoTone .Lock ,
172+ contentDescription = null ,
173+ modifier = Modifier .size(16 .dp),
174+ )
175+ Text (
176+ text = stringResource(R .string.upgrade_required_subtitle),
177+ modifier = Modifier .padding(start = 6 .dp),
178+ style = MaterialTheme .typography.labelMedium,
179+ )
180+ }
181+ }} else null ,
182+ )
183+
184+ SettingsBaseItem (
185+ title = stringResource(R .string.general_settings_scan_speed_label),
186+ subtitle = when (ipcParallelisation) {
187+ 1 -> stringResource(R .string.general_settings_scan_speed_1)
188+ 2 -> stringResource(R .string.general_settings_scan_speed_2)
189+ 3 -> stringResource(R .string.general_settings_scan_speed_3)
190+ 4 -> stringResource(R .string.general_settings_scan_speed_4)
191+ else -> stringResource(R .string.general_settings_scan_speed_auto)
192+ },
193+ icon = Icons .TwoTone .Speed ,
194+ enabled = isPro,
195+ onClick = { openDialog = SettingsDialog .SCAN_SPEED },
158196 )
159197 }
160198 }
161199
162200 when (openDialog) {
163- ThemeDialog . MODE -> SingleChoiceSortDialog (
201+ SettingsDialog . THEME_MODE -> SingleChoiceSortDialog (
164202 title = stringResource(R .string.ui_theme_mode_label),
165203 options = ThemeMode .entries.map { LabeledOption (it, it.labelRes) },
166204 selected = themeMode,
@@ -171,7 +209,7 @@ fun GeneralSettingsScreen(
171209 onDismiss = { openDialog = null },
172210 )
173211
174- ThemeDialog . STYLE -> SingleChoiceSortDialog (
212+ SettingsDialog . THEME_STYLE -> SingleChoiceSortDialog (
175213 title = stringResource(R .string.ui_theme_style_label),
176214 options = ThemeStyle .entries.map { LabeledOption (it, it.labelRes) },
177215 selected = themeStyle,
@@ -182,7 +220,7 @@ fun GeneralSettingsScreen(
182220 onDismiss = { openDialog = null },
183221 )
184222
185- ThemeDialog . COLOR -> ThemeColorSelectorDialog (
223+ SettingsDialog . THEME_COLOR -> ThemeColorSelectorDialog (
186224 selectedColor = themeColor,
187225 onColorSelected = {
188226 onThemeColorSelected(it)
@@ -191,6 +229,23 @@ fun GeneralSettingsScreen(
191229 onDismiss = { openDialog = null },
192230 )
193231
232+ SettingsDialog .SCAN_SPEED -> SingleChoiceSortDialog (
233+ title = stringResource(R .string.general_settings_scan_speed_label),
234+ options = listOf (
235+ LabeledOption (0 , R .string.general_settings_scan_speed_auto),
236+ LabeledOption (1 , R .string.general_settings_scan_speed_1),
237+ LabeledOption (2 , R .string.general_settings_scan_speed_2),
238+ LabeledOption (3 , R .string.general_settings_scan_speed_3),
239+ LabeledOption (4 , R .string.general_settings_scan_speed_4),
240+ ),
241+ selected = ipcParallelisation,
242+ onSelect = {
243+ onIpcParallelisationSelected(it)
244+ openDialog = null
245+ },
246+ onDismiss = { openDialog = null },
247+ )
248+
194249 null -> {}
195250 }
196251}
0 commit comments