manager: Updated colors and styles

- Adapted from reference style

Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Co-authored-by: Der_Googler <54764558+DerGoogler@users.noreply.github.com>
Co-authored-by: rifsxd <rifat.44.azad.rifs@gmail.com>
Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-05-24 00:47:15 +08:00
parent 99a39c6f52
commit b3e2f9b7ff
12 changed files with 136 additions and 139 deletions

View File

@@ -8,24 +8,13 @@ import android.system.Os
*/
data class KernelVersion(val major: Int, val patchLevel: Int, val subLevel: Int) {
override fun toString(): String {
return "$major.$patchLevel.$subLevel"
}
fun isGKI(): Boolean {
// kernel 6.x
if (major > 5) {
return true
}
// kernel 5.10.x
if (major == 5) {
return patchLevel >= 10
}
return false
override fun toString(): String = "$major.$patchLevel.$subLevel"
fun isGKI(): Boolean = when {
major > 5 -> true
major == 5 && patchLevel >= 10 -> true
else -> false
}
fun isGKI1(): Boolean = (major == 4 && patchLevel >= 19) || (major == 5 && patchLevel < 10)
}
fun parseKernelVersion(version: String): KernelVersion {

View File

@@ -239,8 +239,7 @@ private fun BottomBar(navController: NavHostController) {
val isManager = Natives.becomeManager(ksuApp.packageName)
val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable()
val kpmVersion = getKpmVersion()
val containerColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
// 检查是否显示KPM
val showKpmInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -252,7 +251,7 @@ private fun BottomBar(navController: NavHostController) {
),
containerColor = TopAppBarDefaults.topAppBarColors(
containerColor = cardColor.copy(alpha = cardAlpha),
scrolledContainerColor = containerColor.copy(alpha = cardAlpha)
scrolledContainerColor = cardColor.copy(alpha = cardAlpha)
).containerColor,
tonalElevation = cardElevation
) {
@@ -265,32 +264,25 @@ private fun BottomBar(navController: NavHostController) {
selected = isCurrentDestOnBackStack,
onClick = {
if (!isCurrentDestOnBackStack) {
navigator.navigate(destination.direction) {
popUpTo(NavGraphs.root as RouteOrDirection) {
saveState = true
}
launchSingleTop = true
restoreState = true
navigator.popBackStack(destination.direction, false)
}
navigator.navigate(destination.direction) {
popUpTo(NavGraphs.root as RouteOrDirection) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
icon = {
Icon(
imageVector = if (isCurrentDestOnBackStack) {
destination.iconSelected
} else {
destination.iconNotSelected
},
contentDescription = stringResource(destination.label),
tint = if (isCurrentDestOnBackStack) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant
)
if (isCurrentDestOnBackStack) {
Icon(destination.iconSelected, stringResource(destination.label))
} else {
Icon(destination.iconNotSelected, stringResource(destination.label))
}
},
label = {
Text(
text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium
)
}
label = { Text(stringResource(destination.label),style = MaterialTheme.typography.labelMedium) },
alwaysShowLabel = false
)
}
} else {
@@ -299,33 +291,26 @@ private fun BottomBar(navController: NavHostController) {
NavigationBarItem(
selected = isCurrentDestOnBackStack,
onClick = {
if (!isCurrentDestOnBackStack) {
navigator.navigate(destination.direction) {
popUpTo(NavGraphs.root as RouteOrDirection) {
saveState = true
}
launchSingleTop = true
restoreState = true
if (isCurrentDestOnBackStack) {
navigator.popBackStack(destination.direction, false)
}
navigator.navigate(destination.direction) {
popUpTo(NavGraphs.root) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
icon = {
Icon(
imageVector = if (isCurrentDestOnBackStack) {
destination.iconSelected
} else {
destination.iconNotSelected
},
contentDescription = stringResource(destination.label),
tint = if (isCurrentDestOnBackStack) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant
)
if (isCurrentDestOnBackStack) {
Icon(destination.iconSelected, stringResource(destination.label))
} else {
Icon(destination.iconNotSelected, stringResource(destination.label))
}
},
label = {
Text(
text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium
)
}
label = { Text(stringResource(destination.label),style = MaterialTheme.typography.labelMedium) },
alwaysShowLabel = false
)
}
}

View File

@@ -63,7 +63,7 @@ fun SearchAppBar(
var onSearch by remember { mutableStateOf(false) }
// 获取卡片颜色和透明度
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = CardConfig.cardAlpha
if (onSearch) {

View File

@@ -122,7 +122,7 @@ fun AppProfileScreen(
mutableStateOf(initialProfile)
}
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = CardConfig.cardAlpha
Scaffold(

View File

@@ -22,7 +22,7 @@ enum class BottomBarDestination(
) {
Home(HomeScreenDestination, R.string.home, Icons.Filled.Home, Icons.Outlined.Home, false),
Kpm(KpmScreenDestination, R.string.kpm_title, Icons.Filled.Build, Icons.Outlined.Build, true),
SuperUser(SuperUserScreenDestination, R.string.superuser, Icons.Filled.Security, Icons.Outlined.Security, true),
SuperUser(SuperUserScreenDestination, R.string.superuser, Icons.Filled.AdminPanelSettings, Icons.Outlined.AdminPanelSettings, true),
Module(ModuleScreenDestination, R.string.module, Icons.Filled.Apps, Icons.Outlined.Apps, true),
Settings(SettingScreenDestination, R.string.settings, Icons.Filled.Settings, Icons.Outlined.Settings, false),
}

View File

@@ -435,7 +435,7 @@ private fun TopBar(
onSave: () -> Unit = {},
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = CardConfig.cardAlpha
val statusColor = when(status) {

View File

@@ -13,6 +13,7 @@ import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -29,6 +30,7 @@ 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
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Android
@@ -55,6 +57,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
@@ -225,7 +228,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
exit = shrinkVertically() + fadeOut()
) {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.secondaryContainer),
colors = getCardColors(MaterialTheme.colorScheme.surfaceVariant),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.clip(MaterialTheme.shapes.medium)
@@ -245,11 +248,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Outlined.Info,
contentDescription = null,
modifier = Modifier.padding(end = 12.dp)
)
Text(
text = stringResource(R.string.using_mksu_manager),
style = MaterialTheme.typography.bodyMedium,
@@ -319,7 +317,7 @@ fun UpdateCard() {
val updateDialog = rememberConfirmDialog(onConfirm = { uriHandler.openUri(newVersionUrl) })
WarningCard(
message = stringResource(id = R.string.new_version_available).format(newVersionCode),
color = MaterialTheme.colorScheme.tertiaryContainer,
color = MaterialTheme.colorScheme.surfaceVariant,
onClick = {
if (changelog.isEmpty()) {
uriHandler.openUri(newVersionUrl)
@@ -357,7 +355,7 @@ private fun TopBar(
onInstallClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = CardConfig.cardAlpha
TopAppBar(
@@ -422,7 +420,7 @@ private fun StatusCard(
onClickInstall: () -> Unit = {}
) {
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceVariant),
colors = getCardColors(MaterialTheme.colorScheme.secondaryContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
@@ -451,26 +449,13 @@ private fun StatusCard(
else -> ""
}
val workingMode = when (lkmMode) {
null -> " <Non-GKI>"
true -> " <LKM>"
else -> " <GKI>"
val workingModeText = when {
lkmMode == true -> "LKM"
lkmMode == null && kernelVersion.isGKI1() -> "GKI1.0"
lkmMode == false || kernelVersion.isGKI() -> "GKI2.0"
else -> "N-GKI"
}
val workingText = "${stringResource(id = R.string.home_working)}$workingMode$safeMode"
val isHideVersion = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("is_hide_version", false)
val isHideOtherInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("is_hide_other_info", false)
val isHideSusfsStatus = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("is_hide_susfs_status", false)
val showKpmInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("show_kpm_info", true)
Icon(
Icons.Outlined.CheckCircle,
contentDescription = stringResource(R.string.home_working),
@@ -479,11 +464,74 @@ private fun StatusCard(
)
Column(Modifier.padding(start = 20.dp)) {
Text(
text = workingText,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth()
) {
Text(
text = stringResource(id = R.string.home_working),
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
Spacer(Modifier.width(8.dp))
// 工作模式标签
Surface(
shape = RoundedCornerShape(4.dp),
color = MaterialTheme.colorScheme.primary,
modifier = Modifier
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.secondary,
shape = RoundedCornerShape(4.dp)
)
) {
Text(
text = workingModeText,
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,
modifier = Modifier
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.secondary,
shape = RoundedCornerShape(4.dp)
)
) {
Text(
text = Os.uname().machine,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSecondary,
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
if (safeMode.isNotEmpty()) {
Text(
text = safeMode,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
}
}
val isHideVersion = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("is_hide_version", false)
val isHideOtherInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("is_hide_other_info", false)
val showKpmInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("show_kpm_info", true)
if (!isHideVersion) {
Spacer(Modifier.height(4.dp))
@@ -519,25 +567,6 @@ private fun StatusCard(
)
}
}
if (!isHideSusfsStatus) {
Spacer(modifier = Modifier.height(4.dp))
val suSFS = getSuSFS()
if (lkmMode != true) {
val translatedStatus = when (suSFS) {
"Supported" -> stringResource(R.string.status_supported)
"Not Supported" -> stringResource(R.string.status_not_supported)
else -> stringResource(R.string.status_unknown)
}
Text(
text = stringResource(R.string.home_susfs, translatedStatus),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
}
@@ -596,7 +625,7 @@ private fun StatusCard(
@Composable
fun WarningCard(
message: String,
color: Color = MaterialTheme.colorScheme.errorContainer,
color: Color = MaterialTheme.colorScheme.error,
onClick: (() -> Unit)? = null
) {
ElevatedCard(
@@ -608,7 +637,6 @@ fun WarningCard(
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.error.copy(alpha = 0.1f)
)
) {
Row(
@@ -618,14 +646,6 @@ fun WarningCard(
.padding(24.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Filled.Warning,
contentDescription = null,
tint = MaterialTheme.colorScheme.onErrorContainer,
modifier = Modifier
.padding(end = 16.dp)
.size(28.dp)
)
Text(
text = message,
style = MaterialTheme.typography.bodyMedium,
@@ -641,7 +661,7 @@ fun ContributionCard() {
val links = listOf("https://github.com/ShirkNeko", "https://github.com/udochina")
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
@@ -687,7 +707,7 @@ fun LearnMoreCard() {
val url = stringResource(R.string.home_learn_kernelsu_url)
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
@@ -730,7 +750,7 @@ fun DonateCard() {
val uriHandler = LocalUriHandler.current
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
@@ -778,7 +798,7 @@ private fun InfoCard() {
.getBoolean("show_kpm_info", true)
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHighest),
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainer),
elevation = CardDefaults.cardElevation(defaultElevation = cardElevation),
modifier = Modifier
.fillMaxWidth()
@@ -839,7 +859,7 @@ private fun InfoCard() {
InfoCardItem(
stringResource(R.string.home_kernel),
"${uname.release} (${uname.machine})",
uname.release,
icon = Icons.Default.Memory,
)
@@ -893,7 +913,7 @@ private fun InfoCard() {
InfoCardItem(
stringResource(R.string.home_kpm_version),
displayVersion,
icon = Icons.Default.Code
icon = Icons.Default.Settings
)
}
}
@@ -955,7 +975,7 @@ private fun WarningCardPreview() {
WarningCard(message = "Warning message")
WarningCard(
message = "Warning message ",
MaterialTheme.colorScheme.tertiaryContainer,
MaterialTheme.colorScheme.outlineVariant,
onClick = {})
}
}

View File

@@ -752,7 +752,7 @@ private fun TopBar(
onLkmUpload: () -> Unit = {},
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = cardAlpha
TopAppBar(

View File

@@ -846,6 +846,9 @@ fun ModuleItem(
onClick = { onUpdate(module) },
shape = ButtonDefaults.textShape,
contentPadding = ButtonDefaults.TextButtonContentPadding,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainer
)
) {
Icon(
modifier = Modifier.size(20.dp),

View File

@@ -506,7 +506,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
)
}
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlphaUse = CardConfig.cardAlpha
val isDarkTheme = isSystemInDarkTheme()

View File

@@ -789,7 +789,7 @@ private fun TopBar(
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val systemIsDark = isSystemInDarkTheme()
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = if (ThemeConfig.customBackgroundUri != null) {
cardAlpha
} else {

View File

@@ -231,7 +231,7 @@ private fun TopBar(
colors: TopAppBarColors,
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceContainer
val cardAlpha = CardConfig.cardAlpha
TopAppBar(