添加同步进度开关,默认开启

pull/736/head
gedoor 4 years ago
parent 5c06f7e220
commit e3ab0ea9b4
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 2
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 1
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  4. 19
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  5. 2
      app/src/main/res/values-zh-rHK/strings.xml
  6. 2
      app/src/main/res/values-zh-rTW/strings.xml
  7. 2
      app/src/main/res/values-zh/strings.xml
  8. 2
      app/src/main/res/values/strings.xml
  9. 9
      app/src/main/res/xml/pref_config_backup.xml

@ -63,6 +63,7 @@ object PreferKey {
const val autoChangeSource = "autoChangeSource"
const val importKeepName = "importKeepName"
const val screenDirection = "screenDirection"
const val syncBookProgress = "syncBookProgress"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

@ -147,6 +147,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val importKeepName get() = context.getPrefBoolean(PreferKey.importKeepName)
val syncBookProgress get() = context.getPrefBoolean(PreferKey.syncBookProgress, true)
private fun getPrefUserAgent(): String {
val ua = context.getPrefString(PreferKey.userAgent)
if (ua.isNullOrBlank()) {

@ -91,6 +91,7 @@ object ReadBook {
}
fun uploadProgress() {
if (!AppConfig.syncBookProgress) return
book?.let {
BookWebDav.uploadBookProgress(it)
}

@ -163,17 +163,18 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
fun syncBookProgress(book: Book) {
execute {
BookWebDav.getBookProgress(book)?.let { progress ->
if (progress.durChapterIndex < book.durChapterIndex ||
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos)
) {
processLiveData.postValue(progress)
} else {
ReadBook.setProgress(progress)
if (!AppConfig.syncBookProgress)
execute {
BookWebDav.getBookProgress(book)?.let { progress ->
if (progress.durChapterIndex < book.durChapterIndex ||
(progress.durChapterIndex == book.durChapterIndex && progress.durChapterPos < book.durChapterPos)
) {
processLiveData.postValue(progress)
} else {
ReadBook.setProgress(progress)
}
}
}
}
}
fun changeTo(newBook: Book) {

@ -790,5 +790,7 @@
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
<string name="sync_book_progress_t">同步阅读进度</string>
<string name="sync_book_progress_s">进入退出阅读界面时同步阅读进度</string>
</resources>

@ -791,5 +791,7 @@
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
<string name="sync_book_progress_t">同步阅读进度</string>
<string name="sync_book_progress_s">进入退出阅读界面时同步阅读进度</string>
</resources>

@ -794,5 +794,7 @@
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
<string name="sync_book_progress_t">同步阅读进度</string>
<string name="sync_book_progress_s">进入退出阅读界面时同步阅读进度</string>
</resources>

@ -797,5 +797,7 @@
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进度</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
<string name="sync_book_progress_t">同步阅读进度</string>
<string name="sync_book_progress_s">进入退出阅读界面时同步阅读进度</string>
</resources>

@ -36,6 +36,15 @@
app:allowDividerBelow="false"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:key="syncBookProgress"
android:defaultValue="true"
android:title="@string/sync_book_progress_t"
android:summary="@string/sync_book_progress_s"
app:allowDividerAbove="false"
app:allowDividerBelow="false"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:key="webDavCacheBackup"
android:defaultValue="false"

Loading…
Cancel
Save