From cabb6d494d415dea953a611462de44fb8d94c695 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 27 Sep 2022 15:09:33 +0200 Subject: [PATCH] Cleaning. --- .../android/HomeActivity.kt | 1 - .../android/LoginActivity.kt | 2 +- .../android/settings/SettingsActivity.kt | 7 +++- .../src/main/res/values-ca-rES/strings.xml | 4 +++ .../src/main/res/values-de-rDE/strings.xml | 4 +++ .../src/main/res/values-es-rES/strings.xml | 4 +++ .../src/main/res/values-fa-rIR/strings.xml | 4 +++ .../src/main/res/values-fr-rFR/strings.xml | 4 +++ .../src/main/res/values-gl-rES/strings.xml | 4 +++ .../src/main/res/values-in-rID/strings.xml | 4 +++ .../src/main/res/values-it-rIT/strings.xml | 4 +++ .../src/main/res/values-ko-rKR/strings.xml | 4 +++ .../src/main/res/values-nl-rNL/strings.xml | 4 +++ .../src/main/res/values-pt-rBR/strings.xml | 4 +++ .../src/main/res/values-pt-rPT/strings.xml | 4 +++ .../src/main/res/values-si-rLK/strings.xml | 4 +++ .../src/main/res/values-tr-rTR/strings.xml | 4 +++ .../src/main/res/values-zh-rCN/strings.xml | 4 +++ .../src/main/res/values-zh-rTW/strings.xml | 4 +++ .../src/main/res/values/mode_settings.xml | 32 +++++++++++++++++++ androidApp/src/main/res/values/strings.xml | 4 +++ androidApp/src/main/res/xml/pref_theme.xml | 12 ++++--- .../service/AppSettingsService.kt | 13 -------- 23 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 androidApp/src/main/res/values/mode_settings.xml diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index c0f222e..87828ad 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -92,7 +92,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar private val settingsLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { appSettingsService.refreshUserSettings() - AppCompatDelegate.setDefaultNightMode(if (appSettingsService.isDarkThemeEnabled()) MODE_NIGHT_YES else MODE_NIGHT_NO) } override val di by closestDI() diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt index ef790bf..880b3d1 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt @@ -38,7 +38,7 @@ class LoginActivity : AppCompatActivity(), DIAware { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - AppCompatDelegate.setDefaultNightMode(if (appSettingsService.isDarkThemeEnabled()) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO) + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO) binding = ActivityLoginBinding.inflate(layoutInflater) val view = binding.root diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt index c37f782..a99ce0e 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt @@ -9,6 +9,7 @@ import android.text.InputType import android.text.TextWatcher import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.app.AppCompatDelegate import androidx.core.widget.addTextChangedListener import androidx.preference.EditTextPreference import androidx.preference.Preference @@ -155,7 +156,11 @@ class SettingsActivity : AppCompatActivity(), class ThemePreferenceFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.pref_theme, rootKey) - setHasOptionsMenu(true) + + preferenceManager.findPreference("currentMode")?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> + AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯ + true + } } } diff --git a/androidApp/src/main/res/values-ca-rES/strings.xml b/androidApp/src/main/res/values-ca-rES/strings.xml index a1cc9d2..6a54c8e 100644 --- a/androidApp/src/main/res/values-ca-rES/strings.xml +++ b/androidApp/src/main/res/values-ca-rES/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index caf8a5b..1a89c3c 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index 43661d4..0121995 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index efbceb6..f17cb56 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index e3b366c..7d9d0b9 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -128,4 +128,8 @@ La barre sera affichée La barre sera affichée grâce au bouton Supprimer la source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index f4d819a..7546b5c 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -128,4 +128,8 @@ A barra inferior mostrarase sempre A barra inferior pode mostrarse a través do botón flotante Eliminar fonte + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index c4a9e94..8ef98dc 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index 041f602..c59e06a 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index 5478b18..05880da 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-nl-rNL/strings.xml b/androidApp/src/main/res/values-nl-rNL/strings.xml index e4a0120..00d6e3a 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index 045f660..832641f 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index c090915..4703ba3 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index 664f42d..d5e15cc 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index 2f8b4c3..a2c19ea 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index fafa455..6177dff 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -128,4 +128,8 @@ 底部栏将始终显示 底部栏可以通过浮动按钮显示 删除源 + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index 3fc4874..ac911c8 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -128,4 +128,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Light mode + Dark mode + Follow the system setting diff --git a/androidApp/src/main/res/values/mode_settings.xml b/androidApp/src/main/res/values/mode_settings.xml new file mode 100644 index 0000000..ca41323 --- /dev/null +++ b/androidApp/src/main/res/values/mode_settings.xml @@ -0,0 +1,32 @@ + + + + @string/mode_light + @string/mode_dark + @string/mode_system + + + + 1 + 2 + 0 + + + + Male + Female + + + + "usenglishmale" + "usenglishfemale" + "ukenglishmale" + "ukenglishfemale" + "eurfrenchmale" + "eurfrenchfemale" + "eurspanishmale" + "eurspanishfemale" + "euritalianmale" + "euritalianfemale" + + \ No newline at end of file diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 6f03a6f..86978a0 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -130,4 +130,8 @@ The bottom bar will always be displayed The bottom bar can be shown through the floating button Remove source + Light/Dark mode + Dark mode + Follow the system setting + Light mode diff --git a/androidApp/src/main/res/xml/pref_theme.xml b/androidApp/src/main/res/xml/pref_theme.xml index 01b6c83..5a6ea0b 100644 --- a/androidApp/src/main/res/xml/pref_theme.xml +++ b/androidApp/src/main/res/xml/pref_theme.xml @@ -1,11 +1,13 @@ - - + android:title="@string/pref_theme_title" + app:useSimpleSummaryProvider="false" /> \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt index cba25f9..8a28a23 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/AppSettingsService.kt @@ -34,7 +34,6 @@ class AppSettingsService { private var _fontSize: Int? = null private var _staticBar: Boolean? = null - private var _darkTheme: Boolean? = null private var _font: String = "" @@ -308,17 +307,6 @@ class AppSettingsService { return _staticBar == true } - private fun refreshDarkThemeEnabled() { - _darkTheme = settings.getBoolean("dark_theme", false) - } - - fun isDarkThemeEnabled(): Boolean { - if (_darkTheme != null) { - refreshDarkThemeEnabled() - } - return _darkTheme == true - } - private fun refreshFont() { _font = settings.getString("reader_font", "") } @@ -358,7 +346,6 @@ class AppSettingsService { refreshFontSize() refreshFont() refreshStaticBarEnabled() - refreshDarkThemeEnabled() } fun refreshLoginInformation(