cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject [01/50] cordova-plugin-screen-orientation git commit: Removed flicker in iOS8 closes #23
Date Mon, 23 May 2016 13:41:59 GMT
Repository: cordova-plugin-screen-orientation
Updated Branches:
  refs/heads/master [created] 781a2c1e4


Removed flicker in iOS8 closes #23


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/3b7d2591
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/3b7d2591
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/3b7d2591

Branch: refs/heads/master
Commit: 3b7d259193134577abf68916b14211fda858969f
Parents: d98ea66
Author: Grant Benvenuti <g.benvenuti@pni.com.au>
Authored: Thu Sep 18 09:42:23 2014 +1000
Committer: Grant Benvenuti <g.benvenuti@pni.com.au>
Committed: Thu Sep 18 09:42:23 2014 +1000

----------------------------------------------------------------------
 README.md                       | 14 ++++++++++-
 src/ios/YoikScreenOrientation.h |  6 +++++
 src/ios/YoikScreenOrientation.m | 48 ++++++++++++++++++++++++++++++------
 www/screenorientation.ios.js    |  3 +--
 4 files changed, 60 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/3b7d2591/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 2ad7bd5..5f7b745 100644
--- a/README.md
+++ b/README.md
@@ -82,10 +82,22 @@ Issue [#1](https://github.com/yoik/cordova-yoik-screenorientation/issues/1)
@dok
 
 ####iOS8
 
-Versions prior to 1.2.0 will cause an application crash in iOS8.
+Versions prior to 1.2.0 will cause an application crash in iOS8 due to a change in presentViewController
timing.
 
 ##BB10 Notes
 
 Wraps the com.blackberry.app plugin functions, auto installed as a dependancy.
 
+#Changelog
+
+##1.3.0
+
+* [#23](https://github.com/yoik/cordova-yoik-screenorientation/issues/23) iOS8 flicker
+
+##1.2.0-1.2.1
+
+* [#19](https://github.com/yoik/cordova-yoik-screenorientation/issues/19) iOS8 Crash
+
+
+
 Pull requests welcome.

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/3b7d2591/src/ios/YoikScreenOrientation.h
----------------------------------------------------------------------
diff --git a/src/ios/YoikScreenOrientation.h b/src/ios/YoikScreenOrientation.h
index 4ec730d..95da6e8 100644
--- a/src/ios/YoikScreenOrientation.h
+++ b/src/ios/YoikScreenOrientation.h
@@ -29,4 +29,10 @@ SOFTWARE.
 
 - (void)screenOrientation:(CDVInvokedUrlCommand *)command;
 
+@end
+
+@interface ForcedViewController : UIViewController
+
+@property (strong, nonatomic) NSString *calledWith;
+
 @end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/3b7d2591/src/ios/YoikScreenOrientation.m
----------------------------------------------------------------------
diff --git a/src/ios/YoikScreenOrientation.m b/src/ios/YoikScreenOrientation.m
index 3cf8eb1..17ca3db 100644
--- a/src/ios/YoikScreenOrientation.m
+++ b/src/ios/YoikScreenOrientation.m
@@ -27,12 +27,8 @@ SOFTWARE.
 
 -(void)screenOrientation:(CDVInvokedUrlCommand *)command
 {
-    // this method does not control the orientation, it is set in the .js file.
-
-    // SEE https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation
-    // HACK: Force rotate by changing the view hierarchy. Present modal view then dismiss
it immediately.
-    [self.viewController presentViewController:[UIViewController new] animated:NO completion:nil];
-    [self.viewController dismissViewControllerAnimated:NO completion:nil];
+    NSArray* arguments = command.arguments;
+    NSString* orientationIn = [arguments objectAtIndex:1];
 
     // grab the device orientation so we can pass it back to the js side.
     NSString *orientation;
@@ -53,10 +49,46 @@ SOFTWARE.
             orientation = @"portait";
             break;
     }
-    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
-                                                  messageAsDictionary:@{@"device":orientation}];
 
+    if ([orientationIn isEqual: @"unlocked"]) {
+        orientationIn = orientation;
+    }
+
+    // we send the result prior to the view controller presentation so that the JS side
+    // is ready for the unlock call.
+    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
+        messageAsDictionary:@{@"device":orientation}];
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+
+    // SEE https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation
+    // HACK: Force rotate by changing the view hierarchy. Present modal view then dismiss
it immediately
+    // This has been changed substantially since iOS8 broke it...
+    ForcedViewController *vc = [[ForcedViewController alloc] init];
+    vc.calledWith = orientationIn;
+
+    // backgound should be transparent as it is briefly visible
+    // prior to closing.
+    vc.view.backgroundColor = [UIColor clearColor];
+    // vc.view.alpha = 0.0;
+    vc.view.opaque = YES;
+    // This stops us getting the black application background flash, iOS8
+    vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
+
+    [self.viewController presentViewController:vc animated:NO completion:nil];
+    [self.viewController dismissViewControllerAnimated:NO completion:nil];
 }
 
+@end
+
+@implementation ForcedViewController
+
+- (NSUInteger) supportedInterfaceOrientations
+{
+    if ([self.calledWith rangeOfString:@"portrait"].location != NSNotFound) {
+        return UIInterfaceOrientationMaskPortrait;
+    } else if([self.calledWith rangeOfString:@"landscape"].location != NSNotFound) {
+        return UIInterfaceOrientationMaskLandscape;
+    }
+    return UIInterfaceOrientationMaskAll;
+}
 @end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/3b7d2591/www/screenorientation.ios.js
----------------------------------------------------------------------
diff --git a/www/screenorientation.ios.js b/www/screenorientation.ios.js
index 9cb878b..11d30f7 100644
--- a/www/screenorientation.ios.js
+++ b/www/screenorientation.ios.js
@@ -17,10 +17,9 @@ screenOrientation.setOrientation = function(orientation) {
     var success = function(res) {
         if (orientation === 'unlocked' && res.device) {
             iosOrientation = res.device;
-
             setTimeout(function() {
                 iosOrientation = 'unlocked';
-            },0);
+            },300);
         }
     };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message