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.accentColor
import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor 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.book.read.ReadBookActivity
import io.legado.app.ui.widget.font.FontSelectDialog import io.legado.app.ui.widget.font.FontSelectDialog
import io.legado.app.utils.* import io.legado.app.utils.*
@ -239,18 +238,38 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
} }
} }
private fun upBg() = requireContext().apply { private fun upBg() = ReadBookConfig.apply {
bg0.borderColor = primaryColor bg0.borderColor = getConfig(0).textColor()
bg1.borderColor = primaryColor bg0.setTextBold(false)
bg2.borderColor = primaryColor bg1.borderColor = getConfig(1).textColor()
bg3.borderColor = primaryColor bg1.setTextBold(false)
bg4.borderColor = primaryColor bg2.borderColor = getConfig(2).textColor()
when (ReadBookConfig.styleSelect) { bg2.setTextBold(false)
1 -> bg1.borderColor = accentColor bg3.borderColor = getConfig(3).textColor()
2 -> bg2.borderColor = accentColor bg3.setTextBold(false)
3 -> bg3.borderColor = accentColor bg4.borderColor = getConfig(4).textColor()
4 -> bg4.borderColor = accentColor bg4.setTextBold(false)
else -> bg0.borderColor = accentColor 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 text: String? = null
private var textColor = context.getCompatColor(R.color.primaryText) private var textColor = context.getCompatColor(R.color.primaryText)
private var textBold = false
init { init {
super.setScaleType(SCALE_TYPE) super.setScaleType(SCALE_TYPE)
@ -210,6 +211,7 @@ class CircleImageView(context: Context, attrs: AttributeSet) :
private fun drawText(canvas: Canvas) { private fun drawText(canvas: Canvas) {
text?.let { text?.let {
textPaint.color = textColor textPaint.color = textColor
textPaint.isFakeBoldText = textBold
textPaint.textSize = 15.sp.toFloat() textPaint.textSize = 15.sp.toFloat()
val fm = textPaint.fontMetrics val fm = textPaint.fontMetrics
canvas.drawText( canvas.drawText(
@ -226,6 +228,11 @@ class CircleImageView(context: Context, attrs: AttributeSet) :
invalidate() invalidate()
} }
fun setTextBold(bold: Boolean) {
this.textBold = bold
invalidate()
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh) super.onSizeChanged(w, h, oldw, oldh)
setup() setup()

Loading…
Cancel
Save