[新增] 合并代码
This commit is contained in:
@@ -94,6 +94,8 @@ object PreferKey {
|
|||||||
const val defaultCoverDark = "defaultCoverDark"
|
const val defaultCoverDark = "defaultCoverDark"
|
||||||
const val replaceEnableDefault = "replaceEnableDefault"
|
const val replaceEnableDefault = "replaceEnableDefault"
|
||||||
const val showBrightnessView = "showBrightnessView"
|
const val showBrightnessView = "showBrightnessView"
|
||||||
|
const val useUnderline = "useUnderline"
|
||||||
|
const val adaptSpecialStyle = "adaptSpecialStyle"
|
||||||
const val autoClearExpired = "autoClearExpired"
|
const val autoClearExpired = "autoClearExpired"
|
||||||
const val autoChangeSource = "autoChangeSource"
|
const val autoChangeSource = "autoChangeSource"
|
||||||
const val importKeepName = "importKeepName"
|
const val importKeepName = "importKeepName"
|
||||||
@@ -174,6 +176,8 @@ object PreferKey {
|
|||||||
const val cAccent = "colorAccent"
|
const val cAccent = "colorAccent"
|
||||||
const val customMode = "customMode"
|
const val customMode = "customMode"
|
||||||
const val paletteStyle = "paletteStyle"
|
const val paletteStyle = "paletteStyle"
|
||||||
|
const val composeEngine = "composeEngine"
|
||||||
|
const val containerOpacity = "containerOpacity"
|
||||||
const val enableBlur = "enableBlur"
|
const val enableBlur = "enableBlur"
|
||||||
const val cBackground = "colorBackground"
|
const val cBackground = "colorBackground"
|
||||||
const val cBBackground = "colorBottomBackground"
|
const val cBBackground = "colorBottomBackground"
|
||||||
|
|||||||
@@ -53,14 +53,26 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
|
|
||||||
var themeMode = appCtx.getPrefString(PreferKey.themeMode, "0")
|
var themeMode = appCtx.getPrefString(PreferKey.themeMode, "0")
|
||||||
var AppTheme = appCtx.getPrefString(PreferKey.appTheme, "0")
|
var AppTheme = appCtx.getPrefString(PreferKey.appTheme, "0")
|
||||||
|
var containerOpacity = appCtx.getPrefInt(PreferKey.containerOpacity, 100)
|
||||||
var useDefaultCover = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false)
|
var useDefaultCover = appCtx.getPrefBoolean(PreferKey.useDefaultCover, false)
|
||||||
var optimizeRender = CanvasRecorderFactory.isSupport
|
var optimizeRender = CanvasRecorderFactory.isSupport
|
||||||
&& appCtx.getPrefBoolean(PreferKey.optimizeRender, false)
|
&& appCtx.getPrefBoolean(PreferKey.optimizeRender, false)
|
||||||
var recordLog = appCtx.getPrefBoolean(PreferKey.recordLog)
|
var recordLog = appCtx.getPrefBoolean(PreferKey.recordLog)
|
||||||
|
|
||||||
|
// -- lyc 版本特性 --
|
||||||
|
var adaptSpecialStyle = appCtx.getPrefBoolean(PreferKey.adaptSpecialStyle, true)
|
||||||
|
var useUnderline = appCtx.getPrefBoolean(PreferKey.useUnderline, false)
|
||||||
|
|
||||||
var webServiceAutoStart = appCtx.getPrefBoolean(PreferKey.webServiceAutoStart)
|
var webServiceAutoStart = appCtx.getPrefBoolean(PreferKey.webServiceAutoStart)
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
when (key) {
|
when (key) {
|
||||||
|
|
||||||
|
PreferKey.adaptSpecialStyle -> adaptSpecialStyle =
|
||||||
|
appCtx.getPrefBoolean(PreferKey.adaptSpecialStyle, true)
|
||||||
|
|
||||||
|
PreferKey.useUnderline -> useUnderline =
|
||||||
|
appCtx.getPrefBoolean(PreferKey.useUnderline, false)
|
||||||
|
|
||||||
PreferKey.appTheme -> {
|
PreferKey.appTheme -> {
|
||||||
AppTheme = appCtx.getPrefString(PreferKey.appTheme, "0")
|
AppTheme = appCtx.getPrefString(PreferKey.appTheme, "0")
|
||||||
}
|
}
|
||||||
@@ -973,16 +985,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
appCtx.putPrefBoolean(PreferKey.sliderVibrator, value)
|
appCtx.putPrefBoolean(PreferKey.sliderVibrator, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
val audioPreDownloadNum: Int
|
|
||||||
get() = appCtx.getPrefInt(PreferKey.audioPreDownloadNum, 10)
|
|
||||||
|
|
||||||
val audioCacheCleanTimeOrgin: Int
|
|
||||||
get() = appCtx.getPrefInt(PreferKey.audioCacheCleanTime, 10)
|
|
||||||
|
|
||||||
val audioCacheCleanTime: Long
|
|
||||||
get() {
|
|
||||||
val str = appCtx.getPrefInt(PreferKey.audioCacheCleanTime, 10)
|
|
||||||
return str * 60 * 1000L
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
addPreferencesFromResource(R.xml.pref_config_theme)
|
addPreferencesFromResource(R.xml.pref_config_theme)
|
||||||
|
|
||||||
upPreferenceSummary(PreferKey.fontScale)
|
upPreferenceSummary(PreferKey.fontScale)
|
||||||
|
upPreferenceSummary(PreferKey.containerOpacity)
|
||||||
|
|
||||||
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
|
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
|
||||||
it.onSaveColor = { color ->
|
it.onSaveColor = { color ->
|
||||||
@@ -254,6 +255,20 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
recreateActivities()
|
recreateActivities()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PreferKey.containerOpacity -> NumberPickerDialog(requireContext())
|
||||||
|
.setTitle(getString(R.string.container_opacity))
|
||||||
|
.setMaxValue(100)
|
||||||
|
.setMinValue(0)
|
||||||
|
.setValue(100)
|
||||||
|
.setCustomButton((R.string.btn_default_s)) {
|
||||||
|
putPrefInt(PreferKey.containerOpacity, 100)
|
||||||
|
ThemeSyncer.syncContainerOpacity()
|
||||||
|
}
|
||||||
|
.show {
|
||||||
|
putPrefInt(PreferKey.containerOpacity, it)
|
||||||
|
ThemeSyncer.syncContainerOpacity()
|
||||||
|
}
|
||||||
|
|
||||||
PreferKey.bgImage -> selectBgAction(false)
|
PreferKey.bgImage -> selectBgAction(false)
|
||||||
PreferKey.bgImageN -> selectBgAction(true)
|
PreferKey.bgImageN -> selectBgAction(true)
|
||||||
"colorImage" -> selectBgAction(null)
|
"colorImage" -> selectBgAction(null)
|
||||||
@@ -402,6 +417,10 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
when (preferenceKey) {
|
when (preferenceKey) {
|
||||||
//PreferKey.barElevation -> preference.summary =
|
//PreferKey.barElevation -> preference.summary =
|
||||||
// getString(R.string.bar_elevation_s, value)
|
// getString(R.string.bar_elevation_s, value)
|
||||||
|
PreferKey.containerOpacity -> {
|
||||||
|
preference.summary =
|
||||||
|
getString(R.string.container_opacity_summary, AppConfig.containerOpacity)
|
||||||
|
}
|
||||||
|
|
||||||
PreferKey.fontScale -> {
|
PreferKey.fontScale -> {
|
||||||
val fontScale = AppContextWrapper.getFontScale(requireContext())
|
val fontScale = AppContextWrapper.getFontScale(requireContext())
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ fun AppTheme(
|
|||||||
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
val isPureBlack by ThemeState.isPureBlack.collectAsState()
|
||||||
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
val hasImageBg by ThemeState.hasImageBg.collectAsState()
|
||||||
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
val paletteStyle by ThemeState.paletteStyle.collectAsState()
|
||||||
|
val opacity by ThemeState.containerOpacity.collectAsState()
|
||||||
|
|
||||||
val colorScheme = ThemeManager.getColorScheme(
|
val colorScheme = ThemeManager.getColorScheme(
|
||||||
mode = appThemeMode,
|
mode = appThemeMode,
|
||||||
darkTheme = darkTheme,
|
darkTheme = darkTheme,
|
||||||
isAmoled = isPureBlack,
|
isAmoled = isPureBlack,
|
||||||
isImageBg = hasImageBg,
|
isImageBg = hasImageBg,
|
||||||
paletteStyle = paletteStyle
|
paletteStyle = paletteStyle,
|
||||||
|
opacity = opacity
|
||||||
)
|
)
|
||||||
|
|
||||||
MaterialExpressiveTheme(
|
MaterialExpressiveTheme(
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ object ThemeManager {
|
|||||||
isAmoled: Boolean,
|
isAmoled: Boolean,
|
||||||
isImageBg: Boolean,
|
isImageBg: Boolean,
|
||||||
paletteStyle: String?,
|
paletteStyle: String?,
|
||||||
forceOpaque: Boolean = false
|
forceOpaque: Boolean = false,
|
||||||
|
opacity: Int = 100
|
||||||
): ColorScheme {
|
): ColorScheme {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val style = resolvePaletteStyle(paletteStyle)
|
val style = resolvePaletteStyle(paletteStyle)
|
||||||
@@ -83,16 +84,27 @@ object ThemeManager {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (!forceOpaque && (isImageBg || actualMode == AppThemeMode.Transparent)) {
|
if (!forceOpaque && (isImageBg || actualMode == AppThemeMode.Transparent)) {
|
||||||
scheme.copy(
|
return scheme.copy(
|
||||||
surface = Color.Transparent,
|
surface = Color.Transparent,
|
||||||
background = Color.Transparent,
|
background = Color.Transparent,
|
||||||
surfaceContainerLow = Color.Transparent,
|
surfaceContainerLow = Color.Transparent,
|
||||||
surfaceContainer = Color.Transparent
|
surfaceContainer = Color.Transparent,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val alpha = opacity / 100f
|
||||||
|
|
||||||
|
return if (opacity < 100 && !forceOpaque) {
|
||||||
|
scheme.copy(
|
||||||
|
surfaceContainerLowest = scheme.surfaceContainerLowest.copy(alpha = alpha),
|
||||||
|
surfaceContainerLow = scheme.surfaceContainerLow.copy(alpha = alpha),
|
||||||
|
surfaceContainer = scheme.surfaceContainer.copy(alpha = alpha),
|
||||||
|
surfaceContainerHigh = scheme.surfaceContainerHigh.copy(alpha = alpha),
|
||||||
|
surfaceContainerHighest = scheme.surfaceContainerHighest.copy(alpha = alpha),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
scheme
|
scheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,10 @@ object ThemeState {
|
|||||||
MutableStateFlow(AppConfig.enableBlur)
|
MutableStateFlow(AppConfig.enableBlur)
|
||||||
val enableBlur: StateFlow<Boolean> = _enableBlur.asStateFlow()
|
val enableBlur: StateFlow<Boolean> = _enableBlur.asStateFlow()
|
||||||
|
|
||||||
|
private val _containerOpacity =
|
||||||
|
MutableStateFlow(AppConfig.containerOpacity)
|
||||||
|
val containerOpacity: StateFlow<Int> = _containerOpacity
|
||||||
|
|
||||||
fun updateThemeMode(newMode: AppThemeMode) {
|
fun updateThemeMode(newMode: AppThemeMode) {
|
||||||
if (_themeMode.value != newMode) {
|
if (_themeMode.value != newMode) {
|
||||||
_themeMode.value = newMode
|
_themeMode.value = newMode
|
||||||
@@ -60,4 +64,10 @@ object ThemeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateContainerOpacity(opacity: Int) {
|
||||||
|
if (_containerOpacity.value != opacity) {
|
||||||
|
_containerOpacity.value = opacity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ object ThemeSyncer {
|
|||||||
syncImageBg()
|
syncImageBg()
|
||||||
syncPaletteStyle()
|
syncPaletteStyle()
|
||||||
syncEnableBlur()
|
syncEnableBlur()
|
||||||
|
syncContainerOpacity()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun syncThemeMode() {
|
fun syncThemeMode() {
|
||||||
@@ -36,4 +37,9 @@ object ThemeSyncer {
|
|||||||
fun syncEnableBlur() {
|
fun syncEnableBlur() {
|
||||||
ThemeState.updateEnableBlur(AppConfig.enableBlur)
|
ThemeState.updateEnableBlur(AppConfig.enableBlur)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun syncContainerOpacity() {
|
||||||
|
ThemeState.updateContainerOpacity(AppConfig.containerOpacity)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1370,6 +1370,11 @@
|
|||||||
<string name="palette_style">调色板样式</string>
|
<string name="palette_style">调色板样式</string>
|
||||||
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
||||||
<string name="is_blur_enable">启用控件模糊</string>
|
<string name="is_blur_enable">启用控件模糊</string>
|
||||||
|
<string name="use_underline">总是使用下划线表示强调文本</string>
|
||||||
|
<string name="adapt_special_style">适配特殊样式</string>
|
||||||
|
<string name="compose_engine">主题风格</string>
|
||||||
|
<string name="container_opacity">容器背景不透明度</string>
|
||||||
|
<string name="container_opacity_summary">%d</string>
|
||||||
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
||||||
<string name="read_aloud_preload">听书预加载数量</string>
|
<string name="read_aloud_preload">听书预加载数量</string>
|
||||||
<string name="read_aloud_preload_summary">%d</string>
|
<string name="read_aloud_preload_summary">%d</string>
|
||||||
|
|||||||
@@ -1375,6 +1375,11 @@
|
|||||||
<string name="palette_style">调色板样式</string>
|
<string name="palette_style">调色板样式</string>
|
||||||
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
<string name="tip_compose_set">这里的选项仅可以控制使用Compose重写的界面。</string>
|
||||||
<string name="is_blur_enable">启用控件模糊</string>
|
<string name="is_blur_enable">启用控件模糊</string>
|
||||||
|
<string name="use_underline">总是使用下划线表示强调文本</string>
|
||||||
|
<string name="adapt_special_style">适配特殊样式</string>
|
||||||
|
<string name="compose_engine">主题风格</string>
|
||||||
|
<string name="container_opacity">容器背景不透明度</string>
|
||||||
|
<string name="container_opacity_summary">%d</string>
|
||||||
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
||||||
<string name="read_aloud_preload">听书预加载数量</string>
|
<string name="read_aloud_preload">听书预加载数量</string>
|
||||||
<string name="read_aloud_preload_summary">%d</string>
|
<string name="read_aloud_preload_summary">%d</string>
|
||||||
|
|||||||
@@ -96,8 +96,23 @@
|
|||||||
app:entries="@array/paletteStyle"
|
app:entries="@array/paletteStyle"
|
||||||
app:entryValues="@array/paletteStyle_value" />
|
app:entryValues="@array/paletteStyle_value" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.NameListPreference
|
||||||
|
android:defaultValue="material"
|
||||||
|
android:enabled="false"
|
||||||
|
android:key="composeEngine"
|
||||||
|
android:title="@string/compose_engine"
|
||||||
|
app:entries="@array/composeEngine"
|
||||||
|
app:entryValues="@array/composeEngine_value" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.Preference
|
||||||
|
android:key="containerOpacity"
|
||||||
|
android:summary="@string/container_opacity_summary"
|
||||||
|
android:title="@string/container_opacity"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.SwitchPreference
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
android:enabled="false"
|
||||||
android:key="enableBlur"
|
android:key="enableBlur"
|
||||||
android:title="@string/is_blur_enable"
|
android:title="@string/is_blur_enable"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|||||||
Reference in New Issue
Block a user