diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 4b76c77e2..ca0ce5494 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -58,7 +58,7 @@ class App : MultiDexApplication() { 2 -> ChineseUtils.s2t("初始化") } //同步阅读记录 - if (AppWebDav.isOk && AppConfig.syncBookProgress) { + if (AppWebDav.syncBookProgress) { AppWebDav.downloadAllBookProgress() } } 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 b069eddb8..25525406f 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 @@ -282,8 +282,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName) - val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) - var preDownloadNum get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10) set(value) { diff --git a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt index 02538dd73..8898f1f4f 100644 --- a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt +++ b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt @@ -29,6 +29,8 @@ object AppWebDav { private val bookProgressUrl = "${rootWebDavUrl}bookProgress/" private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" + val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) + var isOk = false init { @@ -167,7 +169,7 @@ object AppWebDav { fun uploadBookProgress(book: Book) { if (!isOk) return - if (!AppConfig.syncBookProgress) return + if (!syncBookProgress) return if (!NetworkUtils.isAvailable()) return Coroutine.async { val bookProgress = BookProgress(book) 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 c7b95217a..f87b2f259 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 @@ -168,7 +168,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { book: Book, alertSync: ((progress: BookProgress) -> Unit)? = null ) { - if (AppConfig.syncBookProgress) + if (AppWebDav.syncBookProgress) execute { AppWebDav.getBookProgress(book) }.onSuccess {