pull/517/head
gedoor 4 years ago
parent 06d3902e81
commit cdad502e5e
  1. 88
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt

@ -57,46 +57,48 @@ class ContentView(context: Context) : FrameLayout(context) {
} }
} }
fun upStyle() = ReadBookConfig.apply { fun upStyle() = with(binding) {
binding.bvHeaderLeft.typeface = ChapterProvider.typeface ReadBookConfig.apply {
binding.tvHeaderLeft.typeface = ChapterProvider.typeface bvHeaderLeft.typeface = ChapterProvider.typeface
binding.tvHeaderMiddle.typeface = ChapterProvider.typeface tvHeaderLeft.typeface = ChapterProvider.typeface
binding.tvHeaderRight.typeface = ChapterProvider.typeface tvHeaderMiddle.typeface = ChapterProvider.typeface
binding.bvFooterLeft.typeface = ChapterProvider.typeface tvHeaderRight.typeface = ChapterProvider.typeface
binding.tvFooterLeft.typeface = ChapterProvider.typeface bvFooterLeft.typeface = ChapterProvider.typeface
binding.tvFooterMiddle.typeface = ChapterProvider.typeface tvFooterLeft.typeface = ChapterProvider.typeface
binding.tvFooterRight.typeface = ChapterProvider.typeface tvFooterMiddle.typeface = ChapterProvider.typeface
tvFooterRight.typeface = ChapterProvider.typeface
val tipColor = if (ReadTipConfig.tipColor == 0) textColor else ReadTipConfig.tipColor val tipColor = if (ReadTipConfig.tipColor == 0) textColor else ReadTipConfig.tipColor
binding.bvHeaderLeft.setColor(tipColor) bvHeaderLeft.setColor(tipColor)
binding.tvHeaderLeft.setColor(tipColor) tvHeaderLeft.setColor(tipColor)
binding.tvHeaderMiddle.setColor(tipColor) tvHeaderMiddle.setColor(tipColor)
binding.tvHeaderRight.setColor(tipColor) tvHeaderRight.setColor(tipColor)
binding.bvFooterLeft.setColor(tipColor) bvFooterLeft.setColor(tipColor)
binding.tvFooterLeft.setColor(tipColor) tvFooterLeft.setColor(tipColor)
binding.tvFooterMiddle.setColor(tipColor) tvFooterMiddle.setColor(tipColor)
binding.tvFooterRight.setColor(tipColor) tvFooterRight.setColor(tipColor)
upStatusBar() upStatusBar()
binding.llHeader.setPadding( llHeader.setPadding(
headerPaddingLeft.dp, headerPaddingLeft.dp,
headerPaddingTop.dp, headerPaddingTop.dp,
headerPaddingRight.dp, headerPaddingRight.dp,
headerPaddingBottom.dp headerPaddingBottom.dp
) )
binding.llFooter.setPadding( llFooter.setPadding(
footerPaddingLeft.dp, footerPaddingLeft.dp,
footerPaddingTop.dp, footerPaddingTop.dp,
footerPaddingRight.dp, footerPaddingRight.dp,
footerPaddingBottom.dp footerPaddingBottom.dp
) )
binding.vwTopDivider.visible(showHeaderLine) vwTopDivider.visible(showHeaderLine)
binding.vwBottomDivider.visible(showFooterLine) vwBottomDivider.visible(showFooterLine)
binding.pageNvBar.layoutParams = binding.pageNvBar.layoutParams.apply { pageNvBar.layoutParams = pageNvBar.layoutParams.apply {
height = if (hideNavigationBar) 0 else App.navigationBarHeight height = if (hideNavigationBar) 0 else App.navigationBarHeight
} }
binding.contentTextView.upVisibleRect() contentTextView.upVisibleRect()
upTime() upTime()
upBattery(battery) upBattery(battery)
} }
}
/** /**
* 显示状态栏时隐藏header * 显示状态栏时隐藏header
@ -107,24 +109,24 @@ class ContentView(context: Context) : FrameLayout(context) {
ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true
} }
fun upTipStyle() { fun upTipStyle() = with(binding) {
ReadTipConfig.apply { ReadTipConfig.apply {
binding.tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle
binding.bvHeaderLeft.isInvisible = bvHeaderLeft.isInvisible =
tipHeaderLeft == none || !binding.tvHeaderLeft.isInvisible tipHeaderLeft == none || !tvHeaderLeft.isInvisible
binding.tvHeaderRight.isGone = tipHeaderRight == none tvHeaderRight.isGone = tipHeaderRight == none
binding.tvHeaderMiddle.isGone = tipHeaderMiddle == none tvHeaderMiddle.isGone = tipHeaderMiddle == none
binding.tvFooterLeft.isInvisible = tipFooterLeft != chapterTitle tvFooterLeft.isInvisible = tipFooterLeft != chapterTitle
binding.bvFooterLeft.isInvisible = bvFooterLeft.isInvisible =
tipFooterLeft == none || !binding.tvFooterLeft.isInvisible tipFooterLeft == none || !tvFooterLeft.isInvisible
binding.tvFooterRight.isGone = tipFooterRight == none tvFooterRight.isGone = tipFooterRight == none
binding.tvFooterMiddle.isGone = tipFooterMiddle == none tvFooterMiddle.isGone = tipFooterMiddle == none
binding.llHeader.isGone = when (headerMode) { llHeader.isGone = when (headerMode) {
1 -> false 1 -> false
2 -> true 2 -> true
else -> !ReadBookConfig.hideStatusBar else -> !ReadBookConfig.hideStatusBar
} }
binding.llFooter.isGone = when (footerMode) { llFooter.isGone = when (footerMode) {
1 -> true 1 -> true
else -> false else -> false
} }
@ -171,16 +173,16 @@ class ContentView(context: Context) : FrameLayout(context) {
} }
} }
private fun getTipView(tip: Int): BatteryView? { private fun getTipView(tip: Int): BatteryView? = with(binding) {
return when (tip) { return when (tip) {
ReadTipConfig.tipHeaderLeft -> ReadTipConfig.tipHeaderLeft ->
if (tip == ReadTipConfig.chapterTitle) binding.tvHeaderLeft else binding.bvHeaderLeft if (tip == ReadTipConfig.chapterTitle) tvHeaderLeft else bvHeaderLeft
ReadTipConfig.tipHeaderMiddle -> binding.tvHeaderMiddle ReadTipConfig.tipHeaderMiddle -> tvHeaderMiddle
ReadTipConfig.tipHeaderRight -> binding.tvHeaderRight ReadTipConfig.tipHeaderRight -> tvHeaderRight
ReadTipConfig.tipFooterLeft -> ReadTipConfig.tipFooterLeft ->
if (tip == ReadTipConfig.chapterTitle) binding.tvFooterLeft else binding.bvFooterLeft if (tip == ReadTipConfig.chapterTitle) tvFooterLeft else bvFooterLeft
ReadTipConfig.tipFooterMiddle -> binding.tvFooterMiddle ReadTipConfig.tipFooterMiddle -> tvFooterMiddle
ReadTipConfig.tipFooterRight -> binding.tvFooterRight ReadTipConfig.tipFooterRight -> tvFooterRight
else -> null else -> null
} }
} }

Loading…
Cancel
Save