From 146386d78e089890bd04cb28d148216d158b80d3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Jan 2020 11:07:41 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/App.kt | 2 +- app/src/main/java/io/legado/app/constant/Theme.kt | 2 +- app/src/main/java/io/legado/app/help/PrefExtensions.kt | 5 +++++ app/src/main/java/io/legado/app/lib/theme/ATH.kt | 4 ++-- app/src/main/java/io/legado/app/ui/book/read/Help.kt | 2 +- .../main/java/io/legado/app/ui/book/read/ReadMenu.kt | 1 + .../main/java/io/legado/app/utils/ContextExtensions.kt | 10 +++++----- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index ee3e4f5f6..8565ceb9e 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -17,11 +17,11 @@ import io.legado.app.data.AppDatabase import io.legado.app.help.ActivityHelp import io.legado.app.help.CrashHandler import io.legado.app.help.ReadBookConfig +import io.legado.app.help.isNightTheme import io.legado.app.lib.theme.ThemeStore import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt -import io.legado.app.utils.isNightTheme @Suppress("DEPRECATION") class App : Application() { diff --git a/app/src/main/java/io/legado/app/constant/Theme.kt b/app/src/main/java/io/legado/app/constant/Theme.kt index 40467a688..975eaa802 100644 --- a/app/src/main/java/io/legado/app/constant/Theme.kt +++ b/app/src/main/java/io/legado/app/constant/Theme.kt @@ -1,7 +1,7 @@ package io.legado.app.constant import io.legado.app.App -import io.legado.app.utils.isNightTheme +import io.legado.app.help.isNightTheme enum class Theme { Dark, Light, Auto; diff --git a/app/src/main/java/io/legado/app/help/PrefExtensions.kt b/app/src/main/java/io/legado/app/help/PrefExtensions.kt index 9a41707a1..4b89939cc 100644 --- a/app/src/main/java/io/legado/app/help/PrefExtensions.kt +++ b/app/src/main/java/io/legado/app/help/PrefExtensions.kt @@ -5,6 +5,11 @@ import io.legado.app.constant.PreferKey import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefInt +val Context.isNightTheme: Boolean + get() = getPrefBoolean("isNightTheme") + +val Context.isTransparentStatusBar: Boolean + get() = getPrefBoolean("transparentStatusBar", true) val Context.isShowRSS: Boolean get() = getPrefBoolean(PreferKey.showRss, true) diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index 57c7c8403..91c7fcda2 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -16,9 +16,9 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager.widget.ViewPager import com.google.android.material.bottomnavigation.BottomNavigationView import io.legado.app.R +import io.legado.app.help.isNightTheme +import io.legado.app.help.isTransparentStatusBar import io.legado.app.utils.getCompatColor -import io.legado.app.utils.isNightTheme -import io.legado.app.utils.isTransparentStatusBar import kotlinx.android.synthetic.main.activity_main.view.* import org.jetbrains.anko.backgroundColor diff --git a/app/src/main/java/io/legado/app/ui/book/read/Help.kt b/app/src/main/java/io/legado/app/ui/book/read/Help.kt index 247349a60..9d1be9f0c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/Help.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/Help.kt @@ -10,10 +10,10 @@ import android.view.WindowManager import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.help.ReadBookConfig +import io.legado.app.help.isTransparentStatusBar import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.getPrefBoolean -import io.legado.app.utils.isTransparentStatusBar object Help { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 19729f20b..972f89cb7 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -11,6 +11,7 @@ import androidx.core.view.isVisible import io.legado.app.App import io.legado.app.R import io.legado.app.constant.PreferKey +import io.legado.app.help.isNightTheme import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.buttonDisabledColor import io.legado.app.service.help.ReadBook diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 7b920dfa7..8d81ace88 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.content.res.ColorStateList +import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.drawable.Drawable import android.provider.Settings @@ -126,8 +127,7 @@ fun Context.shareWithQr(title: String, text: String) { } } -val Context.isNightTheme: Boolean - get() = getPrefBoolean("isNightTheme") - -val Context.isTransparentStatusBar: Boolean - get() = getPrefBoolean("transparentStatusBar", true) +fun Context.getDarkModeStatus(): Boolean { + val mode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK + return mode == Configuration.UI_MODE_NIGHT_YES +} \ No newline at end of file