feat: tipConfig

pull/198/head
kunfei 5 years ago
parent f332e8b0a1
commit 16ebda0a99
  1. 4
      app/src/main/java/io/legado/app/help/ReadTipConfig.kt
  2. 1
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  3. 115
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  4. 3
      app/src/main/res/values/arrays.xml

@ -14,6 +14,8 @@ object ReadTipConfig {
const val time = 2
const val battery = 3
const val page = 4
const val totalProgress = 5
const val pageAndTotal = 6
val tipHeaderLeftStr: String get() = tipArray.getOrElse(tipHeaderLeft) { tipArray[none] }
val tipHeaderMiddleStr: String get() = tipArray.getOrElse(tipHeaderMiddle) { tipArray[none] }
@ -53,7 +55,7 @@ object ReadTipConfig {
}
var tipFooterRight: Int
get() = App.INSTANCE.getPrefInt("tipFooterRight", page)
get() = App.INSTANCE.getPrefInt("tipFooterRight", pageAndTotal)
set(value) {
App.INSTANCE.putPrefInt("tipFooterRight", value)
}

@ -22,6 +22,7 @@ class AboutFragment : PreferenceFragmentCompat() {
private val qqGroups = linkedMapOf(
Pair("(QQ群VIP1)701903217", "-iolizL4cbJSutKRpeImHlXlpLDZnzeF"),
Pair("(QQ群VIP2)263949160", "xwfh7_csb2Gf3Aw2qexEcEtviLfLfd4L"),
Pair("(QQ群VIP3)680280282", "_N0i7yZObjKSeZQvzoe2ej7j02kLnOOK"),
Pair("(QQ群1)805192012", "6GlFKjLeIk5RhQnR3PNVDaKB6j10royo"),
Pair("(QQ群2)773736122", "5Bm5w6OgLupXnICbYvbgzpPUgf0UlsJF"),
Pair("(QQ群3)981838750", "g_Sgmp2nQPKqcZQ5qPcKLHziwX_mpps9"),

@ -14,6 +14,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.ui.widget.BatteryView
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.statusBarHeight
@ -25,6 +26,12 @@ import java.util.*
class ContentView(context: Context) : FrameLayout(context) {
private var battery = 100
private var tvTitle: BatteryView? = null
private var tvTime: BatteryView? = null
private var tvBattery: BatteryView? = null
private var tvPage: BatteryView? = null
private var tvTotalProgress: BatteryView? = null
private var tvPageAndTotal: BatteryView? = null
val headerHeight: Int
get() = if (ReadBookConfig.hideStatusBar) ll_header.height else context.statusBarHeight
@ -94,14 +101,20 @@ class ContentView(context: Context) : FrameLayout(context) {
ll_header.isGone = hideHeader
ll_footer.isGone = hideFooter
}
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
}
fun setBg(bg: Drawable?) {
page_panel.background = bg
tvTitle?.apply {
isBattery = false
textSize = 12f
}
fun upTime() {
val tvTime = when (ReadTipConfig.time) {
tvTime = when (ReadTipConfig.time) {
ReadTipConfig.tipHeaderLeft -> tv_header_left
ReadTipConfig.tipHeaderMiddle -> tv_header_middle
ReadTipConfig.tipHeaderRight -> tv_header_right
@ -110,13 +123,50 @@ class ContentView(context: Context) : FrameLayout(context) {
ReadTipConfig.tipFooterRight -> tv_footer_right
else -> null
}
tvTime?.isBattery = false
tvTime?.text = timeFormat.format(Date(System.currentTimeMillis()))
tvTime?.apply {
isBattery = false
textSize = 12f
}
fun upBattery(battery: Int) {
this.battery = battery
val tvBattery = when (ReadTipConfig.battery) {
tvBattery = when (ReadTipConfig.battery) {
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
}
tvBattery?.apply {
isBattery = true
textSize = 10f
}
tvPage = when (ReadTipConfig.page) {
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
}
tvPage?.apply {
isBattery = false
textSize = 12f
}
tvTotalProgress = when (ReadTipConfig.totalProgress) {
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
}
tvTotalProgress?.apply {
isBattery = false
textSize = 12f
}
tvPageAndTotal = when (ReadTipConfig.pageAndTotal) {
ReadTipConfig.tipHeaderLeft -> tv_header_left
ReadTipConfig.tipHeaderMiddle -> tv_header_middle
ReadTipConfig.tipHeaderRight -> tv_header_right
@ -125,7 +175,22 @@ class ContentView(context: Context) : FrameLayout(context) {
ReadTipConfig.tipFooterRight -> tv_footer_right
else -> null
}
tvBattery?.isBattery = true
tvPageAndTotal?.apply {
isBattery = false
textSize = 12f
}
}
fun setBg(bg: Drawable?) {
page_panel.background = bg
}
fun upTime() {
tvTime?.text = timeFormat.format(Date(System.currentTimeMillis()))
}
fun upBattery(battery: Int) {
this.battery = battery
tvBattery?.setBattery(battery)
}
@ -147,28 +212,10 @@ class ContentView(context: Context) : FrameLayout(context) {
2 -> HanLP.convertToTraditionalChinese(textPage.title)
else -> textPage.title
}
val 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?.isBattery = false
tvTitle?.text = title
val tvPage = when (ReadTipConfig.page) {
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
}
tvPage?.isBattery = false
tvPage?.text = "${index.plus(1)}/$pageSize $readProgress"
tvPage?.text = "${index.plus(1)}/$pageSize"
tvTotalProgress?.text = readProgress
tvPageAndTotal?.text = "${index.plus(1)}/$pageSize $readProgress"
}
fun onScroll(offset: Float) {

@ -102,7 +102,8 @@
<item>时间</item>
<item>电量</item>
<item>页数</item>
<item>总进度</item>
<item>进度</item>
<item>页数及进度</item>
</string-array>
</resources>
Loading…
Cancel
Save