From 4fc68405edc545c5eb2a68f632c7c4c5cefb7d37 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 27 Feb 2022 11:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadTipConfig.kt | 10 +- .../ui/book/read/config/TipConfigDialog.kt | 93 ++++++++++--------- .../legado/app/ui/book/read/page/PageView.kt | 17 ++++ app/src/main/res/values-es-rES/arrays.xml | 4 +- app/src/main/res/values-pt-rBR/arrays.xml | 4 +- app/src/main/res/values-zh-rHK/arrays.xml | 4 +- app/src/main/res/values-zh-rTW/arrays.xml | 4 +- app/src/main/res/values-zh/arrays.xml | 4 +- app/src/main/res/values/arrays.xml | 6 +- 9 files changed, 93 insertions(+), 53 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 30eae9ec0..01547c84d 100644 --- a/app/src/main/java/io/legado/app/help/ReadTipConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadTipConfig.kt @@ -5,16 +5,24 @@ import io.legado.app.R import splitties.init.appCtx object ReadTipConfig { - val tips get() = appCtx.resources.getStringArray(R.array.read_tip).toList() + const val none = 0 const val chapterTitle = 1 const val time = 2 const val battery = 3 + const val batteryPercentage = 10 const val page = 4 const val totalProgress = 5 const val pageAndTotal = 6 const val bookName = 7 const val timeBattery = 8 + const val timeBatteryPercentage = 9 + + val tipValues = arrayOf( + none, bookName, chapterTitle, time, battery, batteryPercentage, page, + totalProgress, pageAndTotal, timeBattery, timeBatteryPercentage + ) + val tipNames get() = appCtx.resources.getStringArray(R.array.read_tip).toList() var tipHeaderLeft: Int get() = ReadBookConfig.config.tipHeaderLeft diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index 0ef17032b..788276957 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -36,30 +36,33 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) { } } - private fun initView() = binding.run { - rgTitleMode.checkByIndex(ReadBookConfig.titleMode) - dsbTitleSize.progress = ReadBookConfig.titleSize - dsbTitleTop.progress = ReadBookConfig.titleTopSpacing - dsbTitleBottom.progress = ReadBookConfig.titleBottomSpacing + private fun initView() { + binding.rgTitleMode.checkByIndex(ReadBookConfig.titleMode) + binding.dsbTitleSize.progress = ReadBookConfig.titleSize + binding.dsbTitleTop.progress = ReadBookConfig.titleTopSpacing + binding.dsbTitleBottom.progress = ReadBookConfig.titleBottomSpacing - tvHeaderShow.text = ReadTipConfig.getHeaderModes(requireContext())[ReadTipConfig.headerMode] - tvFooterShow.text = ReadTipConfig.getFooterModes(requireContext())[ReadTipConfig.footerMode] + binding.tvHeaderShow.text = + ReadTipConfig.getHeaderModes(requireContext())[ReadTipConfig.headerMode] + binding.tvFooterShow.text = + ReadTipConfig.getFooterModes(requireContext())[ReadTipConfig.footerMode] - ReadTipConfig.tips.let { tips -> - tvHeaderLeft.text = - tips.getOrElse(ReadTipConfig.tipHeaderLeft) { tips[ReadTipConfig.none] } - tvHeaderMiddle.text = - tips.getOrElse(ReadTipConfig.tipHeaderMiddle) { tips[ReadTipConfig.none] } - tvHeaderRight.text = - tips.getOrElse(ReadTipConfig.tipHeaderRight) { tips[ReadTipConfig.none] } - tvFooterLeft.text = - tips.getOrElse(ReadTipConfig.tipFooterLeft) { tips[ReadTipConfig.none] } - tvFooterMiddle.text = - tips.getOrElse(ReadTipConfig.tipFooterMiddle) { tips[ReadTipConfig.none] } - tvFooterRight.text = - tips.getOrElse(ReadTipConfig.tipFooterRight) { tips[ReadTipConfig.none] } + ReadTipConfig.run { + tipNames.let { tipNames -> + binding.tvHeaderLeft.text = + tipNames.getOrElse(tipValues.indexOf(tipHeaderLeft)) { tipNames[none] } + binding.tvHeaderMiddle.text = + tipNames.getOrElse(tipValues.indexOf(tipHeaderMiddle)) { tipNames[none] } + binding.tvHeaderRight.text = + tipNames.getOrElse(tipValues.indexOf(tipHeaderRight)) { tipNames[none] } + binding.tvFooterLeft.text = + tipNames.getOrElse(tipValues.indexOf(tipFooterLeft)) { tipNames[none] } + binding.tvFooterMiddle.text = + tipNames.getOrElse(tipValues.indexOf(tipFooterMiddle)) { tipNames[none] } + binding.tvFooterRight.text = + tipNames.getOrElse(tipValues.indexOf(tipFooterRight)) { tipNames[none] } + } } - upTvTipColor() } @@ -106,50 +109,50 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) { } } llHeaderLeft.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipHeaderLeft = i - tvHeaderLeft.text = ReadTipConfig.tips[i] + ReadTipConfig.tipHeaderLeft = ReadTipConfig.tipValues[i] + tvHeaderLeft.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } llHeaderMiddle.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipHeaderMiddle = i - tvHeaderMiddle.text = ReadTipConfig.tips[i] + ReadTipConfig.tipHeaderMiddle = ReadTipConfig.tipValues[i] + tvHeaderMiddle.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } llHeaderRight.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipHeaderRight = i - tvHeaderRight.text = ReadTipConfig.tips[i] + ReadTipConfig.tipHeaderRight = ReadTipConfig.tipValues[i] + tvHeaderRight.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } llFooterLeft.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipFooterLeft = i - tvFooterLeft.text = ReadTipConfig.tips[i] + ReadTipConfig.tipFooterLeft = ReadTipConfig.tipValues[i] + tvFooterLeft.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } llFooterMiddle.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipFooterMiddle = i - tvFooterMiddle.text = ReadTipConfig.tips[i] + ReadTipConfig.tipFooterMiddle = ReadTipConfig.tipValues[i] + tvFooterMiddle.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } llFooterRight.setOnClickListener { - context?.selector(items = ReadTipConfig.tips) { _, i -> + context?.selector(items = ReadTipConfig.tipNames) { _, i -> clearRepeat(i) - ReadTipConfig.tipFooterRight = i - tvFooterRight.text = ReadTipConfig.tips[i] + ReadTipConfig.tipFooterRight = ReadTipConfig.tipValues[i] + tvFooterRight.text = ReadTipConfig.tipNames[i] postEvent(EventBus.UP_CONFIG, true) } } @@ -175,27 +178,27 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) { if (repeat != none) { if (tipHeaderLeft == repeat) { tipHeaderLeft = none - binding.tvHeaderLeft.text = tips[none] + binding.tvHeaderLeft.text = tipNames[none] } if (tipHeaderMiddle == repeat) { tipHeaderMiddle = none - binding.tvHeaderMiddle.text = tips[none] + binding.tvHeaderMiddle.text = tipNames[none] } if (tipHeaderRight == repeat) { tipHeaderRight = none - binding.tvHeaderRight.text = tips[none] + binding.tvHeaderRight.text = tipNames[none] } if (tipFooterLeft == repeat) { tipFooterLeft = none - binding.tvFooterLeft.text = tips[none] + binding.tvFooterLeft.text = tipNames[none] } if (tipFooterMiddle == repeat) { tipFooterMiddle = none - binding.tvFooterMiddle.text = tips[none] + binding.tvFooterMiddle.text = tipNames[none] } if (tipFooterRight == repeat) { tipFooterRight = none - binding.tvFooterRight.text = tips[none] + binding.tvFooterRight.text = tipNames[none] } } } 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 ce67f6c8d..dcd82dbbf 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 @@ -33,11 +33,13 @@ class PageView(context: Context) : FrameLayout(context) { private var tvTitle: BatteryView? = null private var tvTime: BatteryView? = null private var tvBattery: BatteryView? = null + private var tvBatteryP: BatteryView? = null private var tvPage: BatteryView? = null private var tvTotalProgress: BatteryView? = null private var tvPageAndTotal: BatteryView? = null private var tvBookName: BatteryView? = null private var tvTimeBattery: BatteryView? = null + private var tvTimeBatteryP: BatteryView? = null val headerHeight: Int get() { @@ -169,6 +171,18 @@ class PageView(context: Context) : FrameLayout(context) { typeface = ChapterProvider.typeface textSize = 11f } + tvBatteryP = getTipView(ReadTipConfig.batteryPercentage)?.apply { + tag = ReadTipConfig.batteryPercentage + isBattery = false + typeface = ChapterProvider.typeface + textSize = 12f + } + tvTimeBatteryP = getTipView(ReadTipConfig.timeBatteryPercentage)?.apply { + tag = ReadTipConfig.timeBatteryPercentage + isBattery = false + typeface = ChapterProvider.typeface + textSize = 12f + } } private fun getTipView(tip: Int): BatteryView? = binding.run { @@ -198,9 +212,11 @@ class PageView(context: Context) : FrameLayout(context) { upTimeBattery() } + @SuppressLint("SetTextI18n") fun upBattery(battery: Int) { this.battery = battery tvBattery?.setBattery(battery) + tvBatteryP?.text = "$battery%" upTimeBattery() } @@ -208,6 +224,7 @@ class PageView(context: Context) : FrameLayout(context) { private fun upTimeBattery() { val time = timeFormat.format(Date(System.currentTimeMillis())) tvTimeBattery?.setBattery(battery, time) + tvTimeBatteryP?.text = "$time $battery%" } fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { diff --git a/app/src/main/res/values-es-rES/arrays.xml b/app/src/main/res/values-es-rES/arrays.xml index 3975e26f4..345f6964a 100644 --- a/app/src/main/res/values-es-rES/arrays.xml +++ b/app/src/main/res/values-es-rES/arrays.xml @@ -84,14 +84,16 @@ En blanco + Nombre del libro Título Tiempo Batería + Batería% Páginas Avance Páginas y avance - Nombre del libro Tiempo y Batería + Tiempo y Batería% diff --git a/app/src/main/res/values-pt-rBR/arrays.xml b/app/src/main/res/values-pt-rBR/arrays.xml index f4def0a7a..aaa9e60d6 100644 --- a/app/src/main/res/values-pt-rBR/arrays.xml +++ b/app/src/main/res/values-pt-rBR/arrays.xml @@ -84,14 +84,16 @@ Em branco + Nome do livro Título Tempo Bateria + Bateria% Páginas Progresso Páginas e progresso - Nome do livro Tempo e Bateria + Tempo e Bateria% diff --git a/app/src/main/res/values-zh-rHK/arrays.xml b/app/src/main/res/values-zh-rHK/arrays.xml index 5853e6b1c..ca4ebc0fc 100644 --- a/app/src/main/res/values-zh-rHK/arrays.xml +++ b/app/src/main/res/values-zh-rHK/arrays.xml @@ -48,14 +48,16 @@ + 書名 標題 時間 電量 + 電量% 頁數 進度 頁數同埋進度 - 書名 時間同埋電量 + 時間同埋電量% diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index 33738c795..019b34be3 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -63,14 +63,16 @@ + 書名 標題 時間 電量 + 電量% 頁數 進度 頁數及進度 - 書名 時間及電量 + 時間及電量% diff --git a/app/src/main/res/values-zh/arrays.xml b/app/src/main/res/values-zh/arrays.xml index 7d51edef5..970ae369c 100644 --- a/app/src/main/res/values-zh/arrays.xml +++ b/app/src/main/res/values-zh/arrays.xml @@ -63,14 +63,16 @@ + 书名 标题 时间 电量 + 电量% 页数 进度 页数及进度 - 书名 时间及电量 + 时间及电量% diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ad2565d39..8bc2d5232 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -84,14 +84,16 @@ Blank - Heading + Book name + Title Time Battery + Battery% Pages Progress Pages and progress - Book name Time and Battery + Time and Battery%