未完成的按钮点击
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<FloatArray> = 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 长按
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.legado.app.utils.textHeight
|
||||
data class TextLine(
|
||||
var text: String = "",
|
||||
val textChars: ArrayList<TextChar> = arrayListOf(),
|
||||
val reviewCount: Int = 0,
|
||||
val reviewCount: Int = 1,
|
||||
var lineTop: Float = 0f,
|
||||
var lineBase: Float = 0f,
|
||||
var lineBottom: Float = 0f,
|
||||
|
||||
Reference in New Issue
Block a user