Update the default theme color to blue and remove the related blue theme code

This commit is contained in:
ShirkNeko
2025-04-29 17:29:45 +08:00
parent 3526e84e04
commit 39adba62d1
9 changed files with 70 additions and 141 deletions

View File

@@ -33,6 +33,7 @@ import com.sukisu.ultra.Natives
import com.sukisu.ultra.ksuApp
import com.sukisu.ultra.ui.screen.BottomBarDestination
import com.sukisu.ultra.ui.theme.*
import com.sukisu.ultra.ui.theme.CardConfig.cardAlpha
import com.sukisu.ultra.ui.util.*
class MainActivity : ComponentActivity() {
@@ -138,78 +139,29 @@ class MainActivity : ComponentActivity() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun BottomBar(navController: NavHostController) {
val navigator = navController.rememberDestinationsNavigator()
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 containerColor = MaterialTheme.colorScheme.surfaceContainer
val selectedColor = MaterialTheme.colorScheme.primary
val unselectedColor = MaterialTheme.colorScheme.onSurfaceVariant
val cornerRadius = 18.dp
Surface(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 8.dp)
.clip(RoundedCornerShape(cornerRadius)),
color = containerColor.copy(alpha = 0.95f),
NavigationBar(
modifier = Modifier.windowInsetsPadding(
WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
),
containerColor = TopAppBarDefaults.topAppBarColors(
containerColor = cardColor.copy(alpha = cardAlpha),
scrolledContainerColor = containerColor.copy(alpha = cardAlpha)
).containerColor,
tonalElevation = 0.dp
) {
NavigationBar(
modifier = Modifier.windowInsetsPadding(
WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
),
containerColor = Color.Transparent,
tonalElevation = 0.dp
) {
BottomBarDestination.entries.forEach { destination ->
if (destination == BottomBarDestination.Kpm) {
if (kpmVersion.isNotEmpty() && !kpmVersion.startsWith("Error")) {
if (!fullFeatured && destination.rootRequired) return@forEach
val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem(
selected = isCurrentDestOnBackStack,
onClick = {
if (!isCurrentDestOnBackStack) {
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) selectedColor else unselectedColor
)
},
label = {
Text(
text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium
)
},
colors = NavigationBarItemDefaults.colors(
selectedIconColor = selectedColor,
unselectedIconColor = unselectedColor,
selectedTextColor = selectedColor,
unselectedTextColor = unselectedColor,
indicatorColor = MaterialTheme.colorScheme.secondaryContainer
)
)
}
} else {
BottomBarDestination.entries.forEach { destination ->
if (destination == BottomBarDestination.Kpm) {
if (kpmVersion.isNotEmpty() && !kpmVersion.startsWith("Error")) {
if (!fullFeatured && destination.rootRequired) return@forEach
val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem(
@@ -233,7 +185,7 @@ private fun BottomBar(navController: NavHostController) {
destination.iconNotSelected
},
contentDescription = stringResource(destination.label),
tint = if (isCurrentDestOnBackStack) selectedColor else unselectedColor
tint = if (isCurrentDestOnBackStack) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant
)
},
label = {
@@ -241,16 +193,43 @@ private fun BottomBar(navController: NavHostController) {
text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium
)
},
colors = NavigationBarItemDefaults.colors(
selectedIconColor = selectedColor,
unselectedIconColor = unselectedColor,
selectedTextColor = selectedColor,
unselectedTextColor = unselectedColor,
indicatorColor = MaterialTheme.colorScheme.secondaryContainer
)
}
)
}
} else {
if (!fullFeatured && destination.rootRequired) return@forEach
val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem(
selected = isCurrentDestOnBackStack,
onClick = {
if (!isCurrentDestOnBackStack) {
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
)
},
label = {
Text(
text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium
)
}
)
}
}
}

View File

@@ -1,13 +1,11 @@
package com.sukisu.ultra.ui.screen
import android.R.attr.layerType
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.PowerManager
import android.system.Os
import android.util.Log
import androidx.annotation.StringRes
import androidx.compose.animation.*
import androidx.compose.animation.core.*
@@ -35,7 +33,6 @@ import androidx.core.content.pm.PackageInfoCompat
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SettingScreenDestination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@@ -54,6 +51,8 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import com.sukisu.ultra.ui.theme.CardConfig
import androidx.core.content.edit
@@ -113,7 +112,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
TopBar(
kernelVersion,
onInstallClick = { navigator.navigate(InstallScreenDestination) },
onSettingsClick = { navigator.navigate(SettingScreenDestination) },
scrollBehavior = scrollBehavior
)
},
@@ -124,6 +122,8 @@ fun HomeScreen(navigator: DestinationsNavigator) {
Column(
modifier = Modifier
.padding(innerPadding)
.graphicsLayer(clip = true)
.disableOverscroll()
.nestedScroll(scrollBehavior.nestedScrollConnection)
.verticalScroll(rememberScrollState())
.padding(top = 16.dp)
@@ -293,7 +293,6 @@ fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
private fun TopBar(
kernelVersion: KernelVersion,
onInstallClick: () -> Unit,
onSettingsClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant
@@ -348,14 +347,6 @@ private fun TopBar(
}
}
}
IconButton(onClick = onSettingsClick) {
Icon(
Icons.Filled.Settings,
contentDescription = stringResource(id = R.string.settings),
tint = MaterialTheme.colorScheme.primary
)
}
},
windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
scrollBehavior = scrollBehavior
@@ -962,4 +953,13 @@ private fun checkKpmConfigured(): Boolean {
e.printStackTrace()
}
return false
}
@SuppressLint("UnnecessaryComposedModifier")
fun Modifier.disableOverscroll(): Modifier = composed {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
this
} else {
this
}
}

View File

@@ -249,7 +249,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
// 主题色选项
val themeColorOptions = listOf(
stringResource(R.string.color_default) to ThemeColors.Default,
stringResource(R.string.color_blue) to ThemeColors.Blue,
stringResource(R.string.color_green) to ThemeColors.Green,
stringResource(R.string.color_purple) to ThemeColors.Purple,
stringResource(R.string.color_orange) to ThemeColors.Orange,
@@ -396,7 +395,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
supportingContent = {
val currentThemeName = when (ThemeConfig.currentTheme) {
is ThemeColors.Default -> stringResource(R.string.color_default)
is ThemeColors.Blue -> stringResource(R.string.color_blue)
is ThemeColors.Green -> stringResource(R.string.color_green)
is ThemeColors.Purple -> stringResource(R.string.color_purple)
is ThemeColors.Orange -> stringResource(R.string.color_orange)
@@ -820,7 +818,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
.clickable {
context.saveThemeColors(when (theme) {
ThemeColors.Default -> "default"
ThemeColors.Blue -> "blue"
ThemeColors.Green -> "green"
ThemeColors.Purple -> "purple"
ThemeColors.Orange -> "orange"

View File

@@ -23,8 +23,6 @@ object CardConfig {
var isUserLightModeEnabled by mutableStateOf(false)
var isCustomBackgroundEnabled by mutableStateOf(false)
private var lastSystemDarkMode: Boolean? = null
/**
* 保存卡片配置到SharedPreferences
*/
@@ -91,22 +89,14 @@ fun getCardColors(originalColor: Color) = CardDefaults.cardColors(
@Composable
private fun determineContentColor(originalColor: Color): Color {
val isDarkTheme = isSystemInDarkTheme()
// 处理主题切换过程中的颜色
if (ThemeConfig.isThemeChanging) {
return if (isDarkTheme) Color.White else Color.Black
}
return when {
// 用户明确设置了浅色或深色模式
CardConfig.isUserLightModeEnabled -> Color.Black
CardConfig.isUserDarkModeEnabled -> Color.White
// 根据系统主题和背景亮度自动确定
!isDarkTheme && originalColor.luminance() > 0.5f -> Color.Black
isDarkTheme -> Color.White
// 其他情况根据背景亮度确定
else -> if (originalColor.luminance() > 0.5f) Color.Black else Color.White
}
}

View File

@@ -35,40 +35,8 @@ sealed class ThemeColors {
abstract val Background: Color
abstract val OnBackground: Color
// 默认主题 (色)
// 默认主题 (色)
object Default : ThemeColors() {
override val Primary = Color(0xFFFFFFFF)
override val Secondary = Color(0xFF5F6368)
override val Tertiary = Color(0xFFFFFFFF)
override val OnPrimary = Color(0xFFFFFFFF)
override val OnSecondary = Color(0xFFFFFFFF)
override val OnTertiary = Color(0xFFFFFFFF)
override val PrimaryContainer = Color(0xFFD1E3FF)
override val SecondaryContainer = Color(0xFFE4E6E8)
override val TertiaryContainer = Color(0xFFD0E1FC)
override val OnPrimaryContainer = Color(0xFF0D2E5E)
override val OnSecondaryContainer = Color(0xFF24262A)
override val OnTertiaryContainer = Color(0xFF0A2E62)
override val ButtonContrast = Color(0xFF0A2E62)
override val Surface = Color(0xFFFCFCFC)
override val SurfaceVariant = Color(0xFFF2F2F2)
override val OnSurface = Color(0xFF202124)
override val OnSurfaceVariant = Color(0xFF5F6368)
override val Error = Color(0xFFD93025)
override val OnError = Color(0xFFFFFFFF)
override val ErrorContainer = Color(0xFFFDECEA)
override val OnErrorContainer = Color(0xFF58160F)
override val Outline = Color(0xFFDADADA)
override val OutlineVariant = Color(0xFFEEEEEE)
override val Background = Color(0xFFFFFFFF)
override val OnBackground = Color(0xFF202124)
}
// 蓝色主题
object Blue : ThemeColors() {
override val Primary = Color(0xFF2196F3)
override val Secondary = Color(0xFF64B5F6)
override val Tertiary = Color(0xFF0D47A1)
@@ -293,7 +261,6 @@ sealed class ThemeColors {
companion object {
fun fromName(name: String): ThemeColors = when (name.lowercase()) {
"blue" -> Blue
"green" -> Green
"purple" -> Purple
"orange" -> Orange