tip 添加时间及电量

pull/517/head
gedoor 4 years ago
parent 82ca16cb38
commit 0fa79f9b77
  1. 1
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  2. 96
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 1
      app/src/main/res/values-zh-rHK/arrays.xml
  4. 1
      app/src/main/res/values-zh-rTW/arrays.xml
  5. 1
      app/src/main/res/values-zh/arrays.xml
  6. 1
      app/src/main/res/values/arrays.xml

@ -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] }

@ -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) {

@ -44,6 +44,7 @@
<item>进度</item>
<item>页数及进度</item>
<item>書名</item>
<item>时间及电量</item>
</string-array>
<string-array name="text_font_weight">

@ -85,6 +85,7 @@
<item>進度</item>
<item>頁數及進度</item>
<item>書名</item>
<item>時間及電量</item>
</string-array>
<string-array name="text_font_weight">

@ -85,6 +85,7 @@
<item>进度</item>
<item>页数及进度</item>
<item>书名</item>
<item>时间及电量</item>
</string-array>
<string-array name="text_font_weight">

@ -85,6 +85,7 @@
<item>Progress</item>
<item>Pages and progress</item>
<item>Book name</item>
<item>Time and Battery</item>
</string-array>
<string-array name="text_font_weight">

Loading…
Cancel
Save