From 76aec33fb4b2d4feab7f9b76f571131634f345d6 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 21 Jul 2020 08:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/help/storage/Restore.kt | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) 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 0708dfe67..f3d56c214 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 @@ -25,19 +25,32 @@ import org.jetbrains.anko.defaultSharedPreferences import java.io.File object Restore { - private val ignoreConfigPath = - App.INSTANCE.filesDir.absolutePath + File.separator + "restoreIgnore.json" + private val ignoreConfigPath = FileUtils.getPath(App.INSTANCE.filesDir, "restoreIgnore.json") val ignoreConfig: HashMap by lazy { val file = FileUtils.createFileIfNotExist(ignoreConfigPath) val json = file.readText() GSON.fromJsonObject>(json) ?: hashMapOf() } - val ignoreKeys = arrayOf("readConfig", "themeMode") + + //忽略key + val ignoreKeys = arrayOf( + "readConfig", + PreferKey.themeMode, + PreferKey.bookshelfLayout + ) + + //忽略标题 val ignoreTitle = arrayOf( App.INSTANCE.getString(R.string.read_config), - App.INSTANCE.getString(R.string.theme_mode) + App.INSTANCE.getString(R.string.theme_mode), + App.INSTANCE.getString(R.string.bookshelf_layout) + ) + + //默认忽略keys + private val ignorePrefKeys = arrayOf( + PreferKey.versionCode, + PreferKey.defaultCover ) - private val ignorePrefKeys = arrayOf(PreferKey.versionCode, PreferKey.defaultCover) private val readPrefKeys = arrayOf( PreferKey.readStyleSelect, PreferKey.shareLayout, @@ -173,12 +186,17 @@ object Restore { ignorePrefKeys.contains(key) -> false readPrefKeys.contains(key) && ignoreReadConfig -> false PreferKey.themeMode == key && ignoreThemeMode -> false + PreferKey.bookshelfLayout == key && ignoreBookshelfLayout -> false else -> true } } - private val ignoreReadConfig: Boolean get() = ignoreConfig["readConfig"] == true - private val ignoreThemeMode: Boolean get() = ignoreConfig["themeMode"] == true + private val ignoreReadConfig: Boolean + get() = ignoreConfig["readConfig"] == true + private val ignoreThemeMode: Boolean + get() = ignoreConfig[PreferKey.themeMode] == true + private val ignoreBookshelfLayout: Boolean + get() = ignoreConfig[PreferKey.bookshelfLayout] == true fun saveIgnoreConfig() { val json = GSON.toJson(ignoreConfig)