mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-05-11 05:11:37 +08:00
Merge branch 'master' into 2.0.x
This commit is contained in:
commit
55e897c288
@ -17,9 +17,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|Android 4.4|Android 5.1|iOS 9.3|iOS 10.0|Windows 10 Store|
|
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|
|
||||||
|:-:|:-:|:-:|:-:|:-:|
|
|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||||
|[](http://cordova-ci.cloudapp.net:8080/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-5.1,PLUGIN=cordova-plugin-screen-orientation/)|[](http://cordova-ci.cloudapp.net:8080/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-10.0,PLUGIN=cordova-plugin-screen-orientation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-screen-orientation/)|
|
|[](http://cordova-ci.cloudapp.net:8080/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-5.1,PLUGIN=cordova-plugin-screen-orientation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-screen-orientation/)|[](http://cordova-ci.cloudapp.net:8080/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-10.0,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
|
# Cordova Screen Orientation Plugin
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@
|
|||||||
# Release Notes
|
# 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)
|
### 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/
|
* [CB-11628](https://issues.apache.org/jira/browse/CB-11628) - w3c spec compliance https://www.w3.org/TR/screen-orientation/
|
||||||
|
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-plugin-screen-orientation",
|
"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.",
|
"description": "Adds Screen Orientation API lock and unlock functions to the global screen object in android, iOS, WP8, W8.1, and BB10.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -33,10 +33,10 @@
|
|||||||
"jshint": "^2.9.4"
|
"jshint": "^2.9.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"cordovaDependencies": {
|
"cordovaDependencies": {
|
||||||
"3.0.0": {
|
"3.0.0": {
|
||||||
"cordova": ">100"
|
"cordova": ">100"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
id="cordova-plugin-screen-orientation"
|
id="cordova-plugin-screen-orientation"
|
||||||
version="2.0.0">
|
version="2.0.1">
|
||||||
<name>Screen Orientation</name>
|
<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>
|
<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>
|
<license>Apache 2.0</license>
|
||||||
|
@ -52,10 +52,27 @@
|
|||||||
|
|
||||||
if([vc respondsToSelector:selector]) {
|
if([vc respondsToSelector:selector]) {
|
||||||
((void (*)(CDVViewController*, SEL, NSMutableArray*))objc_msgSend)(vc,selector,result);
|
((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];
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
}
|
}
|
||||||
else {
|
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];
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
|
@ -57,6 +57,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
require("cordova/exec/proxy").add("CDVOrientation", module.exports);
|
require("cordova/exec/proxy").add("CDVOrientation", module.exports);
|
||||||
|
14
tests/package.json
Normal file
14
tests/package.json
Normal 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"
|
||||||
|
}
|
@ -22,7 +22,7 @@
|
|||||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="cordova-plugin-screen-orientation-tests"
|
id="cordova-plugin-screen-orientation-tests"
|
||||||
version="2.0.0">
|
version="2.0.1">
|
||||||
<name>Cordova Screen Orientation Plugin Tests</name>
|
<name>Cordova Screen Orientation Plugin Tests</name>
|
||||||
<license>Apache 2.0</license>
|
<license>Apache 2.0</license>
|
||||||
|
|
||||||
|
@ -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>';
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -59,7 +59,7 @@ function addScreenOrientationApi(screenObject) {
|
|||||||
screenObject.lock = function(orientation) {
|
screenObject.lock = function(orientation) {
|
||||||
var promiseLock;
|
var promiseLock;
|
||||||
var p = new Promise(function(resolve, reject) {
|
var p = new Promise(function(resolve, reject) {
|
||||||
if (screenObject.nativeLock != null) {
|
if (screenObject.nativeLock) {
|
||||||
promiseLock = screenObject.nativeLock(orientation);
|
promiseLock = screenObject.nativeLock(orientation);
|
||||||
promiseLock.then(function success(res) {
|
promiseLock.then(function success(res) {
|
||||||
resolve();
|
resolve();
|
||||||
@ -70,14 +70,12 @@ function addScreenOrientationApi(screenObject) {
|
|||||||
} else {
|
} else {
|
||||||
resolveOrientation(orientation, resolve, reject);
|
resolveOrientation(orientation, resolve, reject);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return p;
|
return p;
|
||||||
}
|
};
|
||||||
|
|
||||||
screenObject.unlock = function() {
|
screenObject.unlock = function() {
|
||||||
screenOrientation.setOrientation('any');
|
screenOrientation.setOrientation('any');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveOrientation(orientation, resolve, reject) {
|
function resolveOrientation(orientation, resolve, reject) {
|
||||||
@ -99,11 +97,11 @@ var onChangeListener = null;
|
|||||||
Object.defineProperty(screen.orientation, 'onchange', {
|
Object.defineProperty(screen.orientation, 'onchange', {
|
||||||
set: function(listener) {
|
set: function(listener) {
|
||||||
|
|
||||||
if (onChangeListener != null) {
|
if (onChangeListener) {
|
||||||
screen.orientation.removeEventListener('change', onChangeListener);
|
screen.orientation.removeEventListener('change', onChangeListener);
|
||||||
}
|
}
|
||||||
onChangeListener = listener;
|
onChangeListener = listener;
|
||||||
if (onChangeListener != null) {
|
if (onChangeListener) {
|
||||||
screen.orientation.addEventListener('change', onChangeListener);
|
screen.orientation.addEventListener('change', onChangeListener);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -124,10 +122,11 @@ var orientationchange = function() {
|
|||||||
|
|
||||||
screen.orientation.addEventListener = function(a,b,c) {
|
screen.orientation.addEventListener = function(a,b,c) {
|
||||||
return evtTarget.addEventListener(a,b,c);
|
return evtTarget.addEventListener(a,b,c);
|
||||||
}
|
};
|
||||||
|
|
||||||
screen.orientation.removeEventListener = function(a,b,c) {
|
screen.orientation.removeEventListener = function(a,b,c) {
|
||||||
return evtTarget.removeEventListener(a,b,c);
|
return evtTarget.removeEventListener(a,b,c);
|
||||||
}
|
};
|
||||||
|
|
||||||
function setOrientationProperties() {
|
function setOrientationProperties() {
|
||||||
switch (window.orientation) {
|
switch (window.orientation) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user