This commit is contained in:
Horis
2023-09-26 23:43:09 +08:00
parent b5bea5e3c4
commit 1d7e696766
2 changed files with 13 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.page.entities.column
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.text.StaticLayout
import androidx.annotation.Keep
import io.legado.app.ui.book.read.page.provider.ChapterProvider
@@ -17,8 +18,8 @@ data class ReviewColumn(
) : BaseColumn {
val countText by lazy {
if (count > 99) {
return@lazy "99+"
if (count > 999) {
return@lazy "999"
}
return@lazy count.toString()
}
@@ -28,19 +29,22 @@ data class ReviewColumn(
fun drawToCanvas(canvas: Canvas, baseLine: Float, height: Float) {
if (count == 0) return
path.reset()
path.moveTo(start, baseLine - height / 2)
path.lineTo(start + height / 6, baseLine - height)
path.lineTo(end, baseLine - height)
path.lineTo(end, baseLine)
path.moveTo(start + 1, baseLine - height * 2 / 5)
path.lineTo(start + height / 6, baseLine - height * 0.55f)
path.lineTo(start + height / 6, baseLine - height * 0.8f)
path.lineTo(end - 1, baseLine - height * 0.8f)
path.lineTo(end - 1, baseLine)
path.lineTo(start + height / 6, baseLine)
path.lineTo(start + height / 6, baseLine - height / 4)
path.close()
ChapterProvider.reviewPaint.style = Paint.Style.STROKE
canvas.drawPath(path, ChapterProvider.reviewPaint)
ChapterProvider.reviewPaint.style = Paint.Style.FILL
val textWidth = StaticLayout.getDesiredWidth(countText, ChapterProvider.reviewPaint)
canvas.drawText(
countText,
(start + end) / 2,
baseLine - height / 6,
start + height / 6 + textWidth * 0.45f,
baseLine - height / 5,
ChapterProvider.reviewPaint
)
}

View File

@@ -667,7 +667,7 @@ object ChapterProvider {
titlePaint = it.first
contentPaint = it.second
reviewPaint.color = contentPaint.color
reviewPaint.textSize = contentPaint.textSize * 0.6f
reviewPaint.textSize = contentPaint.textSize * 0.45f
reviewPaint.textAlign = Paint.Align.CENTER
}
//间距