From 9e0547b03532ee228a6ae2813013d5169adfef53 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 25 Apr 2021 19:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=AB=98=E5=88=B7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/base/BaseActivity.kt | 20 +++++++++++++++++++ .../java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/data/entities/Book.kt | 2 ++ app/src/main/res/values-zh-rHK/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values-zh/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_config_other.xml | 6 ++++++ 8 files changed, 37 insertions(+) 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 ef9c23953..7ae907b99 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -14,6 +14,7 @@ import androidx.viewbinding.ViewBinding import io.legado.app.App import io.legado.app.R import io.legado.app.constant.AppConst +import io.legado.app.constant.PreferKey import io.legado.app.constant.Theme import io.legado.app.help.AppConfig import io.legado.app.help.ThemeConfig @@ -66,6 +67,25 @@ abstract class BaseActivity( } override fun onCreate(savedInstanceState: Bundle?) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && + getPrefBoolean(PreferKey.highBrush) + ) { + /** + * 添加高刷新率支持 + */ + // 获取系统window支持的模式 + val modes = window.windowManager.defaultDisplay.supportedModes + // 对获取的模式,基于刷新率的大小进行排序,从小到大排序 + modes.sortBy { + it.refreshRate + } + window.let { + val lp = it.attributes + // 取出最大的那一个刷新率,直接设置给window + lp.preferredDisplayModeId = modes.last().modeId + it.attributes = lp + } + } window.decorView.disableAutoFill() initTheme() super.onCreate(savedInstanceState) 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 0d1e5ef7e..651830256 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -73,6 +73,7 @@ object PreferKey { const val exportUseReplace = "exportUseReplace" const val useZhLayout = "useZhLayout" const val fullScreenGesturesSupport = "fullScreenGesturesSupport" + const val highBrush = "highBrush" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 5093c05c1..2ee782122 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -107,6 +107,8 @@ data class Book( fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0) + fun getDisplayTag() = if (customTag.isNullOrBlank()) kind else customTag + fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 29e200c8c..cab096ed7 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -820,5 +820,7 @@ 正文源码 列表源码 此url已订阅 + 高刷 + 使用屏幕最高刷新率 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c04585a7d..a29b45531 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -822,5 +822,7 @@ 正文原始碼 列表原始碼 此url已訂閱 + 高刷 + 使用屏幕最高刷新率 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 05aa55b5a..240704cac 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -824,5 +824,7 @@ 正文源码 列表源码 此url已订阅 + 高刷 + 使用屏幕最高刷新率 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 04b53023e..501d88d96 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -827,5 +827,7 @@ 正文源码 列表源码 此url已订阅 + 高刷 + 使用屏幕最高刷新率 diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index c15aee51e..66a9cc4fa 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -55,6 +55,12 @@ android:key="userAgent" android:title="UserAgent" /> + +