电池图标禁止替换字体

pull/540/head
gedoor 4 years ago
parent 18e264cc9c
commit d873208c72
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 21
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  4. 13
      app/src/main/java/io/legado/app/ui/widget/BatteryView.kt

@ -852,7 +852,6 @@ class ReadBookActivity : ReadBookBaseActivity(),
observeEvent<Boolean>(EventBus.UP_CONFIG) {
upSystemUiVisibility()
readView.upBg()
readView.upTipStyle()
readView.upStyle()
if (it) {
ReadBook.loadContent(resetPageOffset = false)

@ -49,7 +49,6 @@ class PageView(context: Context) : FrameLayout(context) {
if (!isInEditMode) {
//设置背景防止切换背景时文字重叠
setBackgroundColor(context.getCompatColor(R.color.background))
upTipStyle()
upStyle()
}
binding.contentTextView.upView = {
@ -58,16 +57,7 @@ class PageView(context: Context) : FrameLayout(context) {
}
fun upStyle() = with(binding) {
ChapterProvider.let {
bvHeaderLeft.typeface = it.typeface
tvHeaderLeft.typeface = it.typeface
tvHeaderMiddle.typeface = it.typeface
tvHeaderRight.typeface = it.typeface
bvFooterLeft.typeface = it.typeface
tvFooterLeft.typeface = it.typeface
tvFooterMiddle.typeface = it.typeface
tvFooterRight.typeface = it.typeface
}
upTipStyle()
ReadBookConfig.let {
val tipColor = with(ReadTipConfig) {
if (tipColor == 0) it.textColor else tipColor
@ -113,7 +103,7 @@ class PageView(context: Context) : FrameLayout(context) {
ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true
}
fun upTipStyle() = with(binding) {
private fun upTipStyle() = with(binding) {
ReadTipConfig.apply {
tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle
bvHeaderLeft.isInvisible =
@ -138,11 +128,13 @@ class PageView(context: Context) : FrameLayout(context) {
tvTitle = getTipView(ReadTipConfig.chapterTitle)
tvTitle?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvTime = getTipView(ReadTipConfig.time)
tvTime?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvBattery = getTipView(ReadTipConfig.battery)
@ -153,26 +145,31 @@ class PageView(context: Context) : FrameLayout(context) {
tvPage = getTipView(ReadTipConfig.page)
tvPage?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvTotalProgress = getTipView(ReadTipConfig.totalProgress)
tvTotalProgress?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal)
tvPageAndTotal?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvBookName = getTipView(ReadTipConfig.bookName)
tvBookName?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
tvTimeBattery = getTipView(ReadTipConfig.timeBattery)
tvTimeBattery?.apply {
isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f
}
}

@ -489,12 +489,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
callBack.screenOffTimerStart()
}
fun upTipStyle() {
curPage.upTipStyle()
prevPage.upTipStyle()
nextPage.upTipStyle()
}
fun upStyle() {
ChapterProvider.upStyle()
curPage.upStyle()

@ -16,19 +16,26 @@ class BatteryView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : AppCompatTextView(context, attrs) {
private val batteryTypeface by lazy {
Typeface.createFromAsset(context.assets, "font${File.separator}number.ttf")
}
private val batteryPaint = Paint()
private val outFrame = Rect()
private val polar = Rect()
var isBattery = false
set(value) {
field = value
if (value) {
typeface = batteryTypeface
postInvalidate()
}
}
init {
setPadding(4.dp, 0, 6.dp, 0)
batteryPaint.strokeWidth = 1.dp.toFloat()
batteryPaint.isAntiAlias = true
batteryPaint.color = paint.color
if (!isInEditMode) {
typeface = Typeface.createFromAsset(context.assets, "font${File.separator}number.ttf")
}
}
fun setColor(@ColorInt color: Int) {

Loading…
Cancel
Save