diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 82afe6a8b..e2831a80f 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -131,5 +131,8 @@ object AppConfig { App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true) } + val changeSourceLoadInfo get() = App.INSTANCE.getPrefBoolean(PreferKey.changeSourceLoadToc) + + val changeSourceLoadToc get() = App.INSTANCE.getPrefBoolean(PreferKey.changeSourceLoadToc) } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 6cd88dad1..17ab34970 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -16,9 +16,13 @@ import io.legado.app.base.BaseDialogFragment import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook +import io.legado.app.help.AppConfig import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.recycler.VerticalDivider -import io.legado.app.utils.* +import io.legado.app.utils.applyTint +import io.legado.app.utils.getSize +import io.legado.app.utils.getViewModel +import io.legado.app.utils.putPrefBoolean import kotlinx.android.synthetic.main.dialog_change_source.* @@ -81,10 +85,8 @@ class ChangeSourceDialog : BaseDialogFragment(), tool_bar.inflateMenu(R.menu.change_source) tool_bar.menu.applyTint(requireContext()) tool_bar.setOnMenuItemClickListener(this) - tool_bar.menu.findItem(R.id.menu_load_toc)?.isChecked = - getPrefBoolean(PreferKey.changeSourceLoadToc) - tool_bar.menu.findItem(R.id.menu_load_info)?.isChecked = - getPrefBoolean(PreferKey.changeSourceLoadInfo) + tool_bar.menu.findItem(R.id.menu_load_info)?.isChecked = AppConfig.changeSourceLoadInfo + tool_bar.menu.findItem(R.id.menu_load_toc)?.isChecked = AppConfig.changeSourceLoadToc } private fun initRecyclerView() { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 9516867dd..1ed25cdfe 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -124,9 +124,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio it.forEach { searchBook -> if (searchBook.name == name && searchBook.author == author) { if (searchBook.latestChapterTitle.isNullOrEmpty()) { - if (context.getPrefBoolean(PreferKey.changeSourceLoadInfo) - || context.getPrefBoolean(PreferKey.changeSourceLoadToc) - ) { + if (AppConfig.changeSourceLoadInfo || AppConfig.changeSourceLoadToc) { loadBookInfo(webBook, searchBook.toBook()) } else { searchFinish(searchBook)