|
|
@ -5,11 +5,14 @@ import android.content.Context |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.view.MotionEvent |
|
|
|
import android.view.MotionEvent |
|
|
|
import android.widget.FrameLayout |
|
|
|
import android.widget.FrameLayout |
|
|
|
|
|
|
|
import androidx.core.view.isGone |
|
|
|
|
|
|
|
import androidx.core.view.isInvisible |
|
|
|
import com.hankcs.hanlp.HanLP |
|
|
|
import com.hankcs.hanlp.HanLP |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.constant.AppConst.timeFormat |
|
|
|
import io.legado.app.constant.AppConst.timeFormat |
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.ReadBookConfig |
|
|
|
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.book.read.page.entities.TextPage |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
import kotlinx.android.synthetic.main.view_book_page.view.* |
|
|
|
import kotlinx.android.synthetic.main.view_book_page.view.* |
|
|
@ -24,9 +27,8 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
//设置背景防止切换背景时文字重叠 |
|
|
|
//设置背景防止切换背景时文字重叠 |
|
|
|
setBackgroundColor(context.getCompatColor(R.color.background)) |
|
|
|
setBackgroundColor(context.getCompatColor(R.color.background)) |
|
|
|
inflate(context, R.layout.view_book_page, this) |
|
|
|
inflate(context, R.layout.view_book_page, this) |
|
|
|
|
|
|
|
upTipStyle() |
|
|
|
upStyle() |
|
|
|
upStyle() |
|
|
|
upTime() |
|
|
|
|
|
|
|
content_text_view.upView = { |
|
|
|
content_text_view.upView = { |
|
|
|
setProgress(it) |
|
|
|
setProgress(it) |
|
|
|
} |
|
|
|
} |
|
|
@ -34,11 +36,18 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
|
|
|
|
|
|
|
|
fun upStyle() { |
|
|
|
fun upStyle() { |
|
|
|
ReadBookConfig.apply { |
|
|
|
ReadBookConfig.apply { |
|
|
|
tv_top_left.typeface = ChapterProvider.typeface |
|
|
|
tv_header_left.typeface = ChapterProvider.typeface |
|
|
|
tv_top_right.typeface = ChapterProvider.typeface |
|
|
|
tv_header_middle.typeface = ChapterProvider.typeface |
|
|
|
tv_bottom_left.typeface = ChapterProvider.typeface |
|
|
|
tv_header_right.typeface = ChapterProvider.typeface |
|
|
|
tv_bottom_right.typeface = ChapterProvider.typeface |
|
|
|
tv_footer_left.typeface = ChapterProvider.typeface |
|
|
|
battery_view.typeface = ChapterProvider.typeface |
|
|
|
tv_footer_middle.typeface = ChapterProvider.typeface |
|
|
|
|
|
|
|
tv_footer_right.typeface = ChapterProvider.typeface |
|
|
|
|
|
|
|
tv_header_left.setColor(durConfig.textColor()) |
|
|
|
|
|
|
|
tv_header_middle.setColor(durConfig.textColor()) |
|
|
|
|
|
|
|
tv_header_right.setColor(durConfig.textColor()) |
|
|
|
|
|
|
|
tv_footer_left.setColor(durConfig.textColor()) |
|
|
|
|
|
|
|
tv_footer_middle.setColor(durConfig.textColor()) |
|
|
|
|
|
|
|
tv_footer_right.setColor(durConfig.textColor()) |
|
|
|
//显示状态栏时隐藏header |
|
|
|
//显示状态栏时隐藏header |
|
|
|
if (hideStatusBar) { |
|
|
|
if (hideStatusBar) { |
|
|
|
ll_header.setPadding( |
|
|
|
ll_header.setPadding( |
|
|
@ -62,20 +71,25 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
vw_top_divider.visible(showHeaderLine) |
|
|
|
vw_top_divider.visible(showHeaderLine) |
|
|
|
vw_bottom_divider.visible(showFooterLine) |
|
|
|
vw_bottom_divider.visible(showFooterLine) |
|
|
|
content_text_view.upVisibleRect() |
|
|
|
content_text_view.upVisibleRect() |
|
|
|
durConfig.textColor().let { |
|
|
|
|
|
|
|
tv_top_left.setTextColor(it) |
|
|
|
|
|
|
|
tv_top_right.setTextColor(it) |
|
|
|
|
|
|
|
tv_bottom_left.setTextColor(it) |
|
|
|
|
|
|
|
tv_bottom_right.setTextColor(it) |
|
|
|
|
|
|
|
battery_view.setColor(it) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (hideStatusBar) { |
|
|
|
upTime() |
|
|
|
tv_bottom_left.text = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
upBattery(battery) |
|
|
|
battery_view.visible() |
|
|
|
|
|
|
|
battery_view.setBattery(battery) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
battery_view.gone() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun upTipStyle() { |
|
|
|
|
|
|
|
ReadTipConfig.apply { |
|
|
|
|
|
|
|
val tipHeaderLeftNone = tipHeaderLeft == none |
|
|
|
|
|
|
|
val tipHeaderRightNone = tipHeaderRight == none |
|
|
|
|
|
|
|
val tipHeaderMiddleNone = tipHeaderMiddle == none |
|
|
|
|
|
|
|
val tipFooterLeftNone = tipFooterLeft == none |
|
|
|
|
|
|
|
val tipFooterRightNone = tipFooterRight == none |
|
|
|
|
|
|
|
val tipFooterMiddleNone = tipFooterMiddle == none |
|
|
|
|
|
|
|
tv_header_left.isInvisible = tipHeaderLeftNone |
|
|
|
|
|
|
|
tv_header_right.isGone = tipHeaderRightNone |
|
|
|
|
|
|
|
tv_header_middle.isGone = tipHeaderMiddleNone |
|
|
|
|
|
|
|
tv_footer_left.isInvisible = tipFooterLeftNone |
|
|
|
|
|
|
|
tv_footer_right.isGone = tipFooterRightNone |
|
|
|
|
|
|
|
tv_footer_middle.isGone = tipFooterMiddleNone |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,16 +107,32 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upTime() { |
|
|
|
fun upTime() { |
|
|
|
if (ReadBookConfig.hideStatusBar) { |
|
|
|
val tvTime = when (ReadTipConfig.time) { |
|
|
|
tv_bottom_right.text = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tvTime?.isBattery = false |
|
|
|
|
|
|
|
tvTime?.text = timeFormat.format(Date(System.currentTimeMillis())) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upBattery(battery: Int) { |
|
|
|
fun upBattery(battery: Int) { |
|
|
|
this.battery = battery |
|
|
|
this.battery = battery |
|
|
|
if (ReadBookConfig.hideStatusBar) { |
|
|
|
val tvBattery = when (ReadTipConfig.battery) { |
|
|
|
battery_view.setBattery(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?.isBattery = true |
|
|
|
|
|
|
|
tvBattery?.setBattery(battery) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { |
|
|
|
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { |
|
|
@ -123,14 +153,28 @@ class ContentView(context: Context) : FrameLayout(context) { |
|
|
|
2 -> HanLP.convertToTraditionalChinese(textPage.title) |
|
|
|
2 -> HanLP.convertToTraditionalChinese(textPage.title) |
|
|
|
else -> textPage.title |
|
|
|
else -> textPage.title |
|
|
|
} |
|
|
|
} |
|
|
|
if (ReadBookConfig.hideStatusBar) { |
|
|
|
val tvTitle = when (ReadTipConfig.chapterTitle) { |
|
|
|
tv_top_left.text = title |
|
|
|
ReadTipConfig.tipHeaderLeft -> tv_header_left |
|
|
|
tv_top_right.text = readProgress |
|
|
|
ReadTipConfig.tipHeaderMiddle -> tv_header_middle |
|
|
|
tv_bottom_left.text = "${index.plus(1)}/$pageSize" |
|
|
|
ReadTipConfig.tipHeaderRight -> tv_header_right |
|
|
|
} else { |
|
|
|
ReadTipConfig.tipFooterLeft -> tv_footer_left |
|
|
|
tv_bottom_left.text = title |
|
|
|
ReadTipConfig.tipFooterMiddle -> tv_footer_middle |
|
|
|
tv_bottom_right.text = "${index.plus(1)}/$pageSize $readProgress" |
|
|
|
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" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun onScroll(offset: Float) { |
|
|
|
fun onScroll(offset: Float) { |
|
|
|