From 1e9cecef8135e1222430cc8c4f97f553b8cdd48d Mon Sep 17 00:00:00 2001 From: Seidko Date: Tue, 6 Sep 2022 14:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/ContentTextView.kt | 12 ++++++++---- .../java/io/legado/app/ui/book/read/page/PageView.kt | 2 +- .../java/io/legado/app/ui/book/read/page/ReadView.kt | 1 - 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index a0164302d..f95f4f196 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -102,6 +102,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at * 绘制页面 */ private fun drawPage(canvas: Canvas) { + reviewButtonArea.clear() var relativeOffset = relativeOffset(0) textPage.textLines.forEach { textLine -> draw(canvas, textPage, textLine, relativeOffset) @@ -111,7 +112,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at if (!pageFactory.hasNext()) return val textPage1 = relativePage(1) relativeOffset = relativeOffset(1) - reviewButtonArea.clear() textPage1.textLines.forEach { textLine -> draw(canvas, textPage1, textLine, relativeOffset) } @@ -172,8 +172,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at if (textLine.reviewCount <= 0) return@forEach reviewButtonArea.add( floatArrayOf( - it.start, lineBase, it.start + textPaint.textSize * 1.6F, - lineBase - textPaint.textSize * 0.8F, + it.start - textPaint.textSize * 0.4F, + lineBase + textPaint.textSize * 0.2F, + it.start + textPaint.textSize * 2F, + lineBase - textPaint.textSize * 1F, ) ) canvas.drawLine( @@ -351,7 +353,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at */ fun pressReviewButton(x: Float, y: Float): Boolean { reviewButtonArea.forEach { - if (x in it[0]..it[2] && y + textPage.height in it[3]..it[1]) return true + if (x in it[0]..it[2] && y in it[3]..it[1]) { + return true + } } return false } 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 32584b3f1..9103231ce 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 @@ -269,7 +269,7 @@ class PageView(context: Context) : FrameLayout(context) { } fun pressReviewButton(x: Float, y: Float): Boolean { - return binding.contentTextView.pressReviewButton(x, y) + return binding.contentTextView.pressReviewButton(x, y - headerHeight) } fun longPress( 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 7583c318c..fa4e4d8e0 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 @@ -372,7 +372,6 @@ class ReadView(context: Context, attrs: AttributeSet) : when { curPage.pressReviewButton(startX, startY) -> { context.toastOnUi("Button Pressed!") - ReadBook.upMsg(null) } isTextSelected -> Unit mcRect.contains(startX, startY) -> if (!isAbortAnim) {