mirror of
https://github.com/mediathekview/zapp.git
synced 2024-09-20 04:12:14 +02:00
Fix dynamic colors not being applied in release build
This commit is contained in:
parent
fd803f2b6d
commit
3513ceeeb5
@ -43,8 +43,17 @@ class SettingsRepository(context: Context) {
|
||||
val downloadToSdCard: Boolean
|
||||
get() = preferences.getBoolean(context.getString(R.string.pref_key_download_to_sd_card), true)
|
||||
|
||||
val dynamicColors: Boolean
|
||||
var dynamicColors: Boolean
|
||||
get() = preferences.getBoolean(context.getString(R.string.pref_key_dynamic_colors), false)
|
||||
@SuppressLint("ApplySharedPref")
|
||||
set(enabled) {
|
||||
// "commit" instead of "apply" is fine here, because we need to restart the app
|
||||
// after setting this preference. Doing it synchroniously is the only way to save
|
||||
// the setting across the app restart.
|
||||
preferences.edit()
|
||||
.putBoolean(context.getString(R.string.pref_key_dynamic_colors), enabled)
|
||||
.commit()
|
||||
}
|
||||
|
||||
val uiMode: Int
|
||||
get() {
|
||||
|
@ -72,7 +72,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
// only show the preference for dynamic colors when available (Android 12 and up)
|
||||
dynamicColorsPreference.isVisible = DynamicColors.isDynamicColorAvailable()
|
||||
dynamicColorsPreference.setOnPreferenceChangeListener { _, _ ->
|
||||
dynamicColorsPreference.setOnPreferenceChangeListener { _, useDynamicColors ->
|
||||
// save explicitly to persist before app restart
|
||||
settingsRepository.dynamicColors = useDynamicColors as Boolean
|
||||
// app restart
|
||||
ProcessPhoenix.triggerRebirth(context)
|
||||
true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user