From c01a68e46daf0667b3c809481eb603b72b819e9c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Dec 2020 18:50:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/utils/SystemUtils.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/SystemUtils.kt b/app/src/main/java/io/legado/app/utils/SystemUtils.kt index b8027528d..7faccc935 100644 --- a/app/src/main/java/io/legado/app/utils/SystemUtils.kt +++ b/app/src/main/java/io/legado/app/utils/SystemUtils.kt @@ -56,12 +56,16 @@ object SystemUtils { */ fun isNavigationBarExist(activity: Activity?): Boolean { activity?.let { - val vp = it.window.decorView as? ViewGroup - if (vp != null) { - for (i in 0 until vp.childCount) { - vp.getChildAt(i).context.packageName - if (vp.getChildAt(i).id != View.NO_ID - && NAVIGATION == activity.resources.getResourceEntryName(vp.getChildAt(i).id) + val viewGroup = it.window.decorView as? ViewGroup + if (viewGroup != null) { + for (i in 0 until viewGroup.childCount) { + viewGroup.getChildAt(i).context.packageName + if (viewGroup.getChildAt(i).id != View.NO_ID + && NAVIGATION == activity.resources.getResourceEntryName( + viewGroup.getChildAt( + i + ).id + ) ) { return true } From b81ef8a0c2e70e5b6996f0bb23b81c1ce0b0faa7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Dec 2020 19:17:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=A0=8F=E9=9D=9E=E6=B2=89=E6=B5=B8=E6=98=AF=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=B7=B1=E4=B8=80=E4=BA=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/base/BaseActivity.kt | 2 +- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 8 ++++---- .../io/legado/app/ui/book/read/ReadBookBaseActivity.kt | 2 +- .../java/io/legado/app/ui/config/ThemeConfigFragment.kt | 1 + app/src/main/res/values-zh-rHK/strings.xml | 4 ++-- app/src/main/res/values-zh-rTW/strings.xml | 4 ++-- app/src/main/res/values-zh/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- app/src/main/res/xml/pref_config_theme.xml | 6 +++--- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 94bd38a64..4f1124ae4 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -167,7 +167,7 @@ abstract class BaseActivity( } open fun upNavigationBarColor() { - if (AppConfig.isTransparentStatusBar) { + if (AppConfig.immNavigationBar) { ATH.setNavigationBarColorAuto(this, ThemeStore.navigationBarColor(this)) } else { val nbColor = ColorUtils.darkenColor(ThemeStore.navigationBarColor(this)) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 76a17bca1..a69fd3368 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -55,6 +55,7 @@ object PreferKey { const val autoReadSpeed = "autoReadSpeed" const val barElevation = "barElevation" const val transparentStatusBar = "transparentStatusBar" + const val immNavigationBar = "immNavigationBar" const val defaultCover = "defaultCover" const val replaceEnableDefault = "replaceEnableDefault" const val showBrightnessView = "showBrightnessView" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index d6854a306..2a8a5cd94 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -73,11 +73,11 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { } } - var isTransparentStatusBar: Boolean + val isTransparentStatusBar: Boolean get() = context.getPrefBoolean(PreferKey.transparentStatusBar) - set(value) { - context.putPrefBoolean(PreferKey.transparentStatusBar, value) - } + + val immNavigationBar: Boolean + get() = context.getPrefBoolean(PreferKey.immNavigationBar) val screenDirection: String? get() = context.getPrefString(PreferKey.screenDirection) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 22b4c1e80..e50ebf435 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -145,7 +145,7 @@ abstract class ReadBookBaseActivity : when { binding.readMenu.isVisible -> super.upNavigationBarColor() bottomDialog > 0 -> super.upNavigationBarColor() - else -> if (AppConfig.isTransparentStatusBar) { + else -> if (AppConfig.immNavigationBar) { ATH.setNavigationBarColorAuto(this, Color.TRANSPARENT) } else { ATH.setNavigationBarColorAuto(this, Color.parseColor("#20000000")) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 8a4f1863b..b7a29434e 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -133,6 +133,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), when (key) { PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key)) PreferKey.transparentStatusBar -> recreateActivities() + PreferKey.immNavigationBar -> recreateActivities() PreferKey.cPrimary, PreferKey.cAccent, PreferKey.cBackground, diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 32146a70e..44d480018 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -361,8 +361,8 @@ 完結書籍 本地書籍 狀態欄顏色透明 - 導航欄變色 - 導航欄根據夜間模式變化 + 沉浸式导航栏 + 导航栏颜色透明 放入書架 繼續閲讀 封面地址 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 370eaeb0a..71781981d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -362,8 +362,8 @@ 完結書籍 本機書籍 狀態欄顏色透明 - 導航欄變色 - 導航欄根據夜間模式變化 + 沉浸式导航栏 + 导航栏颜色透明 放入書架 繼續閱讀 封面地址 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 15c4f5604..4baf18b05 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -364,8 +364,8 @@ 完结书籍 本地书籍 状态栏颜色透明 - 导航栏变色 - 导航栏根据夜间模式变化 + 沉浸式导航栏 + 导航栏颜色透明 放入书架 继续阅读 封面地址 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 18e1473b0..b28807641 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -365,8 +365,8 @@ Finished books Local books The status bar color becomes transparent - Discolored navigation bar - The navigation bar changes color following the dark mode + immersion navigation bar + The navigation bar becomes transparent Add to Bookshelf Continue reading Cover path diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 673332a25..383e29ba3 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -21,9 +21,9 @@ Date: Sun, 13 Dec 2020 19:22:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/AppConfig.kt | 4 ++-- app/src/main/res/xml/pref_config_theme.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 2a8a5cd94..2efcd482c 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -74,10 +74,10 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { } val isTransparentStatusBar: Boolean - get() = context.getPrefBoolean(PreferKey.transparentStatusBar) + get() = context.getPrefBoolean(PreferKey.transparentStatusBar, true) val immNavigationBar: Boolean - get() = context.getPrefBoolean(PreferKey.immNavigationBar) + get() = context.getPrefBoolean(PreferKey.immNavigationBar, true) val screenDirection: String? get() = context.getPrefString(PreferKey.screenDirection) diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index 383e29ba3..081c49b37 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -20,7 +20,7 @@ app:iconSpaceReserved="false" />