From 6ca5850adef30ac8d3fdfb262af9c1da44ab71dd Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 10 Dec 2021 20:45:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../io/legado/app/ui/book/read/page/ContentTextView.kt | 2 +- .../io/legado/app/ui/book/read/page/entities/TextLine.kt | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 4821d6dba..6c3215528 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -16,6 +16,7 @@ * 朗读出错不弹出朗读界面的时候可以长按朗读按钮进入朗读界面切换朗读引擎,这个有很多人不知道 * 修复cronet访问出错时应用崩溃的bug * 修复一些epub目录不全或内容不全的问题 +* 修复横屏双页时文字选择的问题 * 电脑硬盘坏了还好资料恢复出来了,还是要经常备份比较好 **2021/11/27** 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 91e182c47..9c0de4a3f 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 @@ -313,7 +313,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } val textPage = relativePage(relativePos) for ((lineIndex, textLine) in textPage.textLines.withIndex()) { - if (textLine.isTouch(y, relativeOffset)) { + if (textLine.isTouch(x, y, relativeOffset)) { for ((charIndex, textChar) in textLine.textChars.withIndex()) { if (textChar.isTouch(x)) { touched.invoke( diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 2ad80b8a1..bc05317b8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -17,6 +17,8 @@ data class TextLine( ) { val charSize: Int get() = textChars.size + val lineStart: Float get() = textChars.firstOrNull()?.start ?: 0f + val lineEnd: Float get() = textChars.lastOrNull()?.end ?: 0f fun upTopBottom(durY: Float, textPaint: TextPaint) { lineTop = ChapterProvider.paddingTop + durY @@ -38,7 +40,10 @@ data class TextLine( return textChars.size } - fun isTouch(y: Float, relativeOffset: Float): Boolean { - return y > lineTop + relativeOffset && y < lineBottom + relativeOffset + fun isTouch(x: Float, y: Float, relativeOffset: Float): Boolean { + return y > lineTop + relativeOffset + && y < lineBottom + relativeOffset + && x >= lineStart + && x <= lineEnd } }