Repository: cordova-plugin-screen-orientation
Updated Branches:
  refs/heads/master f0c65cfee -> eaeb4f1a7


Rotate to specified orientation when locked

Refactor


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/fce44f49
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/fce44f49
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/fce44f49

Branch: refs/heads/master
Commit: fce44f4942adf20cff6769f4c7b53715584f6b31
Parents: f0c65cf
Author: Pascal Häusler <[email protected]>
Authored: Fri Mar 3 15:03:09 2017 +0100
Committer: Jesse MacFadyen <[email protected]>
Committed: Mon Apr 24 11:31:04 2017 -0700

----------------------------------------------------------------------
 src/ios/CDVOrientation.m           | 21 +++++++++++++++++++--
 src/windows/CDVOrientationProxy.js |  2 +-
 www/screenorientation.js           | 17 ++++++++---------
 3 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/fce44f49/src/ios/CDVOrientation.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVOrientation.m b/src/ios/CDVOrientation.m
index b38a55d..c7704e4 100644
--- a/src/ios/CDVOrientation.m
+++ b/src/ios/CDVOrientation.m
@@ -52,14 +52,31 @@
     
     if([vc respondsToSelector:selector]) {
         ((void (*)(CDVViewController*, SEL, 
NSMutableArray*))objc_msgSend)(vc,selector,result);
+        
+        if ([UIDevice currentDevice] != nil){
+            NSNumber *value = nil;
+            if(orientationMask == 8 || orientationMask == 12) {
+                value = [NSNumber 
numberWithInt:UIInterfaceOrientationLandscapeRight];
+            } else if (orientationMask == 4){
+                value = [NSNumber 
numberWithInt:UIInterfaceOrientationLandscapeLeft];
+            } else if (orientationMask == 1 || orientationMask == 3) {
+                value = [NSNumber 
numberWithInt:UIInterfaceOrientationPortrait];
+            } else if (orientationMask == 2) {
+                value = [NSNumber 
numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
+            }
+            if (value != nil) {
+                [[UIDevice currentDevice] setValue:value 
forKey:@"orientation"];
+            }
+        }
+        
         pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
     }
     else {
-        pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_INVALID_ACTION                
messageAsString:@"Error calling to set supported orientations"];
+        pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsString:@"Error 
calling to set supported orientations"];
     }
     
     [self.commandDelegate sendPluginResult:pluginResult 
callbackId:command.callbackId];
     
 }
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/fce44f49/src/windows/CDVOrientationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/CDVOrientationProxy.js 
b/src/windows/CDVOrientationProxy.js
index 214994a..7f36b49 100644
--- a/src/windows/CDVOrientationProxy.js
+++ b/src/windows/CDVOrientationProxy.js
@@ -57,6 +57,6 @@ module.exports = {
         }
 
     }
-}
+};
 
 require("cordova/exec/proxy").add("CDVOrientation", module.exports);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/fce44f49/www/screenorientation.js
----------------------------------------------------------------------
diff --git a/www/screenorientation.js b/www/screenorientation.js
index 0bdb814..ef2eb49 100644
--- a/www/screenorientation.js
+++ b/www/screenorientation.js
@@ -59,7 +59,7 @@ function addScreenOrientationApi(screenObject) {
     screenObject.lock = function(orientation) {
         var promiseLock;
         var p = new Promise(function(resolve, reject) {
-            if (screenObject.nativeLock != null) {
+            if (screenObject.nativeLock) {
                 promiseLock = screenObject.nativeLock(orientation);
                 promiseLock.then(function success(res) {
                     resolve();
@@ -70,14 +70,12 @@ function addScreenOrientationApi(screenObject) {
             } else {
                 resolveOrientation(orientation, resolve, reject);
             }
-        })
+        });
         return p;
-    }
-
+    };
     screenObject.unlock = function() {
         screenOrientation.setOrientation('any');
     };
-
 }
 
 function resolveOrientation(orientation, resolve, reject) {
@@ -99,11 +97,11 @@ var onChangeListener = null;
 Object.defineProperty(screen.orientation, 'onchange', {
     set: function(listener) {
 
-        if (onChangeListener != null) {
+        if (onChangeListener) {
             screen.orientation.removeEventListener('change', onChangeListener);
         }
         onChangeListener = listener;
-        if (onChangeListener != null) {
+        if (onChangeListener) {
             screen.orientation.addEventListener('change', onChangeListener);
         }
     },
@@ -124,10 +122,11 @@ var orientationchange = function() {
 
 screen.orientation.addEventListener = function(a,b,c) {
     return evtTarget.addEventListener(a,b,c);
-}
+};
+
 screen.orientation.removeEventListener = function(a,b,c) {
     return evtTarget.removeEventListener(a,b,c);
-}
+};
 
 function setOrientationProperties() {
     switch (window.orientation) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to