From 7861af4fc051ad8a2c220e5416d529933a577430 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 15 May 2017 16:41:34 -0400 Subject: [PATCH 1/4] mention voice notes in mic permission request // FREEBIE --- Signal/Signal-Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 1d38a4db5..4090eeb04 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -93,7 +93,7 @@ NSContactsUsageDescription Signal uses your contacts to find users you know. We do not store your contacts on the server. NSMicrophoneUsageDescription - Signal needs access to your microphone to make and receive phone calls. + Signal needs access to your microphone to make and receive phone calls and record voice messages. NSPhotoLibraryUsageDescription Signal will let you choose which photos from your library to send. UIAppFonts From c56ff7532c3393c8b54c3002d838986277b4558b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 15 May 2017 16:51:12 -0400 Subject: [PATCH 2/4] Fix confusing double permission request on new install when sending voice notes // FREEBIE --- .../ViewControllers/MessagesViewController.m | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/MessagesViewController.m b/Signal/src/ViewControllers/MessagesViewController.m index 28057efc6..012bd16ed 100644 --- a/Signal/src/ViewControllers/MessagesViewController.m +++ b/Signal/src/ViewControllers/MessagesViewController.m @@ -3105,6 +3105,22 @@ typedef enum : NSUInteger { #pragma mark - Audio +- (void)requestRecordingVoiceMemo +{ + OWSAssert([NSThread isMainThread]); + [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) { + dispatch_async(dispatch_get_main_queue(), ^{ + if (granted) { + [self startRecordingVoiceMemo]; + } else { + DDLogInfo(@"%@ we do not have recording permission.", self.tag); + [self cancelVoiceMemo]; + [OWSAlerts showNoMicrophonePermissionAlert]; + } + }); + }]; +} + - (void)startRecordingVoiceMemo { OWSAssert([NSThread isMainThread]); @@ -3122,6 +3138,8 @@ typedef enum : NSUInteger { // Setup audio session AVAudioSession *session = [AVAudioSession sharedInstance]; + OWSAssert(session.recordPermission == AVAudioSessionRecordPermissionGranted); + NSError *error; [session setCategory:AVAudioSessionCategoryRecord error:&error]; if (error) { @@ -3162,13 +3180,6 @@ typedef enum : NSUInteger { OWSAssert(0); return; } - - if (session.recordPermission != AVAudioSessionRecordPermissionGranted) { - DDLogInfo(@"%@ we do not have recording permission.", self.tag); - [self cancelVoiceMemo]; - [OWSAlerts showNoMicrophonePermissionAlert]; - return; - } } - (void)endRecordingVoiceMemo @@ -3557,7 +3568,7 @@ typedef enum : NSUInteger { [((OWSMessagesInputToolbar *)self.inputToolbar)showVoiceMemoUI]; AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); - [self startRecordingVoiceMemo]; + [self requestRecordingVoiceMemo]; } - (void)voiceMemoGestureDidEnd From 16032b9c614522f11cf200ee03aeb35937389be8 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 15 May 2017 17:03:46 -0400 Subject: [PATCH 3/4] strongSelf per CR // FREEBIE --- Signal/src/ViewControllers/MessagesViewController.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/MessagesViewController.m b/Signal/src/ViewControllers/MessagesViewController.m index 012bd16ed..361cf70d5 100644 --- a/Signal/src/ViewControllers/MessagesViewController.m +++ b/Signal/src/ViewControllers/MessagesViewController.m @@ -3108,13 +3108,20 @@ typedef enum : NSUInteger { - (void)requestRecordingVoiceMemo { OWSAssert([NSThread isMainThread]); + + __weak typeof(self) weakSelf = self; [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) { dispatch_async(dispatch_get_main_queue(), ^{ + __strong typeof(self) strongSelf = weakSelf; + if (!strongSelf) { + return; + } + if (granted) { - [self startRecordingVoiceMemo]; + [strongSelf startRecordingVoiceMemo]; } else { DDLogInfo(@"%@ we do not have recording permission.", self.tag); - [self cancelVoiceMemo]; + [strongSelf cancelVoiceMemo]; [OWSAlerts showNoMicrophonePermissionAlert]; } }); From e727c0a77a815910f9090e58b030db7de31d3b23 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 15 May 2017 17:04:01 -0400 Subject: [PATCH 4/4] update mic perm copy // FREEBIE --- Signal/translations/en.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 2f5ef8bda..5c40c61bf 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -182,7 +182,7 @@ "BLOCK_OFFER_ACTIONSHEET_TITLE_FORMAT" = "Block %@?"; /* Alert message when calling and permissions for microphone are missing */ -"CALL_AUDIO_PERMISSION_MESSAGE" = "Signal requires access to your microphone to make calls. You can grant this permission in the Settings app."; +"CALL_AUDIO_PERMISSION_MESSAGE" = "Signal requires access to your microphone to make calls and record voice messages. You can grant this permission in the Settings app."; /* Alert title when calling and permissions for microphone are missing */ "CALL_AUDIO_PERMISSION_TITLE" = "Microphone Access Required";