Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking(ios): remove code warnings #177

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 23 additions & 67 deletions src/ios/CDVCapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,27 @@ - (BOOL)hasCameraAccess

- (void)showPermissionsAlert
{
__weak CDVCapture* weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:[[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleDisplayName"]
message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil)
delegate:weakSelf
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:NSLocalizedString(@"Settings", nil), nil] show];
});
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]
message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil)
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[self returnNoPermissionError];
}]];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Settings", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]options:@{} completionHandler:nil];
[self returnNoPermissionError];
}]];
[self.viewController presentViewController:alertController animated:YES completion:^{}];
}

- (void)returnNoPermissionError
{
if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}

CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_PERMISSION_DENIED];

[[pickerController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
Expand Down Expand Up @@ -588,19 +592,11 @@ - (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker

@implementation CDVAudioNavigationController

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
// delegate to CVDAudioRecorderViewController
return [self.topViewController supportedInterfaceOrientations];
}
#else
- (NSUInteger)supportedInterfaceOrientations
{
// delegate to CVDAudioRecorderViewController
return [self.topViewController supportedInterfaceOrientations];
}
#endif

@end

Expand Down Expand Up @@ -654,7 +650,7 @@ - (void)loadView
}

// create view and display
CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
CGRect viewRect = [[UIScreen mainScreen] bounds];
UIView* tmp = [[UIView alloc] initWithFrame:viewRect];

// make backgrounds
Expand Down Expand Up @@ -696,12 +692,7 @@ - (void)loadView
// timerLabel.autoresizingMask = reSizeMask;
[self.timerLabel setBackgroundColor:[UIColor clearColor]];
[self.timerLabel setTextColor:[UIColor whiteColor]];
#ifdef __IPHONE_6_0
[self.timerLabel setTextAlignment:NSTextAlignmentCenter];
#else
// for iOS SDK < 6.0
[self.timerLabel setTextAlignment:UITextAlignmentCenter];
#endif
[self.timerLabel setText:@"0:00"];
[self.timerLabel setAccessibilityHint:PluginLocalizedString(captureCommand, @"recorded time in minutes and seconds", nil)];
self.timerLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
Expand Down Expand Up @@ -776,7 +767,6 @@ - (void)viewDidLoad
}
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
UIInterfaceOrientationMask orientation = UIInterfaceOrientationMaskPortrait;
Expand All @@ -785,22 +775,6 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations
orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
return orientation;
}
#else
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];

orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
return orientation;
}
#endif

- (void)viewDidUnload
{
[self setView:nil];
[self.captureCommand setInUse:NO];
}

- (void)processButton:(id)sender
{
Expand Down Expand Up @@ -828,7 +802,7 @@ - (void)processButton:(id)sender
} else {
if (weakSelf.duration) {
weakSelf.isTimed = true;
[weakSelf.avRecorder recordForDuration:[duration doubleValue]];
[weakSelf.avRecorder recordForDuration:[weakSelf.duration doubleValue]];
} else {
[weakSelf.avRecorder record];
}
Expand Down Expand Up @@ -882,7 +856,7 @@ - (void)stopRecordingCleanup
//BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
if (UIAccessibilityAnnouncementNotification) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, PluginLocalizedString(captureCommand, @"timed recording complete", nil));
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, PluginLocalizedString(self->captureCommand, @"timed recording complete", nil));
});
}
} else {
Expand All @@ -908,10 +882,6 @@ - (void)dismissAudioView:(id)sender
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
// return result
[self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];

if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
}
}

- (void)updateTime
Expand Down Expand Up @@ -962,18 +932,4 @@ - (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder*)recorder error:(NSErr
[self dismissAudioView:nil];
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}

- (void)viewWillAppear:(BOOL)animated
{
if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
}

[super viewWillAppear:animated];
}

@end