Use the preference value to render the push notifications toggle
This commit is contained in:
parent
2941cfa329
commit
67d2a6faab
@ -120,31 +120,25 @@ class VectorSettingsNotificationPreferenceFragment :
|
|||||||
(pref as SwitchPreference).isChecked = areNotifEnabledAtAccountLevel
|
(pref as SwitchPreference).isChecked = areNotifEnabledAtAccountLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)?.let {
|
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
||||||
pushersManager.getPusherForCurrentSession()?.let { pusher ->
|
?.setTransactionalSwitchChangeListener(lifecycleScope) { isChecked ->
|
||||||
it.isChecked = pusher.enabled
|
if (isChecked) {
|
||||||
}
|
enableNotificationsForCurrentSessionUseCase.execute(requireActivity())
|
||||||
|
|
||||||
it.setTransactionalSwitchChangeListener(lifecycleScope) { isChecked ->
|
findPreference<VectorPreference>(VectorPreferences.SETTINGS_NOTIFICATION_METHOD_KEY)
|
||||||
if (isChecked) {
|
?.summary = unifiedPushHelper.getCurrentDistributorName()
|
||||||
enableNotificationsForCurrentSessionUseCase.execute(requireActivity())
|
|
||||||
|
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_NOTIFICATION_METHOD_KEY)
|
notificationPermissionManager.eventuallyRequestPermission(
|
||||||
?.summary = unifiedPushHelper.getCurrentDistributorName()
|
requireActivity(),
|
||||||
|
postPermissionLauncher,
|
||||||
// TODO test with API 33
|
showRationale = false,
|
||||||
notificationPermissionManager.eventuallyRequestPermission(
|
ignorePreference = true
|
||||||
requireActivity(),
|
)
|
||||||
postPermissionLauncher,
|
} else {
|
||||||
showRationale = false,
|
disableNotificationsForCurrentSessionUseCase.execute()
|
||||||
ignorePreference = true
|
notificationPermissionManager.eventuallyRevokePermission(requireActivity())
|
||||||
)
|
}
|
||||||
} else {
|
|
||||||
disableNotificationsForCurrentSessionUseCase.execute()
|
|
||||||
notificationPermissionManager.eventuallyRevokePermission(requireActivity())
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_FDROID_BACKGROUND_SYNC_MODE)?.let {
|
findPreference<VectorPreference>(VectorPreferences.SETTINGS_FDROID_BACKGROUND_SYNC_MODE)?.let {
|
||||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
|
Loading…
Reference in New Issue
Block a user