修复主题应用
This commit is contained in:
1 parent
32e7e78c69
commit
9c3f185fa7
10 files changed
+59
-78
No files matched your search
@@ -43,9 +43,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
when (key) {
|
||||
|
||||
PreferKey.themeMode -> {
|
||||
themeMode = appCtx.getPrefString(PreferKey.themeMode, "0")
|
||||
isEInkMode = themeMode == "3"
|
||||
}
|
||||
|
||||
PreferKey.clickActionTL -> clickActionTL =
|
||||
@@ -103,12 +103,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
else -> sysConfiguration.isNightMode
|
||||
}
|
||||
set(value) {
|
||||
if (isNightTheme != value) {
|
||||
if (value) {
|
||||
appCtx.putPrefString(PreferKey.themeMode, "2")
|
||||
} else {
|
||||
appCtx.putPrefString(PreferKey.themeMode, "1")
|
||||
}
|
||||
val newMode = if (value) "2" else "1"
|
||||
if (themeMode != newMode) {
|
||||
appCtx.putPrefString(PreferKey.themeMode, newMode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,25 +51,28 @@ object ThemeConfig {
|
||||
}
|
||||
|
||||
fun applyDayNight(context: Context) {
|
||||
applyTheme(context)
|
||||
initNightMode()
|
||||
BookCover.upDefaultCover()
|
||||
postEvent(EventBus.RECREATE, "")
|
||||
}
|
||||
|
||||
fun applyDayNightInit(context: Context) {
|
||||
applyTheme(context)
|
||||
//applyTheme(context)
|
||||
initNightMode()
|
||||
}
|
||||
|
||||
private fun initNightMode() {
|
||||
val targetMode =
|
||||
if (AppConfig.isNightTheme) {
|
||||
AppCompatDelegate.MODE_NIGHT_YES
|
||||
} else {
|
||||
AppCompatDelegate.MODE_NIGHT_NO
|
||||
when (appCtx.getPrefString(PreferKey.themeMode, "0")) {
|
||||
"1" -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
}
|
||||
AppCompatDelegate.setDefaultNightMode(targetMode)
|
||||
"2" -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
}
|
||||
else -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getBgImage(context: Context, metrics: DisplayMetrics): Bitmap? {
|
||||
@@ -214,9 +217,9 @@ object ThemeConfig {
|
||||
/**
|
||||
* 更新主题
|
||||
*/
|
||||
fun applyTheme(context: Context) = with(context) {
|
||||
|
||||
}
|
||||
// fun applyTheme(context: Context) = with(context) {
|
||||
//
|
||||
// }
|
||||
|
||||
@Keep
|
||||
data class Config(
|
||||
|
||||
Reference in new issue
Block a user