diff --git a/Signal/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift b/Signal/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift index b5456febfc..54cc85a8c2 100644 --- a/Signal/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift +++ b/Signal/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift @@ -56,6 +56,7 @@ extension ConversationViewController: ConversationInputToolbarDelegate { if SSKEnvironment.shared.preferencesRef.soundInForeground, + SSKEnvironment.shared.preferencesRef.isMessageSentSoundEnabled, let soundId = Sounds.systemSoundIDForSound(.standard(.messageSent), quiet: true) { AudioServicesPlaySystemSound(soundId) diff --git a/Signal/src/ViewControllers/AppSettings/Notifications/NotificationSettingsViewController.swift b/Signal/src/ViewControllers/AppSettings/Notifications/NotificationSettingsViewController.swift index 77929f3ae5..8c30207b51 100644 --- a/Signal/src/ViewControllers/AppSettings/Notifications/NotificationSettingsViewController.swift +++ b/Signal/src/ViewControllers/AppSettings/Notifications/NotificationSettingsViewController.swift @@ -49,6 +49,15 @@ class NotificationSettingsViewController: OWSTableViewController2 { target: self, selector: #selector(didToggleSoundNotificationsSwitch), )) + soundsSection.add(.switch( + withText: OWSLocalizedString( + "SETTINGS_MESSAGE_SENT_SOUND", + comment: "Setting for enabling & disabling the sound effect played when a message is sent.", + ), + isOn: { SSKEnvironment.shared.preferencesRef.isMessageSentSoundEnabled }, + target: self, + selector: #selector(didToggleMessageSentSoundSwitch), + )) contents.add(soundsSection) let notificationContentSection = OWSTableSection() @@ -125,6 +134,11 @@ class NotificationSettingsViewController: OWSTableViewController2 { SSKEnvironment.shared.preferencesRef.setSoundInForeground(sender.isOn) } + @objc + private func didToggleMessageSentSoundSwitch(_ sender: UISwitch) { + SSKEnvironment.shared.preferencesRef.setIsMessageSentSoundEnabled(sender.isOn) + } + @objc private func didToggleIncludesMutedConversationsInBadgeCountSwitch(_ sender: UISwitch) { SSKEnvironment.shared.databaseStorageRef.write { tx in SSKPreferences.setIncludeMutedThreadsInBadgeCount(sender.isOn, transaction: tx) } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 05c15c6fe7..d670affde0 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -8473,6 +8473,9 @@ /* Label for the 'video' attachment type in the media download settings. */ "SETTINGS_MEDIA_DOWNLOAD_TYPE_VIDEO" = "Videos"; +/* Setting for enabling & disabling the sound effect played when a message is sent. */ +"SETTINGS_MESSAGE_SENT_SOUND" = "Message Sent Sound"; + /* Explanation for the 'messaging' privacy settings. */ "SETTINGS_MESSAGING_FOOTER" = "See and share when messages are being read and typed. If disabled, you won’t see read receipts or typing indicators from others."; diff --git a/SignalServiceKit/Util/Preferences.swift b/SignalServiceKit/Util/Preferences.swift index 4f6cafbd80..88738587d9 100644 --- a/SignalServiceKit/Util/Preferences.swift +++ b/SignalServiceKit/Util/Preferences.swift @@ -28,6 +28,7 @@ public class Preferences { case screenSecurity = "Screen Security Key" case notificationPreviewType = "Notification Preview Type Key" case playSoundInForeground = "NotificationSoundInForeground" + case messageSentSound = "MessageSentSound" case lastRecordedPushToken = "LastRecordedPushToken" case callsHideIPAddress = "CallsHideIPAddress" case hasDeclinedNoContactsView = "hasDeclinedNoContactsView" @@ -282,6 +283,14 @@ public class Preferences { setBool(value, forKey: .playSoundInForeground) } + public var isMessageSentSoundEnabled: Bool { + bool(forKey: .messageSentSound, defaultValue: true) + } + + public func setIsMessageSentSoundEnabled(_ value: Bool) { + setBool(value, forKey: .messageSentSound) + } + public func notificationPreviewType(tx: DBReadTransaction) -> NotificationType { let rawValue = keyValueStore.getUInt( Key.notificationPreviewType.rawValue,