Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notification preferences when fragment is created #7469

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,14 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
findPreference<NotificationSoundPreference>(PREFERENCE_NOTIFICATION_SOUND)?.let { preference ->
notificationSoundPreference = preference
preference.isEnabled = false
}

findPreference<ListPreference>(PREFERENCE_NOTIFICATION_LIGHT)?.let { preference ->
notificationLightPreference = preference
preference.isEnabled = false
}

findPreference<VibrationPreference>(PREFERENCE_NOTIFICATION_VIBRATION)?.let { preference ->
notificationVibrationPreference = preference
preference.isEnabled = false
}

findPreference<NotificationsPreference>(PREFERENCE_NOTIFICATION_SETTINGS_MESSAGES)?.let {
Expand All @@ -232,6 +229,8 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr
notificationChannelManager.getChannelIdFor(account, ChannelType.MISCELLANEOUS)
}
}

updateNotificationPreferences(account)
} else {
findPreference<PreferenceCategory>(PREFERENCE_NOTIFICATION_CHANNELS).remove()
}
Expand All @@ -251,15 +250,9 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr
notificationSettingsUpdater.updateNotificationSettings(account)
val notificationSettings = account.notificationSettings

notificationSoundPreference?.let { preference ->
preference.setNotificationSound(notificationSettings.ringtone?.toUri())
preference.isEnabled = true
}
notificationSoundPreference?.setNotificationSound(notificationSettings.ringtone?.toUri())

notificationLightPreference?.let { preference ->
preference.value = notificationSettings.light.name
preference.isEnabled = true
}
notificationLightPreference?.value = notificationSettings.light.name

notificationVibrationPreference?.let { preference ->
val notificationVibration = notificationSettings.vibration
Expand All @@ -268,7 +261,6 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr
vibratePattern = notificationVibration.pattern,
vibrationTimes = notificationVibration.repeatCount,
)
preference.isEnabled = true
}
}

Expand Down