Merge branch 'master' into 2.0.x

This commit is contained in:
filmaj 2017-04-27 13:11:44 -07:00
commit 55e897c288
10 changed files with 78 additions and 22 deletions

View File

@ -17,9 +17,9 @@
# under the License.
-->
|Android 4.4|Android 5.1|iOS 9.3|iOS 10.0|Windows 10 Store|
|:-:|:-:|:-:|:-:|:-:|
|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-screen-orientation/)|
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|
|:-:|:-:|:-:|:-:|:-:|:-:|
|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-screen-orientation/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-screen-orientation)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-screen-orientation/)|
# Cordova Screen Orientation Plugin

View File

@ -22,6 +22,12 @@
# Release Notes
### 2.0.1 (Apr 27, 2017)
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
* [CB-12543](https://issues.apache.org/jira/browse/CB-12543) (iOS) Rotate to specified orientation when locked
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
* [CB-12588](https://issues.apache.org/jira/browse/CB-12588) add manual tests in cordova-plugin-test-framework style
### 2.0.0 (Mar 14, 2017)
* [CB-11628](https://issues.apache.org/jira/browse/CB-11628) - w3c spec compliance https://www.w3.org/TR/screen-orientation/

View File

@ -1,6 +1,6 @@
{
"name": "cordova-plugin-screen-orientation",
"version": "2.0.0",
"version": "2.0.1",
"description": "Adds Screen Orientation API lock and unlock functions to the global screen object in android, iOS, WP8, W8.1, and BB10.",
"repository": {
"type": "git",
@ -33,10 +33,10 @@
"jshint": "^2.9.4"
},
"engines": {
"cordovaDependencies": {
"3.0.0": {
"cordova": ">100"
}
"cordovaDependencies": {
"3.0.0": {
"cordova": ">100"
}
}
}
}

View File

@ -18,7 +18,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-screen-orientation"
version="2.0.0">
version="2.0.1">
<name>Screen Orientation</name>
<description>Adds Screen Orientation API lock and unlock functions to the global screen object in android, iOS, WP8, W8.1, and BB10.</description>
<license>Apache 2.0</license>

View File

@ -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
@end

View File

@ -57,6 +57,6 @@ module.exports = {
}
}
}
};
require("cordova/exec/proxy").add("CDVOrientation", module.exports);

14
tests/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "cordova-plugin-screen-orientation-tests",
"version": "2.0.1-dev",
"description": "",
"cordova": {
"id": "cordova-plugin-screen-orientation-tests",
"platforms": []
},
"keywords": [
"ecosystem:cordova"
],
"author": "",
"license": "Apache 2.0"
}

View File

@ -22,7 +22,7 @@
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-screen-orientation-tests"
version="2.0.0">
version="2.0.1">
<name>Cordova Screen Orientation Plugin Tests</name>
<license>Apache 2.0</license>

View File

@ -139,3 +139,23 @@ exports.defineAutoTests = function() {
});
});
};
exports.defineManualTests = function(contentEl, createActionButton) {
createActionButton('Listen to orientationchange events', function() {
window.addEventListener("orientationchange", function(){
contentEl.innerHTML += '<p>Orientation changed! ' + screen.orientation.type + '</p>';
});
});
createActionButton('Unlock orientation', function() {
screen.orientation.unlock();
contentEl.innerHTML += '<p>Orientation unlocked.</p>';
});
createActionButton('Lock to portrait', function() {
screen.orientation.lock('portrait');
contentEl.innerHTML += '<p>Orientation locked to portrait.</p>';
});
createActionButton('Lock to landscape', function() {
screen.orientation.lock('landscape');
contentEl.innerHTML += '<p>Orientation locked to landscape.</p>';
});
};

View File

@ -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) {