Skip to content

Commit

Permalink
Disable widget opacity on unsupported color scheme
Browse files Browse the repository at this point in the history
The dynamic widget color scheme does not support opacity, so inform the user by
disabling the setting input.
  • Loading branch information
Riyyi committed Nov 4, 2023
1 parent 63b81eb commit cfbbbc7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP

/* Update preferences which depend on multiple others. */
updateRemindersScreen()
updateWidgetScreen()
}

private fun setupVersionPreference() {
Expand Down Expand Up @@ -326,6 +327,7 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
}

updateRemindersScreen()
updateWidgetScreen()

/* Always notify about possibly changed data, if settings are modified.
*
Expand Down Expand Up @@ -363,6 +365,16 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
}
}

private fun updateWidgetScreen() {
val colorScheme = preference(R.string.pref_key_widget_color_scheme)

if (colorScheme != null) {
/* Widget opacity isn't supported on the dynamic color scheme. */
val opacityEnabled = (colorScheme as ListPreference).value != "dynamic"
preference(R.string.pref_key_widget_opacity)?.isEnabled = opacityEnabled
}
}

/**
* Update list of possible states that can be used as default for a new note.
*/
Expand Down

0 comments on commit cfbbbc7

Please sign in to comment.