|
|
@ -25,19 +25,32 @@ import org.jetbrains.anko.defaultSharedPreferences |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
object Restore { |
|
|
|
object Restore { |
|
|
|
private val ignoreConfigPath = |
|
|
|
private val ignoreConfigPath = FileUtils.getPath(App.INSTANCE.filesDir, "restoreIgnore.json") |
|
|
|
App.INSTANCE.filesDir.absolutePath + File.separator + "restoreIgnore.json" |
|
|
|
|
|
|
|
val ignoreConfig: HashMap<String, Boolean> by lazy { |
|
|
|
val ignoreConfig: HashMap<String, Boolean> by lazy { |
|
|
|
val file = FileUtils.createFileIfNotExist(ignoreConfigPath) |
|
|
|
val file = FileUtils.createFileIfNotExist(ignoreConfigPath) |
|
|
|
val json = file.readText() |
|
|
|
val json = file.readText() |
|
|
|
GSON.fromJsonObject<HashMap<String, Boolean>>(json) ?: hashMapOf() |
|
|
|
GSON.fromJsonObject<HashMap<String, Boolean>>(json) ?: hashMapOf() |
|
|
|
} |
|
|
|
} |
|
|
|
val ignoreKeys = arrayOf("readConfig", "themeMode") |
|
|
|
|
|
|
|
|
|
|
|
//忽略key |
|
|
|
|
|
|
|
val ignoreKeys = arrayOf( |
|
|
|
|
|
|
|
"readConfig", |
|
|
|
|
|
|
|
PreferKey.themeMode, |
|
|
|
|
|
|
|
PreferKey.bookshelfLayout |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//忽略标题 |
|
|
|
val ignoreTitle = arrayOf( |
|
|
|
val ignoreTitle = arrayOf( |
|
|
|
App.INSTANCE.getString(R.string.read_config), |
|
|
|
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( |
|
|
|
private val readPrefKeys = arrayOf( |
|
|
|
PreferKey.readStyleSelect, |
|
|
|
PreferKey.readStyleSelect, |
|
|
|
PreferKey.shareLayout, |
|
|
|
PreferKey.shareLayout, |
|
|
@ -173,12 +186,17 @@ object Restore { |
|
|
|
ignorePrefKeys.contains(key) -> false |
|
|
|
ignorePrefKeys.contains(key) -> false |
|
|
|
readPrefKeys.contains(key) && ignoreReadConfig -> false |
|
|
|
readPrefKeys.contains(key) && ignoreReadConfig -> false |
|
|
|
PreferKey.themeMode == key && ignoreThemeMode -> false |
|
|
|
PreferKey.themeMode == key && ignoreThemeMode -> false |
|
|
|
|
|
|
|
PreferKey.bookshelfLayout == key && ignoreBookshelfLayout -> false |
|
|
|
else -> true |
|
|
|
else -> true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val ignoreReadConfig: Boolean get() = ignoreConfig["readConfig"] == true |
|
|
|
private val ignoreReadConfig: Boolean |
|
|
|
private val ignoreThemeMode: Boolean get() = ignoreConfig["themeMode"] == true |
|
|
|
get() = ignoreConfig["readConfig"] == true |
|
|
|
|
|
|
|
private val ignoreThemeMode: Boolean |
|
|
|
|
|
|
|
get() = ignoreConfig[PreferKey.themeMode] == true |
|
|
|
|
|
|
|
private val ignoreBookshelfLayout: Boolean |
|
|
|
|
|
|
|
get() = ignoreConfig[PreferKey.bookshelfLayout] == true |
|
|
|
|
|
|
|
|
|
|
|
fun saveIgnoreConfig() { |
|
|
|
fun saveIgnoreConfig() { |
|
|
|
val json = GSON.toJson(ignoreConfig) |
|
|
|
val json = GSON.toJson(ignoreConfig) |
|
|
|