commit
dd4aae1b87
18 files changed
+102
-5
No files matched your search
@@ -30,4 +30,5 @@ object EventBus {
|
|||||||
const val SEARCH_RESULT = "searchResult"
|
const val SEARCH_RESULT = "searchResult"
|
||||||
const val FILE_SOURCE_DOWNLOAD_DONE = "fileSourceDownloadDone"
|
const val FILE_SOURCE_DOWNLOAD_DONE = "fileSourceDownloadDone"
|
||||||
const val updateReadActionBar = "updateReadActionBar"
|
const val updateReadActionBar = "updateReadActionBar"
|
||||||
|
const val UP_SEEK_BAR = "upSeekBar"
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,7 @@ object PreferKey {
|
|||||||
const val asyncLoadImage = "asyncLoadImage"
|
const val asyncLoadImage = "asyncLoadImage"
|
||||||
const val ignoreAudioFocus = "ignoreAudioFocus"
|
const val ignoreAudioFocus = "ignoreAudioFocus"
|
||||||
const val parallelExportBook = "parallelExportBook"
|
const val parallelExportBook = "parallelExportBook"
|
||||||
|
const val progressBarBehavior = "progressBarBehavior"
|
||||||
|
|
||||||
const val cPrimary = "colorPrimary"
|
const val cPrimary = "colorPrimary"
|
||||||
const val cAccent = "colorAccent"
|
const val cAccent = "colorAccent"
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class ContentProcessor private constructor(
|
|||||||
|
|
||||||
suspend fun replaceContent(content: String): String {
|
suspend fun replaceContent(content: String): String {
|
||||||
var mContent = content
|
var mContent = content
|
||||||
|
mContent = mContent.lines().joinToString("\n") { it.trim() }
|
||||||
getContentReplaceRules().forEach { item ->
|
getContentReplaceRules().forEach { item ->
|
||||||
if (item.pattern.isNotEmpty()) {
|
if (item.pattern.isNotEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -339,6 +339,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
val doublePageHorizontal: String?
|
val doublePageHorizontal: String?
|
||||||
get() = appCtx.getPrefString(PreferKey.doublePageHorizontal)
|
get() = appCtx.getPrefString(PreferKey.doublePageHorizontal)
|
||||||
|
|
||||||
|
val progressBarBehavior: String?
|
||||||
|
get() = appCtx.getPrefString(PreferKey.progressBarBehavior, "page")
|
||||||
|
|
||||||
var searchGroup: String
|
var searchGroup: String
|
||||||
get() = appCtx.getPrefString("searchGroup") ?: ""
|
get() = appCtx.getPrefString("searchGroup") ?: ""
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
launch {
|
launch {
|
||||||
autoPageProgress = 0
|
autoPageProgress = 0
|
||||||
binding.readView.upContent(relativePosition, resetPageOffset)
|
binding.readView.upContent(relativePosition, resetPageOffset)
|
||||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
upSeekBarProgress()
|
||||||
loadStates = false
|
loadStates = false
|
||||||
success?.invoke()
|
success?.invoke()
|
||||||
}
|
}
|
||||||
@@ -775,11 +775,22 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun pageChanged() {
|
override fun pageChanged() {
|
||||||
launch {
|
launch {
|
||||||
autoPageProgress = 0
|
autoPageProgress = 0
|
||||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
upSeekBarProgress()
|
||||||
startBackupJob()
|
startBackupJob()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新进度条位置
|
||||||
|
*/
|
||||||
|
private fun upSeekBarProgress() {
|
||||||
|
val progress = when (AppConfig.progressBarBehavior) {
|
||||||
|
"page" -> ReadBook.durPageIndex
|
||||||
|
else /* chapter */ -> ReadBook.durChapterIndex
|
||||||
|
}
|
||||||
|
binding.readMenu.setSeekPage(progress)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示菜单
|
* 显示菜单
|
||||||
*/
|
*/
|
||||||
@@ -915,6 +926,13 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到指定章节
|
||||||
|
*/
|
||||||
|
override fun skipToChapter(index: Int) {
|
||||||
|
viewModel.openChapter(index)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开搜索界面
|
* 打开搜索界面
|
||||||
*/
|
*/
|
||||||
@@ -1282,6 +1300,9 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
observeEvent<Boolean>(EventBus.updateReadActionBar) {
|
observeEvent<Boolean>(EventBus.updateReadActionBar) {
|
||||||
binding.readMenu.reset()
|
binding.readMenu.reset()
|
||||||
}
|
}
|
||||||
|
observeEvent<Boolean>(EventBus.UP_SEEK_BAR) {
|
||||||
|
binding.readMenu.upSeekBar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upScreenTimeOut() {
|
private fun upScreenTimeOut() {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
var cnaShowMenu: Boolean = false
|
var cnaShowMenu: Boolean = false
|
||||||
private val callBack: CallBack get() = activity as CallBack
|
private val callBack: CallBack get() = activity as CallBack
|
||||||
private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
|
private var confirmSkipToChapter: Boolean = false
|
||||||
private val menuTopIn: Animation by lazy {
|
private val menuTopIn: Animation by lazy {
|
||||||
loadAnimation(context, R.anim.anim_readbook_top_in)
|
loadAnimation(context, R.anim.anim_readbook_top_in)
|
||||||
}
|
}
|
||||||
@@ -370,7 +371,27 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
ReadBook.skipToPage(seekBar.progress)
|
when (AppConfig.progressBarBehavior) {
|
||||||
|
"page" -> ReadBook.skipToPage(seekBar.progress)
|
||||||
|
"chapter" -> {
|
||||||
|
if (confirmSkipToChapter) {
|
||||||
|
callBack.skipToChapter(seekBar.progress)
|
||||||
|
} else {
|
||||||
|
context.alert("章节跳转确认", "确定要跳转章节吗?") {
|
||||||
|
yesButton {
|
||||||
|
confirmSkipToChapter = true
|
||||||
|
callBack.skipToChapter(seekBar.progress)
|
||||||
|
}
|
||||||
|
noButton {
|
||||||
|
upSeekBar()
|
||||||
|
}
|
||||||
|
onCancelled {
|
||||||
|
upSeekBar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -453,8 +474,7 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
} else {
|
} else {
|
||||||
binding.tvChapterUrl.gone()
|
binding.tvChapterUrl.gone()
|
||||||
}
|
}
|
||||||
binding.seekReadPage.max = it.pageSize.minus(1)
|
upSeekBar()
|
||||||
binding.seekReadPage.progress = ReadBook.durPageIndex
|
|
||||||
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
||||||
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
||||||
} ?: let {
|
} ?: let {
|
||||||
@@ -463,6 +483,23 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun upSeekBar() {
|
||||||
|
binding.seekReadPage.apply {
|
||||||
|
when (AppConfig.progressBarBehavior) {
|
||||||
|
"page" -> {
|
||||||
|
ReadBook.curTextChapter?.let {
|
||||||
|
|||||||