diff --git a/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt b/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt index e42cbe170..33d61373b 100644 --- a/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt +++ b/app/src/main/java/io/legado/app/help/storage/BackupConfig.kt @@ -10,6 +10,7 @@ import splitties.init.appCtx /** * 备份配置 */ +@Suppress("ConstPropertyName") object BackupConfig { private val ignoreConfigPath = FileUtils.getPath(appCtx.filesDir, "restoreIgnore.json") @@ -19,24 +20,34 @@ object BackupConfig { GSON.fromJsonObject>(json).getOrNull() ?: hashMapOf() } + private const val readConfigKey = "readConfig" + private const val themeConfigKey = "themeConfig" + private const val coverConfigKey = "coverConfig" + private const val localBookKey = "localBook" + //配置忽略key val ignoreKeys = arrayOf( - "readConfig", + readConfigKey, PreferKey.themeMode, + themeConfigKey, + coverConfigKey, PreferKey.bookshelfLayout, PreferKey.showRss, PreferKey.threadCount, + localBookKey ) //配置忽略标题 - val ignoreTitle - get() = arrayOf( - appCtx.getString(R.string.read_config), - appCtx.getString(R.string.theme_mode), - appCtx.getString(R.string.bookshelf_layout), - appCtx.getString(R.string.show_rss), - appCtx.getString(R.string.thread_count) - ) + val ignoreTitle = arrayOf( + appCtx.getString(R.string.read_config), + appCtx.getString(R.string.theme_mode), + appCtx.getString(R.string.theme_config), + appCtx.getString(R.string.cover_config), + appCtx.getString(R.string.bookshelf_layout), + appCtx.getString(R.string.show_rss), + appCtx.getString(R.string.thread_count), + appCtx.getString(R.string.local_book) + ) //自动忽略keys private val ignorePrefKeys = arrayOf( @@ -70,11 +81,36 @@ object BackupConfig { PreferKey.clickActionBR ) + private val themePrefKeys = arrayOf( + PreferKey.cPrimary, + PreferKey.cAccent, + PreferKey.cBackground, + PreferKey.cBBackground, + PreferKey.bgImage, + PreferKey.bgImageBlurring, + PreferKey.cNPrimary, + PreferKey.cNAccent, + PreferKey.cNBackground, + PreferKey.cNBBackground, + PreferKey.bgImageN, + PreferKey.bgImageNBlurring + ) + + private val coverPrefKeys = arrayOf( + PreferKey.useDefaultCover, + PreferKey.loadCoverOnlyWifi, + PreferKey.coverShowName, + PreferKey.coverShowAuthor, + PreferKey.coverShowNameN, + PreferKey.coverShowAuthorN + ) fun keyIsNotIgnore(key: String): Boolean { return when { ignorePrefKeys.contains(key) -> false - readPrefKeys.contains(key) && ignoreReadConfig -> false + ignoreReadConfig && readPrefKeys.contains(key) -> false + ignoreThemeConfig && themePrefKeys.contains(key) -> false + ignoreCoverConfig && coverPrefKeys.contains(key) -> false PreferKey.themeMode == key && ignoreThemeMode -> false PreferKey.bookshelfLayout == key && ignoreBookshelfLayout -> false PreferKey.showRss == key && ignoreShowRss -> false @@ -84,15 +120,21 @@ object BackupConfig { } val ignoreReadConfig: Boolean - get() = ignoreConfig["readConfig"] == true + get() = ignoreConfig[readConfigKey] == true private val ignoreThemeMode: Boolean get() = ignoreConfig[PreferKey.themeMode] == true + private val ignoreThemeConfig: Boolean + get() = ignoreConfig[themeConfigKey] == true + private val ignoreCoverConfig: Boolean + get() = ignoreConfig[coverConfigKey] == true private val ignoreBookshelfLayout: Boolean get() = ignoreConfig[PreferKey.bookshelfLayout] == true private val ignoreShowRss: Boolean get() = ignoreConfig[PreferKey.showRss] == true private val ignoreThreadCount: Boolean get() = ignoreConfig[PreferKey.threadCount] == true + val ignoreLocalBook: Boolean + get() = ignoreConfig[localBookKey] == true fun saveIgnoreConfig() { val json = GSON.toJson(ignoreConfig) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index a0b5e70cc..36646b20c 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -107,7 +107,11 @@ object Restore { } val updateBooks = arrayListOf() val newBooks = arrayListOf() + val ignoreLocalBook = BackupConfig.ignoreLocalBook it.forEach { book -> + if (ignoreLocalBook && book.isLocal) { + return@forEach + } if (appDb.bookDao.has(book.bookUrl) == true) { updateBooks.add(book) } else { diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 703bdf8f5..fa3203704 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -54,7 +54,6 @@ import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import splitties.init.appCtx -import kotlin.collections.set import kotlin.coroutines.coroutineContext class BackupConfigFragment : PreferenceFragment(), diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 8ec0d96ef..b40b3be5d 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1176,4 +1176,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 9231d2321..ecf9eee3e 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1179,4 +1179,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 55e019ffc..2f0a38f2b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1179,4 +1179,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-v24/strings.xml b/app/src/main/res/values-v24/strings.xml deleted file mode 100644 index f97e6415f..000000000 --- a/app/src/main/res/values-v24/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - 显示重复书源 - \ No newline at end of file diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 0295bcb00..217e08b34 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1175,4 +1175,5 @@ Còn 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 4b3214a80..2d8db8543 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1176,4 +1176,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 826fddff5..0e69f311d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1178,4 +1178,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 3afe6c950..b5ea4a207 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1178,4 +1178,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7bdaf908a..ab2c21571 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1179,4 +1179,5 @@ 耳机按键启动朗读 通过耳机按键来启动朗读 显示重复书源 + 主题配置