From e8a97c1132268c0f8840c2ac33c1f3ac92b785c1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 14 Nov 2022 20:59:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 2 +- app/src/main/java/io/legado/app/help/AppWebDav.kt | 5 ++--- app/src/main/java/io/legado/app/help/config/AppConfig.kt | 2 ++ .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 0d8a73cbb..8ed281747 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -68,7 +68,7 @@ class App : MultiDexApplication() { 2 -> ChineseUtils.preLoad(true, TransType.SIMPLE_TO_TRADITIONAL) } //同步阅读记录 - if (AppWebDav.syncBookProgress) { + if (AppConfig.syncBookProgress) { AppWebDav.downloadAllBookProgress() } } diff --git a/app/src/main/java/io/legado/app/help/AppWebDav.kt b/app/src/main/java/io/legado/app/help/AppWebDav.kt index 7b0ffe3b7..513269876 100644 --- a/app/src/main/java/io/legado/app/help/AppWebDav.kt +++ b/app/src/main/java/io/legado/app/help/AppWebDav.kt @@ -39,7 +39,6 @@ object AppWebDav { private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" private val bookProgressUrl get() = "${rootWebDavUrl}bookProgress/" private val exportsWebDavUrl get() = "${rootWebDavUrl}books/" - val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) var authorization: Authorization? = null private set @@ -225,7 +224,7 @@ object AppWebDav { fun uploadBookProgress(book: Book) { val authorization = authorization ?: return - if (!syncBookProgress) return + if (!AppConfig.syncBookProgress) return if (!NetworkUtils.isAvailable()) return Coroutine.async { val bookProgress = BookProgress(book) @@ -239,7 +238,7 @@ object AppWebDav { fun uploadBookProgress(bookProgress: BookProgress) { val authorization = authorization ?: return - if (!syncBookProgress) return + if (!AppConfig.syncBookProgress) return if (!NetworkUtils.isAvailable()) return Coroutine.async { val json = GSON.toJson(bookProgress) diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index 91eac15ef..74af052c6 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -338,6 +338,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefInt(PreferKey.preDownloadNum, value) } + val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) + val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true) val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 9b761b6fb..c063033bf 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -186,7 +186,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { book: Book, alertSync: ((progress: BookProgress) -> Unit)? = null ) { - if (!AppWebDav.syncBookProgress) return + if (!AppConfig.syncBookProgress) return execute { AppWebDav.getBookProgress(book) ?: throw NoStackTraceException("没有进度") From a65031d10bd67a1c57b258ce91c56b1a91e83e78 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 14 Nov 2022 23:16:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt index 78a99b08d..dc8968325 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt @@ -86,7 +86,7 @@ class TocActivity : VMBaseActivity() { return false } }) - setOnQueryTextFocusChangeListener { v, hasFocus -> + setOnQueryTextFocusChangeListener { _, hasFocus -> if (!hasFocus) { searchView?.isIconified = true }