优化
This commit is contained in:
@@ -10,6 +10,7 @@ import splitties.init.appCtx
|
|||||||
/**
|
/**
|
||||||
* 备份配置
|
* 备份配置
|
||||||
*/
|
*/
|
||||||
|
@Suppress("ConstPropertyName")
|
||||||
object BackupConfig {
|
object BackupConfig {
|
||||||
|
|
||||||
private val ignoreConfigPath = FileUtils.getPath(appCtx.filesDir, "restoreIgnore.json")
|
private val ignoreConfigPath = FileUtils.getPath(appCtx.filesDir, "restoreIgnore.json")
|
||||||
@@ -19,24 +20,34 @@ object BackupConfig {
|
|||||||
GSON.fromJsonObject<HashMap<String, Boolean>>(json).getOrNull() ?: hashMapOf()
|
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
|
//配置忽略key
|
||||||
val ignoreKeys = arrayOf(
|
val ignoreKeys = arrayOf(
|
||||||
"readConfig",
|
readConfigKey,
|
||||||
PreferKey.themeMode,
|
PreferKey.themeMode,
|
||||||
|
themeConfigKey,
|
||||||
|
coverConfigKey,
|
||||||
PreferKey.bookshelfLayout,
|
PreferKey.bookshelfLayout,
|
||||||
PreferKey.showRss,
|
PreferKey.showRss,
|
||||||
PreferKey.threadCount,
|
PreferKey.threadCount,
|
||||||
|
localBookKey
|
||||||
)
|
)
|
||||||
|
|
||||||
//配置忽略标题
|
//配置忽略标题
|
||||||
val ignoreTitle
|
val ignoreTitle = arrayOf(
|
||||||
get() = arrayOf(
|
appCtx.getString(R.string.read_config),
|
||||||
appCtx.getString(R.string.read_config),
|
appCtx.getString(R.string.theme_mode),
|
||||||
appCtx.getString(R.string.theme_mode),
|
appCtx.getString(R.string.theme_config),
|
||||||
appCtx.getString(R.string.bookshelf_layout),
|
appCtx.getString(R.string.cover_config),
|
||||||
appCtx.getString(R.string.show_rss),
|
appCtx.getString(R.string.bookshelf_layout),
|
||||||
appCtx.getString(R.string.thread_count)
|
appCtx.getString(R.string.show_rss),
|
||||||
)
|
appCtx.getString(R.string.thread_count),
|
||||||
|
appCtx.getString(R.string.local_book)
|
||||||
|
)
|
||||||
|
|
||||||
//自动忽略keys
|
//自动忽略keys
|
||||||
private val ignorePrefKeys = arrayOf(
|
private val ignorePrefKeys = arrayOf(
|
||||||
@@ -70,11 +81,36 @@ object BackupConfig {
|
|||||||
PreferKey.clickActionBR
|
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 {
|
fun keyIsNotIgnore(key: String): Boolean {
|
||||||
return when {
|
return when {
|
||||||
ignorePrefKeys.contains(key) -> false
|
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.themeMode == key && ignoreThemeMode -> false
|
||||||
PreferKey.bookshelfLayout == key && ignoreBookshelfLayout -> false
|
PreferKey.bookshelfLayout == key && ignoreBookshelfLayout -> false
|
||||||
PreferKey.showRss == key && ignoreShowRss -> false
|
PreferKey.showRss == key && ignoreShowRss -> false
|
||||||
@@ -84,15 +120,21 @@ object BackupConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val ignoreReadConfig: Boolean
|
val ignoreReadConfig: Boolean
|
||||||
get() = ignoreConfig["readConfig"] == true
|
get() = ignoreConfig[readConfigKey] == true
|
||||||
private val ignoreThemeMode: Boolean
|
private val ignoreThemeMode: Boolean
|
||||||
get() = ignoreConfig[PreferKey.themeMode] == true
|
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
|
private val ignoreBookshelfLayout: Boolean
|
||||||
get() = ignoreConfig[PreferKey.bookshelfLayout] == true
|
get() = ignoreConfig[PreferKey.bookshelfLayout] == true
|
||||||
private val ignoreShowRss: Boolean
|
private val ignoreShowRss: Boolean
|
||||||
get() = ignoreConfig[PreferKey.showRss] == true
|
get() = ignoreConfig[PreferKey.showRss] == true
|
||||||
private val ignoreThreadCount: Boolean
|
private val ignoreThreadCount: Boolean
|
||||||
get() = ignoreConfig[PreferKey.threadCount] == true
|
get() = ignoreConfig[PreferKey.threadCount] == true
|
||||||
|
val ignoreLocalBook: Boolean
|
||||||
|
get() = ignoreConfig[localBookKey] == true
|
||||||
|
|
||||||
fun saveIgnoreConfig() {
|
fun saveIgnoreConfig() {
|
||||||
val json = GSON.toJson(ignoreConfig)
|
val json = GSON.toJson(ignoreConfig)
|
||||||
|
|||||||
@@ -107,7 +107,11 @@ object Restore {
|
|||||||
}
|
}
|
||||||
val updateBooks = arrayListOf<Book>()
|
val updateBooks = arrayListOf<Book>()
|
||||||
val newBooks = arrayListOf<Book>()
|
val newBooks = arrayListOf<Book>()
|
||||||
|
val ignoreLocalBook = BackupConfig.ignoreLocalBook
|
||||||
it.forEach { book ->
|
it.forEach { book ->
|
||||||
|
if (ignoreLocalBook && book.isLocal) {
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
if (appDb.bookDao.has(book.bookUrl) == true) {
|
if (appDb.bookDao.has(book.bookUrl) == true) {
|
||||||
updateBooks.add(book)
|
updateBooks.add(book)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ import kotlinx.coroutines.ensureActive
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import kotlin.collections.set
|
|
||||||
import kotlin.coroutines.coroutineContext
|
import kotlin.coroutines.coroutineContext
|
||||||
|
|
||||||
class BackupConfigFragment : PreferenceFragment(),
|
class BackupConfigFragment : PreferenceFragment(),
|
||||||
|
|||||||
@@ -1176,4 +1176,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1179,4 +1179,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1179,4 +1179,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</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_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1176,4 +1176,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1178,4 +1178,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1178,4 +1178,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1179,4 +1179,5 @@
|
|||||||
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
|
||||||
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
|
||||||
<string name="show_same_source">显示重复书源</string>
|
<string name="show_same_source">显示重复书源</string>
|
||||||
|
<string name="theme_config">主题配置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user