背景同步

This commit is contained in:
kunfei
2023-08-02 23:56:14 +08:00
parent 6fde14c71f
commit b57789b336
4 changed files with 30 additions and 5 deletions

View File

@@ -191,9 +191,12 @@ object AppWebDav {
/**
* 下载背景图片
*/
suspend fun downBgs(fileNames: String) {
suspend fun downBgs() {
val authorization = authorization ?: return
if (!NetworkUtils.isAvailable()) return
val bgWebDavFiles = getAllBgWebDavFiles().getOrThrow()
.map { it.displayName }
.toSet()
}
suspend fun exportWebDav(byteArray: ByteArray, fileName: String) {

View File

@@ -131,6 +131,22 @@ object ReadBookConfig {
}
}
fun getAllPicBgStr(): ArrayList<String> {
val list = arrayListOf<String>()
configList.forEach {
if (it.bgType == 2) {
list.add(it.bgStr)
}
if (it.bgTypeNight == 2) {
list.add(it.bgStrNight)
}
if (it.bgTypeEInk == 2) {
list.add(it.bgStrEInk)
}
}
return list
}
fun deleteDur(): Boolean {
if (configList.size > 5) {
configList.removeAt(styleSelect)

View File

@@ -190,8 +190,14 @@ object Backup {
FileUtils.delete(backupPath)
FileUtils.delete(zipFilePath)
coroutineContext.ensureActive()
appCtx.externalFiles.getFile("bg").listFiles()?.let {
AppWebDav.upBgs(it)
ReadBookConfig.getAllPicBgStr().map {
if (it.contains(File.separator)) {
File(it)
} else {
appCtx.externalFiles.getFile("bg", it)
}
}.let {
AppWebDav.upBgs(it.toTypedArray())
}
}

View File

@@ -7,7 +7,6 @@ import io.legado.app.BuildConfig
import io.legado.app.R
import io.legado.app.constant.AppConst.androidId
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
@@ -25,6 +24,7 @@ import io.legado.app.data.entities.RuleSub
import io.legado.app.data.entities.SearchKeyword
import io.legado.app.data.entities.Server
import io.legado.app.data.entities.TxtTocRule
import io.legado.app.help.AppWebDav
import io.legado.app.help.DirectLinkUpload
import io.legado.app.help.LauncherIconHelp
import io.legado.app.help.book.isLocal
@@ -46,7 +46,6 @@ import io.legado.app.utils.getSharedPreferences
import io.legado.app.utils.isContentScheme
import io.legado.app.utils.isJsonArray
import io.legado.app.utils.openInputStream
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.delay
@@ -213,6 +212,7 @@ object Restore {
AppLog.put("恢复阅读界面出错\n${it.localizedMessage}", it)
}
}
AppWebDav.downBgs()
appCtx.getSharedPreferences(path, "config")?.all?.let { map ->
val edit = appCtx.defaultSharedPreferences.edit()