mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 00:20:32 +00:00
Merge pull request #8233 from Stypox/fix-notification-settings-2
Fix new streams notifications preference screen
This commit is contained in:
commit
5c6e2ed071
@ -26,6 +26,10 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
|
|||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
addPreferencesFromResource(R.xml.notifications_settings)
|
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() {
|
override fun onStart() {
|
||||||
@ -64,7 +68,7 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
|
|||||||
// If they are disabled, show a snackbar informing the user about that
|
// If they are disabled, show a snackbar informing the user about that
|
||||||
// while allowing them to open the device's app settings.
|
// while allowing them to open the device's app settings.
|
||||||
val enabled = NotificationHelper.areNotificationsEnabledOnDevice(requireContext())
|
val enabled = NotificationHelper.areNotificationsEnabledOnDevice(requireContext())
|
||||||
preferenceScreen.isEnabled = enabled
|
preferenceScreen.isEnabled = enabled // it is disabled by default, see the xml
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
if (notificationWarningSnackbar == null) {
|
if (notificationWarningSnackbar == null) {
|
||||||
notificationWarningSnackbar = Snackbar.make(
|
notificationWarningSnackbar = Snackbar.make(
|
||||||
@ -85,9 +89,6 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
|
|||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
notificationWarningSnackbar?.dismiss()
|
|
||||||
notificationWarningSnackbar = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Re-)Create loader
|
// (Re-)Create loader
|
||||||
@ -102,6 +103,9 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
|
|||||||
loader?.dispose()
|
loader?.dispose()
|
||||||
loader = null
|
loader = null
|
||||||
|
|
||||||
|
notificationWarningSnackbar?.dismiss()
|
||||||
|
notificationWarningSnackbar = null
|
||||||
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user