[新增] 新增了一些 Compose 界面的相关配置,界面模糊配置尚不可用
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
@@ -172,6 +172,8 @@ object PreferKey {
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
const val customMode = "customMode"
|
||||
const val paletteStyle = "paletteStyle"
|
||||
const val enableBlur = "enableBlur"
|
||||
const val cBackground = "colorBackground"
|
||||
const val cBBackground = "colorBottomBackground"
|
||||
const val bgImage = "backgroundImage"
|
||||
|
||||
@@ -902,6 +902,17 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefString(PreferKey.labelVisibilityMode, value)
|
||||
}
|
||||
|
||||
var paletteStyle
|
||||
get() = appCtx.getPrefString(PreferKey.paletteStyle, "tonalSpot")
|
||||
set(value) {
|
||||
appCtx.putPrefString(PreferKey.paletteStyle, value)
|
||||
}
|
||||
|
||||
var enableBlur
|
||||
get() = appCtx.getPrefBoolean(PreferKey.enableBlur, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.enableBlur, value)
|
||||
}
|
||||
var menuAlpha: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.menuAlpha, 100)
|
||||
set(value) {
|
||||
@@ -961,5 +972,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.sliderVibrator, value)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
true
|
||||
}
|
||||
|
||||
// TODO:删掉种子色了喵
|
||||
val hasColorImage = !getPrefString(PreferKey.colorImage).isNullOrBlank()
|
||||
colorPrimary?.isEnabled = !hasColorImage
|
||||
if (hasColorImage)
|
||||
@@ -178,15 +179,16 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
//recreateActivities()
|
||||
}
|
||||
|
||||
PreferKey.customMode -> handleRestartRequired()
|
||||
|
||||
PreferKey.pureBlack -> {
|
||||
PreferKey.paletteStyle, PreferKey.pureBlack, PreferKey.enableBlur -> {
|
||||
ThemeSyncer.syncAll()
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
recreateActivities()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
PreferKey.customMode -> handleRestartRequired()
|
||||
|
||||
PreferKey.isPredictiveBackEnabled -> {
|
||||
toastOnUi("重启以应用")
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ fun AppTheme(
|
||||
val appThemeMode by ThemeState.themeMode.collectAsState()
|
||||
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
||||
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
||||
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
||||
|
||||
val colorScheme = ThemeManager.getColorScheme(
|
||||
mode = appThemeMode,
|
||||
darkTheme = darkTheme,
|
||||
isAmoled = isPureBlack,
|
||||
isImageBg = hasImageBg
|
||||
isImageBg = hasImageBg,
|
||||
paletteStyle = paletteStyle
|
||||
)
|
||||
|
||||
MaterialExpressiveTheme(
|
||||
@@ -34,4 +36,5 @@ fun AppTheme(
|
||||
shapes = Shapes(),
|
||||
content = content
|
||||
)
|
||||
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.materialkolor.PaletteStyle
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.theme.ThemeResolver.resolvePaletteStyle
|
||||
import io.legado.app.ui.theme.colorScheme.AugustColorScheme
|
||||
import io.legado.app.ui.theme.colorScheme.CarlottaColorScheme
|
||||
import io.legado.app.ui.theme.colorScheme.ElinkColorScheme
|
||||
@@ -46,10 +46,11 @@ object ThemeManager {
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
isAmoled: Boolean,
|
||||
isImageBg: Boolean,
|
||||
paletteStyle: String?,
|
||||
forceOpaque: Boolean = false
|
||||
): ColorScheme {
|
||||
val context = LocalContext.current
|
||||
|
||||
val style = resolvePaletteStyle(paletteStyle)
|
||||
val actualMode = if (forceOpaque && mode == AppThemeMode.Transparent) {
|
||||
AppThemeMode.WH
|
||||
} else {
|
||||
@@ -66,7 +67,7 @@ object ThemeManager {
|
||||
}
|
||||
|
||||
AppThemeMode.CUSTOM -> {
|
||||
CustomColorScheme(context, context.primaryColor, PaletteStyle.Vibrant)
|
||||
CustomColorScheme(context, context.primaryColor, style)
|
||||
.getColorScheme(darkTheme)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.legado.app.ui.theme
|
||||
|
||||
import com.materialkolor.PaletteStyle
|
||||
|
||||
object ThemeResolver {
|
||||
|
||||
fun resolveThemeMode(value: String): AppThemeMode = when (value) {
|
||||
@@ -19,4 +21,20 @@ object ThemeResolver {
|
||||
"13" -> AppThemeMode.Transparent
|
||||
else -> AppThemeMode.Dynamic
|
||||
}
|
||||
|
||||
fun resolvePaletteStyle(value: String?): PaletteStyle {
|
||||
return when (value) {
|
||||
"tonalSpot" -> PaletteStyle.TonalSpot
|
||||
"neutral" -> PaletteStyle.Neutral
|
||||
"vibrant" -> PaletteStyle.Vibrant
|
||||
"expressive" -> PaletteStyle.Expressive
|
||||
"rainbow" -> PaletteStyle.Rainbow
|
||||
"fruitSalad" -> PaletteStyle.FruitSalad
|
||||
"monochrome" -> PaletteStyle.Monochrome
|
||||
"fidelity" -> PaletteStyle.Fidelity
|
||||
"content" -> PaletteStyle.Content
|
||||
else -> PaletteStyle.TonalSpot
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ object ThemeState {
|
||||
MutableStateFlow(AppConfig.hasImageBg)
|
||||
val hasImageBg: StateFlow<Boolean> = _hasImageBg.asStateFlow()
|
||||
|
||||
private val _paletteStyle =
|
||||
MutableStateFlow(AppConfig.paletteStyle)
|
||||
val paletteStyle: StateFlow<String?> = _paletteStyle.asStateFlow()
|
||||
|
||||
private val _enableBlur =
|
||||
MutableStateFlow(AppConfig.enableBlur)
|
||||
val enableBlur: StateFlow<Boolean> = _enableBlur.asStateFlow()
|
||||
|
||||
fun updateThemeMode(newMode: AppThemeMode) {
|
||||
if (_themeMode.value != newMode) {
|
||||
_themeMode.value = newMode
|
||||
@@ -39,4 +47,17 @@ object ThemeState {
|
||||
_hasImageBg.value = enabled
|
||||
}
|
||||
}
|
||||
|
||||
fun updatePaletteStyle(style: String?) {
|
||||
if (_paletteStyle.value != style) {
|
||||
_paletteStyle.value = style
|
||||
}
|
||||
}
|
||||
|
||||
fun updateEnableBlur(enabled: Boolean) {
|
||||
if (_enableBlur.value != enabled) {
|
||||
_enableBlur.value = enabled
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ object ThemeSyncer {
|
||||
syncThemeMode()
|
||||
syncPureBlack()
|
||||
syncImageBg()
|
||||
syncPaletteStyle()
|
||||
syncEnableBlur()
|
||||
}
|
||||
|
||||
fun syncThemeMode() {
|
||||
@@ -26,4 +28,12 @@ object ThemeSyncer {
|
||||
fun syncImageBg() {
|
||||
ThemeState.updateImageBg(AppConfig.hasImageBg)
|
||||
}
|
||||
|
||||
fun syncPaletteStyle() {
|
||||
ThemeState.updatePaletteStyle(AppConfig.paletteStyle)
|
||||
}
|
||||
|
||||
fun syncEnableBlur() {
|
||||
ThemeState.updateEnableBlur(AppConfig.enableBlur)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -34,12 +34,14 @@ fun GlobalModalBottomSheet(
|
||||
val themeMode by ThemeState.themeMode.collectAsState()
|
||||
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
||||
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
||||
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
||||
|
||||
val colorScheme = ThemeManager.getColorScheme(
|
||||
mode = themeMode,
|
||||
isAmoled = isPureBlack,
|
||||
isImageBg = hasImageBg,
|
||||
forceOpaque = true
|
||||
forceOpaque = true,
|
||||
paletteStyle = paletteStyle
|
||||
)
|
||||
|
||||
ModalBottomSheet(
|
||||
|
||||
@@ -156,6 +156,18 @@
|
||||
<item>关闭</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="paletteStyle">
|
||||
<item>柔和</item>
|
||||
<item>中性</item>
|
||||
<item>鲜艳</item>
|
||||
<item>表现力</item>
|
||||
<item>彩虹</item>
|
||||
<item>水果拼盘</item>
|
||||
<item>单色</item>
|
||||
<item>仿真</item>
|
||||
<item>内容取色</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="customMode">
|
||||
<item>全局</item>
|
||||
<item>仅强调色</item>
|
||||
|
||||
@@ -1367,4 +1367,7 @@
|
||||
<string name="text_accent_color">强调</string>
|
||||
<string name="read_color">颜色样式</string>
|
||||
<string name="reverse_volume_key_page">反转音量键翻页方向</string>
|
||||
<string name="palette_style">调色板样式</string>
|
||||
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
||||
<string name="is_blur_enable">启用控件模糊</string>
|
||||
</resources>
|
||||
@@ -78,6 +78,18 @@
|
||||
<item>off</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="paletteStyle_value">
|
||||
<item>tonalSpot</item>
|
||||
<item>neutral</item>
|
||||
<item>vibrant</item>
|
||||
<item>expressive</item>
|
||||
<item>rainbow</item>
|
||||
<item>fruitSalad</item>
|
||||
<item>monochrome</item>
|
||||
<item>fidelity</item>
|
||||
<item>content</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="customMode_value">
|
||||
<item>global</item>
|
||||
<item>accent</item>
|
||||
|
||||
@@ -193,7 +193,19 @@
|
||||
<item>Off</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="customMode">
|
||||
<string-array name="paletteStyle">
|
||||
<item>TonalSpot</item>
|
||||
<item>Neutral</item>
|
||||
<item>Vibrant</item>
|
||||
<item>Expressive</item>
|
||||
<item>Rainbow</item>
|
||||
<item>FruitSalad</item>
|
||||
<item>Monochrome</item>
|
||||
<item>Fidelity</item>
|
||||
<item>Content</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="customMode">
|
||||
<item>Global</item>
|
||||
<item>Accent</item>
|
||||
</string-array>
|
||||
|
||||
@@ -1372,4 +1372,7 @@
|
||||
<string name="text_accent_color">强调</string>
|
||||
<string name="read_color">颜色样式</string>
|
||||
<string name="reverse_volume_key_page">反转音量键翻页方向</string>
|
||||
<string name="palette_style">调色板样式</string>
|
||||
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
||||
<string name="is_blur_enable">启用控件模糊</string>
|
||||
</resources>
|
||||
|
||||
@@ -43,11 +43,6 @@
|
||||
app:cpv_dialogType="preset"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<io.legado.app.lib.prefs.ImagePreviewPreference
|
||||
android:key="colorImage"
|
||||
android:title="种子图片"
|
||||
android:summary="@string/seed_photo_summary"/>
|
||||
|
||||
<io.legado.app.lib.prefs.NameListPreference
|
||||
android:defaultValue="global"
|
||||
android:key="customMode"
|
||||
@@ -81,6 +76,34 @@
|
||||
|
||||
</io.legado.app.lib.prefs.PreferenceCategory>
|
||||
|
||||
<io.legado.app.lib.prefs.PreferenceCategory
|
||||
android:title="Compose 相关"
|
||||
app:allowDividerAbove="false"
|
||||
app:allowDividerBelow="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:layout="@layout/view_preference_category">
|
||||
|
||||
<io.legado.app.lib.prefs.TipPreference
|
||||
android:key="tip"
|
||||
android:selectable="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:tipText="@string/tip_compose_set" />
|
||||
|
||||
<io.legado.app.lib.prefs.NameListPreference
|
||||
android:defaultValue="tonalSpot"
|
||||
android:key="paletteStyle"
|
||||
android:title="@string/palette_style"
|
||||
app:entries="@array/paletteStyle"
|
||||
app:entryValues="@array/paletteStyle_value" />
|
||||
|
||||
<io.legado.app.lib.prefs.SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="enableBlur"
|
||||
android:title="@string/is_blur_enable"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
</io.legado.app.lib.prefs.PreferenceCategory>
|
||||
|
||||
<io.legado.app.lib.prefs.PreferenceCategory
|
||||
android:title="@string/main_activity"
|
||||
app:allowDividerAbove="false"
|
||||
|
||||
@@ -42,7 +42,7 @@ markwon = "4.6.2"
|
||||
material = "1.14.0-alpha08"
|
||||
material3 = "1.5.0-alpha11"
|
||||
material3IconsExtended = "1.7.8"
|
||||
materialKolor = "4.0.5"
|
||||
materialKolor = "4.1.0"
|
||||
media = "1.7.1"
|
||||
media3 = "1.8.0"
|
||||
nanoHttpd = "2.3.1"
|
||||
|
||||
Reference in New Issue
Block a user