From bebce7d7a23fc73db17413034aff3152d62a0096 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 24 Jan 2020 23:01:03 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + .../java/io/legado/app/ui/book/read/ReadBookActivity.kt | 8 ++++++-- .../io/legado/app/ui/book/read/config/MoreConfigDialog.kt | 1 + .../main/java/io/legado/app/ui/book/read/page/PageView.kt | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) 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 bc98f163b..80efd5925 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -20,4 +20,5 @@ object PreferKey { const val fontFolder = "fontFolder" const val backupPath = "backupUri" const val threadCount = "threadCount" + const val keepLight = "keep_light" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 8bd8c8d0c..d74ea4be4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -553,18 +553,22 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo observeEvent(Bus.REPLACE) { ReplaceEditDialog().show(supportFragmentManager, "replaceEditDialog") } + observeEvent(PreferKey.keepLight) { + upScreenTimeOut() + } } private fun upScreenTimeOut() { - getPrefString("keep_light")?.let { + getPrefString(PreferKey.keepLight)?.let { screenTimeOut = it.toLong() * 1000 } + screenOffTimerStart() } /** * 重置黑屏时间 */ - fun screenOffTimerStart() { + override fun screenOffTimerStart() { if (screenTimeOut < 0) { Help.keepScreenOn(window, true) return diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 899d58d63..0eac917a1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -95,6 +95,7 @@ class MoreConfigDialog : DialogFragment() { PreferKey.hideStatusBar -> postEvent(Bus.UP_CONFIG, true) PreferKey.hideNavigationBar -> postEvent(Bus.UP_CONFIG, true) PreferKey.clickAllNext -> postEvent(Bus.UP_CONFIG, true) + PreferKey.keepLight -> postEvent(PreferKey.keepLight, true) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 84dafcaa6..5a57dbdd6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -65,6 +65,7 @@ class PageView(context: Context, attrs: AttributeSet) : @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent): Boolean { + callBack?.screenOffTimerStart() return pageDelegate?.onTouch(event) ?: super.onTouchEvent(event) } @@ -241,5 +242,7 @@ class PageView(context: Context, attrs: AttributeSet) : fun clickCenter() val isInitFinish: Boolean + + fun screenOffTimerStart() } }