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 86d16f80..46181166 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 @@ -291,9 +291,15 @@ private fun BottomBar(navController: NavHostController) { val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable() val kpmVersion = getKpmVersion() val cardColor = MaterialTheme.colorScheme.surfaceContainer + val context = LocalContext.current + + // 获取计数数据 + val superuserCount = getSuperuserCount() + val moduleCount = getModuleCount() + val kpmModuleCount = getKpmModuleCount() // 检查是否显示KPM - val showKpmInfo = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE) + val showKpmInfo = context.getSharedPreferences("settings", Context.MODE_PRIVATE) .getBoolean("show_kpm_info", true) NavigationBar( @@ -326,19 +332,121 @@ private fun BottomBar(navController: NavHostController) { } }, icon = { - if (isCurrentDestOnBackStack) { - Icon(destination.iconSelected, stringResource(destination.label)) - } else { - Icon(destination.iconNotSelected, stringResource(destination.label)) + BadgedBox( + badge = { + if (kpmModuleCount > 0) { + Badge( + containerColor = MaterialTheme.colorScheme.error + ) { + Text( + text = kpmModuleCount.toString(), + style = MaterialTheme.typography.labelSmall + ) + } + } + } + ) { + if (isCurrentDestOnBackStack) { + Icon(destination.iconSelected, stringResource(destination.label)) + } else { + Icon(destination.iconNotSelected, stringResource(destination.label)) + } } }, label = { Text(stringResource(destination.label),style = MaterialTheme.typography.labelMedium) }, alwaysShowLabel = false ) } + } else if (destination == BottomBarDestination.SuperUser) { + if (!fullFeatured && destination.rootRequired) return@forEach + val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) + + NavigationBarItem( + selected = isCurrentDestOnBackStack, + onClick = { + if (isCurrentDestOnBackStack) { + navigator.popBackStack(destination.direction, false) + } + navigator.navigate(destination.direction) { + popUpTo(NavGraphs.root) { + saveState = true + } + launchSingleTop = true + restoreState = true + } + }, + icon = { + BadgedBox( + badge = { + if (superuserCount > 0) { + Badge( + containerColor = MaterialTheme.colorScheme.error + ) { + Text( + text = superuserCount.toString(), + style = MaterialTheme.typography.labelSmall + ) + } + } + } + ) { + if (isCurrentDestOnBackStack) { + Icon(destination.iconSelected, stringResource(destination.label)) + } else { + Icon(destination.iconNotSelected, stringResource(destination.label)) + } + } + }, + label = { Text(stringResource(destination.label),style = MaterialTheme.typography.labelMedium) }, + alwaysShowLabel = false + ) + } else if (destination == BottomBarDestination.Module) { + if (!fullFeatured && destination.rootRequired) return@forEach + val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) + + NavigationBarItem( + selected = isCurrentDestOnBackStack, + onClick = { + if (isCurrentDestOnBackStack) { + navigator.popBackStack(destination.direction, false) + } + navigator.navigate(destination.direction) { + popUpTo(NavGraphs.root) { + saveState = true + } + launchSingleTop = true + restoreState = true + } + }, + icon = { + BadgedBox( + badge = { + if (moduleCount > 0) { + Badge( + containerColor = MaterialTheme.colorScheme.error + ) { + Text( + text = moduleCount.toString(), + style = MaterialTheme.typography.labelSmall + ) + } + } + } + ) { + if (isCurrentDestOnBackStack) { + Icon(destination.iconSelected, stringResource(destination.label)) + } else { + Icon(destination.iconNotSelected, stringResource(destination.label)) + } + } + }, + label = { Text(stringResource(destination.label),style = MaterialTheme.typography.labelMedium) }, + alwaysShowLabel = false + ) } else { if (!fullFeatured && destination.rootRequired) return@forEach val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) + NavigationBarItem( selected = isCurrentDestOnBackStack, onClick = { 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 ead891be..9f7efe8b 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 @@ -354,7 +354,7 @@ private fun StatusCard( } } .padding(24.dp), - verticalAlignment = Alignment.Top + verticalAlignment = Alignment.CenterVertically ) { when { systemStatus.ksuVersion != null -> { @@ -434,12 +434,6 @@ private fun StatusCard( 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)) Text( @@ -448,32 +442,6 @@ private fun StatusCard( color = MaterialTheme.colorScheme.secondary, ) } - - if (!isHideOtherInfo) { - Spacer(Modifier.height(4.dp)) - Text( - text = stringResource(R.string.home_superuser_count, getSuperuserCount()), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.secondary, - ) - - Spacer(Modifier.height(4.dp)) - Text( - text = stringResource(R.string.home_module_count, getModuleCount()), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.secondary, - ) - - val kpmVersion = getKpmVersion() - if (kpmVersion.isNotEmpty() && !kpmVersion.startsWith("Error") && showKpmInfo && Natives.version >= Natives.MINIMAL_SUPPORTED_KPM) { - Spacer(Modifier.height(4.dp)) - Text( - text = stringResource(R.string.home_kpm_module, getKpmModuleCount()), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.secondary, - ) - } - } } } 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 a036c5ef..237b3c4b 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 @@ -716,7 +716,7 @@ fun rememberSelectKmiDialog(onSelected: (String?) -> Unit): DialogHandle { } var selection by remember { mutableStateOf(null) } - val backgroundColor = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else MaterialTheme.colorScheme.surfaceContainerHigh + val backgroundColor = MaterialTheme.colorScheme.surfaceContainerHigh MaterialTheme( colorScheme = MaterialTheme.colorScheme.copy( 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 719ff748..efcf3180 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 @@ -77,9 +77,11 @@ import kotlin.math.roundToInt import androidx.compose.foundation.border import androidx.compose.foundation.layout.height import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.NavigateNext import androidx.compose.material3.Card import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.IconButton import androidx.compose.material3.Switch import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector @@ -89,6 +91,7 @@ import androidx.compose.material3.RadioButton import androidx.compose.material3.TextButton import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.unit.sp +import com.ramcosta.composedestinations.navigation.DestinationsNavigator /** * @author ShirkNeko @@ -127,7 +130,9 @@ fun toggleLauncherIcon(context: Context, useAlt: Boolean) { @OptIn(ExperimentalMaterial3Api::class) @Destination @Composable -fun MoreSettingsScreen() { +fun MoreSettingsScreen( + navigator: DestinationsNavigator +) { // 顶部滚动行为 val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) val context = LocalContext.current @@ -650,6 +655,16 @@ fun MoreSettingsScreen() { style = MaterialTheme.typography.titleLarge ) }, + navigationIcon = { + IconButton(onClick = { + navigator.popBackStack() + }) { + Icon( + imageVector = Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = stringResource(R.string.back) + ) + } + }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.surfaceContainerLow.copy(alpha = CardConfig.cardAlpha), scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerLow.copy(alpha = CardConfig.cardAlpha)