Check whether to enable New streams settings in onCreate to prevent flickering

This commit is contained in:
Stypox 2022-04-16 18:57:02 +02:00
parent 0a2fc08706
commit f2fc2cc24a
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,10 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.notifications_settings)
// main check is done in onResume, but also do it here to prevent flickering
preferenceScreen.isEnabled =
NotificationHelper.areNotificationsEnabledOnDevice(requireContext())
}
override fun onStart() {
@ -64,7 +68,7 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
// If they are disabled, show a snackbar informing the user about that
// while allowing them to open the device's app settings.
val enabled = NotificationHelper.areNotificationsEnabledOnDevice(requireContext())
preferenceScreen.isEnabled = enabled
preferenceScreen.isEnabled = enabled // it is disabled by default, see the xml
if (!enabled) {
if (notificationWarningSnackbar == null) {
notificationWarningSnackbar = Snackbar.make(