Skip to content

Commit

Permalink
Merge pull request #67 from spoonconsulting/change-statusBarOrientati…
Browse files Browse the repository at this point in the history
…on-to-interfaceOrientation

use interfaceOrientation for ios 13+
  • Loading branch information
parveshneedhoo authored Jul 4, 2023
2 parents 5ed105f + f1c2743 commit 2962777
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## [2.0.17](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/compare/v2.0.16...v2.0.17) (2023-07-04)

* **iOS:** Use interfaceOrientation for ios 13+. ([#67](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/pull/67))

## [2.0.16](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/compare/v2.0.15...v2.0.16) (2023-05-08)

* **iOS:** Added a NSNotification observer to check if app is interrupted by a drawer app on ipad. ([#64](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/pull/66))
* **iOS:** Added a NSNotification observer to check if app is interrupted by a drawer app on ipad. ([#66](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/pull/66))

## [2.0.15](https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview/compare/v2.0.14...v2.0.15) (2023-01-30)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spoonconsulting/cordova-plugin-simple-camera-preview",
"version": "2.0.16",
"version": "2.0.17",
"description": "Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.",
"keywords": [
"cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<plugin id="@spoonconsulting/cordova-plugin-simple-camera-preview" version="2.0.16" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="@spoonconsulting/cordova-plugin-simple-camera-preview" version="2.0.17" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">

<name>cordova-plugin-simple-camera-preview</name>
<description>Cordova plugin that allows camera interaction from HTML code. Show camera preview popup on top of the HTML.</description>
Expand Down
5 changes: 3 additions & 2 deletions src/ios/CameraRenderController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ - (void) viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appplicationIsActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnteredForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];

UIInterfaceOrientation orientation= [UIApplication sharedApplication].statusBarOrientation;
dispatch_async(self.sessionManager.sessionQueue, ^{
if (!self.sessionManager.session.running){
NSLog(@"Starting session from viewWillAppear");
[self.sessionManager.session startRunning];
}
UIInterfaceOrientation orientation = [self.sessionManager getOrientation];
[self.sessionManager updateOrientation:[self.sessionManager getCurrentOrientation: orientation]];
});
}
Expand Down Expand Up @@ -171,7 +171,8 @@ -(void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
__block UIInterfaceOrientation toInterfaceOrientation;
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
toInterfaceOrientation = [self.sessionManager getOrientation];

} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.sessionManager updateOrientation:[self.sessionManager getCurrentOrientation:toInterfaceOrientation]];
}];
Expand Down
1 change: 1 addition & 0 deletions src/ios/CameraSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- (void) updateOrientation:(AVCaptureVideoOrientation)orientation;
- (AVCaptureVideoOrientation) getCurrentOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
+ (AVCaptureSessionPreset) calculateResolution:(NSInteger)targetSize;
- (UIInterfaceOrientation) getOrientation;

@property (atomic) CIFilter *ciFilter;
@property (nonatomic) NSLock *filterLock;
Expand Down
12 changes: 11 additions & 1 deletion src/ios/CameraSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ - (CameraSessionManager *)init {
}

- (AVCaptureVideoOrientation) getCurrentOrientation {
return [self getCurrentOrientation: [[UIApplication sharedApplication] statusBarOrientation]];
UIInterfaceOrientation orientation = [self getOrientation];
return [self getCurrentOrientation: orientation];
}

- (AVCaptureVideoOrientation) getCurrentOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
Expand Down Expand Up @@ -195,4 +196,13 @@ - (AVCaptureDevice *) cameraWithPosition:(AVCaptureDevicePosition) position {
return nil;
}

- (UIInterfaceOrientation) getOrientation {
if (@available(iOS 13.0, *)) {
UIWindowScene *activeWindow = (UIWindowScene *)[[[UIApplication sharedApplication] windows] firstObject];
return [activeWindow interfaceOrientation] ?: UIInterfaceOrientationPortrait;
} else {
return [[UIApplication sharedApplication] statusBarOrientation];
}
}

@end

0 comments on commit 2962777

Please sign in to comment.