This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/cordova-plugin-media-capture.git
The following commit(s) were added to refs/heads/master by this push:
new 1796d0a fix(ios): UI issues with main thread and added alert for
permission. (#184)
1796d0a is described below
commit 1796d0a6619fef1ee8d735f140458bc226a7a39d
Author: Denis Kovalev <[email protected]>
AuthorDate: Mon Aug 14 08:29:16 2023 +0500
fix(ios): UI issues with main thread and added alert for permission. (#184)
* iOS: Fixed UI issues with main thread and added alert for permission.
- solved critical error connected with performing the UI operation on the
non-UI thread.
- added the alert dialog for the Microphone permission, if it is not
granted.
* chore: use localizable strings for mic permission alert
* chore: add blank new line on localizable strings files
* chore: updated French Localizable.strings
---------
Co-authored-by: Erisu <[email protected]>
---
.../CDVCapture.bundle/de.lproj/Localizable.strings | 4 +++
.../CDVCapture.bundle/en.lproj/Localizable.strings | 4 +++
.../CDVCapture.bundle/es.lproj/Localizable.strings | 4 +++
.../CDVCapture.bundle/fr.lproj/Localizable.strings | 4 +++
.../CDVCapture.bundle/se.lproj/Localizable.strings | 4 +++
src/ios/CDVCapture.m | 40 ++++++++++++++++------
6 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/src/ios/CDVCapture.bundle/de.lproj/Localizable.strings
b/src/ios/CDVCapture.bundle/de.lproj/Localizable.strings
index 4ae15bf..f3350dc 100644
--- a/src/ios/CDVCapture.bundle/de.lproj/Localizable.strings
+++ b/src/ios/CDVCapture.bundle/de.lproj/Localizable.strings
@@ -25,3 +25,7 @@
"timed recording complete" = "programmierte Aufnahme beendet";
// accessibility hint for display of recorded elapsed time
"recorded time in minutes and seconds" = "aufgenommene Zeit in Minuten und
Sekunden";
+// Access denied
+"Access denied" = "Zugriff abgelehnt";
+// Microphone access has been prohibited
+"Access to the microphone has been prohibited. Please enable it in the
Settings app to continue." = "Der Zugriff auf das Mikrofon wurde verboten.
Bitte aktivieren Sie es in der Einstellungen-App, um fortzufahren.";
diff --git a/src/ios/CDVCapture.bundle/en.lproj/Localizable.strings
b/src/ios/CDVCapture.bundle/en.lproj/Localizable.strings
index a4a049e..203de57 100644
--- a/src/ios/CDVCapture.bundle/en.lproj/Localizable.strings
+++ b/src/ios/CDVCapture.bundle/en.lproj/Localizable.strings
@@ -25,3 +25,7 @@
"timed recording complete" = "timed recording complete";
// accessibility hint for display of recorded elapsed time
"recorded time in minutes and seconds" = "recorded time in minutes and
seconds";
+// Access denied
+"Access denied" = "Access denied";
+// Microphone access has been prohibited
+"Access to the microphone has been prohibited. Please enable it in the
Settings app to continue." = "Access to the microphone has been prohibited.
Please enable it in the Settings app to continue.";
diff --git a/src/ios/CDVCapture.bundle/es.lproj/Localizable.strings
b/src/ios/CDVCapture.bundle/es.lproj/Localizable.strings
index 255d9c5..1a88f2b 100644
--- a/src/ios/CDVCapture.bundle/es.lproj/Localizable.strings
+++ b/src/ios/CDVCapture.bundle/es.lproj/Localizable.strings
@@ -25,3 +25,7 @@
"timed recording complete" = "límite de grabación alcanzado";
// accessibility hint for display of recorded elapsed time
"recorded time in minutes and seconds" = "tiempo de grabación en minutos y
segundos";
+// Access denied
+"Access denied" = "Acceso denegado";
+// Microphone access has been prohibited
+"Access to the microphone has been prohibited. Please enable it in the
Settings app to continue." = "Se ha prohibido el acceso al micrófono.
Habilítelo en la aplicación Configuración para continuar.";
diff --git a/src/ios/CDVCapture.bundle/fr.lproj/Localizable.strings
b/src/ios/CDVCapture.bundle/fr.lproj/Localizable.strings
index 2e5d0b0..116503a 100644
--- a/src/ios/CDVCapture.bundle/fr.lproj/Localizable.strings
+++ b/src/ios/CDVCapture.bundle/fr.lproj/Localizable.strings
@@ -25,3 +25,7 @@
"timed recording complete" = "limite d'enregistrement atteinte";
// accessibility hint for display of recorded elapsed time
"recorded time in minutes and seconds" = "temps d'enregistrement en minutes et
secondes";
+// Access denied
+"Access denied" = "Accès refusé";
+// Microphone access has been prohibited
+"Access to the microphone has been prohibited. Please enable it in the
Settings app to continue." = "L'accès au micro a été interdit. Veuillez
l'activer dans l'application Paramètres pour continuer.";
diff --git a/src/ios/CDVCapture.bundle/se.lproj/Localizable.strings
b/src/ios/CDVCapture.bundle/se.lproj/Localizable.strings
index d01542f..72724c2 100644
--- a/src/ios/CDVCapture.bundle/se.lproj/Localizable.strings
+++ b/src/ios/CDVCapture.bundle/se.lproj/Localizable.strings
@@ -25,3 +25,7 @@
"timed recording complete" = "inspelning har avslutad";
// accessibility hint for display of recorded elapsed time
"recorded time in minutes and seconds" = "inspelad tid in minuter och sekund";
+// Access denied
+"Access denied" = "Tillträde beviljas ej";
+// Microphone access has been prohibited
+"Access to the microphone has been prohibited. Please enable it in the
Settings app to continue." = "Tillgång till mikrofonen har förbjudits. Aktivera
det i appen Inställningar för att fortsätta.";
diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m
index f66efda..3919848 100644
--- a/src/ios/CDVCapture.m
+++ b/src/ios/CDVCapture.m
@@ -800,9 +800,6 @@
// view cleanup will occur in audioRecordingDidFinishRecording
} else {
// begin recording
- [self.recordButton setImage:stopRecordImage
forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits &= ~[self accessibilityTraits];
- [self.recordingView setHidden:NO];
__block NSError* error = nil;
__weak CDVAudioRecorderViewController* weakSelf = self;
@@ -814,6 +811,9 @@
weakSelf.errorCode = CAPTURE_INTERNAL_ERR;
[weakSelf dismissAudioView:nil];
} else {
+ [weakSelf.recordButton setImage:weakSelf.stopRecordImage
forState:UIControlStateNormal];
+ weakSelf.recordButton.accessibilityTraits &= ~[self
accessibilityTraits];
+ [weakSelf.recordingView setHidden:NO];
if (weakSelf.duration) {
weakSelf.isTimed = true;
[weakSelf.avRecorder recordForDuration:[weakSelf.duration
doubleValue]];
@@ -833,13 +833,15 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.avSession performSelector:rrpSel withObject:^(BOOL granted){
- if (granted) {
- startRecording();
- } else {
- NSLog(@"Error creating audio session, microphone
permission denied.");
- weakSelf.errorCode = CAPTURE_INTERNAL_ERR;
- [weakSelf dismissAudioView:nil];
- }
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (granted) {
+ startRecording();
+ } else {
+ NSLog(@"Error creating audio session, microphone
permission denied.");
+ weakSelf.errorCode = CAPTURE_INTERNAL_ERR;
+ [weakSelf showMicrophonePermissionAlert];
+ }
+ });
}];
#pragma clang diagnostic pop
} else {
@@ -879,6 +881,24 @@
}
}
+- (void) showMicrophonePermissionAlert {
+ UIAlertController* controller =
+ [UIAlertController
alertControllerWithTitle:PluginLocalizedString(captureCommand, @"Access
denied", nil)
+
message:PluginLocalizedString(captureCommand, @"Access to the microphone has
been prohibited. Please enable it in the Settings app to continue.", nil)
+
preferredStyle:UIAlertControllerStyleAlert];
+
+ UIAlertAction* actionOk = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault handler:nil];
+ [controller addAction:actionOk];
+
+ UIAlertAction* actionSettings = [UIAlertAction actionWithTitle:@"Settings"
style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ [[UIApplication sharedApplication] openURL:[NSURL
URLWithString:UIApplicationOpenSettingsURLString] options:[NSDictionary
dictionary] completionHandler:nil];
+ }];
+ [controller addAction:actionSettings];
+
+ __weak CDVAudioRecorderViewController* weakSelf = self;
+ [weakSelf presentViewController:controller animated:true completion:nil];
+}
+
- (void)dismissAudioView:(id)sender
{
// called when done button pressed or when error condition to do cleanup
and remove view
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]