Updated agp version to 8.9.1, added white color theme

This commit is contained in:
ShirkNeko
2025-03-26 14:53:10 +08:00
parent 75c63a1305
commit 52514cc5b3
6 changed files with 69 additions and 43 deletions

View File

@@ -49,8 +49,7 @@ import shirkneko.zako.sukisu.ui.util.getSuSFSFeatures
import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_0 import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_0
import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_2 import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_2
import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_Mode import shirkneko.zako.sukisu.ui.util.susfsSUS_SU_Mode
import androidx.compose.foundation.gestures.detectTapGestures import androidx.core.content.edit
import androidx.compose.ui.input.pointer.pointerInput
fun saveCardConfig(context: Context) { fun saveCardConfig(context: Context) {
@@ -72,7 +71,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
val prefs = remember { context.getSharedPreferences("settings", Context.MODE_PRIVATE) } val prefs = remember { context.getSharedPreferences("settings", Context.MODE_PRIVATE) }
// 主题模式选择 // 主题模式选择
var themeMode by remember { var themeMode by remember {
mutableStateOf( mutableIntStateOf(
when(ThemeConfig.forceDarkMode) { when(ThemeConfig.forceDarkMode) {
true -> 2 // 深色 true -> 2 // 深色
false -> 1 // 浅色 false -> 1 // 浅色
@@ -101,7 +100,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
// 更新简洁模块开关状态 // 更新简洁模块开关状态
val onSimpleModeChange = { newValue: Boolean -> val onSimpleModeChange = { newValue: Boolean ->
prefs.edit().putBoolean("is_simple_mode", newValue).apply() prefs.edit { putBoolean("is_simple_mode", newValue) }
isSimpleMode = newValue isSimpleMode = newValue
} }
@@ -111,7 +110,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
// 卡片配置状态 // 卡片配置状态
var cardAlpha by rememberSaveable { mutableStateOf(CardConfig.cardAlpha) } var cardAlpha by rememberSaveable { mutableFloatStateOf(CardConfig.cardAlpha) }
var showCardSettings by remember { mutableStateOf(false) } var showCardSettings by remember { mutableStateOf(false) }
var isCustomBackgroundEnabled by rememberSaveable { var isCustomBackgroundEnabled by rememberSaveable {
mutableStateOf(ThemeConfig.customBackgroundUri != null) mutableStateOf(ThemeConfig.customBackgroundUri != null)
@@ -122,7 +121,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
CardConfig.apply { CardConfig.apply {
cardAlpha = prefs.getFloat("card_alpha", 0.65f) cardAlpha = prefs.getFloat("card_alpha", 0.65f)
cardElevation = if (prefs.getBoolean("custom_background_enabled", false)) 0.dp else CardConfig.defaultElevation cardElevation = if (prefs.getBoolean("custom_background_enabled", false)) 0.dp else defaultElevation
isCustomAlphaSet = prefs.getBoolean("is_custom_alpha_set", false) isCustomAlphaSet = prefs.getBoolean("is_custom_alpha_set", false)
// 如果没有手动设置透明度,且是深色模式,则使用默认值 // 如果没有手动设置透明度,且是深色模式,则使用默认值
@@ -149,6 +148,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
stringResource(R.string.color_orange) to ThemeColors.Orange, stringResource(R.string.color_orange) to ThemeColors.Orange,
stringResource(R.string.color_pink) to ThemeColors.Pink, stringResource(R.string.color_pink) to ThemeColors.Pink,
stringResource(R.string.color_gray) to ThemeColors.Gray, stringResource(R.string.color_gray) to ThemeColors.Gray,
stringResource(R.string.color_yellow) to ThemeColors.Yellow
) )
var showThemeColorDialog by remember { mutableStateOf(false) } var showThemeColorDialog by remember { mutableStateOf(false) }
@@ -226,7 +226,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
val wasManuallyDisabled = prefs.getBoolean("enable_sus_su", true) val wasManuallyDisabled = prefs.getBoolean("enable_sus_su", true)
if (currentMode != "2" && wasManuallyDisabled) { if (currentMode != "2" && wasManuallyDisabled) {
susfsSUS_SU_2() // 强制切换到模式2 susfsSUS_SU_2() // 强制切换到模式2
prefs.edit().putBoolean("enable_sus_su", true).apply() prefs.edit { putBoolean("enable_sus_su", true) }
} }
isEnabled = currentMode == "2" isEnabled = currentMode == "2"
} }
@@ -240,11 +240,11 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
if (it) { if (it) {
// 手动启用 // 手动启用
susfsSUS_SU_2() susfsSUS_SU_2()
prefs.edit().putBoolean("enable_sus_su", true).apply() prefs.edit { putBoolean("enable_sus_su", true) }
} else { } else {
// 手动关闭 // 手动关闭
susfsSUS_SU_0() susfsSUS_SU_0()
prefs.edit().putBoolean("enable_sus_su", false).apply() prefs.edit { putBoolean("enable_sus_su", false) }
} }
isEnabled = it isEnabled = it
} }
@@ -277,6 +277,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
is ThemeColors.Orange -> stringResource(R.string.color_orange) is ThemeColors.Orange -> stringResource(R.string.color_orange)
is ThemeColors.Pink -> stringResource(R.string.color_pink) is ThemeColors.Pink -> stringResource(R.string.color_pink)
is ThemeColors.Gray -> stringResource(R.string.color_gray) is ThemeColors.Gray -> stringResource(R.string.color_gray)
is ThemeColors.Yellow -> stringResource(R.string.color_yellow)
else -> stringResource(R.string.color_default) else -> stringResource(R.string.color_default)
} }
Text(currentThemeName) Text(currentThemeName)
@@ -303,6 +304,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
ThemeColors.Orange -> "orange" ThemeColors.Orange -> "orange"
ThemeColors.Pink -> "pink" ThemeColors.Pink -> "pink"
ThemeColors.Gray -> "gray" ThemeColors.Gray -> "gray"
ThemeColors.Yellow -> "yellow"
else -> "default" else -> "default"
}) })
showThemeColorDialog = false showThemeColorDialog = false
@@ -377,8 +379,8 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
cardAlpha = newValue cardAlpha = newValue
CardConfig.cardAlpha = newValue CardConfig.cardAlpha = newValue
CardConfig.isCustomAlphaSet = true CardConfig.isCustomAlphaSet = true
prefs.edit().putBoolean("is_custom_alpha_set", true).apply() prefs.edit { putBoolean("is_custom_alpha_set", true) }
prefs.edit().putFloat("card_alpha", newValue).apply() prefs.edit { putFloat("card_alpha", newValue) }
}, },
onValueChangeFinished = { onValueChangeFinished = {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {

View File

@@ -21,18 +21,18 @@ sealed class ThemeColors {
// Default Theme (Yellow) // Default Theme (Yellow)
object Default : ThemeColors() { object Default : ThemeColors() {
override val Primary = Color(0xFFFFD700) override val Primary = Color(0xFFFFFFFF)
override val Secondary = Color(0xFFFFBC52) override val Secondary = Color(0xFFF5F5F5)
override val Tertiary = Color(0xFF795548) override val Tertiary = Color(0xFFE0E0E0)
override val OnPrimary = Color(0xFFFFFFFF) override val OnPrimary = Color(0xFF616161)
override val OnSecondary = Color(0xFFFFFFFF) override val OnSecondary = Color(0xFF616161)
override val OnTertiary = Color(0xFFFFFFFF) override val OnTertiary = Color(0xFF616161)
override val PrimaryContainer = Color(0xFFFFF7D6) override val PrimaryContainer = Color(0xFFF5F5F5)
override val SecondaryContainer = Color(0xFFFFE6B3) override val SecondaryContainer = Color(0xFFEEEEEE)
override val TertiaryContainer = Color(0xFFD7CCC8) override val TertiaryContainer = Color(0xFFE0E0E0)
override val OnPrimaryContainer = Color(0xFF1A1600) override val OnPrimaryContainer = Color(0xFF000000)
override val OnSecondaryContainer = Color(0xFF1A1100) override val OnSecondaryContainer = Color(0xFF000000)
override val OnTertiaryContainer = Color(0xFF1A1717) override val OnTertiaryContainer = Color(0xFF000000)
} }
// Blue Theme // Blue Theme
@@ -131,6 +131,21 @@ sealed class ThemeColors {
override val OnTertiaryContainer = Color(0xFF141414) override val OnTertiaryContainer = Color(0xFF141414)
} }
object Yellow : ThemeColors() {
override val Primary = Color(0xFFFFD700)
override val Secondary = Color(0xFFFFBC52)
override val Tertiary = Color(0xFF795548)
override val OnPrimary = Color(0xFFFFFFFF)
override val OnSecondary = Color(0xFFFFFFFF)
override val OnTertiary = Color(0xFFFFFFFF)
override val PrimaryContainer = Color(0xFFFFF7D6)
override val SecondaryContainer = Color(0xFFFFE6B3)
override val TertiaryContainer = Color(0xFFD7CCC8)
override val OnPrimaryContainer = Color(0xFF1A1600)
override val OnSecondaryContainer = Color(0xFF1A1100)
override val OnTertiaryContainer = Color(0xFF1A1717)
}
companion object { companion object {
fun fromName(name: String): ThemeColors = when (name.lowercase()) { fun fromName(name: String): ThemeColors = when (name.lowercase()) {
"blue" -> Blue "blue" -> Blue
@@ -139,6 +154,7 @@ sealed class ThemeColors {
"orange" -> Orange "orange" -> Orange
"pink" -> Pink "pink" -> Pink
"gray" -> Gray "gray" -> Gray
"white" -> Yellow
else -> Default else -> Default
} }
} }

View File

@@ -30,6 +30,8 @@ import androidx.compose.ui.graphics.luminance
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.InputStream import java.io.InputStream
import androidx.core.content.edit
import androidx.core.net.toUri
object ThemeConfig { object ThemeConfig {
var customBackgroundUri by mutableStateOf<Uri?>(null) var customBackgroundUri by mutableStateOf<Uri?>(null)
@@ -243,27 +245,29 @@ fun KernelSUTheme(
fun Context.saveCustomBackground(uri: Uri?) { fun Context.saveCustomBackground(uri: Uri?) {
val newUri = uri?.let { copyImageToInternalStorage(it) } val newUri = uri?.let { copyImageToInternalStorage(it) }
getSharedPreferences("theme_prefs", Context.MODE_PRIVATE) getSharedPreferences("theme_prefs", Context.MODE_PRIVATE)
.edit() .edit {
.putString("custom_background", newUri?.toString()) putString("custom_background", newUri?.toString())
.apply() }
ThemeConfig.customBackgroundUri = newUri ThemeConfig.customBackgroundUri = newUri
} }
fun Context.loadCustomBackground() { fun Context.loadCustomBackground() {
val uriString = getSharedPreferences("theme_prefs", Context.MODE_PRIVATE) val uriString = getSharedPreferences("theme_prefs", Context.MODE_PRIVATE)
.getString("custom_background", null) .getString("custom_background", null)
ThemeConfig.customBackgroundUri = uriString?.let { Uri.parse(it) } ThemeConfig.customBackgroundUri = uriString?.toUri()
} }
fun Context.saveThemeMode(forceDark: Boolean?) { fun Context.saveThemeMode(forceDark: Boolean?) {
getSharedPreferences("theme_prefs", Context.MODE_PRIVATE) getSharedPreferences("theme_prefs", Context.MODE_PRIVATE)
.edit() .edit {
.putString("theme_mode", when(forceDark) { putString(
true -> "dark" "theme_mode", when (forceDark) {
false -> "light" true -> "dark"
null -> "system" false -> "light"
}) null -> "system"
.apply() }
)
}
ThemeConfig.forceDarkMode = forceDark ThemeConfig.forceDarkMode = forceDark
} }
@@ -279,9 +283,9 @@ fun Context.loadThemeMode() {
fun Context.saveThemeColors(themeName: String) { fun Context.saveThemeColors(themeName: String) {
getSharedPreferences("theme_prefs", Context.MODE_PRIVATE) getSharedPreferences("theme_prefs", Context.MODE_PRIVATE)
.edit() .edit {
.putString("theme_colors", themeName) putString("theme_colors", themeName)
.apply() }
ThemeConfig.currentTheme = when(themeName) { ThemeConfig.currentTheme = when(themeName) {
"blue" -> ThemeColors.Blue "blue" -> ThemeColors.Blue
@@ -290,6 +294,7 @@ fun Context.saveThemeColors(themeName: String) {
"orange" -> ThemeColors.Orange "orange" -> ThemeColors.Orange
"pink" -> ThemeColors.Pink "pink" -> ThemeColors.Pink
"gray" -> ThemeColors.Gray "gray" -> ThemeColors.Gray
"yellow" -> ThemeColors.Yellow
else -> ThemeColors.Default else -> ThemeColors.Default
} }
} }
@@ -305,15 +310,16 @@ fun Context.loadThemeColors() {
"orange" -> ThemeColors.Orange "orange" -> ThemeColors.Orange
"pink" -> ThemeColors.Pink "pink" -> ThemeColors.Pink
"gray" -> ThemeColors.Gray "gray" -> ThemeColors.Gray
"yellow" -> ThemeColors.Yellow
else -> ThemeColors.Default else -> ThemeColors.Default
} }
} }
fun Context.saveDynamicColorState(enabled: Boolean) { fun Context.saveDynamicColorState(enabled: Boolean) {
getSharedPreferences("theme_prefs", Context.MODE_PRIVATE) getSharedPreferences("theme_prefs", Context.MODE_PRIVATE)
.edit() .edit {
.putBoolean("use_dynamic_color", enabled) putBoolean("use_dynamic_color", enabled)
.apply() }
ThemeConfig.useDynamicColor = enabled ThemeConfig.useDynamicColor = enabled
} }

View File

@@ -197,7 +197,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_blue">蓝色</string>
<string name="color_green">绿色</string> <string name="color_green">绿色</string>
<string name="color_purple">紫色</string> <string name="color_purple">紫色</string>
@@ -217,4 +217,5 @@
<string name="failed_reboot">重启失败</string> <string name="failed_reboot">重启失败</string>
<string name="batch_authorization">批量授权</string> <string name="batch_authorization">批量授权</string>
<string name="batch_cancel_authorization">批量取消授权</string> <string name="batch_cancel_authorization">批量取消授权</string>
<string name="color_yellow">黄色</string>
</resources> </resources>

View File

@@ -198,7 +198,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">yellow</string> <string name="color_default">White</string>
<string name="color_blue">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>
@@ -219,4 +219,5 @@
<string name="batch_authorization">bulk license</string> <string name="batch_authorization">bulk license</string>
<string name="batch_cancel_authorization">Batch cancel authorization</string> <string name="batch_cancel_authorization">Batch cancel authorization</string>
<string name="backup">Backup</string> <string name="backup">Backup</string>
<string name="color_yellow">Yellow</string>
</resources> </resources>

View File

@@ -1,5 +1,5 @@
[versions] [versions]
agp = "8.8.1" agp = "8.9.1"
kotlin = "2.1.10" kotlin = "2.1.10"
ksp = "2.1.10-1.0.30" ksp = "2.1.10-1.0.30"
compose-bom = "2025.02.00" compose-bom = "2025.02.00"