@@ -26,6 +26,10 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
2626
2727 override fun onCreatePreferences (savedInstanceState : Bundle ? , rootKey : String? ) {
2828 addPreferencesFromResource(R .xml.notifications_settings)
29+
30+ // main check is done in onResume, but also do it here to prevent flickering
31+ preferenceScreen.isEnabled =
32+ NotificationHelper .areNotificationsEnabledOnDevice(requireContext())
2933 }
3034
3135 override fun onStart () {
@@ -64,7 +68,7 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
6468 // If they are disabled, show a snackbar informing the user about that
6569 // while allowing them to open the device's app settings.
6670 val enabled = NotificationHelper .areNotificationsEnabledOnDevice(requireContext())
67- preferenceScreen.isEnabled = enabled
71+ preferenceScreen.isEnabled = enabled // it is disabled by default, see the xml
6872 if (! enabled) {
6973 if (notificationWarningSnackbar == null ) {
7074 notificationWarningSnackbar = Snackbar .make(
@@ -85,9 +89,6 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
8589 show()
8690 }
8791 }
88- } else {
89- notificationWarningSnackbar?.dismiss()
90- notificationWarningSnackbar = null
9192 }
9293
9394 // (Re-)Create loader
@@ -102,6 +103,9 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
102103 loader?.dispose()
103104 loader = null
104105
106+ notificationWarningSnackbar?.dismiss()
107+ notificationWarningSnackbar = null
108+
105109 super .onPause()
106110 }
107111
0 commit comments