Merge pull request #243 from FadeApp/eink

保存打开 E-Ink 模式前的主题、翻页动画,关闭后恢复之前的配置, 现在可以切着玩了
pull/248/head
kunfei 5 years ago committed by GitHub
commit 57565e0c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt

@ -15,6 +15,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.service.WebService import io.legado.app.service.WebService
import io.legado.app.ui.about.AboutActivity import io.legado.app.ui.about.AboutActivity
import io.legado.app.ui.about.DonateActivity import io.legado.app.ui.about.DonateActivity
@ -124,6 +125,15 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
PreferKey.einkMode -> { PreferKey.einkMode -> {
//既然是 E-Ink 模式,为什么不一步到位呢 //既然是 E-Ink 模式,为什么不一步到位呢
if (AppConfig.isEInkMode) { if (AppConfig.isEInkMode) {
//保存开启前的设置
putPrefInt("lastReadBookPageAnim", ReadBookConfig.pageAnim)
putPrefInt("lastColorPrimary", ThemeStore.primaryColor(requireContext()))
putPrefInt("lastColorAccent", ThemeStore.accentColor(requireContext()))
putPrefInt("lastColorBackground", ThemeStore.backgroundColor(requireContext()))
putPrefInt("lastColorBottomBackground", ThemeStore.bottomBackground(requireContext()))
putPrefBoolean("lastIsNightTheme", AppConfig.isNightTheme)
//设置 E-Ink 模式配置
ReadBookConfig.pageAnim = 4 ReadBookConfig.pageAnim = 4
putPrefInt("colorPrimary", getCompatColor(R.color.white)) putPrefInt("colorPrimary", getCompatColor(R.color.white))
putPrefInt("colorAccent", getCompatColor(R.color.black)) putPrefInt("colorAccent", getCompatColor(R.color.black))
@ -132,6 +142,15 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
AppConfig.isNightTheme = false AppConfig.isNightTheme = false
App.INSTANCE.applyDayNight() App.INSTANCE.applyDayNight()
postEvent(EventBus.RECREATE, "") postEvent(EventBus.RECREATE, "")
} else {
ReadBookConfig.pageAnim = getPrefInt("lastReadBookPageAnim")
putPrefInt("colorPrimary", getPrefInt("lastColorPrimary"))
putPrefInt("colorAccent", getPrefInt("lastColorAccent"))
putPrefInt("colorBackground", getPrefInt("lastColorBackground"))
putPrefInt("colorBottomBackground", getPrefInt("lastColorBottomBackground"))
AppConfig.isNightTheme = getPrefBoolean("lastIsNightTheme")
App.INSTANCE.applyDayNight()
postEvent(EventBus.RECREATE, "")
} }
} }
} }

Loading…
Cancel
Save