优化
This commit is contained in:
@@ -48,7 +48,6 @@ import io.legado.app.utils.isJsonArray
|
|||||||
import io.legado.app.utils.openInputStream
|
import io.legado.app.utils.openInputStream
|
||||||
import io.legado.app.utils.postEvent
|
import io.legado.app.utils.postEvent
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -81,7 +80,6 @@ object Restore {
|
|||||||
|
|
||||||
suspend fun restore(path: String) {
|
suspend fun restore(path: String) {
|
||||||
val aes = BackupAES()
|
val aes = BackupAES()
|
||||||
withContext(IO) {
|
|
||||||
fileToListT<Book>(path, "bookshelf.json")?.let {
|
fileToListT<Book>(path, "bookshelf.json")?.let {
|
||||||
it.forEach { book ->
|
it.forEach { book ->
|
||||||
book.upType()
|
book.upType()
|
||||||
@@ -218,7 +216,12 @@ object Restore {
|
|||||||
if (BackupConfig.keyIsNotIgnore(key)) {
|
if (BackupConfig.keyIsNotIgnore(key)) {
|
||||||
when (key) {
|
when (key) {
|
||||||
PreferKey.webDavPassword -> {
|
PreferKey.webDavPassword -> {
|
||||||
edit.putString(key, aes.decryptStr(value.toString()))
|
edit.putString(
|
||||||
|
key,
|
||||||
|
kotlin.runCatching {
|
||||||
|
aes.decryptStr(value.toString())
|
||||||
|
}.getOrDefault(value.toString())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> when (value) {
|
else -> when (value) {
|
||||||
@@ -240,7 +243,6 @@ object Restore {
|
|||||||
hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
hideNavigationBar = appCtx.getPrefBoolean(PreferKey.hideNavigationBar)
|
||||||
autoReadSpeed = appCtx.getPrefInt(PreferKey.autoReadSpeed, 46)
|
autoReadSpeed = appCtx.getPrefInt(PreferKey.autoReadSpeed, 46)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
appCtx.toastOnUi(R.string.restore_success)
|
appCtx.toastOnUi(R.string.restore_success)
|
||||||
withContext(Main) {
|
withContext(Main) {
|
||||||
delay(100)
|
delay(100)
|
||||||
|
|||||||
Reference in New Issue
Block a user