Skip to content

Commit

Permalink
Merge pull request #7469 from thunderbird/fix_notification_preferences
Browse files Browse the repository at this point in the history
Update notification preferences when fragment is created
  • Loading branch information
cketti authored Jan 3, 2024
2 parents 1847e19 + da8a762 commit c11ed93
Showing 1 changed file with 4 additions and 12 deletions.
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

0 comments on commit c11ed93

Please sign in to comment.