Skip to content

Commit f2fc2cc

Browse files
committed
Check whether to enable New streams settings in onCreate to prevent flickering
1 parent 0a2fc08 commit f2fc2cc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/settings/NotificationsSettingsFragment.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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(

0 commit comments

Comments
 (0)