From 60d839d7a4a34dd90a91863d6c28d72e3047f84f Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 20 Feb 2018 21:59:15 -0500 Subject: [PATCH] Custom notification sounds. --- .../environment/NotificationSounds.h | 13 +++- .../environment/NotificationSounds.m | 73 +++++++++++++++++-- 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/SignalMessaging/environment/NotificationSounds.h b/SignalMessaging/environment/NotificationSounds.h index 1e4c30327..27991a008 100644 --- a/SignalMessaging/environment/NotificationSounds.h +++ b/SignalMessaging/environment/NotificationSounds.h @@ -4,7 +4,18 @@ typedef NS_ENUM(NSUInteger, NotificationSound) { NotificationSound_Aurora = 0, - NotificationSound_Default = NotificationSound_Aurora + NotificationSound_Bamboo, + NotificationSound_Chord, + NotificationSound_Circles, + NotificationSound_Complete, + NotificationSound_Hello, + NotificationSound_Input, + NotificationSound_Keys, + NotificationSound_Note, + NotificationSound_Popcorn, + NotificationSound_Pulse, + NotificationSound_Synth, + NotificationSound_Default = NotificationSound_Note, }; NS_ASSUME_NONNULL_BEGIN diff --git a/SignalMessaging/environment/NotificationSounds.m b/SignalMessaging/environment/NotificationSounds.m index 3c5113278..3a6add2e3 100644 --- a/SignalMessaging/environment/NotificationSounds.m +++ b/SignalMessaging/environment/NotificationSounds.m @@ -42,6 +42,17 @@ { return @[ @(NotificationSound_Aurora), + @(NotificationSound_Bamboo), + @(NotificationSound_Chord), + @(NotificationSound_Circles), + @(NotificationSound_Complete), + @(NotificationSound_Hello), + @(NotificationSound_Input), + @(NotificationSound_Keys), + @(NotificationSound_Note), + @(NotificationSound_Popcorn), + @(NotificationSound_Pulse), + @(NotificationSound_Synth), ]; } @@ -51,23 +62,71 @@ switch (notificationSound) { case NotificationSound_Aurora: return @"Aurora"; + case NotificationSound_Bamboo: + return @"Bamboo"; + case NotificationSound_Chord: + return @"Chord"; + case NotificationSound_Circles: + return @"Circles"; + case NotificationSound_Complete: + return @"Complete"; + case NotificationSound_Hello: + return @"Hello"; + case NotificationSound_Input: + return @"Input"; + case NotificationSound_Keys: + return @"Keys"; + case NotificationSound_Note: + return @"Note"; + case NotificationSound_Popcorn: + return @"Popcorn"; + case NotificationSound_Pulse: + return @"Pulse"; + case NotificationSound_Synth: + return @"Synth"; } } - (NSURL *)soundURLForNotificationSound:(NotificationSound)notificationSound { - NSString *bundlePath = [NSBundle mainBundle].bundlePath; - NSFileManager *fileManager = [NSFileManager defaultManager]; - for (NSString *filename in [fileManager contentsOfDirectoryAtPath:bundlePath error:nil]) { - DDLogInfo(@"%@ filename: %@", self.logTag, filename); - } - [DDLog flushLog]; - NSURL *_Nullable url; switch (notificationSound) { case NotificationSound_Aurora: url = [[NSBundle mainBundle] URLForResource:@"aurora" withExtension:@"m4r"]; break; + case NotificationSound_Bamboo: + url = [[NSBundle mainBundle] URLForResource:@"bamboo" withExtension:@"m4r"]; + break; + case NotificationSound_Chord: + url = [[NSBundle mainBundle] URLForResource:@"chord" withExtension:@"m4r"]; + break; + case NotificationSound_Circles: + url = [[NSBundle mainBundle] URLForResource:@"circles" withExtension:@"m4r"]; + break; + case NotificationSound_Complete: + url = [[NSBundle mainBundle] URLForResource:@"complete" withExtension:@"m4r"]; + break; + case NotificationSound_Hello: + url = [[NSBundle mainBundle] URLForResource:@"hello" withExtension:@"m4r"]; + break; + case NotificationSound_Input: + url = [[NSBundle mainBundle] URLForResource:@"input" withExtension:@"m4r"]; + break; + case NotificationSound_Keys: + url = [[NSBundle mainBundle] URLForResource:@"keys" withExtension:@"m4r"]; + break; + case NotificationSound_Note: + url = [[NSBundle mainBundle] URLForResource:@"note" withExtension:@"m4r"]; + break; + case NotificationSound_Popcorn: + url = [[NSBundle mainBundle] URLForResource:@"popcorn" withExtension:@"m4r"]; + break; + case NotificationSound_Pulse: + url = [[NSBundle mainBundle] URLForResource:@"pulse" withExtension:@"m4r"]; + break; + case NotificationSound_Synth: + url = [[NSBundle mainBundle] URLForResource:@"synth" withExtension:@"m4r"]; + break; } OWSAssert(url); return url;