Merge branch 'mkirk/mic-perms'

pull/1/head
Michael Kirk 8 years ago
commit ef1dc359f8

@ -93,7 +93,7 @@
<key>NSContactsUsageDescription</key>
<string>Signal uses your contacts to find users you know. We do not store your contacts on the server.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Signal needs access to your microphone to make and receive phone calls.</string>
<string>Signal needs access to your microphone to make and receive phone calls and record voice messages.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Signal will let you choose which photos from your library to send.</string>
<key>UIAppFonts</key>

@ -3105,6 +3105,29 @@ typedef enum : NSUInteger {
#pragma mark - Audio
- (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) {
[strongSelf startRecordingVoiceMemo];
} else {
DDLogInfo(@"%@ we do not have recording permission.", self.tag);
[strongSelf cancelVoiceMemo];
[OWSAlerts showNoMicrophonePermissionAlert];
}
});
}];
}
- (void)startRecordingVoiceMemo
{
OWSAssert([NSThread isMainThread]);
@ -3122,6 +3145,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 +3187,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 +3575,7 @@ typedef enum : NSUInteger {
[((OWSMessagesInputToolbar *)self.inputToolbar)showVoiceMemoUI];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
[self startRecordingVoiceMemo];
[self requestRecordingVoiceMemo];
}
- (void)voiceMemoGestureDidEnd

@ -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";

Loading…
Cancel
Save