|
|
@ -63,11 +63,9 @@ class PageView(context: Context) : FrameLayout(context) { |
|
|
|
val tipColor = with(ReadTipConfig) { |
|
|
|
val tipColor = with(ReadTipConfig) { |
|
|
|
if (tipColor == 0) it.textColor else tipColor |
|
|
|
if (tipColor == 0) it.textColor else tipColor |
|
|
|
} |
|
|
|
} |
|
|
|
bvHeaderLeft.setColor(tipColor) |
|
|
|
|
|
|
|
tvHeaderLeft.setColor(tipColor) |
|
|
|
tvHeaderLeft.setColor(tipColor) |
|
|
|
tvHeaderMiddle.setColor(tipColor) |
|
|
|
tvHeaderMiddle.setColor(tipColor) |
|
|
|
tvHeaderRight.setColor(tipColor) |
|
|
|
tvHeaderRight.setColor(tipColor) |
|
|
|
bvFooterLeft.setColor(tipColor) |
|
|
|
|
|
|
|
tvFooterLeft.setColor(tipColor) |
|
|
|
tvFooterLeft.setColor(tipColor) |
|
|
|
tvFooterMiddle.setColor(tipColor) |
|
|
|
tvFooterMiddle.setColor(tipColor) |
|
|
|
tvFooterRight.setColor(tipColor) |
|
|
|
tvFooterRight.setColor(tipColor) |
|
|
@ -101,15 +99,17 @@ class PageView(context: Context) : FrameLayout(context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upTipStyle() = binding.run { |
|
|
|
private fun upTipStyle() = binding.run { |
|
|
|
|
|
|
|
tvHeaderLeft.tag = null |
|
|
|
|
|
|
|
tvHeaderMiddle.tag = null |
|
|
|
|
|
|
|
tvHeaderRight.tag = null |
|
|
|
|
|
|
|
tvFooterLeft.tag = null |
|
|
|
|
|
|
|
tvFooterMiddle.tag = null |
|
|
|
|
|
|
|
tvFooterRight.tag = null |
|
|
|
ReadTipConfig.apply { |
|
|
|
ReadTipConfig.apply { |
|
|
|
tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle |
|
|
|
tvHeaderLeft.isGone = tipHeaderLeft == none |
|
|
|
bvHeaderLeft.isInvisible = |
|
|
|
|
|
|
|
tipHeaderLeft == none || !tvHeaderLeft.isInvisible |
|
|
|
|
|
|
|
tvHeaderRight.isGone = tipHeaderRight == none |
|
|
|
tvHeaderRight.isGone = tipHeaderRight == none |
|
|
|
tvHeaderMiddle.isGone = tipHeaderMiddle == none |
|
|
|
tvHeaderMiddle.isGone = tipHeaderMiddle == none |
|
|
|
tvFooterLeft.isInvisible = tipFooterLeft != chapterTitle |
|
|
|
tvFooterLeft.isInvisible = tipFooterLeft == none |
|
|
|
bvFooterLeft.isInvisible = |
|
|
|
|
|
|
|
tipFooterLeft == none || !tvFooterLeft.isInvisible |
|
|
|
|
|
|
|
tvFooterRight.isGone = tipFooterRight == none |
|
|
|
tvFooterRight.isGone = tipFooterRight == none |
|
|
|
tvFooterMiddle.isGone = tipFooterMiddle == none |
|
|
|
tvFooterMiddle.isGone = tipFooterMiddle == none |
|
|
|
llHeader.isGone = when (headerMode) { |
|
|
|
llHeader.isGone = when (headerMode) { |
|
|
@ -122,63 +122,61 @@ class PageView(context: Context) : FrameLayout(context) { |
|
|
|
else -> false |
|
|
|
else -> false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
tvTitle = getTipView(ReadTipConfig.chapterTitle) |
|
|
|
tvTitle = getTipView(ReadTipConfig.chapterTitle)?.apply { |
|
|
|
tvTitle?.apply { |
|
|
|
tag = ReadTipConfig.chapterTitle |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvTime = getTipView(ReadTipConfig.time) |
|
|
|
tvTime = getTipView(ReadTipConfig.time)?.apply { |
|
|
|
tvTime?.apply { |
|
|
|
tag = ReadTipConfig.time |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvBattery = getTipView(ReadTipConfig.battery) |
|
|
|
tvBattery = getTipView(ReadTipConfig.battery)?.apply { |
|
|
|
tvBattery?.apply { |
|
|
|
tag = ReadTipConfig.battery |
|
|
|
isBattery = true |
|
|
|
isBattery = true |
|
|
|
textSize = 10f |
|
|
|
textSize = 11f |
|
|
|
} |
|
|
|
} |
|
|
|
tvPage = getTipView(ReadTipConfig.page) |
|
|
|
tvPage = getTipView(ReadTipConfig.page)?.apply { |
|
|
|
tvPage?.apply { |
|
|
|
tag = ReadTipConfig.page |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvTotalProgress = getTipView(ReadTipConfig.totalProgress) |
|
|
|
tvTotalProgress = getTipView(ReadTipConfig.totalProgress)?.apply { |
|
|
|
tvTotalProgress?.apply { |
|
|
|
tag = ReadTipConfig.totalProgress |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal) |
|
|
|
tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal)?.apply { |
|
|
|
tvPageAndTotal?.apply { |
|
|
|
tag = ReadTipConfig.pageAndTotal |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvBookName = getTipView(ReadTipConfig.bookName) |
|
|
|
tvBookName = getTipView(ReadTipConfig.bookName)?.apply { |
|
|
|
tvBookName?.apply { |
|
|
|
tag = ReadTipConfig.bookName |
|
|
|
isBattery = false |
|
|
|
isBattery = false |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 12f |
|
|
|
} |
|
|
|
} |
|
|
|
tvTimeBattery = getTipView(ReadTipConfig.timeBattery) |
|
|
|
tvTimeBattery = getTipView(ReadTipConfig.timeBattery)?.apply { |
|
|
|
tvTimeBattery?.apply { |
|
|
|
tag = ReadTipConfig.timeBattery |
|
|
|
isBattery = false |
|
|
|
isBattery = true |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
typeface = ChapterProvider.typeface |
|
|
|
textSize = 12f |
|
|
|
textSize = 11f |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getTipView(tip: Int): BatteryView? = binding.run { |
|
|
|
private fun getTipView(tip: Int): BatteryView? = binding.run { |
|
|
|
return when (tip) { |
|
|
|
return when (tip) { |
|
|
|
ReadTipConfig.tipHeaderLeft -> |
|
|
|
ReadTipConfig.tipHeaderLeft -> tvHeaderLeft |
|
|
|
if (tip == ReadTipConfig.chapterTitle) tvHeaderLeft else bvHeaderLeft |
|
|
|
|
|
|
|
ReadTipConfig.tipHeaderMiddle -> tvHeaderMiddle |
|
|
|
ReadTipConfig.tipHeaderMiddle -> tvHeaderMiddle |
|
|
|
ReadTipConfig.tipHeaderRight -> tvHeaderRight |
|
|
|
ReadTipConfig.tipHeaderRight -> tvHeaderRight |
|
|
|
ReadTipConfig.tipFooterLeft -> |
|
|
|
ReadTipConfig.tipFooterLeft -> tvFooterLeft |
|
|
|
if (tip == ReadTipConfig.chapterTitle) tvFooterLeft else bvFooterLeft |
|
|
|
|
|
|
|
ReadTipConfig.tipFooterMiddle -> tvFooterMiddle |
|
|
|
ReadTipConfig.tipFooterMiddle -> tvFooterMiddle |
|
|
|
ReadTipConfig.tipFooterRight -> tvFooterRight |
|
|
|
ReadTipConfig.tipFooterRight -> tvFooterRight |
|
|
|
else -> null |
|
|
|
else -> null |
|
|
@ -202,16 +200,14 @@ class PageView(context: Context) : FrameLayout(context) { |
|
|
|
|
|
|
|
|
|
|
|
fun upBattery(battery: Int) { |
|
|
|
fun upBattery(battery: Int) { |
|
|
|
this.battery = battery |
|
|
|
this.battery = battery |
|
|
|
tvBattery?.setBattery(battery) |
|
|
|
tvBattery?.setTextAndBattery(battery = battery) |
|
|
|
upTimeBattery() |
|
|
|
upTimeBattery() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
private fun upTimeBattery() { |
|
|
|
private fun upTimeBattery() { |
|
|
|
tvTimeBattery?.let { |
|
|
|
|
|
|
|
val time = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
val time = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
it.text = "$time $battery%" |
|
|
|
tvTimeBattery?.setTextAndBattery(time, battery) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { |
|
|
|
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { |
|
|
|