diff --git a/kernel/Kconfig b/kernel/Kconfig index 84649060..6a69f2f0 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -16,20 +16,13 @@ config KSU_DEBUG help Enable KernelSU debug mode. -config KSU_HOOK - bool "Enable KernelSU Hook" - default n - help - This option enables the KernelSU Hook feature. If enabled, it will - override the kernel version check and enable the hook functionality. - config KPM bool "Enable SukiSU KPM" + depends on KSU && 64BIT default n help Enabling this option will activate the KPM feature of SukiSU. This option is suitable for scenarios where you need to force KPM to be enabled. but it may affect system stability. - endmenu diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/component/profile/RootProfileConfig.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/component/profile/RootProfileConfig.kt index 9e0cac19..96746e05 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/component/profile/RootProfileConfig.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/component/profile/RootProfileConfig.kt @@ -206,28 +206,36 @@ fun GroupsPanel(selected: List, closeSelection: (selection: Set) } val selection = HashSet(selected) - ListDialog( - state = rememberUseCaseState(visible = true, onFinishedRequest = { - closeSelection(selection) - }, onCloseRequest = { - dismiss() - }), - header = Header.Default( - title = stringResource(R.string.profile_groups), - ), - selection = ListSelection.Multiple( - showCheckBoxes = true, - options = options, - maxChoices = 32, // Kernel only supports 32 groups at most - ) { indecies, _ -> - // Handle selection - selection.clear() - indecies.forEach { index -> - val group = groups[index] - selection.add(group) + val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest + + MaterialTheme( + colorScheme = MaterialTheme.colorScheme.copy( + surface = backgroundColor + ) + ) { + ListDialog( + state = rememberUseCaseState(visible = true, onFinishedRequest = { + closeSelection(selection) + }, onCloseRequest = { + dismiss() + }), + header = Header.Default( + title = stringResource(R.string.profile_groups), + ), + selection = ListSelection.Multiple( + showCheckBoxes = true, + options = options, + maxChoices = 32, // Kernel only supports 32 groups at most + ) { indecies, _ -> + // Handle selection + selection.clear() + indecies.forEach { index -> + val group = groups[index] + selection.add(group) + } } - } - ) + ) + } } OutlinedCard( @@ -278,27 +286,35 @@ fun CapsPanel( } val selection = HashSet(selected) - ListDialog( - state = rememberUseCaseState(visible = true, onFinishedRequest = { - closeSelection(selection) - }, onCloseRequest = { - dismiss() - }), - header = Header.Default( - title = stringResource(R.string.profile_capabilities), - ), - selection = ListSelection.Multiple( - showCheckBoxes = true, - options = options - ) { indecies, _ -> - // Handle selection - selection.clear() - indecies.forEach { index -> - val group = caps[index] - selection.add(group) + val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest + + MaterialTheme( + colorScheme = MaterialTheme.colorScheme.copy( + surface = backgroundColor + ) + ) { + ListDialog( + state = rememberUseCaseState(visible = true, onFinishedRequest = { + closeSelection(selection) + }, onCloseRequest = { + dismiss() + }), + header = Header.Default( + title = stringResource(R.string.profile_capabilities), + ), + selection = ListSelection.Multiple( + showCheckBoxes = true, + options = options + ) { indecies, _ -> + // Handle selection + selection.clear() + indecies.forEach { index -> + val group = caps[index] + selection.add(group) + } } - } - ) + ) + } } OutlinedCard( @@ -425,24 +441,33 @@ private fun SELinuxPanel( ) ) - InputDialog( - state = rememberUseCaseState(visible = true, - onFinishedRequest = { - onSELinuxChange(domain, rules) - }, - onCloseRequest = { - dismiss() - }), - header = Header.Default( - title = stringResource(R.string.profile_selinux_context), - ), - selection = InputSelection( - input = inputOptions, - onPositiveClick = { result -> - // Handle selection - }, + val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest + + MaterialTheme( + colorScheme = MaterialTheme.colorScheme.copy( + surface = backgroundColor ) - ) + ) { + InputDialog( + state = rememberUseCaseState( + visible = true, + onFinishedRequest = { + onSELinuxChange(domain, rules) + }, + onCloseRequest = { + dismiss() + }), + header = Header.Default( + title = stringResource(R.string.profile_selinux_context), + ), + selection = InputSelection( + input = inputOptions, + onPositiveClick = { result -> + // Handle selection + }, + ) + ) + } } ListItem(headlineContent = { diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/MoreSettings.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/MoreSettings.kt index 25825e96..9555976c 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/MoreSettings.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/MoreSettings.kt @@ -359,7 +359,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) { var isCustomizeExpanded by remember { mutableStateOf(false) } var isAppearanceExpanded by remember { mutableStateOf(true) } var isAdvancedExpanded by remember { mutableStateOf(false) } - var isDpiExpanded by remember { mutableStateOf(false) } // DPI 设置 val systemDpi = remember { context.resources.displayMetrics.densityDpi } @@ -680,6 +679,99 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) { } } + // DPI 设置 + ListItem( + headlineContent = { Text(stringResource(R.string.app_dpi_title)) }, + supportingContent = { Text(stringResource(R.string.app_dpi_summary)) }, + leadingContent = { + Icon( + Icons.Default.AcUnit, + contentDescription = null, + tint = MaterialTheme.colorScheme.primary + ) + }, + trailingContent = { + Text( + text = getDpiFriendlyName(tempDpi), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.primary + ) + }, + colors = ListItemDefaults.colors( + containerColor = Color.Transparent + ) + ) + + // DPI 滑动条 + Column(modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp)) { + Slider( + value = tempDpi.toFloat(), + onValueChange = { + tempDpi = it.toInt() + isDpiCustom = !dpiPresets.containsValue(tempDpi) + }, + valueRange = 160f..600f, + steps = 11, + colors = SliderDefaults.colors( + thumbColor = MaterialTheme.colorScheme.primary, + activeTrackColor = MaterialTheme.colorScheme.primary, + inactiveTrackColor = MaterialTheme.colorScheme.surfaceVariant + ) + ) + + Row( + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), + ) { + dpiPresets.forEach { (name, dpi) -> + TextButton( + onClick = { + tempDpi = dpi + isDpiCustom = false + }, + modifier = Modifier.weight(1f) + ) { + Text( + text = name, + color = if (tempDpi == dpi) + MaterialTheme.colorScheme.primary + else + MaterialTheme.colorScheme.onSurfaceVariant + ) + } + } + } + + TextButton( + onClick = { + if (tempDpi != currentDpi) { + showDpiConfirmDialog = true + } + }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp) + ) { + Text(stringResource(R.string.dpi_apply_settings)) + } + + Text( + text = if (isDpiCustom) + "${stringResource(R.string.dpi_size_custom)}: $tempDpi" + else + "${getDpiFriendlyName(tempDpi)}: $tempDpi", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(top = 4.dp) + ) + } + + HorizontalDivider( + modifier = Modifier.padding(horizontal = 16.dp), + color = MaterialTheme.colorScheme.outlineVariant + ) + // 自定义背景开关 ListItem( headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) }, @@ -850,114 +942,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) { } } - // DPI 设置部分 - SectionHeader( - title = stringResource(R.string.dpi_settings), - expanded = isDpiExpanded, - onToggle = { isDpiExpanded = !isDpiExpanded } - ) - - AnimatedVisibility( - visible = isDpiExpanded, - enter = fadeIn() + expandVertically(), - exit = fadeOut() + shrinkVertically() - ) { - Surface( - shape = RoundedCornerShape(16.dp), - tonalElevation = 1.dp, - modifier = Modifier.padding(bottom = 16.dp) - ) { - Column { - ListItem( - headlineContent = { Text(stringResource(R.string.app_dpi_title)) }, - supportingContent = { Text(stringResource(R.string.app_dpi_summary)) }, - leadingContent = { - Icon( - Icons.Default.AcUnit, - contentDescription = null, - tint = MaterialTheme.colorScheme.primary - ) - }, - trailingContent = { - Text( - text = getDpiFriendlyName(tempDpi), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.primary - ) - }, - colors = ListItemDefaults.colors( - containerColor = Color.Transparent - ) - ) - - // DPI 滑动条 - Column(modifier = Modifier.padding(horizontal = 32.dp, vertical = 8.dp)) { - Slider( - value = tempDpi.toFloat(), - onValueChange = { - tempDpi = it.toInt() - isDpiCustom = !dpiPresets.containsValue(tempDpi) - }, - valueRange = 160f..600f, - steps = 11, - colors = SliderDefaults.colors( - thumbColor = MaterialTheme.colorScheme.primary, - activeTrackColor = MaterialTheme.colorScheme.primary, - inactiveTrackColor = MaterialTheme.colorScheme.surfaceVariant - ) - ) - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(top = 8.dp), - ) { - dpiPresets.forEach { (name, dpi) -> - TextButton( - onClick = { - tempDpi = dpi - isDpiCustom = false - }, - modifier = Modifier.weight(1f) - ) { - Text( - text = name, - color = if (tempDpi == dpi) - MaterialTheme.colorScheme.primary - else - MaterialTheme.colorScheme.onSurfaceVariant - ) - } - } - } - - TextButton( - onClick = { - if (tempDpi != currentDpi) { - showDpiConfirmDialog = true - } - }, - modifier = Modifier - .fillMaxWidth() - .padding(top = 8.dp) - ) { - Text(stringResource(R.string.dpi_apply_settings)) - } - - Text( - text = if (isDpiCustom) - "${stringResource(R.string.dpi_size_custom)}: $tempDpi" - else - "${getDpiFriendlyName(tempDpi)}: $tempDpi", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(top = 4.dp) - ) - } - } - } - } - // 自定义设置部分 SectionHeader( title = stringResource(R.string.custom_settings), diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Settings.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Settings.kt index f095f9da..0852bd9f 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Settings.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Settings.kt @@ -12,6 +12,7 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.shrinkVertically import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.* @@ -32,6 +33,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext @@ -645,7 +647,7 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle { ) } - var selection = UninstallType.NONE + var selectedOption by remember { mutableStateOf(null) } val cardColor = if (!ThemeConfig.useDynamicColor) { ThemeConfig.currentTheme.ButtonContrast } else { @@ -668,55 +670,102 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle { modifier = Modifier.padding(vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(16.dp) ) { - listOptions.forEachIndexed { index, option -> + options.forEachIndexed { index, option -> + val isSelected = selectedOption == option + val backgroundColor = if (isSelected) + MaterialTheme.colorScheme.primaryContainer + else + Color.Transparent + val borderColor = if (isSelected) + MaterialTheme.colorScheme.primary + else + Color.Transparent + val contentColor = if (isSelected) + MaterialTheme.colorScheme.onPrimaryContainer + else + MaterialTheme.colorScheme.onSurface + Row( modifier = Modifier .fillMaxWidth() .clip(MaterialTheme.shapes.medium) + .background(backgroundColor) + .border( + width = 1.dp, + color = borderColor, + shape = MaterialTheme.shapes.medium + ) .clickable { - selection = options[index] + selectedOption = option } .padding(vertical = 12.dp, horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Icon( - imageVector = options[index].icon, + imageVector = option.icon, contentDescription = null, - tint = MaterialTheme.colorScheme.primary, + tint = if (isSelected) + MaterialTheme.colorScheme.primary + else + MaterialTheme.colorScheme.primary, modifier = Modifier .padding(end = 16.dp) .size(24.dp) ) - Column { + Column( + modifier = Modifier.weight(1f) + ) { Text( - text = option.titleText, + text = listOptions[index].titleText, style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.onSurface + color = contentColor ) - option.subtitleText?.let { + listOptions[index].subtitleText?.let { Text( text = it, style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant + color = if (isSelected) + contentColor.copy(alpha = 0.8f) + else + MaterialTheme.colorScheme.onSurfaceVariant ) } } + if (isSelected) { + Icon( + imageVector = Icons.Default.RadioButtonChecked, + contentDescription = null, + tint = MaterialTheme.colorScheme.primary, + modifier = Modifier.size(24.dp) + ) + } else { + Icon( + imageVector = Icons.Default.RadioButtonUnchecked, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.size(24.dp) + ) + } } } } }, confirmButton = { - TextButton( + Button( onClick = { - if (selection != UninstallType.NONE) { - onSelected(selection) - } + selectedOption?.let { onSelected(it) } dismiss() - } + }, + enabled = selectedOption != null, + colors = ButtonDefaults.buttonColors( + containerColor = MaterialTheme.colorScheme.primary, + contentColor = MaterialTheme.colorScheme.onPrimary, + disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant, + disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Text( - text = stringResource(android.R.string.ok), - color = MaterialTheme.colorScheme.primary + text = stringResource(android.R.string.ok) ) } },