mirror of
https://github.com/Michatec/Radio.git
synced 2026-04-01 16:06:27 +02:00
feat(ui): save theme selection to preferences
This commit is contained in:
@@ -8,6 +8,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.Keys
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.helpers.AppThemeHelper
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
|
||||
|
||||
/*
|
||||
@@ -85,10 +86,10 @@ class ThemeSelectionDialog(private var themeSelectionDialogListener: ThemeSelect
|
||||
R.id.radio_theme_dark -> Keys.STATE_THEME_DARK_MODE
|
||||
else -> Keys.STATE_THEME_FOLLOW_SYSTEM
|
||||
}
|
||||
// save theme selection to preferences
|
||||
PreferencesHelper.saveThemeSelection(selectedTheme)
|
||||
// apply theme immediately
|
||||
AppThemeHelper.setTheme(selectedTheme)
|
||||
// update radio buttons to reflect new theme
|
||||
updateRadioButtons(context, radioFollowSystem, radioLight, radioDark)
|
||||
// notify listener
|
||||
themeSelectionDialogListener.onThemeSelectionDialog(true, selectedTheme)
|
||||
// dismiss dialog
|
||||
|
||||
@@ -223,6 +223,14 @@ object PreferencesHelper {
|
||||
}
|
||||
|
||||
|
||||
/* Save currently selected app theme */
|
||||
fun saveThemeSelection(theme: String) {
|
||||
sharedPreferences.edit {
|
||||
putString(Keys.PREF_THEME_SELECTION, theme)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Loads value of the option: Edit Stations */
|
||||
fun loadEditStationsEnabled(context: Context): Boolean {
|
||||
val defaultValue = !context.packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
|
||||
|
||||
Reference in New Issue
Block a user