@capawesome/capacitor-screen-orientation 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- require 'json'
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = 'CapawesomeCapacitorScreenOrientation'
7
- s.version = package['version']
8
- s.summary = package['description']
9
- s.license = package['license']
10
- s.homepage = package['repository']['url']
11
- s.author = package['author']
12
- s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '13.0'
15
- s.dependency 'Capacitor'
16
- s.swift_version = '5.1'
17
- end
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapawesomeCapacitorScreenOrientation'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Robin Genz
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Robin Genz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,85 +1,85 @@
1
- <p align="center"><br><img src="https://avatars.githubusercontent.com/u/105555861" width="128" height="128" /></p>
2
- <h3 align="center">Screen Orientation</h3>
3
- <p align="center"><strong><code>@capawesome/capacitor-screen-orientation</code></strong></p>
4
- <p align="center">
5
- Capacitor plugin to lock/unlock the screen orientation.
6
- </p>
7
-
8
- <p align="center">
9
- <img src="https://img.shields.io/maintenance/yes/2022?style=flat-square" />
10
- <a href="https://github.com/capawesome-team/capacitor-screen-orientation/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/workflow/status/capawesome-team/capacitor-screen-orientation/CI/main?style=flat-square" /></a>
11
- <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/l/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
12
- <br>
13
- <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/dw/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
14
- <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/v/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
15
- <a href="https://github.com/capawesome-team"><img src="https://img.shields.io/badge/part%20of-capawesome-%234f46e5?style=flat-square" /></a>
16
- </p>
17
-
18
- ## Maintainers
19
-
20
- | Maintainer | GitHub | Social |
21
- | ---------- | ----------------------------------------- | --------------------------------------------- |
22
- | Robin Genz | [robingenz](https://github.com/robingenz) | [@robin_genz](https://twitter.com/robin_genz) |
23
-
24
- ## Sponsors
25
-
26
- This is an MIT-licensed open source project.
27
- It can grow thanks to the support by these awesome people.
28
- If you'd like to join them, please read more [here](https://github.com/sponsors/capawesome-team).
29
-
30
- <!-- sponsors --><!-- sponsors -->
31
-
32
- ## Installation
33
-
34
- ```bash
35
- npm install @capawesome/capacitor-screen-orientation
36
- npx cap sync
37
- ```
38
-
39
- ### iOS
40
-
41
- On iOS you must add the following to your app's `AppDelegate.swift`:
42
-
43
- ```diff
44
- + import CapawesomeCapacitorScreenOrientation
45
-
46
- @UIApplicationMain
47
- class AppDelegate: UIResponder, UIApplicationDelegate {
48
-
49
- + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
50
- + return ScreenOrientation.getSupportedInterfaceOrientations()
51
- + }
52
- ```
53
-
54
- ## Configuration
55
-
56
- No configuration required for this plugin.
57
-
58
- ## Demo
59
-
60
- A working example can be found here: [robingenz/capacitor-plugin-demo](https://github.com/robingenz/capacitor-plugin-demo)
61
-
62
- ## Usage
63
-
64
- ```typescript
65
- import { ScreenOrientation, OrientationType } from '@capawesome/capacitor-screen-orientation';
66
-
67
- const lock = async () => {
68
- await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE });
69
- };
70
-
71
- const unlock = async () => {
72
- await ScreenOrientation.unlock();
73
- };
74
-
75
- const getCurrentOrientation = async () => {
76
- const result = await ScreenOrientation.getCurrentOrientation();
77
- return result.type;
78
- };
79
- ```
80
-
81
- ## API
82
-
1
+ <p align="center"><br><img src="https://avatars.githubusercontent.com/u/105555861" width="128" height="128" /></p>
2
+ <h3 align="center">Screen Orientation</h3>
3
+ <p align="center"><strong><code>@capawesome/capacitor-screen-orientation</code></strong></p>
4
+ <p align="center">
5
+ Capacitor plugin to lock/unlock the screen orientation.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <img src="https://img.shields.io/maintenance/yes/2023?style=flat-square" />
10
+ <a href="https://github.com/capawesome-team/capacitor-screen-orientation/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/actions/workflow/status/capawesome-team/capacitor-screen-orientation/ci.yml?branch=main&style=flat-square" /></a>
11
+ <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/l/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
12
+ <br>
13
+ <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/dw/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
14
+ <a href="https://www.npmjs.com/package/@capawesome/capacitor-screen-orientation"><img src="https://img.shields.io/npm/v/@capawesome/capacitor-screen-orientation?style=flat-square" /></a>
15
+ <a href="https://github.com/capawesome-team"><img src="https://img.shields.io/badge/part%20of-capawesome-%234f46e5?style=flat-square" /></a>
16
+ </p>
17
+
18
+ ## Maintainers
19
+
20
+ | Maintainer | GitHub | Social |
21
+ | ---------- | ----------------------------------------- | --------------------------------------------- |
22
+ | Robin Genz | [robingenz](https://github.com/robingenz) | [@robin_genz](https://twitter.com/robin_genz) |
23
+
24
+ ## Sponsors
25
+
26
+ This is an MIT-licensed open source project.
27
+ It can grow thanks to the support by these awesome people.
28
+ If you'd like to join them, please read more [here](https://github.com/sponsors/capawesome-team).
29
+
30
+ <!-- sponsors --><!-- sponsors -->
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install @capawesome/capacitor-screen-orientation
36
+ npx cap sync
37
+ ```
38
+
39
+ ### iOS
40
+
41
+ On iOS you must add the following to your app's `AppDelegate.swift`:
42
+
43
+ ```diff
44
+ + import CapawesomeCapacitorScreenOrientation
45
+
46
+ @UIApplicationMain
47
+ class AppDelegate: UIResponder, UIApplicationDelegate {
48
+
49
+ + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
50
+ + return ScreenOrientation.getSupportedInterfaceOrientations()
51
+ + }
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ No configuration required for this plugin.
57
+
58
+ ## Demo
59
+
60
+ A working example can be found here: [robingenz/capacitor-plugin-demo](https://github.com/robingenz/capacitor-plugin-demo)
61
+
62
+ ## Usage
63
+
64
+ ```typescript
65
+ import { ScreenOrientation, OrientationType } from '@capawesome/capacitor-screen-orientation';
66
+
67
+ const lock = async () => {
68
+ await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE });
69
+ };
70
+
71
+ const unlock = async () => {
72
+ await ScreenOrientation.unlock();
73
+ };
74
+
75
+ const getCurrentOrientation = async () => {
76
+ const result = await ScreenOrientation.getCurrentOrientation();
77
+ return result.type;
78
+ };
79
+ ```
80
+
81
+ ## API
82
+
83
83
  <docgen-index>
84
84
 
85
85
  * [`lock(...)`](#lock)
@@ -91,8 +91,8 @@ const getCurrentOrientation = async () => {
91
91
  * [Type Aliases](#type-aliases)
92
92
  * [Enums](#enums)
93
93
 
94
- </docgen-index>
95
-
94
+ </docgen-index>
95
+
96
96
  <docgen-api>
97
97
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
98
98
 
@@ -219,12 +219,12 @@ Callback to receive the screen orientation change notifications.
219
219
  | **`PORTRAIT_PRIMARY`** | <code>'portrait-primary'</code> | The orientation is in the primary portrait mode. |
220
220
  | **`PORTRAIT_SECONDARY`** | <code>'portrait-secondary'</code> | The orientation is in the secondary portrait mode. |
221
221
 
222
- </docgen-api>
223
-
224
- ## Changelog
225
-
226
- See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-screen-orientation/blob/master/CHANGELOG.md).
227
-
228
- ## License
229
-
230
- See [LICENSE](https://github.com/capawesome-team/capacitor-screen-orientation/blob/master/LICENSE).
222
+ </docgen-api>
223
+
224
+ ## Changelog
225
+
226
+ See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-screen-orientation/blob/master/CHANGELOG.md).
227
+
228
+ ## License
229
+
230
+ See [LICENSE](https://github.com/capawesome-team/capacitor-screen-orientation/blob/master/LICENSE).
@@ -1,57 +1,57 @@
1
- ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
6
- }
7
-
8
- buildscript {
9
- repositories {
10
- google()
11
- mavenCentral()
12
- }
13
- dependencies {
14
- classpath 'com.android.tools.build:gradle:7.2.1'
15
- }
16
- }
17
-
18
- apply plugin: 'com.android.library'
19
-
20
- android {
21
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
- defaultConfig {
23
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
- versionCode 1
26
- versionName "1.0"
27
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
- }
29
- buildTypes {
30
- release {
31
- minifyEnabled false
32
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
- }
34
- }
35
- lintOptions {
36
- abortOnError false
37
- }
38
- compileOptions {
39
- sourceCompatibility JavaVersion.VERSION_11
40
- targetCompatibility JavaVersion.VERSION_11
41
- }
42
- }
43
-
44
- repositories {
45
- google()
46
- mavenCentral()
47
- }
48
-
49
-
50
- dependencies {
51
- implementation fileTree(dir: 'libs', include: ['*.jar'])
52
- implementation project(':capacitor-android')
53
- implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
- testImplementation "junit:junit:$junitVersion"
55
- androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
56
- androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
57
- }
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:7.2.1'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
+ defaultConfig {
23
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
+ versionCode 1
26
+ versionName "1.0"
27
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
+ }
29
+ buildTypes {
30
+ release {
31
+ minifyEnabled false
32
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
+ }
34
+ }
35
+ lintOptions {
36
+ abortOnError false
37
+ }
38
+ compileOptions {
39
+ sourceCompatibility JavaVersion.VERSION_11
40
+ targetCompatibility JavaVersion.VERSION_11
41
+ }
42
+ }
43
+
44
+ repositories {
45
+ google()
46
+ mavenCentral()
47
+ }
48
+
49
+
50
+ dependencies {
51
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
52
+ implementation project(':capacitor-android')
53
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
+ testImplementation "junit:junit:$junitVersion"
55
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
56
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
57
+ }
@@ -1,3 +1,3 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="io.capawesome.capacitorjs.plugins.screenorientation">
3
- </manifest>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="io.capawesome.capacitorjs.plugins.screenorientation">
3
+ </manifest>
@@ -1,87 +1,87 @@
1
- package io.capawesome.capacitorjs.plugins.screenorientation;
2
-
3
- import android.content.pm.ActivityInfo;
4
- import android.content.res.Configuration;
5
- import android.view.Surface;
6
- import androidx.annotation.Nullable;
7
- import com.getcapacitor.Bridge;
8
-
9
- public class ScreenOrientation {
10
-
11
- interface ScreenOrientationChangeListener {
12
- void onScreenOrientationChanged();
13
- }
14
-
15
- @Nullable
16
- private ScreenOrientationChangeListener orientationChangeListener;
17
-
18
- @Nullable
19
- private int lastOrientationConfiguration;
20
-
21
- private Bridge bridge;
22
-
23
- ScreenOrientation(Bridge bridge) {
24
- this.bridge = bridge;
25
- }
26
-
27
- public void handleOnConfigurationChanged(Configuration newConfig) {
28
- if (newConfig.orientation == lastOrientationConfiguration) {
29
- return;
30
- }
31
- this.lastOrientationConfiguration = newConfig.orientation;
32
- if (this.orientationChangeListener == null) {
33
- return;
34
- }
35
- this.orientationChangeListener.onScreenOrientationChanged();
36
- }
37
-
38
- public void setOrientationChangeListener(@Nullable ScreenOrientationChangeListener listener) {
39
- this.orientationChangeListener = listener;
40
- }
41
-
42
- @Nullable
43
- public ScreenOrientationChangeListener getOrientationChangeListener() {
44
- return orientationChangeListener;
45
- }
46
-
47
- public void lock(String orientationType) {
48
- switch (orientationType) {
49
- case ScreenOrientationType.LANDSCAPE:
50
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
51
- break;
52
- case ScreenOrientationType.LANDSCAPE_PRIMARY:
53
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
54
- break;
55
- case ScreenOrientationType.LANDSCAPE_SECONDARY:
56
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
57
- break;
58
- case ScreenOrientationType.PORTRAIT:
59
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
60
- break;
61
- case ScreenOrientationType.PORTRAIT_PRIMARY:
62
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
63
- break;
64
- case ScreenOrientationType.PORTRAIT_SECONDARY:
65
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
66
- break;
67
- }
68
- }
69
-
70
- public void unlock() {
71
- bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
72
- }
73
-
74
- public String getCurrentOrientationType() {
75
- int rotation = bridge.getActivity().getWindowManager().getDefaultDisplay().getRotation();
76
- switch (rotation) {
77
- case Surface.ROTATION_90:
78
- return ScreenOrientationType.LANDSCAPE_PRIMARY;
79
- case Surface.ROTATION_180:
80
- return ScreenOrientationType.PORTRAIT_SECONDARY;
81
- case Surface.ROTATION_270:
82
- return ScreenOrientationType.LANDSCAPE_SECONDARY;
83
- default:
84
- return ScreenOrientationType.PORTRAIT_PRIMARY;
85
- }
86
- }
87
- }
1
+ package io.capawesome.capacitorjs.plugins.screenorientation;
2
+
3
+ import android.content.pm.ActivityInfo;
4
+ import android.content.res.Configuration;
5
+ import android.view.Surface;
6
+ import androidx.annotation.Nullable;
7
+ import com.getcapacitor.Bridge;
8
+
9
+ public class ScreenOrientation {
10
+
11
+ interface ScreenOrientationChangeListener {
12
+ void onScreenOrientationChanged();
13
+ }
14
+
15
+ @Nullable
16
+ private ScreenOrientationChangeListener orientationChangeListener;
17
+
18
+ @Nullable
19
+ private int lastOrientationConfiguration;
20
+
21
+ private Bridge bridge;
22
+
23
+ ScreenOrientation(Bridge bridge) {
24
+ this.bridge = bridge;
25
+ }
26
+
27
+ public void handleOnConfigurationChanged(Configuration newConfig) {
28
+ if (newConfig.orientation == lastOrientationConfiguration) {
29
+ return;
30
+ }
31
+ this.lastOrientationConfiguration = newConfig.orientation;
32
+ if (this.orientationChangeListener == null) {
33
+ return;
34
+ }
35
+ this.orientationChangeListener.onScreenOrientationChanged();
36
+ }
37
+
38
+ public void setOrientationChangeListener(@Nullable ScreenOrientationChangeListener listener) {
39
+ this.orientationChangeListener = listener;
40
+ }
41
+
42
+ @Nullable
43
+ public ScreenOrientationChangeListener getOrientationChangeListener() {
44
+ return orientationChangeListener;
45
+ }
46
+
47
+ public void lock(String orientationType) {
48
+ switch (orientationType) {
49
+ case ScreenOrientationType.LANDSCAPE:
50
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
51
+ break;
52
+ case ScreenOrientationType.LANDSCAPE_PRIMARY:
53
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
54
+ break;
55
+ case ScreenOrientationType.LANDSCAPE_SECONDARY:
56
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
57
+ break;
58
+ case ScreenOrientationType.PORTRAIT:
59
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
60
+ break;
61
+ case ScreenOrientationType.PORTRAIT_PRIMARY:
62
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
63
+ break;
64
+ case ScreenOrientationType.PORTRAIT_SECONDARY:
65
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
66
+ break;
67
+ }
68
+ }
69
+
70
+ public void unlock() {
71
+ bridge.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
72
+ }
73
+
74
+ public String getCurrentOrientationType() {
75
+ int rotation = bridge.getActivity().getWindowManager().getDefaultDisplay().getRotation();
76
+ switch (rotation) {
77
+ case Surface.ROTATION_90:
78
+ return ScreenOrientationType.LANDSCAPE_PRIMARY;
79
+ case Surface.ROTATION_180:
80
+ return ScreenOrientationType.PORTRAIT_SECONDARY;
81
+ case Surface.ROTATION_270:
82
+ return ScreenOrientationType.LANDSCAPE_SECONDARY;
83
+ default:
84
+ return ScreenOrientationType.PORTRAIT_PRIMARY;
85
+ }
86
+ }
87
+ }