pull/737/head
Robot 4 years ago
commit 7f355f0523
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 21
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  4. 13
      app/src/main/java/io/legado/app/ui/widget/BatteryView.kt

@ -852,7 +852,6 @@ class ReadBookActivity : ReadBookBaseActivity(),
observeEvent<Boolean>(EventBus.UP_CONFIG) { observeEvent<Boolean>(EventBus.UP_CONFIG) {
upSystemUiVisibility() upSystemUiVisibility()
readView.upBg() readView.upBg()
readView.upTipStyle()
readView.upStyle() readView.upStyle()
if (it) { if (it) {
ReadBook.loadContent(resetPageOffset = false) ReadBook.loadContent(resetPageOffset = false)

@ -49,7 +49,6 @@ class PageView(context: Context) : FrameLayout(context) {
if (!isInEditMode) { if (!isInEditMode) {
//设置背景防止切换背景时文字重叠 //设置背景防止切换背景时文字重叠
setBackgroundColor(context.getCompatColor(R.color.background)) setBackgroundColor(context.getCompatColor(R.color.background))
upTipStyle()
upStyle() upStyle()
} }
binding.contentTextView.upView = { binding.contentTextView.upView = {
@ -58,16 +57,7 @@ class PageView(context: Context) : FrameLayout(context) {
} }
fun upStyle() = with(binding) { fun upStyle() = with(binding) {
ChapterProvider.let { upTipStyle()
bvHeaderLeft.typeface = it.typeface
tvHeaderLeft.typeface = it.typeface
tvHeaderMiddle.typeface = it.typeface
tvHeaderRight.typeface = it.typeface
bvFooterLeft.typeface = it.typeface
tvFooterLeft.typeface = it.typeface
tvFooterMiddle.typeface = it.typeface
tvFooterRight.typeface = it.typeface
}
ReadBookConfig.let { ReadBookConfig.let {
val tipColor = with(ReadTipConfig) { val tipColor = with(ReadTipConfig) {
if (tipColor == 0) it.textColor else tipColor if (tipColor == 0) it.textColor else tipColor
@ -113,7 +103,7 @@ class PageView(context: Context) : FrameLayout(context) {
ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true
} }
fun upTipStyle() = with(binding) { private fun upTipStyle() = with(binding) {
ReadTipConfig.apply { ReadTipConfig.apply {
tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle
bvHeaderLeft.isInvisible = bvHeaderLeft.isInvisible =
@ -138,11 +128,13 @@ class PageView(context: Context) : FrameLayout(context) {
tvTitle = getTipView(ReadTipConfig.chapterTitle) tvTitle = getTipView(ReadTipConfig.chapterTitle)
tvTitle?.apply { tvTitle?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvTime = getTipView(ReadTipConfig.time) tvTime = getTipView(ReadTipConfig.time)
tvTime?.apply { tvTime?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvBattery = getTipView(ReadTipConfig.battery) tvBattery = getTipView(ReadTipConfig.battery)
@ -153,26 +145,31 @@ class PageView(context: Context) : FrameLayout(context) {
tvPage = getTipView(ReadTipConfig.page) tvPage = getTipView(ReadTipConfig.page)
tvPage?.apply { tvPage?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvTotalProgress = getTipView(ReadTipConfig.totalProgress) tvTotalProgress = getTipView(ReadTipConfig.totalProgress)
tvTotalProgress?.apply { tvTotalProgress?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal) tvPageAndTotal = getTipView(ReadTipConfig.pageAndTotal)
tvPageAndTotal?.apply { tvPageAndTotal?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvBookName = getTipView(ReadTipConfig.bookName) tvBookName = getTipView(ReadTipConfig.bookName)
tvBookName?.apply { tvBookName?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
tvTimeBattery = getTipView(ReadTipConfig.timeBattery) tvTimeBattery = getTipView(ReadTipConfig.timeBattery)
tvTimeBattery?.apply { tvTimeBattery?.apply {
isBattery = false isBattery = false
typeface = ChapterProvider.typeface
textSize = 12f textSize = 12f
} }
} }

@ -489,12 +489,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
callBack.screenOffTimerStart() callBack.screenOffTimerStart()
} }
fun upTipStyle() {
curPage.upTipStyle()
prevPage.upTipStyle()
nextPage.upTipStyle()
}
fun upStyle() { fun upStyle() {
ChapterProvider.upStyle() ChapterProvider.upStyle()
curPage.upStyle() curPage.upStyle()

@ -16,19 +16,26 @@ class BatteryView @JvmOverloads constructor(
context: Context, context: Context,
attrs: AttributeSet? = null attrs: AttributeSet? = null
) : AppCompatTextView(context, attrs) { ) : AppCompatTextView(context, attrs) {
private val batteryTypeface by lazy {
Typeface.createFromAsset(context.assets, "font${File.separator}number.ttf")
}
private val batteryPaint = Paint() private val batteryPaint = Paint()
private val outFrame = Rect() private val outFrame = Rect()
private val polar = Rect() private val polar = Rect()
var isBattery = false var isBattery = false
set(value) {
field = value
if (value) {
typeface = batteryTypeface
postInvalidate()
}
}
init { init {
setPadding(4.dp, 0, 6.dp, 0) setPadding(4.dp, 0, 6.dp, 0)
batteryPaint.strokeWidth = 1.dp.toFloat() batteryPaint.strokeWidth = 1.dp.toFloat()
batteryPaint.isAntiAlias = true batteryPaint.isAntiAlias = true
batteryPaint.color = paint.color batteryPaint.color = paint.color
if (!isInEditMode) {
typeface = Typeface.createFromAsset(context.assets, "font${File.separator}number.ttf")
}
} }
fun setColor(@ColorInt color: Int) { fun setColor(@ColorInt color: Int) {

Loading…
Cancel
Save