pull/1654/merge
kunfei 3 years ago
parent 2dee9178fd
commit 4fc68405ed
  1. 10
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  2. 93
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  3. 17
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  4. 4
      app/src/main/res/values-es-rES/arrays.xml
  5. 4
      app/src/main/res/values-pt-rBR/arrays.xml
  6. 4
      app/src/main/res/values-zh-rHK/arrays.xml
  7. 4
      app/src/main/res/values-zh-rTW/arrays.xml
  8. 4
      app/src/main/res/values-zh/arrays.xml
  9. 6
      app/src/main/res/values/arrays.xml

@ -5,16 +5,24 @@ import io.legado.app.R
import splitties.init.appCtx import splitties.init.appCtx
object ReadTipConfig { object ReadTipConfig {
val tips get() = appCtx.resources.getStringArray(R.array.read_tip).toList()
const val none = 0 const val none = 0
const val chapterTitle = 1 const val chapterTitle = 1
const val time = 2 const val time = 2
const val battery = 3 const val battery = 3
const val batteryPercentage = 10
const val page = 4 const val page = 4
const val totalProgress = 5 const val totalProgress = 5
const val pageAndTotal = 6 const val pageAndTotal = 6
const val bookName = 7 const val bookName = 7
const val timeBattery = 8 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 var tipHeaderLeft: Int
get() = ReadBookConfig.config.tipHeaderLeft get() = ReadBookConfig.config.tipHeaderLeft

@ -36,30 +36,33 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
} }
} }
private fun initView() = binding.run { private fun initView() {
rgTitleMode.checkByIndex(ReadBookConfig.titleMode) binding.rgTitleMode.checkByIndex(ReadBookConfig.titleMode)
dsbTitleSize.progress = ReadBookConfig.titleSize binding.dsbTitleSize.progress = ReadBookConfig.titleSize
dsbTitleTop.progress = ReadBookConfig.titleTopSpacing binding.dsbTitleTop.progress = ReadBookConfig.titleTopSpacing
dsbTitleBottom.progress = ReadBookConfig.titleBottomSpacing binding.dsbTitleBottom.progress = ReadBookConfig.titleBottomSpacing
tvHeaderShow.text = ReadTipConfig.getHeaderModes(requireContext())[ReadTipConfig.headerMode] binding.tvHeaderShow.text =
tvFooterShow.text = ReadTipConfig.getFooterModes(requireContext())[ReadTipConfig.footerMode] ReadTipConfig.getHeaderModes(requireContext())[ReadTipConfig.headerMode]
binding.tvFooterShow.text =
ReadTipConfig.getFooterModes(requireContext())[ReadTipConfig.footerMode]
ReadTipConfig.tips.let { tips -> ReadTipConfig.run {
tvHeaderLeft.text = tipNames.let { tipNames ->
tips.getOrElse(ReadTipConfig.tipHeaderLeft) { tips[ReadTipConfig.none] } binding.tvHeaderLeft.text =
tvHeaderMiddle.text = tipNames.getOrElse(tipValues.indexOf(tipHeaderLeft)) { tipNames[none] }
tips.getOrElse(ReadTipConfig.tipHeaderMiddle) { tips[ReadTipConfig.none] } binding.tvHeaderMiddle.text =
tvHeaderRight.text = tipNames.getOrElse(tipValues.indexOf(tipHeaderMiddle)) { tipNames[none] }
tips.getOrElse(ReadTipConfig.tipHeaderRight) { tips[ReadTipConfig.none] } binding.tvHeaderRight.text =
tvFooterLeft.text = tipNames.getOrElse(tipValues.indexOf(tipHeaderRight)) { tipNames[none] }
tips.getOrElse(ReadTipConfig.tipFooterLeft) { tips[ReadTipConfig.none] } binding.tvFooterLeft.text =
tvFooterMiddle.text = tipNames.getOrElse(tipValues.indexOf(tipFooterLeft)) { tipNames[none] }
tips.getOrElse(ReadTipConfig.tipFooterMiddle) { tips[ReadTipConfig.none] } binding.tvFooterMiddle.text =
tvFooterRight.text = tipNames.getOrElse(tipValues.indexOf(tipFooterMiddle)) { tipNames[none] }
tips.getOrElse(ReadTipConfig.tipFooterRight) { tips[ReadTipConfig.none] } binding.tvFooterRight.text =
tipNames.getOrElse(tipValues.indexOf(tipFooterRight)) { tipNames[none] }
}
} }
upTvTipColor() upTvTipColor()
} }
@ -106,50 +109,50 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
} }
} }
llHeaderLeft.setOnClickListener { llHeaderLeft.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipHeaderLeft = i ReadTipConfig.tipHeaderLeft = ReadTipConfig.tipValues[i]
tvHeaderLeft.text = ReadTipConfig.tips[i] tvHeaderLeft.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
llHeaderMiddle.setOnClickListener { llHeaderMiddle.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipHeaderMiddle = i ReadTipConfig.tipHeaderMiddle = ReadTipConfig.tipValues[i]
tvHeaderMiddle.text = ReadTipConfig.tips[i] tvHeaderMiddle.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
llHeaderRight.setOnClickListener { llHeaderRight.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipHeaderRight = i ReadTipConfig.tipHeaderRight = ReadTipConfig.tipValues[i]
tvHeaderRight.text = ReadTipConfig.tips[i] tvHeaderRight.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
llFooterLeft.setOnClickListener { llFooterLeft.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipFooterLeft = i ReadTipConfig.tipFooterLeft = ReadTipConfig.tipValues[i]
tvFooterLeft.text = ReadTipConfig.tips[i] tvFooterLeft.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
llFooterMiddle.setOnClickListener { llFooterMiddle.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipFooterMiddle = i ReadTipConfig.tipFooterMiddle = ReadTipConfig.tipValues[i]
tvFooterMiddle.text = ReadTipConfig.tips[i] tvFooterMiddle.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
llFooterRight.setOnClickListener { llFooterRight.setOnClickListener {
context?.selector(items = ReadTipConfig.tips) { _, i -> context?.selector(items = ReadTipConfig.tipNames) { _, i ->
clearRepeat(i) clearRepeat(i)
ReadTipConfig.tipFooterRight = i ReadTipConfig.tipFooterRight = ReadTipConfig.tipValues[i]
tvFooterRight.text = ReadTipConfig.tips[i] tvFooterRight.text = ReadTipConfig.tipNames[i]
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
@ -175,27 +178,27 @@ class TipConfigDialog : BaseDialogFragment(R.layout.dialog_tip_config) {
if (repeat != none) { if (repeat != none) {
if (tipHeaderLeft == repeat) { if (tipHeaderLeft == repeat) {
tipHeaderLeft = none tipHeaderLeft = none
binding.tvHeaderLeft.text = tips[none] binding.tvHeaderLeft.text = tipNames[none]
} }
if (tipHeaderMiddle == repeat) { if (tipHeaderMiddle == repeat) {
tipHeaderMiddle = none tipHeaderMiddle = none
binding.tvHeaderMiddle.text = tips[none] binding.tvHeaderMiddle.text = tipNames[none]
} }
if (tipHeaderRight == repeat) { if (tipHeaderRight == repeat) {
tipHeaderRight = none tipHeaderRight = none
binding.tvHeaderRight.text = tips[none] binding.tvHeaderRight.text = tipNames[none]
} }
if (tipFooterLeft == repeat) { if (tipFooterLeft == repeat) {
tipFooterLeft = none tipFooterLeft = none
binding.tvFooterLeft.text = tips[none] binding.tvFooterLeft.text = tipNames[none]
} }
if (tipFooterMiddle == repeat) { if (tipFooterMiddle == repeat) {
tipFooterMiddle = none tipFooterMiddle = none
binding.tvFooterMiddle.text = tips[none] binding.tvFooterMiddle.text = tipNames[none]
} }
if (tipFooterRight == repeat) { if (tipFooterRight == repeat) {
tipFooterRight = none tipFooterRight = none
binding.tvFooterRight.text = tips[none] binding.tvFooterRight.text = tipNames[none]
} }
} }
} }

@ -33,11 +33,13 @@ class PageView(context: Context) : FrameLayout(context) {
private var tvTitle: BatteryView? = null private var tvTitle: BatteryView? = null
private var tvTime: BatteryView? = null private var tvTime: BatteryView? = null
private var tvBattery: BatteryView? = null private var tvBattery: BatteryView? = null
private var tvBatteryP: BatteryView? = null
private var tvPage: BatteryView? = null private var tvPage: BatteryView? = null
private var tvTotalProgress: BatteryView? = null private var tvTotalProgress: BatteryView? = null
private var tvPageAndTotal: BatteryView? = null private var tvPageAndTotal: BatteryView? = null
private var tvBookName: BatteryView? = null private var tvBookName: BatteryView? = null
private var tvTimeBattery: BatteryView? = null private var tvTimeBattery: BatteryView? = null
private var tvTimeBatteryP: BatteryView? = null
val headerHeight: Int val headerHeight: Int
get() { get() {
@ -169,6 +171,18 @@ class PageView(context: Context) : FrameLayout(context) {
typeface = ChapterProvider.typeface typeface = ChapterProvider.typeface
textSize = 11f 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 { private fun getTipView(tip: Int): BatteryView? = binding.run {
@ -198,9 +212,11 @@ class PageView(context: Context) : FrameLayout(context) {
upTimeBattery() upTimeBattery()
} }
@SuppressLint("SetTextI18n")
fun upBattery(battery: Int) { fun upBattery(battery: Int) {
this.battery = battery this.battery = battery
tvBattery?.setBattery(battery) tvBattery?.setBattery(battery)
tvBatteryP?.text = "$battery%"
upTimeBattery() upTimeBattery()
} }
@ -208,6 +224,7 @@ class PageView(context: Context) : FrameLayout(context) {
private fun upTimeBattery() { private fun upTimeBattery() {
val time = timeFormat.format(Date(System.currentTimeMillis())) val time = timeFormat.format(Date(System.currentTimeMillis()))
tvTimeBattery?.setBattery(battery, time) tvTimeBattery?.setBattery(battery, time)
tvTimeBatteryP?.text = "$time $battery%"
} }
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) {

@ -84,14 +84,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item>En blanco</item> <item>En blanco</item>
<item>Nombre del libro</item>
<item>Título</item> <item>Título</item>
<item>Tiempo</item> <item>Tiempo</item>
<item>Batería</item> <item>Batería</item>
<item>Batería%</item>
<item>Páginas</item> <item>Páginas</item>
<item>Avance</item> <item>Avance</item>
<item>Páginas y avance</item> <item>Páginas y avance</item>
<item>Nombre del libro</item>
<item>Tiempo y Batería</item> <item>Tiempo y Batería</item>
<item>Tiempo y Batería%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

@ -84,14 +84,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item>Em branco</item> <item>Em branco</item>
<item>Nome do livro</item>
<item>Título</item> <item>Título</item>
<item>Tempo</item> <item>Tempo</item>
<item>Bateria</item> <item>Bateria</item>
<item>Bateria%</item>
<item>Páginas</item> <item>Páginas</item>
<item>Progresso</item> <item>Progresso</item>
<item>Páginas e progresso</item> <item>Páginas e progresso</item>
<item>Nome do livro</item>
<item>Tempo e Bateria</item> <item>Tempo e Bateria</item>
<item>Tempo e Bateria%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

@ -48,14 +48,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item></item> <item></item>
<item>書名</item>
<item>標題</item> <item>標題</item>
<item>時間</item> <item>時間</item>
<item>電量</item> <item>電量</item>
<item>電量%</item>
<item>頁數</item> <item>頁數</item>
<item>進度</item> <item>進度</item>
<item>頁數同埋進度</item> <item>頁數同埋進度</item>
<item>書名</item>
<item>時間同埋電量</item> <item>時間同埋電量</item>
<item>時間同埋電量%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

@ -63,14 +63,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item></item> <item></item>
<item>書名</item>
<item>標題</item> <item>標題</item>
<item>時間</item> <item>時間</item>
<item>電量</item> <item>電量</item>
<item>電量%</item>
<item>頁數</item> <item>頁數</item>
<item>進度</item> <item>進度</item>
<item>頁數及進度</item> <item>頁數及進度</item>
<item>書名</item>
<item>時間及電量</item> <item>時間及電量</item>
<item>時間及電量%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

@ -63,14 +63,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item></item> <item></item>
<item>书名</item>
<item>标题</item> <item>标题</item>
<item>时间</item> <item>时间</item>
<item>电量</item> <item>电量</item>
<item>电量%</item>
<item>页数</item> <item>页数</item>
<item>进度</item> <item>进度</item>
<item>页数及进度</item> <item>页数及进度</item>
<item>书名</item>
<item>时间及电量</item> <item>时间及电量</item>
<item>时间及电量%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

@ -84,14 +84,16 @@
<string-array name="read_tip"> <string-array name="read_tip">
<item>Blank</item> <item>Blank</item>
<item>Heading</item> <item>Book name</item>
<item>Title</item>
<item>Time</item> <item>Time</item>
<item>Battery</item> <item>Battery</item>
<item>Battery%</item>
<item>Pages</item> <item>Pages</item>
<item>Progress</item> <item>Progress</item>
<item>Pages and progress</item> <item>Pages and progress</item>
<item>Book name</item>
<item>Time and Battery</item> <item>Time and Battery</item>
<item>Time and Battery%</item>
</string-array> </string-array>
<string-array name="text_font_weight"> <string-array name="text_font_weight">

Loading…
Cancel
Save