manager: Refactoring the settings interface
- Merge Web Debugging and Web X Eruda switches
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.sukisu.ultra.ui.component
|
package com.sukisu.ultra.ui.component
|
||||||
|
|
||||||
import androidx.compose.foundation.LocalIndication
|
import androidx.compose.foundation.LocalIndication
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.selection.toggleable
|
import androidx.compose.foundation.selection.toggleable
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -13,7 +12,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import com.dergoogler.mmrl.ui.component.LabelItem
|
import com.dergoogler.mmrl.ui.component.LabelItem
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import androidx.compose.animation.expandVertically
|
|||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.shrinkVertically
|
import androidx.compose.animation.shrinkVertically
|
||||||
import androidx.compose.foundation.border
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
@@ -519,12 +518,16 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
enter = fadeIn() + expandVertically(),
|
enter = fadeIn() + expandVertically(),
|
||||||
exit = fadeOut() + shrinkVertically()
|
exit = fadeOut() + shrinkVertically()
|
||||||
) {
|
) {
|
||||||
Surface(
|
Card(
|
||||||
shape = RoundedCornerShape(16.dp),
|
modifier = Modifier
|
||||||
tonalElevation = 1.dp,
|
.fillMaxWidth()
|
||||||
modifier = Modifier.padding(bottom = 16.dp)
|
.padding(bottom = 16.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
|
||||||
|
),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column(modifier = Modifier.padding(vertical = 8.dp)) {
|
||||||
// 语言设置
|
// 语言设置
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.language_setting)) },
|
headlineContent = { Text(stringResource(R.string.language_setting)) },
|
||||||
@@ -552,11 +555,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
modifier = Modifier.clickable { showLanguageDialog = true }
|
modifier = Modifier.clickable { showLanguageDialog = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 主题模式
|
// 主题模式
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.theme_mode)) },
|
headlineContent = { Text(stringResource(R.string.theme_mode)) },
|
||||||
@@ -581,11 +579,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
modifier = Modifier.clickable { showThemeModeDialog = true }
|
modifier = Modifier.clickable { showThemeModeDialog = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 动态颜色开关
|
// 动态颜色开关
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
@@ -597,11 +590,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
useDynamicColor = enabled
|
useDynamicColor = enabled
|
||||||
context.saveDynamicColorState(enabled)
|
context.saveDynamicColorState(enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只在未启用动态颜色时显示主题色选择
|
// 只在未启用动态颜色时显示主题色选择
|
||||||
@@ -644,11 +632,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
),
|
),
|
||||||
modifier = Modifier.clickable { showThemeColorDialog = true }
|
modifier = Modifier.clickable { showThemeColorDialog = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,11 +723,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 自定义背景开关
|
// 自定义背景开关
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) },
|
headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) },
|
||||||
@@ -927,12 +905,16 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
enter = fadeIn() + expandVertically(),
|
enter = fadeIn() + expandVertically(),
|
||||||
exit = fadeOut() + shrinkVertically()
|
exit = fadeOut() + shrinkVertically()
|
||||||
) {
|
) {
|
||||||
Surface(
|
Card(
|
||||||
shape = RoundedCornerShape(16.dp),
|
modifier = Modifier
|
||||||
tonalElevation = 1.dp,
|
.fillMaxWidth()
|
||||||
modifier = Modifier.padding(bottom = 16.dp)
|
.padding(bottom = 16.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
|
||||||
|
),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column(modifier = Modifier.padding(vertical = 8.dp)) {
|
||||||
// 添加简洁模式开关
|
// 添加简洁模式开关
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
icon = Icons.Filled.Brush,
|
icon = Icons.Filled.Brush,
|
||||||
@@ -943,10 +925,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
onSimpleModeChange(it)
|
onSimpleModeChange(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 隐藏内核部分版本号
|
// 隐藏内核部分版本号
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
@@ -958,11 +937,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
onHideVersionChange(it)
|
onHideVersionChange(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 模块数量等信息
|
// 模块数量等信息
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
icon = Icons.Filled.VisibilityOff,
|
icon = Icons.Filled.VisibilityOff,
|
||||||
@@ -973,11 +947,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
onHideOtherInfoChange(it)
|
onHideOtherInfoChange(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// SuSFS 状态信息
|
// SuSFS 状态信息
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
icon = Icons.Filled.VisibilityOff,
|
icon = Icons.Filled.VisibilityOff,
|
||||||
@@ -989,11 +958,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Natives.version >= Natives.MINIMAL_SUPPORTED_KPM) {
|
if (Natives.version >= Natives.MINIMAL_SUPPORTED_KPM) {
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 显示KPM开关
|
// 显示KPM开关
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
icon = Icons.Filled.Visibility,
|
icon = Icons.Filled.Visibility,
|
||||||
@@ -1005,11 +969,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
|
|
||||||
// 隐藏链接信息
|
// 隐藏链接信息
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
icon = Icons.Filled.VisibilityOff,
|
icon = Icons.Filled.VisibilityOff,
|
||||||
@@ -1035,12 +994,16 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
enter = fadeIn() + expandVertically(),
|
enter = fadeIn() + expandVertically(),
|
||||||
exit = fadeOut() + shrinkVertically()
|
exit = fadeOut() + shrinkVertically()
|
||||||
) {
|
) {
|
||||||
Surface(
|
Card(
|
||||||
shape = RoundedCornerShape(16.dp),
|
modifier = Modifier
|
||||||
tonalElevation = 1.dp,
|
.fillMaxWidth()
|
||||||
modifier = Modifier.padding(bottom = 16.dp)
|
.padding(bottom = 16.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
|
||||||
|
),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column(modifier = Modifier.padding(vertical = 8.dp)) {
|
||||||
// SELinux 开关
|
// SELinux 开关
|
||||||
KsuIsValid {
|
KsuIsValid {
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
@@ -1072,11 +1035,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
|
||||||
color = MaterialTheme.colorScheme.outlineVariant
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SuSFS 配置(仅在支持时显示)
|
// SuSFS 配置(仅在支持时显示)
|
||||||
|
|||||||
@@ -229,25 +229,6 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Web调试开关
|
|
||||||
var enableWebDebugging by rememberSaveable {
|
|
||||||
mutableStateOf(
|
|
||||||
prefs.getBoolean("enable_web_debugging", false)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
KsuIsValid {
|
|
||||||
SwitchSettingItem(
|
|
||||||
icon = Icons.Filled.DeveloperMode,
|
|
||||||
title = stringResource(id = R.string.enable_web_debugging),
|
|
||||||
summary = stringResource(id = R.string.enable_web_debugging_summary),
|
|
||||||
checked = enableWebDebugging,
|
|
||||||
onCheckedChange = {
|
|
||||||
prefs.edit { putBoolean("enable_web_debugging", it) }
|
|
||||||
enableWebDebugging = it
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebUI引擎选择
|
// WebUI引擎选择
|
||||||
KsuIsValid {
|
KsuIsValid {
|
||||||
val engineOptions = listOf(
|
val engineOptions = listOf(
|
||||||
@@ -309,29 +290,44 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web X Eruda 开关
|
// Web调试和Web X Eruda 开关
|
||||||
|
var enableWebDebugging by rememberSaveable {
|
||||||
|
mutableStateOf(
|
||||||
|
prefs.getBoolean("enable_web_debugging", false)
|
||||||
|
)
|
||||||
|
}
|
||||||
var useWebUIXEruda by rememberSaveable {
|
var useWebUIXEruda by rememberSaveable {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
prefs.getBoolean("use_webuix_eruda", false)
|
prefs.getBoolean("use_webuix_eruda", false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
KsuIsValid {
|
KsuIsValid {
|
||||||
|
SwitchSettingItem(
|
||||||
|
icon = Icons.Filled.DeveloperMode,
|
||||||
|
title = stringResource(id = R.string.enable_web_debugging),
|
||||||
|
summary = stringResource(id = R.string.enable_web_debugging_summary),
|
||||||
|
checked = enableWebDebugging,
|
||||||
|
onCheckedChange = {
|
||||||
|
prefs.edit { putBoolean("enable_web_debugging", it) }
|
||||||
|
enableWebDebugging = it
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = enableWebDebugging && selectedEngine == "wx",
|
visible = enableWebDebugging && selectedEngine == "wx",
|
||||||
enter = fadeIn() + expandVertically(),
|
enter = fadeIn() + expandVertically(),
|
||||||
exit = fadeOut() + shrinkVertically()
|
exit = fadeOut() + shrinkVertically()
|
||||||
) {
|
) {
|
||||||
SwitchItem(
|
SwitchSettingItem(
|
||||||
beta = true,
|
|
||||||
enabled = Platform.isAlive && enableWebDebugging,
|
|
||||||
icon = Icons.Filled.FormatListNumbered,
|
icon = Icons.Filled.FormatListNumbered,
|
||||||
title = stringResource(id = R.string.use_webuix_eruda),
|
title = stringResource(id = R.string.use_webuix_eruda),
|
||||||
summary = stringResource(id = R.string.use_webuix_eruda_summary),
|
summary = stringResource(id = R.string.use_webuix_eruda_summary),
|
||||||
checked = useWebUIXEruda
|
checked = useWebUIXEruda,
|
||||||
) {
|
onCheckedChange = {
|
||||||
prefs.edit { putBoolean("use_webuix_eruda", it) }
|
prefs.edit { putBoolean("use_webuix_eruda", it) }
|
||||||
useWebUIXEruda = it
|
useWebUIXEruda = it
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user