|
|
@@ -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<HashMap<String, Boolean>>(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)
|