|
|
@ -33,6 +33,7 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
val headerHeight: Int |
|
|
|
val headerHeight: Int |
|
|
|
get() { |
|
|
|
get() { |
|
|
@ -123,97 +124,60 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
else -> false |
|
|
|
else -> false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
tvTitle = when (ReadTipConfig.chapterTitle) { |
|
|
|
tvTitle = getTipView(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?.apply { |
|
|
|
tvTitle?.apply { |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvTime = when (ReadTipConfig.time) { |
|
|
|
tvTime = getTipView(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?.apply { |
|
|
|
tvTime?.apply { |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvBattery = when (ReadTipConfig.battery) { |
|
|
|
tvBattery = getTipView(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?.apply { |
|
|
|
tvBattery?.apply { |
|
|
|
isBattery = true |
|
|
|
isBattery = true |
|
|
|
textSize = 10f |
|
|
|
textSize = 10f |
|
|
|
} |
|
|
|
} |
|
|
|
tvPage = when (ReadTipConfig.page) { |
|
|
|
tvPage = getTipView(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?.apply { |
|
|
|
tvPage?.apply { |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvTotalProgress = when (ReadTipConfig.totalProgress) { |
|
|
|
tvTotalProgress = getTipView(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?.apply { |
|
|
|
tvTotalProgress?.apply { |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvPageAndTotal = when (ReadTipConfig.pageAndTotal) { |
|
|
|
tvPageAndTotal = getTipView(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?.apply { |
|
|
|
tvPageAndTotal?.apply { |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvBookName = when (ReadTipConfig.bookName) { |
|
|
|
tvBookName = getTipView(ReadTipConfig.bookName) |
|
|
|
ReadTipConfig.tipHeaderLeft -> bv_header_left |
|
|
|
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.tipHeaderMiddle -> tv_header_middle |
|
|
|
ReadTipConfig.tipHeaderRight -> tv_header_right |
|
|
|
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.tipFooterMiddle -> tv_footer_middle |
|
|
|
ReadTipConfig.tipFooterRight -> tv_footer_right |
|
|
|
ReadTipConfig.tipFooterRight -> tv_footer_right |
|
|
|
else -> null |
|
|
|
else -> null |
|
|
|
} |
|
|
|
} |
|
|
|
tvBookName?.apply { |
|
|
|
|
|
|
|
isBattery = false |
|
|
|
|
|
|
|
textSize = 12f |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setBg(bg: Drawable?) { |
|
|
|
fun setBg(bg: Drawable?) { |
|
|
@ -222,11 +186,21 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
|
|
|
|
|
|
|
|
fun upTime() { |
|
|
|
fun upTime() { |
|
|
|
tvTime?.text = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
tvTime?.text = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
|
|
|
|
upTimeBattery() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upBattery(battery: Int) { |
|
|
|
fun upBattery(battery: Int) { |
|
|
|
this.battery = battery |
|
|
|
this.battery = battery |
|
|
|
tvBattery?.setBattery(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) { |
|
|
|
fun setContent(pageData: PageData, resetPageOffset: Boolean = true) { |
|
|
|