From 9298638eada558e575d3bf6879bc5cf1e7c30f90 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 4 Mar 2020 22:24:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index de1f63ae1..06577d7c9 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -23,6 +23,7 @@ import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigViewModel import io.legado.app.ui.filechooser.FileChooserDialog import io.legado.app.ui.replacerule.ReplaceRuleActivity +import io.legado.app.ui.widget.prefs.NameListPreference import io.legado.app.ui.widget.prefs.SwitchPreference import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -74,6 +75,13 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. observeEvent(EventBus.WEB_SERVICE_STOP) { webServicePre?.isChecked = false } + findPreference(PreferKey.themeMode)?.let { + it.setOnPreferenceChangeListener { _, newValue -> + App.INSTANCE.putPrefString(PreferKey.themeMode, newValue.toString()) + App.INSTANCE.applyDayNight() + true + } + } } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -96,7 +104,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog. key: String? ) { when (key) { - PreferKey.themeMode -> App.INSTANCE.applyDayNight() PreferKey.webService -> { if (requireContext().getPrefBoolean("webService")) { WebService.start(requireContext())