diff --git a/manager/app/src/main/java/com/sukisu/ultra/Kernels.kt b/manager/app/src/main/java/com/sukisu/ultra/Kernels.kt index 26219505..1f2197b8 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/Kernels.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/Kernels.kt @@ -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 { diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/MainActivity.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/MainActivity.kt index 93c755cc..f362988a 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/MainActivity.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/MainActivity.kt @@ -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 ) } } diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/component/SearchBar.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/component/SearchBar.kt index 83ab9644..57c698cd 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/component/SearchBar.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/component/SearchBar.kt @@ -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) { diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/AppProfile.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/AppProfile.kt index e28a4cea..22e1050b 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/AppProfile.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/AppProfile.kt @@ -122,7 +122,7 @@ fun AppProfileScreen( mutableStateOf(initialProfile) } - val cardColor = MaterialTheme.colorScheme.surfaceVariant + val cardColor = MaterialTheme.colorScheme.surfaceContainer val cardAlpha = CardConfig.cardAlpha Scaffold( diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/BottomBarDestination.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/BottomBarDestination.kt index cbcdc292..f1d51ca0 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/BottomBarDestination.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/BottomBarDestination.kt @@ -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), } diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Flash.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Flash.kt index c5a3ad57..7ea89bf7 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Flash.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Flash.kt @@ -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) { diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt index e4f23c0d..14700f16 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Home.kt @@ -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 -> " " - true -> " " - else -> " " + 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 = {}) } } diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt index 3b32dbee..20532653 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Install.kt @@ -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( diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt index 2d074ae4..04b03b1d 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt @@ -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), 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 aac43ff7..deaabbd8 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 @@ -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() 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 efcf4739..7357d072 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 @@ -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 { diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Template.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Template.kt index 0c89211d..80ffb95c 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Template.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Template.kt @@ -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(