From d873208c72c4334980413d48a257f47973417928 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Dec 2020 16:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=B1=A0=E5=9B=BE=E6=A0=87=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E6=9B=BF=E6=8D=A2=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 1 - .../legado/app/ui/book/read/page/PageView.kt | 21 ++++++++----------- .../legado/app/ui/book/read/page/ReadView.kt | 6 ------ .../io/legado/app/ui/widget/BatteryView.kt | 13 +++++++++--- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 39a001395..ad9d0e2f4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -852,7 +852,6 @@ class ReadBookActivity : ReadBookBaseActivity(), observeEvent(EventBus.UP_CONFIG) { upSystemUiVisibility() readView.upBg() - readView.upTipStyle() readView.upStyle() if (it) { ReadBook.loadContent(resetPageOffset = false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 402666168..dc2919500 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -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 } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index 01578df2d..716a0bd88 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 9e1d9cded..49cdeb330 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -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) {