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.ksuApp
import com.sukisu.ultra.ui.screen.BottomBarDestination import com.sukisu.ultra.ui.screen.BottomBarDestination
import com.sukisu.ultra.ui.theme.* import com.sukisu.ultra.ui.theme.*
import com.sukisu.ultra.ui.theme.CardConfig.cardAlpha
import com.sukisu.ultra.ui.util.* import com.sukisu.ultra.ui.util.*
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
@@ -138,78 +139,29 @@ class MainActivity : ComponentActivity() {
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun BottomBar(navController: NavHostController) { private fun BottomBar(navController: NavHostController) {
val navigator = navController.rememberDestinationsNavigator() val navigator = navController.rememberDestinationsNavigator()
val isManager = Natives.becomeManager(ksuApp.packageName) val isManager = Natives.becomeManager(ksuApp.packageName)
val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable() val fullFeatured = isManager && !Natives.requireNewKernel() && rootAvailable()
val kpmVersion = getKpmVersion() val kpmVersion = getKpmVersion()
val containerColor = MaterialTheme.colorScheme.surfaceVariant
val cardColor = MaterialTheme.colorScheme.surfaceVariant
val containerColor = MaterialTheme.colorScheme.surfaceContainer NavigationBar(
val selectedColor = MaterialTheme.colorScheme.primary modifier = Modifier.windowInsetsPadding(
val unselectedColor = MaterialTheme.colorScheme.onSurfaceVariant WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
val cornerRadius = 18.dp ),
containerColor = TopAppBarDefaults.topAppBarColors(
Surface( containerColor = cardColor.copy(alpha = cardAlpha),
modifier = Modifier scrolledContainerColor = containerColor.copy(alpha = cardAlpha)
.fillMaxWidth() ).containerColor,
.padding(horizontal = 12.dp, vertical = 8.dp)
.clip(RoundedCornerShape(cornerRadius)),
color = containerColor.copy(alpha = 0.95f),
tonalElevation = 0.dp tonalElevation = 0.dp
) { ) {
NavigationBar( BottomBarDestination.entries.forEach { destination ->
modifier = Modifier.windowInsetsPadding( if (destination == BottomBarDestination.Kpm) {
WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal) if (kpmVersion.isNotEmpty() && !kpmVersion.startsWith("Error")) {
),
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 {
if (!fullFeatured && destination.rootRequired) return@forEach if (!fullFeatured && destination.rootRequired) return@forEach
val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem( NavigationBarItem(
@@ -233,7 +185,7 @@ private fun BottomBar(navController: NavHostController) {
destination.iconNotSelected destination.iconNotSelected
}, },
contentDescription = stringResource(destination.label), contentDescription = stringResource(destination.label),
tint = if (isCurrentDestOnBackStack) selectedColor else unselectedColor tint = if (isCurrentDestOnBackStack) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant
) )
}, },
label = { label = {
@@ -241,16 +193,43 @@ private fun BottomBar(navController: NavHostController) {
text = stringResource(destination.label), text = stringResource(destination.label),
style = MaterialTheme.typography.labelMedium 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 package com.sukisu.ultra.ui.screen
import android.R.attr.layerType
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build import android.os.Build
import android.os.PowerManager import android.os.PowerManager
import android.system.Os import android.system.Os
import android.util.Log
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.animation.* import androidx.compose.animation.*
import androidx.compose.animation.core.* 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.Destination
import com.ramcosta.composedestinations.annotation.RootGraph import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SettingScreenDestination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@@ -54,6 +51,8 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically import androidx.compose.animation.shrinkVertically
import androidx.compose.runtime.saveable.rememberSaveable 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 androidx.compose.ui.graphics.vector.ImageVector
import com.sukisu.ultra.ui.theme.CardConfig import com.sukisu.ultra.ui.theme.CardConfig
import androidx.core.content.edit import androidx.core.content.edit
@@ -113,7 +112,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
TopBar( TopBar(
kernelVersion, kernelVersion,
onInstallClick = { navigator.navigate(InstallScreenDestination) }, onInstallClick = { navigator.navigate(InstallScreenDestination) },
onSettingsClick = { navigator.navigate(SettingScreenDestination) },
scrollBehavior = scrollBehavior scrollBehavior = scrollBehavior
) )
}, },
@@ -124,6 +122,8 @@ fun HomeScreen(navigator: DestinationsNavigator) {
Column( Column(
modifier = Modifier modifier = Modifier
.padding(innerPadding) .padding(innerPadding)
.graphicsLayer(clip = true)
.disableOverscroll()
.nestedScroll(scrollBehavior.nestedScrollConnection) .nestedScroll(scrollBehavior.nestedScrollConnection)
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
.padding(top = 16.dp) .padding(top = 16.dp)
@@ -293,7 +293,6 @@ fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
private fun TopBar( private fun TopBar(
kernelVersion: KernelVersion, kernelVersion: KernelVersion,
onInstallClick: () -> Unit, onInstallClick: () -> Unit,
onSettingsClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior? = null scrollBehavior: TopAppBarScrollBehavior? = null
) { ) {
val cardColor = MaterialTheme.colorScheme.surfaceVariant 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), windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
scrollBehavior = scrollBehavior scrollBehavior = scrollBehavior
@@ -963,3 +954,12 @@ private fun checkKpmConfigured(): Boolean {
} }
return false 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( val themeColorOptions = listOf(
stringResource(R.string.color_default) to ThemeColors.Default, 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_green) to ThemeColors.Green,
stringResource(R.string.color_purple) to ThemeColors.Purple, stringResource(R.string.color_purple) to ThemeColors.Purple,
stringResource(R.string.color_orange) to ThemeColors.Orange, stringResource(R.string.color_orange) to ThemeColors.Orange,
@@ -396,7 +395,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
supportingContent = { supportingContent = {
val currentThemeName = when (ThemeConfig.currentTheme) { val currentThemeName = when (ThemeConfig.currentTheme) {
is ThemeColors.Default -> stringResource(R.string.color_default) 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.Green -> stringResource(R.string.color_green)
is ThemeColors.Purple -> stringResource(R.string.color_purple) is ThemeColors.Purple -> stringResource(R.string.color_purple)
is ThemeColors.Orange -> stringResource(R.string.color_orange) is ThemeColors.Orange -> stringResource(R.string.color_orange)
@@ -820,7 +818,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
.clickable { .clickable {
context.saveThemeColors(when (theme) { context.saveThemeColors(when (theme) {
ThemeColors.Default -> "default" ThemeColors.Default -> "default"
ThemeColors.Blue -> "blue"
ThemeColors.Green -> "green" ThemeColors.Green -> "green"
ThemeColors.Purple -> "purple" ThemeColors.Purple -> "purple"
ThemeColors.Orange -> "orange" ThemeColors.Orange -> "orange"

View File

@@ -23,8 +23,6 @@ object CardConfig {
var isUserLightModeEnabled by mutableStateOf(false) var isUserLightModeEnabled by mutableStateOf(false)
var isCustomBackgroundEnabled by mutableStateOf(false) var isCustomBackgroundEnabled by mutableStateOf(false)
private var lastSystemDarkMode: Boolean? = null
/** /**
* 保存卡片配置到SharedPreferences * 保存卡片配置到SharedPreferences
*/ */
@@ -91,22 +89,14 @@ fun getCardColors(originalColor: Color) = CardDefaults.cardColors(
@Composable @Composable
private fun determineContentColor(originalColor: Color): Color { private fun determineContentColor(originalColor: Color): Color {
val isDarkTheme = isSystemInDarkTheme() val isDarkTheme = isSystemInDarkTheme()
// 处理主题切换过程中的颜色
if (ThemeConfig.isThemeChanging) { if (ThemeConfig.isThemeChanging) {
return if (isDarkTheme) Color.White else Color.Black return if (isDarkTheme) Color.White else Color.Black
} }
return when { return when {
// 用户明确设置了浅色或深色模式
CardConfig.isUserLightModeEnabled -> Color.Black CardConfig.isUserLightModeEnabled -> Color.Black
CardConfig.isUserDarkModeEnabled -> Color.White
// 根据系统主题和背景亮度自动确定
!isDarkTheme && originalColor.luminance() > 0.5f -> Color.Black !isDarkTheme && originalColor.luminance() > 0.5f -> Color.Black
isDarkTheme -> Color.White isDarkTheme -> Color.White
// 其他情况根据背景亮度确定
else -> if (originalColor.luminance() > 0.5f) Color.Black else 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 Background: Color
abstract val OnBackground: Color abstract val OnBackground: Color
// 默认主题 (色) // 默认主题 (色)
object Default : ThemeColors() { 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 Primary = Color(0xFF2196F3)
override val Secondary = Color(0xFF64B5F6) override val Secondary = Color(0xFF64B5F6)
override val Tertiary = Color(0xFF0D47A1) override val Tertiary = Color(0xFF0D47A1)
@@ -293,7 +261,6 @@ sealed class ThemeColors {
companion object { companion object {
fun fromName(name: String): ThemeColors = when (name.lowercase()) { fun fromName(name: String): ThemeColors = when (name.lowercase()) {
"blue" -> Blue
"green" -> Green "green" -> Green
"purple" -> Purple "purple" -> Purple
"orange" -> Orange "orange" -> Orange

View File

@@ -203,8 +203,7 @@
<string name="dynamic_color_title">ダイナミックカラー</string> <string name="dynamic_color_title">ダイナミックカラー</string>
<string name="dynamic_color_summary">システムテーマのダイナミックカラーを使用します</string> <string name="dynamic_color_summary">システムテーマのダイナミックカラーを使用します</string>
<string name="choose_theme_color">テーマカラーを選択</string> <string name="choose_theme_color">テーマカラーを選択</string>
<string name="color_default">ホワイト</string> <string name="color_default">ブルー</string>
<string name="color_blue">ブルー</string>
<string name="color_green">グリーン</string> <string name="color_green">グリーン</string>
<string name="color_purple">パープル</string> <string name="color_purple">パープル</string>
<string name="color_orange">オレンジ</string> <string name="color_orange">オレンジ</string>

View File

@@ -201,8 +201,7 @@
<string name="dynamic_color_title">Màu sắc động</string> <string name="dynamic_color_title">Màu sắc động</string>
<string name="dynamic_color_summary">Màu sắc động sử dụng chủ đề hệ thống</string> <string name="dynamic_color_summary">Màu sắc động sử dụng chủ đề hệ thống</string>
<string name="choose_theme_color">Chọn màu chủ đề</string> <string name="choose_theme_color">Chọn màu chủ đề</string>
<string name="color_default">Trắng</string> <string name="color_default">Xanh dương</string>
<string name="color_blue">Xanh dương</string>
<string name="color_green">Xanh lá</string> <string name="color_green">Xanh lá</string>
<string name="color_purple">Tím</string> <string name="color_purple">Tím</string>
<string name="color_orange">Cam</string> <string name="color_orange">Cam</string>

View File

@@ -202,8 +202,7 @@
<string name="dynamic_color_title">动态颜色</string> <string name="dynamic_color_title">动态颜色</string>
<string name="dynamic_color_summary">使用系统主题的动态颜色</string> <string name="dynamic_color_summary">使用系统主题的动态颜色</string>
<string name="choose_theme_color">选择主题色</string> <string name="choose_theme_color">选择主题色</string>
<string name="color_default"></string> <string name="color_default"></string>
<string name="color_blue">蓝色</string>
<string name="color_green">绿色</string> <string name="color_green">绿色</string>
<string name="color_purple">紫色</string> <string name="color_purple">紫色</string>
<string name="color_orange">橙色</string> <string name="color_orange">橙色</string>

View File

@@ -202,8 +202,7 @@
<string name="dynamic_color_title">Dynamic colours</string> <string name="dynamic_color_title">Dynamic colours</string>
<string name="dynamic_color_summary">Dynamic colours using system themes</string> <string name="dynamic_color_summary">Dynamic colours using system themes</string>
<string name="choose_theme_color">Choose a theme colour</string> <string name="choose_theme_color">Choose a theme colour</string>
<string name="color_default">White</string> <string name="color_default">Blue</string>
<string name="color_blue">Blue</string>
<string name="color_green">Green</string> <string name="color_green">Green</string>
<string name="color_purple">Purple</string> <string name="color_purple">Purple</string>
<string name="color_orange">Orange</string> <string name="color_orange">Orange</string>