pull/357/head
gedoor 4 years ago
parent 67a12e9867
commit 0c126b8dfc
  1. 45
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  2. 7
      app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt

@ -15,7 +15,6 @@ import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.widget.font.FontSelectDialog
import io.legado.app.utils.*
@ -239,18 +238,38 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
}
}
private fun upBg() = requireContext().apply {
bg0.borderColor = primaryColor
bg1.borderColor = primaryColor
bg2.borderColor = primaryColor
bg3.borderColor = primaryColor
bg4.borderColor = primaryColor
when (ReadBookConfig.styleSelect) {
1 -> bg1.borderColor = accentColor
2 -> bg2.borderColor = accentColor
3 -> bg3.borderColor = accentColor
4 -> bg4.borderColor = accentColor
else -> bg0.borderColor = accentColor
private fun upBg() = ReadBookConfig.apply {
bg0.borderColor = getConfig(0).textColor()
bg0.setTextBold(false)
bg1.borderColor = getConfig(1).textColor()
bg1.setTextBold(false)
bg2.borderColor = getConfig(2).textColor()
bg2.setTextBold(false)
bg3.borderColor = getConfig(3).textColor()
bg3.setTextBold(false)
bg4.borderColor = getConfig(4).textColor()
bg4.setTextBold(false)
when (styleSelect) {
1 -> {
bg1.borderColor = accentColor
bg1.setTextBold(true)
}
2 -> {
bg2.borderColor = accentColor
bg2.setTextBold(true)
}
3 -> {
bg3.borderColor = accentColor
bg3.setTextBold(true)
}
4 -> {
bg4.borderColor = accentColor
bg4.setTextBold(true)
}
else -> {
bg0.borderColor = accentColor
bg0.setTextBold(true)
}
}
}

@ -118,6 +118,7 @@ class CircleImageView(context: Context, attrs: AttributeSet) :
private var text: String? = null
private var textColor = context.getCompatColor(R.color.primaryText)
private var textBold = false
init {
super.setScaleType(SCALE_TYPE)
@ -210,6 +211,7 @@ class CircleImageView(context: Context, attrs: AttributeSet) :
private fun drawText(canvas: Canvas) {
text?.let {
textPaint.color = textColor
textPaint.isFakeBoldText = textBold
textPaint.textSize = 15.sp.toFloat()
val fm = textPaint.fontMetrics
canvas.drawText(
@ -226,6 +228,11 @@ class CircleImageView(context: Context, attrs: AttributeSet) :
invalidate()
}
fun setTextBold(bold: Boolean) {
this.textBold = bold
invalidate()
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
setup()

Loading…
Cancel
Save