|
|
@ -98,27 +98,29 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
var startX = width * 0.2f |
|
|
|
var startX = width * 0.2f |
|
|
|
var startY = height * 0.2f |
|
|
|
var startY = height * 0.2f |
|
|
|
name?.toStringArray()?.let { name -> |
|
|
|
name?.toStringArray()?.let { name -> |
|
|
|
namePaint.textSize = width / 7 |
|
|
|
namePaint.textSize = width / 6 |
|
|
|
namePaint.strokeWidth = namePaint.textSize / 5 |
|
|
|
namePaint.strokeWidth = namePaint.textSize / 5 |
|
|
|
name.forEach { |
|
|
|
name.forEachIndexed { index, char -> |
|
|
|
namePaint.color = Color.WHITE |
|
|
|
namePaint.color = Color.WHITE |
|
|
|
namePaint.style = Paint.Style.STROKE |
|
|
|
namePaint.style = Paint.Style.STROKE |
|
|
|
canvas.drawText(it, startX, startY, namePaint) |
|
|
|
canvas.drawText(char, startX, startY, namePaint) |
|
|
|
namePaint.color = context.accentColor |
|
|
|
namePaint.color = context.accentColor |
|
|
|
namePaint.style = Paint.Style.FILL |
|
|
|
namePaint.style = Paint.Style.FILL |
|
|
|
canvas.drawText(it, startX, startY, namePaint) |
|
|
|
canvas.drawText(char, startX, startY, namePaint) |
|
|
|
startY += namePaint.textHeight |
|
|
|
startY += namePaint.textHeight |
|
|
|
if (startY > height * 0.8) { |
|
|
|
if (startY > height * 0.8) { |
|
|
|
return@let |
|
|
|
startX += namePaint.textSize |
|
|
|
|
|
|
|
namePaint.textSize = width / 10 |
|
|
|
|
|
|
|
startY = (height - (name.size - index - 1) * namePaint.textHeight) / 2 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!BookCover.drawBookAuthor) return |
|
|
|
if (!BookCover.drawBookAuthor) return |
|
|
|
author?.toStringArray()?.let { author -> |
|
|
|
author?.toStringArray()?.let { author -> |
|
|
|
startX = width * 0.8f |
|
|
|
authorPaint.textSize = width / 10 |
|
|
|
startY = height * 0.7f |
|
|
|
|
|
|
|
authorPaint.textSize = width / 9 |
|
|
|
|
|
|
|
authorPaint.strokeWidth = authorPaint.textSize / 5 |
|
|
|
authorPaint.strokeWidth = authorPaint.textSize / 5 |
|
|
|
|
|
|
|
startX = width * 0.8f |
|
|
|
|
|
|
|
startY = height * 0.95f - author.size * authorPaint.textHeight |
|
|
|
author.forEach { |
|
|
|
author.forEach { |
|
|
|
authorPaint.color = Color.WHITE |
|
|
|
authorPaint.color = Color.WHITE |
|
|
|
authorPaint.style = Paint.Style.STROKE |
|
|
|
authorPaint.style = Paint.Style.STROKE |
|
|
@ -168,8 +170,8 @@ class CoverImageView @JvmOverloads constructor( |
|
|
|
|
|
|
|
|
|
|
|
fun load(path: String? = null, name: String? = null, author: String? = null) { |
|
|
|
fun load(path: String? = null, name: String? = null, author: String? = null) { |
|
|
|
this.bitmapPath = path |
|
|
|
this.bitmapPath = path |
|
|
|
this.name = name?.replace(AppPattern.bdRegex, "") |
|
|
|
this.name = name?.replace(AppPattern.bdRegex, "")?.trim() |
|
|
|
this.author = author?.replace(AppPattern.bdRegex, "") |
|
|
|
this.author = author?.replace(AppPattern.bdRegex, "")?.trim() |
|
|
|
if (AppConfig.useDefaultCover) { |
|
|
|
if (AppConfig.useDefaultCover) { |
|
|
|
defaultCover = true |
|
|
|
defaultCover = true |
|
|
|
ImageLoader.load(context, BookCover.defaultDrawable) |
|
|
|
ImageLoader.load(context, BookCover.defaultDrawable) |
|
|
|