From 98258eefe6f6f520704caa1bc6e819e5d314fd1b Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Wed, 20 Jul 2022 22:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BF=BB=E9=A1=B5=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/BaseReadBookActivity.kt | 2 ++ app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt | 3 ++- app/src/main/java/io/legado/app/utils/ViewExtensions.kt | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt index 27cdef098..75ac8cdfb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt @@ -198,6 +198,8 @@ abstract class BaseReadBookActivity : * 保持亮屏 */ fun keepScreenOn(on: Boolean) { + val isScreenOn = (window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0 + if (on == isScreenOn) return if (on) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index cc0cff8ae..135d5562c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -160,7 +160,6 @@ class ReadView(context: Context, attrs: AttributeSet) : */ @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent): Boolean { - callBack.screenOffTimerStart() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { val insets = this.rootWindowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.mandatorySystemGestures()) @@ -174,6 +173,7 @@ class ReadView(context: Context, attrs: AttributeSet) : when (event.action) { MotionEvent.ACTION_DOWN -> { + callBack.screenOffTimerStart() if (isTextSelected) { curPage.cancelSelect() isTextSelected = false @@ -205,6 +205,7 @@ class ReadView(context: Context, attrs: AttributeSet) : } } MotionEvent.ACTION_UP -> { + callBack.screenOffTimerStart() removeCallbacks(longPressRunnable) if (!pressDown) return true pressDown = false diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index 4a7f5ab90..d38107d9c 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -133,6 +133,7 @@ fun View.screenshot(): Bitmap? { c.translate(-scrollX.toFloat(), -scrollY.toFloat()) this.draw(c) c.setBitmap(null) + screenshot.prepareToDraw() screenshot } else { null