[新增] 可以选择默认换源行为

This commit is contained in:
HapeLee committed 2025-12-04 18:21:12 +08:00
1 parent e8ebfa2c0e
commit 0a70685343
6 files changed
+41 -1

No files matched your search

@@ -224,4 +224,6 @@ object PreferKey {
const val exploreFilterState = "explore_filter_state" const val exploreFilterState = "explore_filter_state"
const val exploreLayoutState = "exploreLayoutState" const val exploreLayoutState = "exploreLayoutState"
const val defaultSourceChangeAll = "defaultSourceChangeAll"
} }
@@ -909,5 +909,10 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.exploreLayoutState, value) appCtx.putPrefInt(PreferKey.exploreLayoutState, value)
} }
var defaultSourceChangeAll: Boolean
get() = appCtx.getPrefBoolean(PreferKey.defaultSourceChangeAll, true)
set(value) {
appCtx.putPrefBoolean(PreferKey.defaultSourceChangeAll, value)
}
} }
@@ -522,12 +522,34 @@ class ReadBookActivity : BaseReadBookActivity(),
} }
} }
private fun defaultChangeSource() {
if (AppConfig.defaultSourceChangeAll)
{
binding.readMenu.runMenuOut()
ReadBook.book?.let {
showDialogFragment(ChangeBookSourceDialog(it.name, it.author))
}
} else {
lifecycleScope.launch {
val book = ReadBook.book ?: return@launch
val chapter =
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
?: return@launch
binding.readMenu.runMenuOut()
showDialogFragment(
ChangeChapterSourceDialog(book.name, book.author, chapter.index, chapter.title)
)
}
}
}
/** /**
* 菜单 * 菜单
*/ */
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_change_source, R.id.menu_change_source -> { defaultChangeSource() }
R.id.menu_book_change_source -> { R.id.menu_book_change_source -> {
binding.readMenu.runMenuOut() binding.readMenu.runMenuOut()
ReadBook.book?.let { ReadBook.book?.let {
+2
View File
@@ -1348,4 +1348,6 @@
<string name="page_anim_fade">渐变</string> <string name="page_anim_fade">渐变</string>
<string name="show_bookshelf_tab_menu">显示更多分组按钮</string> <string name="show_bookshelf_tab_menu">显示更多分组按钮</string>
<string name="show_unread_new">显示新章节更新标志</string> <string name="show_unread_new">显示新章节更新标志</string>
<string name="read_change_all">换源按钮默认弹出整书换源</string>
<string name="read_change_all_s">反之则默认弹出单章换源</string>
</resources> </resources>
+2
View File
@@ -1351,4 +1351,6 @@
<string name="page_anim_fade">渐变</string> <string name="page_anim_fade">渐变</string>
<string name="show_bookshelf_tab_menu">显示更多分组按钮</string> <string name="show_bookshelf_tab_menu">显示更多分组按钮</string>
<string name="show_unread_new">显示新章节更新标志</string> <string name="show_unread_new">显示新章节更新标志</string>
<string name="read_change_all">换源按钮默认弹出整书换源</string>
<string name="read_change_all_s">反之则默认弹出单章换源</string>
</resources> </resources>
@@ -61,6 +61,13 @@
android:title="@string/read_body_to_lh" android:title="@string/read_body_to_lh"
app:isBottomBackground="true" /> app:isBottomBackground="true" />
<io.legado.app.lib.prefs.SwitchPreference
android:defaultValue="true"
android:key="defaultSourceChangeAll"
android:title="@string/read_change_all"
android:summary="@string/read_change_all_s"
app:isBottomBackground="true" />
<io.legado.app.lib.prefs.SwitchPreference <io.legado.app.lib.prefs.SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="textFullJustify" android:key="textFullJustify"