添加高刷设置

pull/967/head
gedoor 4 years ago
parent dea0ab7a2d
commit 9e0547b035
  1. 20
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  3. 2
      app/src/main/java/io/legado/app/data/entities/Book.kt
  4. 2
      app/src/main/res/values-zh-rHK/strings.xml
  5. 2
      app/src/main/res/values-zh-rTW/strings.xml
  6. 2
      app/src/main/res/values-zh/strings.xml
  7. 2
      app/src/main/res/values/strings.xml
  8. 6
      app/src/main/res/xml/pref_config_other.xml

@ -14,6 +14,7 @@ import androidx.viewbinding.ViewBinding
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.PreferKey
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.ThemeConfig import io.legado.app.help.ThemeConfig
@ -66,6 +67,25 @@ abstract class BaseActivity<VB : ViewBinding>(
} }
override fun onCreate(savedInstanceState: Bundle?) { 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() window.decorView.disableAutoFill()
initTheme() initTheme()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

@ -73,6 +73,7 @@ object PreferKey {
const val exportUseReplace = "exportUseReplace" const val exportUseReplace = "exportUseReplace"
const val useZhLayout = "useZhLayout" const val useZhLayout = "useZhLayout"
const val fullScreenGesturesSupport = "fullScreenGesturesSupport" const val fullScreenGesturesSupport = "fullScreenGesturesSupport"
const val highBrush = "highBrush"
const val cPrimary = "colorPrimary" const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent" const val cAccent = "colorAccent"

@ -107,6 +107,8 @@ data class Book(
fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0) fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0)
fun getDisplayTag() = if (customTag.isNullOrBlank()) kind else customTag
fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl
fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro

@ -820,5 +820,7 @@
<string name="content_src">正文源码</string> <string name="content_src">正文源码</string>
<string name="list_src">列表源码</string> <string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string>
</resources> </resources>

@ -822,5 +822,7 @@
<string name="content_src">正文原始碼</string> <string name="content_src">正文原始碼</string>
<string name="list_src">列表原始碼</string> <string name="list_src">列表原始碼</string>
<string name="url_already">此url已訂閱</string> <string name="url_already">此url已訂閱</string>
<string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string>
</resources> </resources>

@ -824,5 +824,7 @@
<string name="content_src">正文源码</string> <string name="content_src">正文源码</string>
<string name="list_src">列表源码</string> <string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string>
</resources> </resources>

@ -827,5 +827,7 @@
<string name="content_src">正文源码</string> <string name="content_src">正文源码</string>
<string name="list_src">列表源码</string> <string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string> <string name="url_already">此url已订阅</string>
<string name="high_brush_title">高刷</string>
<string name="high_brush_summary">使用屏幕最高刷新率</string>
</resources> </resources>

@ -55,6 +55,12 @@
android:key="userAgent" android:key="userAgent"
android:title="UserAgent" /> android:title="UserAgent" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:key="highBrush"
android:defaultValue="false"
android:title="@string/high_brush_title"
android:summary="@string/high_brush_summary" />
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="preDownload" android:key="preDownload"

Loading…
Cancel
Save