diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt index 2d2dc249c..07ff9fb32 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt @@ -14,7 +14,7 @@ data class ReviewRule( // 这些功能将在以上功能完成以后实现 var voteUpUrl: String? = null, // 点赞URL var voteDownUrl: String? = null, // 点踩URL - var postReviewUrl: String? = null, // 发送回复URL + var postReviewUrl: String? = null, // 发送回复URL var postQuoteUrl: String? = null, // 发送回复段评URL var deleteUrl: String? = null, // 删除段评URL ): Parcelable 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 71712c180..a0164302d 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 @@ -51,6 +51,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private var cacheIncreased = false private val increaseSize = 8 * 1024 * 1024 private val maxCacheSize = 256 * 1024 * 1024 + private val reviewButtonArea: ArrayList = arrayListOf() //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory @@ -110,6 +111,7 @@ 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) } @@ -168,6 +170,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } if (it.charData == "\uD83D\uDCAC" && it.isLineEnd) { if (textLine.reviewCount <= 0) return@forEach + reviewButtonArea.add( + floatArrayOf( + it.start, lineBase, it.start + textPaint.textSize * 1.6F, + lineBase - textPaint.textSize * 0.8F, + ) + ) canvas.drawLine( it.start, lineBase - textPaint.textSize * 2 / 5, @@ -338,6 +346,16 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at pageOffset = 0 } + /** + * 点击评论按钮 + */ + 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 + } + 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 f8d86fa9e..32584b3f1 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 @@ -268,6 +268,10 @@ class PageView(context: Context) : FrameLayout(context) { binding.contentTextView.selectAble = selectAble } + fun pressReviewButton(x: Float, y: Float): Boolean { + return binding.contentTextView.pressReviewButton(x, y) + } + fun longPress( x: Float, y: Float, select: (relativePagePos: Int, lineIndex: Int, charIndex: Int) -> Unit, 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 6a8abc9bf..7583c318c 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 @@ -28,6 +28,7 @@ import io.legado.app.ui.book.read.page.provider.TextPageFactory import io.legado.app.utils.activity import io.legado.app.utils.invisible import io.legado.app.utils.screenshot +import io.legado.app.utils.toastOnUi import java.text.BreakIterator import java.util.* import kotlin.math.abs @@ -369,6 +370,10 @@ class ReadView(context: Context, attrs: AttributeSet) : */ private fun onSingleTapUp() { when { + curPage.pressReviewButton(startX, startY) -> { + context.toastOnUi("Button Pressed!") + ReadBook.upMsg(null) + } isTextSelected -> Unit mcRect.contains(startX, startY) -> if (!isAbortAnim) { click(AppConfig.clickActionMC) 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 56225b2ee..faa53a124 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 @@ -8,7 +8,7 @@ import io.legado.app.utils.textHeight data class TextLine( var text: String = "", val textChars: ArrayList = arrayListOf(), - val reviewCount: Int = 0, + val reviewCount: Int = 1, var lineTop: Float = 0f, var lineBase: Float = 0f, var lineBottom: Float = 0f,