完成按钮

pull/2250/head
Seidko 2 years ago
parent 4255749968
commit 1e9cecef81
  1. 12
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

@ -102,6 +102,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
* 绘制页面 * 绘制页面
*/ */
private fun drawPage(canvas: Canvas) { private fun drawPage(canvas: Canvas) {
reviewButtonArea.clear()
var relativeOffset = relativeOffset(0) var relativeOffset = relativeOffset(0)
textPage.textLines.forEach { textLine -> textPage.textLines.forEach { textLine ->
draw(canvas, textPage, textLine, relativeOffset) draw(canvas, textPage, textLine, relativeOffset)
@ -111,7 +112,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (!pageFactory.hasNext()) return if (!pageFactory.hasNext()) return
val textPage1 = relativePage(1) val textPage1 = relativePage(1)
relativeOffset = relativeOffset(1) relativeOffset = relativeOffset(1)
reviewButtonArea.clear()
textPage1.textLines.forEach { textLine -> textPage1.textLines.forEach { textLine ->
draw(canvas, textPage1, textLine, relativeOffset) draw(canvas, textPage1, textLine, relativeOffset)
} }
@ -172,8 +172,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (textLine.reviewCount <= 0) return@forEach if (textLine.reviewCount <= 0) return@forEach
reviewButtonArea.add( reviewButtonArea.add(
floatArrayOf( floatArrayOf(
it.start, lineBase, it.start + textPaint.textSize * 1.6F, it.start - textPaint.textSize * 0.4F,
lineBase - textPaint.textSize * 0.8F, lineBase + textPaint.textSize * 0.2F,
it.start + textPaint.textSize * 2F,
lineBase - textPaint.textSize * 1F,
) )
) )
canvas.drawLine( canvas.drawLine(
@ -351,7 +353,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
*/ */
fun pressReviewButton(x: Float, y: Float): Boolean { fun pressReviewButton(x: Float, y: Float): Boolean {
reviewButtonArea.forEach { 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 return false
} }

@ -269,7 +269,7 @@ class PageView(context: Context) : FrameLayout(context) {
} }
fun pressReviewButton(x: Float, y: Float): Boolean { fun pressReviewButton(x: Float, y: Float): Boolean {
return binding.contentTextView.pressReviewButton(x, y) return binding.contentTextView.pressReviewButton(x, y - headerHeight)
} }
fun longPress( fun longPress(

@ -372,7 +372,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
when { when {
curPage.pressReviewButton(startX, startY) -> { curPage.pressReviewButton(startX, startY) -> {
context.toastOnUi("Button Pressed!") context.toastOnUi("Button Pressed!")
ReadBook.upMsg(null)
} }
isTextSelected -> Unit isTextSelected -> Unit
mcRect.contains(startX, startY) -> if (!isAbortAnim) { mcRect.contains(startX, startY) -> if (!isAbortAnim) {

Loading…
Cancel
Save