mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-05-05 01:32:59 +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>
|
||||
@ -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
|
Loading…
x
Reference in New Issue
Block a user