pull/1744/head
kunfei 3 years ago
parent 1d1440d8ca
commit e02f253252
  1. 2
      app/src/main/java/io/legado/app/App.kt
  2. 2
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  3. 4
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -58,7 +58,7 @@ class App : MultiDexApplication() {
2 -> ChineseUtils.s2t("初始化") 2 -> ChineseUtils.s2t("初始化")
} }
//同步阅读记录 //同步阅读记录
if (AppWebDav.isOk && AppConfig.syncBookProgress) { if (AppWebDav.syncBookProgress) {
AppWebDav.downloadAllBookProgress() AppWebDav.downloadAllBookProgress()
} }
} }

@ -282,8 +282,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName) val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName)
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)
var preDownloadNum var preDownloadNum
get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10) get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10)
set(value) { set(value) {

@ -29,6 +29,8 @@ object AppWebDav {
private val bookProgressUrl = "${rootWebDavUrl}bookProgress/" private val bookProgressUrl = "${rootWebDavUrl}bookProgress/"
private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip"
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)
var isOk = false var isOk = false
init { init {
@ -167,7 +169,7 @@ object AppWebDav {
fun uploadBookProgress(book: Book) { fun uploadBookProgress(book: Book) {
if (!isOk) return if (!isOk) return
if (!AppConfig.syncBookProgress) return if (!syncBookProgress) return
if (!NetworkUtils.isAvailable()) return if (!NetworkUtils.isAvailable()) return
Coroutine.async { Coroutine.async {
val bookProgress = BookProgress(book) val bookProgress = BookProgress(book)

@ -168,7 +168,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
book: Book, book: Book,
alertSync: ((progress: BookProgress) -> Unit)? = null alertSync: ((progress: BookProgress) -> Unit)? = null
) { ) {
if (AppConfig.syncBookProgress) if (AppWebDav.syncBookProgress)
execute { execute {
AppWebDav.getBookProgress(book) AppWebDav.getBookProgress(book)
}.onSuccess { }.onSuccess {

Loading…
Cancel
Save