manager: Optimize color schemes for themes and module screens

- Remove unnecessary background color settings
This commit is contained in:
ShirkNeko
2025-06-01 14:04:10 +08:00
parent dd1d17d2cf
commit ee4c3bb03b
8 changed files with 66 additions and 429 deletions

View File

@@ -1,6 +1,5 @@
package com.sukisu.ultra.ui.screen
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.os.PowerManager
@@ -29,7 +28,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
@@ -63,7 +61,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -75,12 +72,8 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
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
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
@@ -97,7 +90,7 @@ import com.sukisu.ultra.Natives
import com.sukisu.ultra.R
import com.sukisu.ultra.ui.component.KsuIsValid
import com.sukisu.ultra.ui.component.rememberConfirmDialog
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.theme.CardConfig.cardAlpha
import com.sukisu.ultra.ui.theme.CardConfig.cardElevation
import com.sukisu.ultra.ui.theme.getCardColors
import com.sukisu.ultra.ui.util.checkNewVersion
@@ -257,7 +250,7 @@ fun UpdateCard() {
val updateDialog = rememberConfirmDialog(onConfirm = { uriHandler.openUri(newVersionUrl) })
WarningCard(
message = stringResource(id = R.string.new_version_available).format(newVersionCode),
color = MaterialTheme.colorScheme.surfaceVariant,
color = MaterialTheme.colorScheme.outlineVariant,
onClick = {
if (changelog.isEmpty()) {
uriHandler.openUri(newVersionUrl)
@@ -289,7 +282,6 @@ private fun TopBar(
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceContainerLow
val cardAlpha = CardConfig.cardAlpha
TopAppBar(
title = {
@@ -342,16 +334,9 @@ private fun StatusCard(
onClickInstall: () -> Unit = {}
) {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.secondaryContainer),
colors = getCardColors( if (systemStatus.ksuVersion != null)MaterialTheme.colorScheme.secondaryContainer
else MaterialTheme.colorScheme.errorContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.surface.copy(alpha = 0.1f)
)
) {
Row(
modifier = Modifier
@@ -394,7 +379,6 @@ private fun StatusCard(
Text(
text = workingModeText,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
Spacer(Modifier.width(8.dp))
@@ -408,13 +392,13 @@ private fun StatusCard(
Text(
text = workingModeSurfaceText,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSecondary,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
Spacer(Modifier.width(6.dp))
// 架构标签
Surface(
shape = RoundedCornerShape(4.dp),
color = MaterialTheme.colorScheme.primary,
@@ -423,7 +407,6 @@ private fun StatusCard(
Text(
text = Os.uname().machine,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSecondary,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
@@ -443,7 +426,6 @@ private fun StatusCard(
Text(
text = stringResource(R.string.home_working_version, systemStatus.ksuVersion),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
@@ -452,14 +434,12 @@ private fun StatusCard(
Text(
text = stringResource(R.string.home_superuser_count, getSuperuserCount()),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_module_count, getModuleCount()),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
val kpmVersion = getKpmVersion()
@@ -468,7 +448,6 @@ private fun StatusCard(
Text(
text = stringResource(R.string.home_kpm_module, getKpmModuleCount()),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -487,14 +466,12 @@ private fun StatusCard(
Text(
text = stringResource(R.string.home_not_installed),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.error
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_click_to_install),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -511,14 +488,12 @@ private fun StatusCard(
Text(
text = stringResource(R.string.home_unsupported),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.error
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_unsupported_reason),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -536,13 +511,6 @@ fun WarningCard(
ElevatedCard(
colors = getCardColors(color),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
)
) {
Row(
modifier = Modifier
@@ -554,7 +522,6 @@ fun WarningCard(
Text(
text = message,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onErrorContainer
)
}
}
@@ -568,15 +535,6 @@ fun ContributionCard() {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.tertiary.copy(alpha = 0.1f)
)
) {
Row(
modifier = Modifier
@@ -592,14 +550,12 @@ fun ContributionCard() {
Text(
text = stringResource(R.string.home_ContributionCard_kernelsu),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_click_to_ContributionCard_kernelsu),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.8f)
)
}
}
@@ -613,15 +569,7 @@ fun LearnMoreCard() {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Row(
modifier = Modifier
@@ -636,14 +584,12 @@ fun LearnMoreCard() {
Text(
text = stringResource(R.string.home_learn_kernelsu),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_click_to_learn_kernelsu),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.8f)
)
}
}
@@ -657,14 +603,6 @@ fun DonateCard() {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.secondary.copy(alpha = 0.1f)
)
) {
Row(
modifier = Modifier
@@ -679,14 +617,12 @@ fun DonateCard() {
Text(
text = stringResource(R.string.home_support_title),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_support_content),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.8f)
)
}
}
@@ -706,14 +642,6 @@ private fun InfoCard(
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.05f)
)
) {
Column(
modifier = Modifier
@@ -747,12 +675,10 @@ private fun InfoCard(
Text(
text = label,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
text = content,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface,
softWrap = true
)
}
@@ -904,12 +830,3 @@ private fun WarningCardPreview() {
onClick = {})
}
}
@SuppressLint("UnnecessaryComposedModifier")
fun Modifier.disableOverscroll(): Modifier = composed {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
this
} else {
this
}
}

View File

@@ -112,7 +112,6 @@ fun KpmScreen(
Text(
text = kpmInstallMode,
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onSurface
)
},
text = {
@@ -121,7 +120,6 @@ fun KpmScreen(
Text(
text = stringResource(R.string.kpm_install_mode_description, it),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
Spacer(modifier = Modifier.height(16.dp))
@@ -146,9 +144,6 @@ fun KpmScreen(
}
},
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary
)
) {
Icon(
imageVector = Icons.Filled.Download,
@@ -176,9 +171,6 @@ fun KpmScreen(
}
},
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondary
)
) {
Icon(
imageVector = Icons.Filled.Inventory,
@@ -209,7 +201,6 @@ fun KpmScreen(
}
}
},
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
shape = MaterialTheme.shapes.extraLarge
)
}
@@ -309,10 +300,8 @@ fun KpmScreen(
text = {
Text(
text = stringResource(R.string.kpm_install),
color = MaterialTheme.colorScheme.onPrimaryContainer
)
},
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
expanded = true,
)
},
@@ -321,9 +310,6 @@ fun KpmScreen(
Column(modifier = Modifier.padding(padding)) {
if (!isNoticeClosed) {
Card(
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer
),
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
@@ -348,7 +334,6 @@ fun KpmScreen(
text = stringResource(R.string.kernel_module_notice),
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSecondaryContainer
)
IconButton(
@@ -357,9 +342,6 @@ fun KpmScreen(
sharedPreferences.edit { putBoolean("is_notice_closed", true) }
},
modifier = Modifier.size(24.dp),
colors = IconButtonDefaults.iconButtonColors(
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
)
) {
Icon(
imageVector = Icons.Filled.Close,
@@ -391,7 +373,6 @@ fun KpmScreen(
stringResource(R.string.kpm_empty),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -585,7 +566,6 @@ private fun KpmModuleItem(
Text(
text = stringResource(R.string.kpm_control),
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onSurface
)
},
text = {
@@ -595,20 +575,14 @@ private fun KpmModuleItem(
label = {
Text(
text = stringResource(R.string.kpm_args),
color = MaterialTheme.colorScheme.primary
)
},
placeholder = {
Text(
text = module.args,
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f)
)
},
modifier = Modifier.fillMaxWidth(),
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = MaterialTheme.colorScheme.primary,
unfocusedBorderColor = MaterialTheme.colorScheme.outline
)
)
},
confirmButton = {
@@ -627,7 +601,6 @@ private fun KpmModuleItem(
) {
Text(
text = stringResource(R.string.confirm),
color = MaterialTheme.colorScheme.primary
)
}
},
@@ -635,26 +608,16 @@ private fun KpmModuleItem(
TextButton(onClick = { viewModel.hideInputDialog() }) {
Text(
text = stringResource(R.string.cancel),
color = MaterialTheme.colorScheme.primary
)
}
},
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
shape = MaterialTheme.shapes.extraLarge
)
}
Card(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(
modifier = Modifier.padding(20.dp)
@@ -668,7 +631,6 @@ private fun KpmModuleItem(
Text(
text = module.name,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface
)
Spacer(modifier = Modifier.height(4.dp))
@@ -676,19 +638,16 @@ private fun KpmModuleItem(
Text(
text = "${stringResource(R.string.kpm_version)}: ${module.version}",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
text = "${stringResource(R.string.kpm_author)}: ${module.author}",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
text = "${stringResource(R.string.kpm_args)}: ${module.args}",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -698,7 +657,6 @@ private fun KpmModuleItem(
Text(
text = module.description,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(20.dp))
@@ -711,10 +669,6 @@ private fun KpmModuleItem(
onClick = { viewModel.showInputDialog(module.id) },
enabled = module.hasAction,
modifier = Modifier.weight(1f),
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary,
disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant
)
) {
Icon(
imageVector = Icons.Filled.Settings,

View File

@@ -23,9 +23,7 @@ import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.*
import androidx.compose.ui.res.stringResource
@@ -230,10 +228,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
Checkbox(
checked = viewModel.sortActionFirst,
onCheckedChange = null,
colors = CheckboxDefaults.colors(
checkedColor = MaterialTheme.colorScheme.primary,
uncheckedColor = MaterialTheme.colorScheme.outline
)
)
},
onClick = {
@@ -255,10 +249,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
Checkbox(
checked = viewModel.sortEnabledFirst,
onCheckedChange = null,
colors = CheckboxDefaults.colors(
checkedColor = MaterialTheme.colorScheme.primary,
uncheckedColor = MaterialTheme.colorScheme.outline
)
)
},
onClick = {
@@ -325,10 +315,8 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
text = {
Text(
text = moduleInstall,
color = MaterialTheme.colorScheme.onPrimaryContainer
)
},
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
expanded = true,
)
}
@@ -353,7 +341,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
Icon(
imageVector = Icons.Outlined.Warning,
contentDescription = null,
tint = MaterialTheme.colorScheme.error,
modifier = Modifier
.size(64.dp)
.padding(bottom = 16.dp)
@@ -362,7 +349,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
stringResource(R.string.module_magisk_conflict),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -640,7 +626,6 @@ private fun ModuleList(
text = stringResource(R.string.module_empty),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -727,14 +712,6 @@ fun ModuleItem(
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
) {
val textDecoration = if (!module.remove) null else TextDecoration.LineThrough
val interactionSource = remember { MutableInteractionSource() }
@@ -777,7 +754,6 @@ fun ModuleItem(
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
textDecoration = textDecoration,
color = MaterialTheme.colorScheme.onSurface
)
Text(
@@ -786,7 +762,6 @@ fun ModuleItem(
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
textDecoration = textDecoration,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
@@ -795,7 +770,6 @@ fun ModuleItem(
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
textDecoration = textDecoration,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
@@ -810,14 +784,6 @@ fun ModuleItem(
checked = module.enabled,
onCheckedChange = onCheckChanged,
interactionSource = if (!module.hasWebUi) interactionSource else null,
colors = SwitchDefaults.colors(
checkedThumbColor = MaterialTheme.colorScheme.onPrimary,
checkedTrackColor = MaterialTheme.colorScheme.primary,
checkedIconColor = MaterialTheme.colorScheme.primary,
uncheckedThumbColor = MaterialTheme.colorScheme.outline,
uncheckedTrackColor = MaterialTheme.colorScheme.surfaceVariant,
uncheckedIconColor = MaterialTheme.colorScheme.surfaceVariant
)
)
}
}
@@ -833,7 +799,6 @@ fun ModuleItem(
overflow = TextOverflow.Ellipsis,
maxLines = 4,
textDecoration = textDecoration,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(16.dp))
@@ -855,7 +820,6 @@ fun ModuleItem(
viewModel.markNeedRefresh()
},
contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors()
) {
Icon(
modifier = Modifier.size(20.dp),
@@ -872,7 +836,6 @@ fun ModuleItem(
onClick = { onClick(module) },
interactionSource = interactionSource,
contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors()
) {
Icon(
@@ -892,7 +855,6 @@ fun ModuleItem(
onClick = { onUpdate(module) },
shape = ButtonDefaults.textShape,
contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors()
) {
Icon(
modifier = Modifier.size(20.dp),
@@ -906,8 +868,6 @@ fun ModuleItem(
modifier = Modifier.defaultMinSize(minWidth = 52.dp, minHeight = 32.dp),
onClick = { onUninstallClicked(module) },
contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = if (!module.remove) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.errorContainer)
) {
if (!module.remove) {
Icon(

View File

@@ -49,11 +49,9 @@ 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.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.core.content.edit
import com.ramcosta.composedestinations.annotation.Destination
@@ -66,8 +64,10 @@ import com.sukisu.ultra.ui.component.ImageEditorDialog
import com.sukisu.ultra.ui.component.KsuIsValid
import com.sukisu.ultra.ui.component.SwitchItem
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.theme.CardConfig.cardElevation
import com.sukisu.ultra.ui.theme.ThemeColors
import com.sukisu.ultra.ui.theme.ThemeConfig
import com.sukisu.ultra.ui.theme.getCardColors
import com.sukisu.ultra.ui.theme.saveAndApplyCustomBackground
import com.sukisu.ultra.ui.theme.saveCustomBackground
import com.sukisu.ultra.ui.theme.saveDynamicColorState
@@ -331,11 +331,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
var showImageEditor by remember { mutableStateOf(false) }
var selectedImageUri by remember { mutableStateOf<Uri?>(null) }
// 展开/折叠状态
var isCustomizeExpanded by remember { mutableStateOf(false) }
var isAppearanceExpanded by remember { mutableStateOf(true) }
var isAdvancedExpanded by remember { mutableStateOf(false) }
// DPI 设置
val systemDpi = remember { context.resources.displayMetrics.densityDpi }
var currentDpi by remember {
@@ -466,7 +461,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
onConfirm = { transformedUri ->
context.saveAndApplyCustomBackground(transformedUri)
isCustomBackgroundEnabled = true
CardConfig.cardElevation = 0.dp
cardElevation = 0.dp
CardConfig.isCustomBackgroundEnabled = true
saveCardConfig(context)
showImageEditor = false
@@ -483,7 +478,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
}
val cardColor = MaterialTheme.colorScheme.surfaceContainerHigh
val cardAlphaUse = CardConfig.cardAlpha
val isDarkTheme = isSystemInDarkTheme()
Scaffold(
@@ -492,8 +486,8 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
TopAppBar(
title = { Text(stringResource(R.string.more_settings)) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = cardColor.copy(alpha = cardAlphaUse),
scrolledContainerColor = cardColor.copy(alpha = cardAlphaUse)),
containerColor = cardColor.copy(alpha = cardAlpha),
scrolledContainerColor = cardColor.copy(alpha = cardAlpha)),
navigationIcon = {
IconButton(onClick = { navigator.popBackStack() }) {
Icon(Icons.AutoMirrored.Filled.ArrowBack,
@@ -511,27 +505,19 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
// 外观设置部分
SectionHeader(
title = stringResource(R.string.appearance_settings),
expanded = isAppearanceExpanded,
onToggle = { isAppearanceExpanded = !isAppearanceExpanded }
)
AnimatedVisibility(
visible = isAppearanceExpanded,
enter = fadeIn() + expandVertically(),
exit = fadeOut() + shrinkVertically()
) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.appearance_settings),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
// 语言设置
ListItem(
headlineContent = { Text(stringResource(R.string.language_setting)) },
@@ -553,9 +539,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
tint = MaterialTheme.colorScheme.onSurfaceVariant
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
),
modifier = Modifier.clickable { showLanguageDialog = true }
)
@@ -577,9 +560,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
tint = MaterialTheme.colorScheme.onSurfaceVariant
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
),
modifier = Modifier.clickable { showThemeModeDialog = true }
)
@@ -631,9 +611,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
tint = MaterialTheme.colorScheme.onSurfaceVariant
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
),
modifier = Modifier.clickable { showThemeColorDialog = true }
)
}
@@ -654,12 +631,8 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
Text(
text = getDpiFriendlyName(tempDpi),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary
)
},
colors = ListItemDefaults.colors(
containerColor = Color.Transparent
)
}
)
// DPI 滑动条
@@ -722,7 +695,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
else
"${getDpiFriendlyName(tempDpi)}: $tempDpi",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 4.dp)
)
}
@@ -739,7 +711,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} else {
context.saveCustomBackground(null)
isCustomBackgroundEnabled = false
CardConfig.cardElevation
cardElevation
CardConfig.cardAlpha = 1f
CardConfig.cardDim = 0f
CardConfig.isCustomAlphaSet = false
@@ -797,7 +769,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
Text(
text = "${(cardAlpha * 100).roundToInt()}%",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
@@ -846,7 +817,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
Text(
text = "${(cardDim * 100).roundToInt()}%",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
@@ -878,30 +848,21 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
}
}
}
}
// 自定义设置部分
SectionHeader(
title = stringResource(R.string.custom_settings),
expanded = isCustomizeExpanded,
onToggle = { isCustomizeExpanded = !isCustomizeExpanded }
)
AnimatedVisibility(
visible = isCustomizeExpanded,
enter = fadeIn() + expandVertically(),
exit = fadeOut() + shrinkVertically()
) {
// 自定义设置部分
Card(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Column(Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.custom_settings),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
// 添加简洁模式开关
SwitchItem(
icon = Icons.Filled.Brush,
@@ -912,8 +873,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
onSimpleModeChange(it)
}
// 隐藏内核部分版本号
SwitchItem(
icon = Icons.Filled.VisibilityOff,
@@ -967,30 +926,21 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
}
}
}
}
// 高级设置部分
SectionHeader(
title = stringResource(R.string.advanced_settings),
expanded = isAdvancedExpanded,
onToggle = { isAdvancedExpanded = !isAdvancedExpanded }
)
AnimatedVisibility(
visible = isAdvancedExpanded,
enter = fadeIn() + expandVertically(),
exit = fadeOut() + shrinkVertically()
) {
// 高级设置部分
Card(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Column( Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.advanced_settings),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
// SELinux 开关
KsuIsValid {
SwitchItem(
@@ -1077,7 +1027,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
}
}
}
}
// 主题模式选择对话框
if (showThemeModeDialog) {
@@ -1173,7 +1122,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
Text(
stringResource(R.string.dpi_confirm_summary),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(top = 8.dp)
)
}
@@ -1252,35 +1200,3 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
)
}
}
@Composable
fun SectionHeader(
title: String,
expanded: Boolean,
onToggle: () -> Unit
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable { onToggle() }
.padding(vertical = 12.dp, horizontal = 4.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = title,
style = MaterialTheme.typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
color = MaterialTheme.colorScheme.primary
)
Spacer(modifier = Modifier.weight(1f))
Icon(
imageVector = if (expanded) Icons.Default.KeyboardArrowUp else Icons.Default.KeyboardArrowDown,
contentDescription = if (expanded)
stringResource(R.string.collapse)
else
stringResource(R.string.expand),
tint = MaterialTheme.colorScheme.primary
)
}
}

View File

@@ -12,7 +12,6 @@ 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.*
@@ -64,6 +63,7 @@ import com.sukisu.ultra.ui.util.getBugreportFile
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import com.sukisu.ultra.ui.component.KsuIsValid
import com.sukisu.ultra.ui.theme.CardConfig.cardElevation
/**
* @author ShirkNeko
@@ -126,16 +126,13 @@ fun SettingScreen(navigator: DestinationsNavigator) {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.configuration),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
@@ -197,16 +194,13 @@ fun SettingScreen(navigator: DestinationsNavigator) {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.app_settings),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
@@ -345,16 +339,13 @@ fun SettingScreen(navigator: DestinationsNavigator) {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.tools),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
@@ -444,16 +435,13 @@ fun SettingScreen(navigator: DestinationsNavigator) {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = cardAlpha)
),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation)
) {
Column(modifier = Modifier.padding(vertical = 8.dp)) {
Text(
text = stringResource(R.string.about),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
@@ -502,7 +490,6 @@ fun LogActionButton(
Text(
text = text,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface
)
}
}
@@ -534,13 +521,11 @@ fun SettingItem(
Text(
text = title,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
if (summary != null) {
Text(
text = summary,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -642,7 +627,6 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
Text(
text = stringResource(R.string.settings_uninstall),
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onSurface
)
},
text = {
@@ -670,11 +654,6 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
.fillMaxWidth()
.clip(MaterialTheme.shapes.medium)
.background(backgroundColor)
.border(
width = 1.dp,
color = borderColor,
shape = MaterialTheme.shapes.medium
)
.clickable {
selectedOption = option
}
@@ -684,10 +663,7 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
Icon(
imageVector = option.icon,
contentDescription = null,
tint = if (isSelected)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.primary,
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier
.padding(end = 16.dp)
.size(24.dp)
@@ -698,7 +674,6 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
Text(
text = listOptions[index].titleText,
style = MaterialTheme.typography.titleMedium,
color = contentColor
)
listOptions[index].subtitleText?.let {
Text(
@@ -737,12 +712,6 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
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)
@@ -757,11 +726,9 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
) {
Text(
text = stringResource(android.R.string.cancel),
color = MaterialTheme.colorScheme.primary
)
}
},
containerColor = MaterialTheme.colorScheme.secondaryContainer,
shape = MaterialTheme.shapes.extraLarge,
tonalElevation = 4.dp
)

View File

@@ -1,9 +1,10 @@
package com.sukisu.ultra.ui.screen
import android.graphics.Color.alpha
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
@@ -22,7 +23,6 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.input.pointer.pointerInput
@@ -44,11 +44,9 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.launch
import com.sukisu.ultra.Natives
import com.sukisu.ultra.ui.component.SearchAppBar
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.util.ModuleModify
import com.sukisu.ultra.ui.viewmodel.SuperUserViewModel
import com.dergoogler.mmrl.ui.component.LabelItem
import com.dergoogler.mmrl.ui.component.LabelItemDefaults
/**
* @author ShirkNeko
@@ -195,8 +193,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
viewModel.showBatchActions = false
},
modifier = Modifier.size(if (isCancelPressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
shape = CircleShape,
interactionSource = cancelInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -235,8 +231,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isUnauthorizePressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.errorContainer,
contentColor = MaterialTheme.colorScheme.onErrorContainer,
shape = CircleShape,
interactionSource = unauthorizeInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -275,8 +269,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isAuthorizePressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.primaryContainer,
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
shape = CircleShape,
interactionSource = authorizeInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -325,8 +317,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isUmountEnablePressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
shape = CircleShape,
interactionSource = umountEnableInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -368,8 +358,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isUmountDisablePressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
shape = CircleShape,
interactionSource = umountDisableInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -411,8 +399,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isTopBtnPressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 1f),
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
shape = CircleShape,
interactionSource = topBtnInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -454,8 +440,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
}
},
modifier = Modifier.size(if (isBottomBtnPressed) 56.dp else 40.dp),
containerColor = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 1f),
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
shape = CircleShape,
interactionSource = bottomBtnInteractionSource,
elevation = FloatingActionButtonDefaults.elevation(4.dp, 6.dp)
@@ -638,7 +622,7 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
verticalArrangement = Arrangement.Center
) {
Icon(
imageVector = Icons.Filled.Apps,
imageVector = Icons.Filled.Archive,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
modifier = Modifier
@@ -649,7 +633,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
text = stringResource(R.string.no_apps_found),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -665,7 +648,6 @@ fun GroupHeader(title: String) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceContainerHighest.copy(alpha = 0.7f))
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
Text(
@@ -673,13 +655,12 @@ fun GroupHeader(title: String) {
style = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.primary
)
)
}
}
@OptIn(ExperimentalLayoutApi::class)
@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class)
@Composable
private fun AppItem(
app: SuperUserViewModel.AppInfo,
@@ -690,37 +671,10 @@ private fun AppItem(
onLongClick: () -> Unit,
viewModel: SuperUserViewModel
) {
val cardAlpha = CardConfig.cardAlpha
val cardColor = if (app.allowSu)
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = cardAlpha)
else if (app.hasCustomProfile)
MaterialTheme.colorScheme.secondaryContainer.copy(alpha = cardAlpha)
else
MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = cardAlpha)
Card(
colors = CardDefaults.cardColors(containerColor = cardColor),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface.copy(alpha = 0f)),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 4.dp)
.clip(MaterialTheme.shapes.medium)
.shadow(
elevation = 0.dp,
shape = MaterialTheme.shapes.medium,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
.then(
if (isSelected)
Modifier.border(
width = 2.dp,
color = MaterialTheme.colorScheme.primary,
shape = MaterialTheme.shapes.medium
)
else
Modifier
)
.pointerInput(Unit) {
detectTapGestures(
onLongPress = { onLongClick() },
@@ -754,17 +708,13 @@ private fun AppItem(
Text(
text = app.label,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface,
maxLines = 1,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
)
Text(
text = app.packageName,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
)
FlowRow(
@@ -772,21 +722,13 @@ private fun AppItem(
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
if (app.allowSu) {
LabelItem(text = "ROOT",)
LabelItem(text = "ROOT")
}
if (Natives.uidShouldUmount(app.uid)) {
LabelItem(text = "UNMOUNT", style = LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
)
)
LabelItem(text = "UNMOUNT")
}
if (app.hasCustomProfile) {
LabelItem(text = "CUSTOM", style = LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.onTertiary,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
)
)
LabelItem(text = "CUSTOM")
}
}
}
@@ -808,7 +750,6 @@ private fun AppItem(
Text(
text = if (app.allowSu) stringResource(R.string.authorized) else stringResource(R.string.unauthorized),
style = MaterialTheme.typography.labelMedium,
color = if (app.allowSu) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outline,
modifier = Modifier.padding(end = 4.dp)
)
}
@@ -817,18 +758,9 @@ private fun AppItem(
checked = app.allowSu,
onCheckedChange = onSwitchChange,
interactionSource = switchInteractionSource,
colors = SwitchDefaults.colors(
checkedThumbColor = MaterialTheme.colorScheme.onPrimary,
checkedTrackColor = MaterialTheme.colorScheme.primary,
checkedIconColor = MaterialTheme.colorScheme.primary,
uncheckedThumbColor = MaterialTheme.colorScheme.outline,
uncheckedTrackColor = MaterialTheme.colorScheme.surfaceVariant,
uncheckedIconColor = MaterialTheme.colorScheme.surfaceVariant
)
)
}
} else {
// 复选框交互源
val checkboxInteractionSource = remember { MutableInteractionSource() }
val isCheckboxPressed by checkboxInteractionSource.collectIsPressedAsState()
@@ -844,19 +776,13 @@ private fun AppItem(
Text(
text = if (isSelected) stringResource(R.string.selected) else stringResource(R.string.select),
style = MaterialTheme.typography.labelMedium,
color = if (isSelected) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outline,
modifier = Modifier.padding(end = 4.dp)
)
}
Checkbox(
checked = isSelected,
onCheckedChange = { onToggleSelection() },
interactionSource = checkboxInteractionSource,
colors = CheckboxDefaults.colors(
checkedColor = MaterialTheme.colorScheme.primary,
uncheckedColor = MaterialTheme.colorScheme.outline
)
)
}
}
@@ -865,12 +791,12 @@ private fun AppItem(
}
@Composable
fun LabelText(label: String, backgroundColor: Color) {
fun LabelText(label: String) {
Box(
modifier = Modifier
.padding(top = 2.dp, end = 2.dp)
.background(
backgroundColor,
Color.Black,
shape = RoundedCornerShape(4.dp)
)
.clip(RoundedCornerShape(4.dp))
@@ -879,9 +805,8 @@ fun LabelText(label: String, backgroundColor: Color) {
text = label,
modifier = Modifier.padding(vertical = 2.dp, horizontal = 6.dp),
style = TextStyle(
fontSize = 10.sp,
fontSize = 8.sp,
color = Color.White,
fontWeight = FontWeight.Medium
)
)
}

View File

@@ -207,13 +207,13 @@ private fun TemplateItem(
)
Text(template.description)
FlowRow {
LabelText(label = "UID: ${template.uid}", backgroundColor = MaterialTheme.colorScheme.surface)
LabelText(label = "GID: ${template.gid}", backgroundColor = MaterialTheme.colorScheme.surface)
LabelText(label = template.context, backgroundColor = MaterialTheme.colorScheme.surface)
LabelText(label = "UID: ${template.uid}")
LabelText(label = "GID: ${template.gid}")
LabelText(label = template.context,)
if (template.local) {
LabelText(label = "local", backgroundColor = MaterialTheme.colorScheme.surface)
LabelText(label = "local")
} else {
LabelText(label = "remote", backgroundColor = MaterialTheme.colorScheme.surface)
LabelText(label = "remote")
}
}
}

View File

@@ -290,9 +290,7 @@ fun KernelSUTheme(
private fun createDynamicDarkColorScheme(context: Context) =
dynamicDarkColorScheme(context).copy(
background = Color.Transparent,
surface = Color.Transparent,
onBackground = Color.White,
onSurface = Color.White
surface = Color.Transparent
)
/**