Changing the custom background expand more options logic

Co-authored-by:ShirkNeko <ShirkNeko@alone2832165@gmail.com>
This commit is contained in:
ShirkNeko
2025-03-22 16:37:30 +08:00
parent 192f36fb3c
commit ff99ab8e62
5 changed files with 99 additions and 66 deletions

View File

@@ -20,8 +20,8 @@ obj-$(CONFIG_KSU) += kernelsu.o
ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0) ifeq ($(shell test -e $(srctree)/$(src)/../.git; echo $$?),0)
$(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin [ -f ../.git/shallow ] && git fetch --unshallow) $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin [ -f ../.git/shallow ] && git fetch --unshallow)
KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD) KSU_GIT_VERSION := $(shell cd $(srctree)/$(src); /usr/bin/env PATH="$$PATH":/usr/bin:/usr/local/bin git rev-list --count HEAD)
# ksu_version: major * 10000 + git version + 600 for historical reasons # ksu_version: major * 10000 + git version + 606 for historical reasons
$(eval KSU_VERSION=$(shell expr 12000 + $(KSU_GIT_VERSION) + 500)) $(eval KSU_VERSION=$(shell expr 10000 + $(KSU_GIT_VERSION) + 606))
$(info -- KernelSU version: $(KSU_VERSION)) $(info -- KernelSU version: $(KSU_VERSION))
ccflags-y += -DKSU_VERSION=$(KSU_VERSION) ccflags-y += -DKSU_VERSION=$(KSU_VERSION)
else # If there is no .git file, the default version will be passed. else # If there is no .git file, the default version will be passed.

View File

@@ -1,2 +1,33 @@
package shirkneko.zako.sukisu.ui.component package shirkneko.zako.sukisu.ui.component
import androidx.compose.foundation.clickable
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
@Composable
fun SwitchItem(
icon: ImageVector,
title: String,
summary: String,
checked: Boolean,
modifier: Modifier = Modifier,
onCheckedChange: (Boolean) -> Unit
) {
ListItem(
modifier = modifier,
leadingContent = { Icon(icon, contentDescription = null) },
headlineContent = { Text(title) },
supportingContent = { Text(summary) },
trailingContent = {
Switch(
checked = checked,
onCheckedChange = onCheckedChange
)
}
)
}

View File

@@ -49,6 +49,9 @@ 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.compose.ui.input.pointer.pointerInput
fun saveCardConfig(context: Context) { fun saveCardConfig(context: Context) {
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE) val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -314,14 +317,20 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
) )
} }
} }
// 自定义背景开关 // 自定义背景开关
SwitchItem( ListItem(
icon = Icons.Filled.Wallpaper, leadingContent = { Icon(Icons.Filled.Wallpaper, null) },
title = stringResource(id = R.string.settings_custom_background), headlineContent = { Text(stringResource(id = R.string.settings_custom_background)) },
summary = stringResource(id = R.string.settings_custom_background_summary), supportingContent = { Text(stringResource(id = R.string.settings_custom_background_summary)) },
checked = isCustomBackgroundEnabled modifier = Modifier.clickable {
) { isChecked -> if (isCustomBackgroundEnabled) {
showCardSettings = !showCardSettings
}
},
trailingContent = {
Switch(
checked = isCustomBackgroundEnabled,
onCheckedChange = { isChecked ->
if (isChecked) { if (isChecked) {
pickImageLauncher.launch("image/*") pickImageLauncher.launch("image/*")
} else { } else {
@@ -332,16 +341,11 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
saveCardConfig(context) saveCardConfig(context)
} }
} }
)
// 卡片管理展开控制 }
if (ThemeConfig.customBackgroundUri != null) {
ListItem(
leadingContent = { Icon(Icons.Default.ExpandMore, null) },
headlineContent = { Text(stringResource(R.string.settings_card_manage)) },
modifier = Modifier.clickable { showCardSettings = !showCardSettings }
) )
if (showCardSettings) { if (ThemeConfig.customBackgroundUri != null && showCardSettings) {
// 透明度 Slider // 透明度 Slider
ListItem( ListItem(
leadingContent = { Icon(Icons.Filled.Opacity, null) }, leadingContent = { Icon(Icons.Filled.Opacity, null) },
@@ -360,7 +364,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
}, },
valueRange = 0f..1f, valueRange = 0f..1f,
// 确保使用自定义颜色
colors = getSliderColors(cardAlpha, useCustomColors = true), colors = getSliderColors(cardAlpha, useCustomColors = true),
thumb = { thumb = {
SliderDefaults.Thumb( SliderDefaults.Thumb(
@@ -372,7 +375,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
) )
ListItem( ListItem(
leadingContent = { Icon(Icons.Filled.DarkMode, null) }, leadingContent = { Icon(Icons.Filled.DarkMode, null) },
headlineContent = { Text(stringResource(R.string.theme_mode)) }, headlineContent = { Text(stringResource(R.string.theme_mode)) },
@@ -382,6 +384,7 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
) )
// 主题模式选择对话框 // 主题模式选择对话框
if (showThemeModeDialog) { if (showThemeModeDialog) {
AlertDialog( AlertDialog(
@@ -424,7 +427,6 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
} }
} }
} }
}
@Composable @Composable
private fun getSliderColors(cardAlpha: Float, useCustomColors: Boolean = false): SliderColors { private fun getSliderColors(cardAlpha: Float, useCustomColors: Boolean = false): SliderColors {

View File

@@ -33,7 +33,7 @@ val androidCompileSdkVersion = 35
val androidCompileNdkVersion = "28.0.13004108" val androidCompileNdkVersion = "28.0.13004108"
val androidSourceCompatibility = JavaVersion.VERSION_21 val androidSourceCompatibility = JavaVersion.VERSION_21
val androidTargetCompatibility = JavaVersion.VERSION_21 val androidTargetCompatibility = JavaVersion.VERSION_21
val managerVersionCode by extra(1 * 12000 + getGitCommitCount() + 500) val managerVersionCode by extra(1 * 10000 + getGitCommitCount() + 606)
val managerVersionName by extra(getGitDescribe()) val managerVersionName by extra(getGitDescribe())
fun getGitCommitCount(): Int { fun getGitCommitCount(): Int {
@@ -53,7 +53,7 @@ fun getGitDescribe(): String {
fun getVersionCode(): Int { fun getVersionCode(): Int {
val commitCount = getGitCommitCount() val commitCount = getGitCommitCount()
val major = 1 val major = 1
return major * 12000 + commitCount + 500 return major * 10000 + commitCount + 606
} }
fun getVersionName(): String { fun getVersionName(): String {

View File

@@ -15,7 +15,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
.trim() .trim()
.parse() .parse()
.map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Failed to parse git count"))?; .map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Failed to parse git count"))?;
let version_code = 12000 + 500 + version_code; // For historical reasons let version_code = 10000 + 606 + version_code; // For historical reasons
let version_name = String::from_utf8( let version_name = String::from_utf8(
Command::new("git") Command::new("git")