Changing the custom background expand more options logic
Co-authored-by:ShirkNeko <ShirkNeko@alone2832165@gmail.com>
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -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,74 +317,74 @@ 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) {
|
||||||
if (isChecked) {
|
showCardSettings = !showCardSettings
|
||||||
pickImageLauncher.launch("image/*")
|
}
|
||||||
} else {
|
},
|
||||||
context.saveCustomBackground(null)
|
trailingContent = {
|
||||||
isCustomBackgroundEnabled = false
|
Switch(
|
||||||
CardConfig.cardElevation = CardConfig.defaultElevation
|
checked = isCustomBackgroundEnabled,
|
||||||
CardConfig.cardAlpha = 1f
|
onCheckedChange = { isChecked ->
|
||||||
saveCardConfig(context)
|
if (isChecked) {
|
||||||
|
pickImageLauncher.launch("image/*")
|
||||||
|
} else {
|
||||||
|
context.saveCustomBackground(null)
|
||||||
|
isCustomBackgroundEnabled = false
|
||||||
|
CardConfig.cardElevation = CardConfig.defaultElevation
|
||||||
|
CardConfig.cardAlpha = 1f
|
||||||
|
saveCardConfig(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
// 卡片管理展开控制
|
if (ThemeConfig.customBackgroundUri != null && showCardSettings) {
|
||||||
if (ThemeConfig.customBackgroundUri != null) {
|
// 透明度 Slider
|
||||||
ListItem(
|
ListItem(
|
||||||
leadingContent = { Icon(Icons.Default.ExpandMore, null) },
|
leadingContent = { Icon(Icons.Filled.Opacity, null) },
|
||||||
headlineContent = { Text(stringResource(R.string.settings_card_manage)) },
|
headlineContent = { Text(stringResource(R.string.settings_card_alpha)) },
|
||||||
modifier = Modifier.clickable { showCardSettings = !showCardSettings }
|
supportingContent = {
|
||||||
|
Slider(
|
||||||
|
value = cardAlpha,
|
||||||
|
onValueChange = { newValue ->
|
||||||
|
cardAlpha = newValue
|
||||||
|
CardConfig.cardAlpha = newValue
|
||||||
|
prefs.edit().putFloat("card_alpha", newValue).apply()
|
||||||
|
},
|
||||||
|
onValueChangeFinished = {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
saveCardConfig(context)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0f..1f,
|
||||||
|
colors = getSliderColors(cardAlpha, useCustomColors = true),
|
||||||
|
thumb = {
|
||||||
|
SliderDefaults.Thumb(
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
thumbSize = DpSize(0.dp, 0.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showCardSettings) {
|
ListItem(
|
||||||
// 透明度 Slider
|
leadingContent = { Icon(Icons.Filled.DarkMode, null) },
|
||||||
ListItem(
|
headlineContent = { Text(stringResource(R.string.theme_mode)) },
|
||||||
leadingContent = { Icon(Icons.Filled.Opacity, null) },
|
supportingContent = { Text(themeOptions[themeMode]) },
|
||||||
headlineContent = { Text(stringResource(R.string.settings_card_alpha)) },
|
modifier = Modifier.clickable {
|
||||||
supportingContent = {
|
showThemeModeDialog = true
|
||||||
Slider(
|
}
|
||||||
value = cardAlpha,
|
)
|
||||||
onValueChange = { newValue ->
|
|
||||||
cardAlpha = newValue
|
|
||||||
CardConfig.cardAlpha = newValue
|
|
||||||
prefs.edit().putFloat("card_alpha", newValue).apply()
|
|
||||||
},
|
|
||||||
onValueChangeFinished = {
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
saveCardConfig(context)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
valueRange = 0f..1f,
|
|
||||||
// 确保使用自定义颜色
|
|
||||||
colors = getSliderColors(cardAlpha, useCustomColors = true),
|
|
||||||
thumb = {
|
|
||||||
SliderDefaults.Thumb(
|
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
|
||||||
thumbSize = DpSize(0.dp, 0.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
ListItem(
|
|
||||||
leadingContent = { Icon(Icons.Filled.DarkMode, null) },
|
|
||||||
headlineContent = { Text(stringResource(R.string.theme_mode)) },
|
|
||||||
supportingContent = { Text(themeOptions[themeMode]) },
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
showThemeModeDialog = true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// 主题模式选择对话框
|
// 主题模式选择对话框
|
||||||
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 {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user