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 } }