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