From 9c6610bd6ebf99bf18ae16bb427892db8ae6367a Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 7 Aug 2020 13:59:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96,=E6=B7=BB=E5=8A=A0=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E5=87=80=E5=8C=96=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20=E4=B8=BB=E9=A2=98=E8=89=B2=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/help/storage/Restore.kt | 30 ++++++++++--------- .../app/ui/config/OtherConfigFragment.kt | 2 ++ .../legado/app/ui/filechooser/FilePicker.kt | 9 +++--- 3 files changed, 23 insertions(+), 18 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 7494bb453..bed5cd7ce 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 @@ -13,6 +13,7 @@ import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.* +import io.legado.app.help.AppConfig import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ReadBookConfig import io.legado.app.service.help.ReadBook @@ -146,23 +147,24 @@ object Restore { e.printStackTrace() } } - Preferences.getSharedPreferences(App.INSTANCE, path, "config")?.all - ?.let { map -> - val edit = App.INSTANCE.defaultSharedPreferences.edit() - map.forEach { - if (keyIsNotIgnore(it.key)) { - when (val value = it.value) { - is Int -> edit.putInt(it.key, value) - is Boolean -> edit.putBoolean(it.key, value) - is Long -> edit.putLong(it.key, value) - is Float -> edit.putFloat(it.key, value) - is String -> edit.putString(it.key, value) - else -> Unit - } + Preferences.getSharedPreferences(App.INSTANCE, path, "config")?.all?.let { map -> + val edit = App.INSTANCE.defaultSharedPreferences.edit() + map.forEach { + if (keyIsNotIgnore(it.key)) { + when (val value = it.value) { + is Int -> edit.putInt(it.key, value) + is Boolean -> edit.putBoolean(it.key, value) + is Long -> edit.putLong(it.key, value) + is Float -> edit.putFloat(it.key, value) + is String -> edit.putString(it.key, value) + else -> Unit } } - edit.apply() } + edit.apply() + AppConfig.replaceEnableDefault = + App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true) + } ReadBookConfig.apply { styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 0f8cfc8b6..850ee8e39 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -114,6 +114,8 @@ class OtherConfigFragment : PreferenceFragmentCompat(), key, getPrefString(PreferKey.defaultCover) ) + PreferKey.replaceEnableDefault -> AppConfig.replaceEnableDefault = + App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true) } } diff --git a/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt b/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt index 0a5b5485d..1fd125a76 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt @@ -8,6 +8,7 @@ import io.legado.app.base.BaseActivity import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat import io.legado.app.lib.dialogs.alert +import io.legado.app.utils.applyTint import io.legado.app.utils.toast import org.jetbrains.anko.toast @@ -47,7 +48,7 @@ object FilePicker { } } } - }.show() + }.show().applyTint() } fun selectFolder( @@ -84,7 +85,7 @@ object FilePicker { } } } - }.show() + }.show().applyTint() } fun selectFile( @@ -124,7 +125,7 @@ object FilePicker { } } } - }.show() + }.show().applyTint() } fun selectFile( @@ -165,7 +166,7 @@ object FilePicker { } } } - }.show() + }.show().applyTint() } private fun createSelectFileIntent(): Intent {