feat: E-Ink模式合并到主题模式里, E-Ink模式不能修改阅读界面背景和文字颜色

pull/254/head
gedoor 4 years ago
parent ed622adc02
commit 6745ba4baf
  1. 17
      app/src/main/java/io/legado/app/App.kt
  2. 38
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt

@ -5,6 +5,7 @@ import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatDelegate
@ -69,7 +70,17 @@ class App : Application() {
* 更新主题
*/
fun applyTheme() {
if (AppConfig.isNightTheme) {
when {
AppConfig.isEInkMode -> {
ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(Color.WHITE)
.accentColor(Color.BLACK)
.backgroundColor(Color.WHITE)
.bottomBackground(Color.WHITE)
.apply()
}
AppConfig.isNightTheme -> {
ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(
@ -81,7 +92,8 @@ class App : Application() {
).bottomBackground(
getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
).apply()
} else {
}
else -> {
ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(
@ -95,6 +107,7 @@ class App : Application() {
).apply()
}
}
}
fun applyDayNight() {
ReadBookConfig.upBg()

@ -14,7 +14,6 @@ import io.legado.app.base.BaseFragment
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.service.WebService
import io.legado.app.ui.about.AboutActivity
@ -122,43 +121,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
}
}
"recordLog" -> LogUtils.upLevel()
PreferKey.eInkMode -> {
//既然是 E-Ink 模式,为什么不一步到位呢
if (AppConfig.isEInkMode) {
//保存开启前的设置
putPrefInt(PreferKey.lastPageAnim, ReadBookConfig.pageAnim)
putPrefInt(PreferKey.cLPrimary, getPrefInt(PreferKey.cPrimary))
putPrefInt(PreferKey.cLAccent, getPrefInt(PreferKey.cAccent))
putPrefInt(PreferKey.cLBackground, getPrefInt(PreferKey.cBackground))
putPrefInt(PreferKey.cLBBackground, getPrefInt(PreferKey.cBBackground))
putPrefString(
PreferKey.lastThemeMode,
getPrefString(PreferKey.themeMode) ?: "0"
)
//设置 E-Ink 模式配置
ReadBookConfig.pageAnim = 4
putPrefInt(PreferKey.cPrimary, getCompatColor(R.color.white))
putPrefInt(PreferKey.cAccent, getCompatColor(R.color.black))
putPrefInt(PreferKey.cBackground, getCompatColor(R.color.white))
putPrefInt(PreferKey.cBBackground, getCompatColor(R.color.white))
AppConfig.isNightTheme = false
App.INSTANCE.applyDayNight()
postEvent(EventBus.RECREATE, "")
} else if (getPrefString(PreferKey.lastThemeMode) != null) {
ReadBookConfig.pageAnim = getPrefInt(PreferKey.lastPageAnim)
putPrefInt(PreferKey.cPrimary, getPrefInt(PreferKey.cLPrimary))
putPrefInt(PreferKey.cAccent, getPrefInt(PreferKey.cLAccent))
putPrefInt(PreferKey.cBackground, getPrefInt(PreferKey.cLBackground))
putPrefInt(PreferKey.cBBackground, getPrefInt(PreferKey.cLBBackground))
putPrefString(
PreferKey.themeMode,
getPrefString(PreferKey.lastThemeMode) ?: "0"
)
App.INSTANCE.applyDayNight()
postEvent(EventBus.RECREATE, "")
}
}
}
}

Loading…
Cancel
Save