From 6745ba4baf65196029a7cc83b3304454236418ce Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Jun 2020 13:09:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20E-Ink=E6=A8=A1=E5=BC=8F=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F=E9=87=8C?= =?UTF-8?q?,=20E-Ink=E6=A8=A1=E5=BC=8F=E4=B8=8D=E8=83=BD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF=E5=92=8C?= =?UTF-8?q?=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 61 +++++++++++-------- .../io/legado/app/ui/main/my/MyFragment.kt | 38 ------------ 2 files changed, 37 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 05d6f1837..93ea305a1 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.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,30 +70,42 @@ class App : Application() { * 更新主题 */ fun applyTheme() { - if (AppConfig.isNightTheme) { - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) - ).accentColor( - getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) - ).backgroundColor( - getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) - ).bottomBackground( - getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) - ).apply() - } else { - ThemeStore.editTheme(this) - .coloredNavigationBar(true) - .primaryColor( - getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) - ).accentColor( - getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) - ).backgroundColor( - getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) - ).bottomBackground( - getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) - ).apply() + 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( + getPrefInt(PreferKey.cNPrimary, getCompatColor(R.color.md_blue_grey_600)) + ).accentColor( + getPrefInt(PreferKey.cNAccent, getCompatColor(R.color.md_deep_orange_800)) + ).backgroundColor( + getPrefInt(PreferKey.cNBackground, getCompatColor(R.color.shine_color)) + ).bottomBackground( + getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) + ).apply() + } + else -> { + ThemeStore.editTheme(this) + .coloredNavigationBar(true) + .primaryColor( + getPrefInt(PreferKey.cPrimary, getCompatColor(R.color.md_indigo_800)) + ).accentColor( + getPrefInt(PreferKey.cAccent, getCompatColor(R.color.md_red_600)) + ).backgroundColor( + getPrefInt(PreferKey.cBackground, getCompatColor(R.color.md_grey_100)) + ).bottomBackground( + getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) + ).apply() + } } } diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index 806d79942..88bb95afe 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -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, "") - } - } } }