Merge pull request #2086 from 821938089/opt-page-anim

优化翻页动画
pull/2088/head
kunfei 2 years ago committed by GitHub
commit 814cfea73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  3. 1
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt

@ -198,6 +198,8 @@ abstract class BaseReadBookActivity :
* 保持亮屏 * 保持亮屏
*/ */
fun keepScreenOn(on: Boolean) { fun keepScreenOn(on: Boolean) {
val isScreenOn = (window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
if (on == isScreenOn) return
if (on) { if (on) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else { } else {

@ -160,7 +160,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
*/ */
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean { override fun onTouchEvent(event: MotionEvent): Boolean {
callBack.screenOffTimerStart()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val insets = val insets =
this.rootWindowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.mandatorySystemGestures()) this.rootWindowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.mandatorySystemGestures())
@ -174,6 +173,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
when (event.action) { when (event.action) {
MotionEvent.ACTION_DOWN -> { MotionEvent.ACTION_DOWN -> {
callBack.screenOffTimerStart()
if (isTextSelected) { if (isTextSelected) {
curPage.cancelSelect() curPage.cancelSelect()
isTextSelected = false isTextSelected = false
@ -205,6 +205,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
} }
} }
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
callBack.screenOffTimerStart()
removeCallbacks(longPressRunnable) removeCallbacks(longPressRunnable)
if (!pressDown) return true if (!pressDown) return true
pressDown = false pressDown = false

@ -133,6 +133,7 @@ fun View.screenshot(): Bitmap? {
c.translate(-scrollX.toFloat(), -scrollY.toFloat()) c.translate(-scrollX.toFloat(), -scrollY.toFloat())
this.draw(c) this.draw(c)
c.setBitmap(null) c.setBitmap(null)
screenshot.prepareToDraw()
screenshot screenshot
} else { } else {
null null

Loading…
Cancel
Save