mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
@@ -30,4 +30,5 @@ object EventBus {
|
||||
const val SEARCH_RESULT = "searchResult"
|
||||
const val FILE_SOURCE_DOWNLOAD_DONE = "fileSourceDownloadDone"
|
||||
const val updateReadActionBar = "updateReadActionBar"
|
||||
const val UP_SEEK_BAR = "upSeekBar"
|
||||
}
|
||||
@@ -114,6 +114,7 @@ object PreferKey {
|
||||
const val asyncLoadImage = "asyncLoadImage"
|
||||
const val ignoreAudioFocus = "ignoreAudioFocus"
|
||||
const val parallelExportBook = "parallelExportBook"
|
||||
const val progressBarBehavior = "progressBarBehavior"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
||||
@@ -136,6 +136,7 @@ class ContentProcessor private constructor(
|
||||
|
||||
suspend fun replaceContent(content: String): String {
|
||||
var mContent = content
|
||||
mContent = mContent.lines().joinToString("\n") { it.trim() }
|
||||
getContentReplaceRules().forEach { item ->
|
||||
if (item.pattern.isNotEmpty()) {
|
||||
try {
|
||||
|
||||
@@ -339,6 +339,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
val doublePageHorizontal: String?
|
||||
get() = appCtx.getPrefString(PreferKey.doublePageHorizontal)
|
||||
|
||||
val progressBarBehavior: String?
|
||||
get() = appCtx.getPrefString(PreferKey.progressBarBehavior, "page")
|
||||
|
||||
var searchGroup: String
|
||||
get() = appCtx.getPrefString("searchGroup") ?: ""
|
||||
set(value) {
|
||||
|
||||
@@ -757,7 +757,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
launch {
|
||||
autoPageProgress = 0
|
||||
binding.readView.upContent(relativePosition, resetPageOffset)
|
||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
||||
upSeekBarProgress()
|
||||
loadStates = false
|
||||
success?.invoke()
|
||||
}
|
||||
@@ -775,11 +775,22 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
override fun pageChanged() {
|
||||
launch {
|
||||
autoPageProgress = 0
|
||||
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
|
||||
upSeekBarProgress()
|
||||
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) {
|
||||
binding.readMenu.reset()
|
||||
}
|
||||
observeEvent<Boolean>(EventBus.UP_SEEK_BAR) {
|
||||
binding.readMenu.upSeekBar()
|
||||
}
|
||||
}
|
||||
|
||||
private fun upScreenTimeOut() {
|
||||
|
||||
@@ -45,6 +45,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
var cnaShowMenu: Boolean = false
|
||||
private val callBack: CallBack get() = activity as CallBack
|
||||
private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
private var confirmSkipToChapter: Boolean = false
|
||||
private val menuTopIn: Animation by lazy {
|
||||
loadAnimation(context, R.anim.anim_readbook_top_in)
|
||||
}
|
||||
@@ -370,7 +371,27 @@ class ReadMenu @JvmOverloads constructor(
|
||||
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||
|
||||
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 {
|
||||
binding.tvChapterUrl.gone()
|
||||
}
|
||||
binding.seekReadPage.max = it.pageSize.minus(1)
|
||||
binding.seekReadPage.progress = ReadBook.durPageIndex
|
||||
upSeekBar()
|
||||
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
||||
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
||||
} ?: let {
|
||||
@@ -463,6 +483,23 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun upSeekBar() {
|
||||
binding.seekReadPage.apply {
|
||||
when (AppConfig.progressBarBehavior) {
|
||||
"page" -> {
|
||||
ReadBook.curTextChapter?.let {
|
||||
max = it.pageSize.minus(1)
|
||||
progress = ReadBook.durPageIndex
|
||||
}
|
||||
}
|
||||
"chapter" -> {
|
||||
max = ReadBook.chapterSize - 1
|
||||
progress = ReadBook.durChapterIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setSeekPage(seek: Int) {
|
||||
binding.seekReadPage.progress = seek
|
||||
}
|
||||
@@ -493,6 +530,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
fun showLogin()
|
||||
fun payAction()
|
||||
fun disableSource()
|
||||
fun skipToChapter(index: Int)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,6 +137,9 @@ class MoreConfigDialog : DialogFragment() {
|
||||
PreferKey.readBarStyleFollowPage -> {
|
||||
postEvent(EventBus.updateReadActionBar, true)
|
||||
}
|
||||
PreferKey.progressBarBehavior -> {
|
||||
postEvent(EventBus.UP_SEEK_BAR, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,9 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
mode = HandleFileContract.DIR_SYS
|
||||
}
|
||||
}
|
||||
neutralButton("不想设置") {
|
||||
AppConfig.defaultBookTreeUri = "null"
|
||||
}
|
||||
noButton()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1036,4 +1036,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -1039,4 +1039,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -1039,4 +1039,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -1036,4 +1036,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -1038,4 +1038,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -1038,4 +1038,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="progress_bar_behavior_value">
|
||||
<item>page</item>
|
||||
<item>chapter</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="language_value">
|
||||
<item>auto</item>
|
||||
<item>zh</item>
|
||||
|
||||
@@ -67,6 +67,11 @@
|
||||
<item>横屏双页 竖屏单页</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="progress_bar_behavior_title">
|
||||
<item>调整本章页数</item>
|
||||
<item>调整章节位置</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="icon_names" tools:ignore="Typos">
|
||||
<item>iconMain</item>
|
||||
<item>icon1</item>
|
||||
|
||||
@@ -1039,4 +1039,5 @@
|
||||
<string name="net_no_group">网络未分组</string>
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
</resources>
|
||||
|
||||
@@ -50,6 +50,15 @@
|
||||
app:iconSpaceReserved="false"
|
||||
app:isBottomBackground="true" />
|
||||
|
||||
<io.legado.app.lib.prefs.NameListPreference
|
||||
android:defaultValue="page"
|
||||
android:entries="@array/progress_bar_behavior_title"
|
||||
android:entryValues="@array/progress_bar_behavior_value"
|
||||
android:key="progressBarBehavior"
|
||||
android:title="@string/progress_bar_behavior"
|
||||
app:iconSpaceReserved="false"
|
||||
app:isBottomBackground="true" />
|
||||
|
||||
<io.legado.app.lib.prefs.SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="useZhLayout"
|
||||
|
||||
Reference in New Issue
Block a user