From 0fa79f9b775b8a5db9afa95387022c70dfc6a105 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 29 Nov 2020 16:53:22 +0800 Subject: [PATCH] =?UTF-8?q?tip=20=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8F=8A=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadTipConfig.kt | 1 + .../app/ui/book/read/page/ContentView.kt | 96 +++++++------------ app/src/main/res/values-zh-rHK/arrays.xml | 1 + app/src/main/res/values-zh-rTW/arrays.xml | 1 + app/src/main/res/values-zh/arrays.xml | 1 + app/src/main/res/values/arrays.xml | 1 + 6 files changed, 40 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt index 796772273..5a52773ed 100644 --- a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt @@ -21,6 +21,7 @@ object ReadTipConfig { const val totalProgress = 5 const val pageAndTotal = 6 const val bookName = 7 + const val timeBattery = 8 val tipHeaderLeftStr: String get() = tips.getOrElse(tipHeaderLeft) { tips[none] } val tipHeaderMiddleStr: String get() = tips.getOrElse(tipHeaderMiddle) { tips[none] } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 619fa94bc..bc4f8d0e3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -33,6 +33,7 @@ class ContentView(context: Context) : FrameLayout(context) { private var tvTotalProgress: BatteryView? = null private var tvPageAndTotal: BatteryView? = null private var tvBookName: BatteryView? = null + private var tvTimeBattery: BatteryView? = null val headerHeight: Int get() { @@ -123,97 +124,60 @@ class ContentView(context: Context) : FrameLayout(context) { else -> false } } - tvTitle = when (ReadTipConfig.chapterTitle) { - ReadTipConfig.tipHeaderLeft -> tv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> tv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvTitle = getTipView(ReadTipConfig.chapterTitle) tvTitle?.apply { isBattery = false textSize = 12f } - tvTime = when (ReadTipConfig.time) { - ReadTipConfig.tipHeaderLeft -> bv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvTime = getTipView(ReadTipConfig.time) tvTime?.apply { isBattery = false textSize = 12f } - tvBattery = when (ReadTipConfig.battery) { - ReadTipConfig.tipHeaderLeft -> bv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvBattery = getTipView(ReadTipConfig.battery) tvBattery?.apply { isBattery = true textSize = 10f } - tvPage = when (ReadTipConfig.page) { - ReadTipConfig.tipHeaderLeft -> bv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvPage = getTipView(ReadTipConfig.page) tvPage?.apply { isBattery = false textSize = 12f } - tvTotalProgress = when (ReadTipConfig.totalProgress) { - ReadTipConfig.tipHeaderLeft -> bv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvTotalProgress = getTipView(ReadTipConfig.totalProgress) tvTotalProgress?.apply { isBattery = false textSize = 12f } - tvPageAndTotal = when (ReadTipConfig.pageAndTotal) { - ReadTipConfig.tipHeaderLeft -> bv_header_left - ReadTipConfig.tipHeaderMiddle -> tv_header_middle - ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left - ReadTipConfig.tipFooterMiddle -> tv_footer_middle - ReadTipConfig.tipFooterRight -> tv_footer_right - else -> null - } + tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal) tvPageAndTotal?.apply { isBattery = false textSize = 12f } - tvBookName = when (ReadTipConfig.bookName) { - ReadTipConfig.tipHeaderLeft -> bv_header_left + tvBookName = getTipView(ReadTipConfig.bookName) + tvBookName?.apply { + isBattery = false + textSize = 12f + } + tvTimeBattery = getTipView(ReadTipConfig.timeBattery) + tvTimeBattery?.apply { + isBattery = false + textSize = 12f + } + } + + private fun getTipView(tip: Int): BatteryView? { + return when (tip) { + ReadTipConfig.tipHeaderLeft -> + if (tip == ReadTipConfig.chapterTitle) tv_header_left else bv_header_left ReadTipConfig.tipHeaderMiddle -> tv_header_middle ReadTipConfig.tipHeaderRight -> tv_header_right - ReadTipConfig.tipFooterLeft -> bv_footer_left + ReadTipConfig.tipFooterLeft -> + if (tip == ReadTipConfig.chapterTitle) tv_footer_left else bv_footer_left ReadTipConfig.tipFooterMiddle -> tv_footer_middle ReadTipConfig.tipFooterRight -> tv_footer_right else -> null } - tvBookName?.apply { - isBattery = false - textSize = 12f - } } fun setBg(bg: Drawable?) { @@ -222,11 +186,21 @@ class ContentView(context: Context) : FrameLayout(context) { fun upTime() { tvTime?.text = timeFormat.format(Date(System.currentTimeMillis())) + upTimeBattery() } fun upBattery(battery: Int) { this.battery = battery tvBattery?.setBattery(battery) + upTimeBattery() + } + + @SuppressLint("SetTextI18n") + private fun upTimeBattery() { + tvTimeBattery?.let { + val time = timeFormat.format(Date(System.currentTimeMillis())) + it.text = "$time $battery%" + } } fun setContent(pageData: PageData, resetPageOffset: Boolean = true) { diff --git a/app/src/main/res/values-zh-rHK/arrays.xml b/app/src/main/res/values-zh-rHK/arrays.xml index 6e2446f65..475bc41ca 100644 --- a/app/src/main/res/values-zh-rHK/arrays.xml +++ b/app/src/main/res/values-zh-rHK/arrays.xml @@ -44,6 +44,7 @@ 进度 页数及进度 書名 + 时间及电量 diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index 65f021711..af03a5205 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -85,6 +85,7 @@ 進度 頁數及進度 書名 + 時間及電量 diff --git a/app/src/main/res/values-zh/arrays.xml b/app/src/main/res/values-zh/arrays.xml index 219473c09..0046aba58 100644 --- a/app/src/main/res/values-zh/arrays.xml +++ b/app/src/main/res/values-zh/arrays.xml @@ -85,6 +85,7 @@ 进度 页数及进度 书名 + 时间及电量 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index cff790925..6ca480b12 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -85,6 +85,7 @@ Progress Pages and progress Book name + Time and Battery