|
|
|
@ -33,6 +33,16 @@ object Restore { |
|
|
|
|
} |
|
|
|
|
val ignoreKeys = arrayOf("readConfig") |
|
|
|
|
val ignoreTitle = arrayOf("阅读界面设置") |
|
|
|
|
private val ignorePrefKeys = arrayOf(PreferKey.versionCode, PreferKey.defaultCover) |
|
|
|
|
private val readPrefKeys = arrayOf( |
|
|
|
|
PreferKey.readStyleSelect, |
|
|
|
|
PreferKey.shareLayout, |
|
|
|
|
PreferKey.pageAnim, |
|
|
|
|
PreferKey.hideStatusBar, |
|
|
|
|
PreferKey.hideNavigationBar, |
|
|
|
|
PreferKey.bodyIndent, |
|
|
|
|
PreferKey.autoReadSpeed |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
val jsonPath: ParseContext by lazy { |
|
|
|
|
JsonPath.using( |
|
|
|
@ -102,6 +112,7 @@ object Restore { |
|
|
|
|
|
|
|
|
|
suspend fun restoreConfig(path: String = Backup.backupPath) { |
|
|
|
|
withContext(IO) { |
|
|
|
|
if (!ignoreReadConfig) { |
|
|
|
|
try { |
|
|
|
|
val file = |
|
|
|
|
FileUtils.createFileIfNotExist(path + File.separator + ReadBookConfig.readConfigFileName) |
|
|
|
@ -114,12 +125,14 @@ object Restore { |
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
e.printStackTrace() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Preferences.getSharedPreferences(App.INSTANCE, path, "config")?.all |
|
|
|
|
?.let { map -> |
|
|
|
|
val ignoreKeys = arrayOf(PreferKey.versionCode, PreferKey.defaultCover) |
|
|
|
|
val edit = App.INSTANCE.defaultSharedPreferences.edit() |
|
|
|
|
map.forEach { |
|
|
|
|
if (!ignoreKeys.contains(it.key)) { |
|
|
|
|
if (!ignorePrefKeys.contains(it.key) |
|
|
|
|
&& !(readPrefKeys.contains(it.key) && ignoreReadConfig) |
|
|
|
|
) { |
|
|
|
|
when (val value = it.value) { |
|
|
|
|
is Int -> edit.putInt(it.key, value) |
|
|
|
|
is Boolean -> edit.putBoolean(it.key, value) |
|
|
|
@ -153,6 +166,8 @@ object Restore { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val ignoreReadConfig: Boolean get() = ignoreConfig["readConfig"] == true |
|
|
|
|
|
|
|
|
|
fun saveIgnoreConfig() { |
|
|
|
|
val json = GSON.toJson(ignoreConfig) |
|
|
|
|
FileUtils.createFileIfNotExist(ignoreConfigPath).writeText(json) |
|
|
|
|