Cleaning.
This commit is contained in:
parent
5c12481813
commit
cabb6d494d
@ -92,7 +92,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
|
|
||||||
private val settingsLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
private val settingsLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
appSettingsService.refreshUserSettings()
|
appSettingsService.refreshUserSettings()
|
||||||
AppCompatDelegate.setDefaultNightMode(if (appSettingsService.isDarkThemeEnabled()) MODE_NIGHT_YES else MODE_NIGHT_NO)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val di by closestDI()
|
override val di by closestDI()
|
||||||
|
@ -38,7 +38,7 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
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)
|
binding = ActivityLoginBinding.inflate(layoutInflater)
|
||||||
val view = binding.root
|
val view = binding.root
|
||||||
|
@ -9,6 +9,7 @@ import android.text.InputType
|
|||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
@ -155,7 +156,11 @@ class SettingsActivity : AppCompatActivity(),
|
|||||||
class ThemePreferenceFragment : PreferenceFragmentCompat() {
|
class ThemePreferenceFragment : PreferenceFragmentCompat() {
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.pref_theme, rootKey)
|
setPreferencesFromResource(R.xml.pref_theme, rootKey)
|
||||||
setHasOptionsMenu(true)
|
|
||||||
|
preferenceManager.findPreference<Preference>("currentMode")?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
|
AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">La barre sera affichée</string>
|
<string name="reader_static_bar_on">La barre sera affichée</string>
|
||||||
<string name="reader_static_bar_off">La barre sera affichée grâce au bouton</string>
|
<string name="reader_static_bar_off">La barre sera affichée grâce au bouton</string>
|
||||||
<string name="remove_source">Supprimer la source</string>
|
<string name="remove_source">Supprimer la source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">A barra inferior mostrarase sempre</string>
|
<string name="reader_static_bar_on">A barra inferior mostrarase sempre</string>
|
||||||
<string name="reader_static_bar_off">A barra inferior pode mostrarse a través do botón flotante</string>
|
<string name="reader_static_bar_off">A barra inferior pode mostrarse a través do botón flotante</string>
|
||||||
<string name="remove_source">Eliminar fonte</string>
|
<string name="remove_source">Eliminar fonte</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">底部栏将始终显示</string>
|
<string name="reader_static_bar_on">底部栏将始终显示</string>
|
||||||
<string name="reader_static_bar_off">底部栏可以通过浮动按钮显示</string>
|
<string name="reader_static_bar_off">底部栏可以通过浮动按钮显示</string>
|
||||||
<string name="remove_source">删除源</string>
|
<string name="remove_source">删除源</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -128,4 +128,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
32
androidApp/src/main/res/values/mode_settings.xml
Normal file
32
androidApp/src/main/res/values/mode_settings.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string-array name="ModeTitles">
|
||||||
|
<item>@string/mode_light</item>
|
||||||
|
<item>@string/mode_dark</item>
|
||||||
|
<item>@string/mode_system</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="ModeValues">
|
||||||
|
<item>1</item> <!--MODE_NIGHT_NO-->
|
||||||
|
<item>2</item> <!--MODE_NIGHT_YES-->
|
||||||
|
<item>0</item> <!--MODE_NIGHT_AUTO_TIME-->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="Voice">
|
||||||
|
<item>Male</item>
|
||||||
|
<item>Female</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="VoiceAlias">
|
||||||
|
<item>"usenglishmale"</item>
|
||||||
|
<item>"usenglishfemale"</item>
|
||||||
|
<item>"ukenglishmale"</item>
|
||||||
|
<item>"ukenglishfemale"</item>
|
||||||
|
<item>"eurfrenchmale"</item>
|
||||||
|
<item>"eurfrenchfemale"</item>
|
||||||
|
<item>"eurspanishmale"</item>
|
||||||
|
<item>"eurspanishfemale"</item>
|
||||||
|
<item>"euritalianmale"</item>
|
||||||
|
<item>"euritalianfemale"</item>
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
@ -130,4 +130,8 @@
|
|||||||
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
<string name="reader_static_bar_on">The bottom bar will always be displayed</string>
|
||||||
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
<string name="reader_static_bar_off">The bottom bar can be shown through the floating button</string>
|
||||||
<string name="remove_source">Remove source</string>
|
<string name="remove_source">Remove source</string>
|
||||||
|
<string name="pref_theme_title">Light/Dark mode</string>
|
||||||
|
<string name="mode_dark">Dark mode</string>
|
||||||
|
<string name="mode_system">Follow the system setting</string>
|
||||||
|
<string name="mode_light">Light mode</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<!-- TODO translate this file -->
|
|
||||||
|
|
||||||
<SwitchPreference
|
<ListPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="0"
|
||||||
android:key="dark_theme"
|
android:entries="@array/ModeTitles"
|
||||||
|
android:entryValues="@array/ModeValues"
|
||||||
|
android:key="currentMode"
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
android:title="Dark theme" />
|
android:title="@string/pref_theme_title"
|
||||||
|
app:useSimpleSummaryProvider="false" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -34,7 +34,6 @@ class AppSettingsService {
|
|||||||
|
|
||||||
private var _fontSize: Int? = null
|
private var _fontSize: Int? = null
|
||||||
private var _staticBar: Boolean? = null
|
private var _staticBar: Boolean? = null
|
||||||
private var _darkTheme: Boolean? = null
|
|
||||||
private var _font: String = ""
|
private var _font: String = ""
|
||||||
|
|
||||||
|
|
||||||
@ -308,17 +307,6 @@ class AppSettingsService {
|
|||||||
return _staticBar == true
|
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() {
|
private fun refreshFont() {
|
||||||
_font = settings.getString("reader_font", "")
|
_font = settings.getString("reader_font", "")
|
||||||
}
|
}
|
||||||
@ -358,7 +346,6 @@ class AppSettingsService {
|
|||||||
refreshFontSize()
|
refreshFontSize()
|
||||||
refreshFont()
|
refreshFont()
|
||||||
refreshStaticBarEnabled()
|
refreshStaticBarEnabled()
|
||||||
refreshDarkThemeEnabled()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshLoginInformation(
|
fun refreshLoginInformation(
|
||||||
|
Loading…
Reference in New Issue
Block a user