mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-02-23 16:42:50 +08:00
Fixed formatting & cleanup
This commit is contained in:
parent
0a927a0d7d
commit
2f7b5ed086
@ -2,7 +2,7 @@
|
||||
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="net.yoik.cordova.plugins.screenorientation"
|
||||
version="0.0.1">
|
||||
version="0.0.2">
|
||||
|
||||
<name>YoikScreenOrientation</name>
|
||||
<description>Yoik Screen Orientation Plugin</description>
|
||||
@ -16,7 +16,7 @@
|
||||
<clobbers target="cordova.plugins.screenorientation" />
|
||||
</js-module>
|
||||
|
||||
<platform name="ios">
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="YoikScreenOrientation">
|
||||
<param name="ios-package" value="YoikScreenOrientation" />
|
||||
@ -24,11 +24,9 @@
|
||||
</config-file>
|
||||
<header-file src="src/ios/YoikScreenOrientation.h" />
|
||||
<source-file src="src/ios/YoikScreenOrientation.m" />
|
||||
|
||||
</platform>
|
||||
|
||||
<platform name="android">
|
||||
|
||||
<source-file src="src/android/net/yoik/cordova/plugins/screenorientation/YoikScreenOrientation.java" target-dir="src/net/yoik/cordova/plugins/screenorientation/" />
|
||||
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
@ -36,7 +34,6 @@
|
||||
<param name="android-package" value="net.yoik.cordova.plugins.screenorientation.YoikScreenOrientation" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
</platform>
|
||||
|
||||
</plugin>
|
@ -24,8 +24,8 @@ SOFTWARE.
|
||||
package net.yoik.cordova.plugins.screenorientation;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
@ -57,9 +57,6 @@ public class YoikScreenOrientation extends CordovaPlugin {
|
||||
private static final String REVERSE_PORTRAIT = "reversePortrait";
|
||||
private static final String FULL_SENSOR = "fullSensor";
|
||||
|
||||
// an index for the toast message
|
||||
private static final int TOAST_MESSAGE_INDEX = 0;
|
||||
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
|
||||
|
||||
@ -87,8 +84,6 @@ public class YoikScreenOrientation extends CordovaPlugin {
|
||||
|
||||
Activity activity = cordova.getActivity();
|
||||
|
||||
Log.d(TAG, "ROUTING SET");
|
||||
|
||||
if (orientation.equals(UNSPECIFIED)) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else if (orientation.equals(LANDSCAPE)) {
|
||||
@ -123,7 +118,6 @@ public class YoikScreenOrientation extends CordovaPlugin {
|
||||
callbackContext.error("ScreenOrientation not recognised");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,6 @@ SOFTWARE.
|
||||
|
||||
@interface YoikScreenOrientation : CDVPlugin
|
||||
|
||||
|
||||
- (void)screenOrientation:(CDVInvokedUrlCommand *)command;
|
||||
|
||||
@end
|
@ -1,24 +1,44 @@
|
||||
//
|
||||
// YoikScreenOrientation.m
|
||||
// Yoik
|
||||
//
|
||||
// Created by Nick Luo on 14/06/13.
|
||||
//
|
||||
//
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#import "YoikScreenOrientation.h"
|
||||
|
||||
@implementation YoikScreenOrientation
|
||||
|
||||
-(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:^{ [self.viewController dismissViewControllerAnimated:NO completion:nil]; }];
|
||||
|
||||
// Assume everything went ok
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
|
||||
// ------------------
|
||||
}
|
||||
|
||||
@end
|
@ -24,20 +24,20 @@ SOFTWARE.
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
exec = require('cordova/exec'),
|
||||
Constants = {
|
||||
Orientation: {
|
||||
Orientation: {
|
||||
UNSPECIFIED: "unspecified",
|
||||
LANDSCAPE: "landscape",
|
||||
PORTRAIT: "portrait",
|
||||
USER: "user",
|
||||
BEHIND: "behind",
|
||||
SENSOR: "sensor",
|
||||
NOSENSOR: "nosensor",
|
||||
SENSOR_LANDSCAPE: "sensorLandscape",
|
||||
SENSOR_PORTRAIT: "sensorPortrait",
|
||||
REVERSE_LANDSCAPE: "reverseLandscape",
|
||||
REVERSE_PORTRAIT: "reversePortrait",
|
||||
FULL_SENSOR: "fullSensor"
|
||||
}
|
||||
LANDSCAPE: "landscape",
|
||||
PORTRAIT: "portrait",
|
||||
USER: "user",
|
||||
BEHIND: "behind",
|
||||
SENSOR: "sensor",
|
||||
NOSENSOR: "nosensor",
|
||||
SENSOR_LANDSCAPE: "sensorLandscape",
|
||||
SENSOR_PORTRAIT: "sensorPortrait",
|
||||
REVERSE_LANDSCAPE: "reverseLandscape",
|
||||
REVERSE_PORTRAIT: "reversePortrait",
|
||||
FULL_SENSOR: "fullSensor"
|
||||
}
|
||||
},
|
||||
currOrientation = Constants.Orientation.UNSPECIFIED;
|
||||
|
||||
@ -62,32 +62,32 @@ orientationExports.setOrientation = function(successCallback, errorCallback, ori
|
||||
|
||||
// ios orientation callback/hook
|
||||
window.shouldRotateToOrientation = function(orientation) {
|
||||
var o = Constants.Orientation;
|
||||
switch (currOrientation) {
|
||||
case o.PORTRAIT:
|
||||
case o.SENSOR_PORTRAIT:
|
||||
if (orientation === 0) return true;
|
||||
break;
|
||||
case o.LANDSCAPE:
|
||||
case o.SENSOR_LANDSCAPE:
|
||||
if (orientation === -90) return true;
|
||||
break;
|
||||
case o.REVERSE_LANDSCAPE:
|
||||
if (orientation === 90) return true;
|
||||
break;
|
||||
case o.REVERSE_PORTRAIT:
|
||||
if (orientation === 180) return true;
|
||||
break;
|
||||
case o.FULL_SENSOR:
|
||||
return true;
|
||||
break;
|
||||
var o = Constants.Orientation;
|
||||
switch (currOrientation) {
|
||||
case o.PORTRAIT:
|
||||
case o.SENSOR_PORTRAIT:
|
||||
if (orientation === 0) return true;
|
||||
break;
|
||||
case o.LANDSCAPE:
|
||||
case o.SENSOR_LANDSCAPE:
|
||||
if (orientation === -90) return true;
|
||||
break;
|
||||
case o.REVERSE_LANDSCAPE:
|
||||
if (orientation === 90) return true;
|
||||
break;
|
||||
case o.REVERSE_PORTRAIT:
|
||||
if (orientation === 180) return true;
|
||||
break;
|
||||
case o.FULL_SENSOR:
|
||||
return true;
|
||||
break;
|
||||
case o.SENSOR:
|
||||
case o.UNSPECIFIED:
|
||||
if (orientation === -90 || orientation === 90 || orientation === 0) return true;
|
||||
break;
|
||||
}
|
||||
case o.UNSPECIFIED:
|
||||
if (orientation === -90 || orientation === 90 || orientation === 0) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = orientationExports;
|
Loading…
Reference in New Issue
Block a user