|
|
@ -16,6 +16,8 @@ import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
import io.legado.app.utils.getPrefString |
|
|
|
import io.legado.app.utils.getPrefString |
|
|
|
|
|
|
|
import io.legado.app.utils.textHeight |
|
|
|
|
|
|
|
import io.legado.app.utils.toStringArray |
|
|
|
import splitties.init.appCtx |
|
|
|
import splitties.init.appCtx |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -44,7 +46,6 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
textPaint.typeface = Typeface.DEFAULT_BOLD |
|
|
|
textPaint.typeface = Typeface.DEFAULT_BOLD |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textSkewX = -0.2f |
|
|
|
|
|
|
|
textPaint |
|
|
|
textPaint |
|
|
|
} |
|
|
|
} |
|
|
|
private val authorPaint by lazy { |
|
|
|
private val authorPaint by lazy { |
|
|
@ -52,7 +53,6 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
textPaint.typeface = Typeface.DEFAULT |
|
|
|
textPaint.typeface = Typeface.DEFAULT |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textSkewX = -0.1f |
|
|
|
|
|
|
|
textPaint |
|
|
|
textPaint |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -86,11 +86,8 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
namePaint.textSize = width / 6 |
|
|
|
namePaint.textSize = width / 6 |
|
|
|
namePaint.strokeWidth = namePaint.textSize / 10 |
|
|
|
namePaint.strokeWidth = namePaint.textSize / 10 |
|
|
|
authorPaint.textSize = width / 9 |
|
|
|
authorPaint.textSize = width / 8 |
|
|
|
authorPaint.strokeWidth = authorPaint.textSize / 10 |
|
|
|
authorPaint.strokeWidth = authorPaint.textSize / 10 |
|
|
|
val fm = namePaint.fontMetrics |
|
|
|
|
|
|
|
nameHeight = height * 0.5f + (fm.bottom - fm.top) * 0.5f |
|
|
|
|
|
|
|
authorHeight = nameHeight + (fm.bottom - fm.top) * 0.6f |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
@ -104,21 +101,37 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun drawName(canvas: Canvas) { |
|
|
|
private fun drawName(canvas: Canvas) { |
|
|
|
name?.let { |
|
|
|
var startX = width * 0.2f |
|
|
|
namePaint.color = Color.WHITE |
|
|
|
var startY = height * 0.2f |
|
|
|
namePaint.style = Paint.Style.STROKE |
|
|
|
name?.toStringArray()?.let { name -> |
|
|
|
canvas.drawText(it, width / 2, nameHeight, namePaint) |
|
|
|
name.forEach { |
|
|
|
namePaint.color = Color.RED |
|
|
|
namePaint.color = Color.WHITE |
|
|
|
namePaint.style = Paint.Style.FILL |
|
|
|
namePaint.style = Paint.Style.STROKE |
|
|
|
canvas.drawText(it, width / 2, nameHeight, namePaint) |
|
|
|
canvas.drawText(it, startX, startY, namePaint) |
|
|
|
|
|
|
|
namePaint.color = Color.DKGRAY |
|
|
|
|
|
|
|
namePaint.style = Paint.Style.FILL |
|
|
|
|
|
|
|
canvas.drawText(it, startX, startY, namePaint) |
|
|
|
|
|
|
|
startY += namePaint.textHeight |
|
|
|
|
|
|
|
if (startY > height * 0.9) { |
|
|
|
|
|
|
|
return@let |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
author?.let { |
|
|
|
startX = width * 0.8f |
|
|
|
authorPaint.color = Color.WHITE |
|
|
|
startY = height * 0.7f |
|
|
|
authorPaint.style = Paint.Style.STROKE |
|
|
|
author?.toStringArray()?.let { author -> |
|
|
|
canvas.drawText(it, width / 2, authorHeight, authorPaint) |
|
|
|
author.forEach { |
|
|
|
authorPaint.color = Color.RED |
|
|
|
authorPaint.color = Color.WHITE |
|
|
|
authorPaint.style = Paint.Style.FILL |
|
|
|
authorPaint.style = Paint.Style.STROKE |
|
|
|
canvas.drawText(it, width / 2, authorHeight, authorPaint) |
|
|
|
canvas.drawText(it, startX, startY, authorPaint) |
|
|
|
|
|
|
|
authorPaint.color = Color.DKGRAY |
|
|
|
|
|
|
|
authorPaint.style = Paint.Style.FILL |
|
|
|
|
|
|
|
canvas.drawText(it, startX, startY, authorPaint) |
|
|
|
|
|
|
|
startY += authorPaint.textHeight |
|
|
|
|
|
|
|
if (startY > height * 0.95) { |
|
|
|
|
|
|
|
return@let |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|