优化
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -107,7 +107,11 @@ object Restore {
|
||||
}
|
||||
val updateBooks = arrayListOf<Book>()
|
||||
val newBooks = arrayListOf<Book>()
|
||||
val ignoreLocalBook = BackupConfig.ignoreLocalBook
|
||||
it.forEach { book ->
|
||||
if (ignoreLocalBook && book.isLocal) {
|
||||
return@forEach
|
||||
}
|
||||
if (appDb.bookDao.has(book.bookUrl) == true) {
|
||||
updateBooks.add(book)
|
||||
} else {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -1176,4 +1176,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1179,4 +1179,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1179,4 +1179,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
</resources>
|
||||
@@ -1175,4 +1175,5 @@ Còn </string>
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1176,4 +1176,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1178,4 +1178,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1178,4 +1178,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1179,4 +1179,5 @@
|
||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||
<string name="show_same_source">显示重复书源</string>
|
||||
<string name="theme_config">主题配置</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user