@capawesome/capacitor-screen-orientation 1.1.7-dev.36f3183.1659623993 → 2.0.0
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.
- package/CapawesomeCapacitorScreenOrientation.podspec +1 -1
- package/README.md +93 -95
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/io/capawesome/{capacitor → capacitorjs/plugins}/screenorientation/ScreenOrientation.java +87 -87
- package/android/src/main/java/io/capawesome/{capacitor → capacitorjs/plugins}/screenorientation/ScreenOrientationPlugin.java +56 -56
- package/android/src/main/java/io/capawesome/{capacitor → capacitorjs/plugins}/screenorientation/ScreenOrientationType.java +11 -11
- package/package.json +14 -1
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -1,87 +1,85 @@
|
|
|
1
|
-
<p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" 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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
+
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
## API
|
|
84
|
-
|
|
1
|
+
<p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" 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
|
+
|
|
85
83
|
<docgen-index>
|
|
86
84
|
|
|
87
85
|
* [`lock(...)`](#lock)
|
|
@@ -93,8 +91,8 @@ const getCurrentOrientation = async () => {
|
|
|
93
91
|
* [Type Aliases](#type-aliases)
|
|
94
92
|
* [Enums](#enums)
|
|
95
93
|
|
|
96
|
-
</docgen-index>
|
|
97
|
-
|
|
94
|
+
</docgen-index>
|
|
95
|
+
|
|
98
96
|
<docgen-api>
|
|
99
97
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
100
98
|
|
|
@@ -221,12 +219,12 @@ Callback to receive the screen orientation change notifications.
|
|
|
221
219
|
| **`PORTRAIT_PRIMARY`** | <code>'portrait-primary'</code> | The orientation is in the primary portrait mode. |
|
|
222
220
|
| **`PORTRAIT_SECONDARY`** | <code>'portrait-secondary'</code> | The orientation is in the secondary portrait mode. |
|
|
223
221
|
|
|
224
|
-
</docgen-api>
|
|
225
|
-
|
|
226
|
-
## Changelog
|
|
227
|
-
|
|
228
|
-
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-screen-orientation/blob/master/CHANGELOG.md).
|
|
229
|
-
|
|
230
|
-
## License
|
|
231
|
-
|
|
232
|
-
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,87 +1,87 @@
|
|
|
1
|
-
package io.capawesome.
|
|
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
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
package io.capawesome.
|
|
2
|
-
|
|
3
|
-
import android.content.res.Configuration;
|
|
4
|
-
import com.getcapacitor.JSObject;
|
|
5
|
-
import com.getcapacitor.Plugin;
|
|
6
|
-
import com.getcapacitor.PluginCall;
|
|
7
|
-
import com.getcapacitor.PluginMethod;
|
|
8
|
-
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
-
|
|
10
|
-
@CapacitorPlugin(name = "ScreenOrientation")
|
|
11
|
-
public class ScreenOrientationPlugin extends Plugin {
|
|
12
|
-
|
|
13
|
-
public static final String SCREEN_ORIENTATION_CHANGE_EVENT = "screenOrientationChange";
|
|
14
|
-
|
|
15
|
-
private ScreenOrientation implementation;
|
|
16
|
-
|
|
17
|
-
@Override
|
|
18
|
-
public void load() {
|
|
19
|
-
implementation = new ScreenOrientation(getBridge());
|
|
20
|
-
implementation.setOrientationChangeListener(this::updateOrientation);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Override
|
|
24
|
-
public void handleOnConfigurationChanged(Configuration newConfig) {
|
|
25
|
-
super.handleOnConfigurationChanged(newConfig);
|
|
26
|
-
implementation.handleOnConfigurationChanged(newConfig);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@PluginMethod
|
|
30
|
-
public void lock(PluginCall call) {
|
|
31
|
-
String orientationType = call.getString("type");
|
|
32
|
-
implementation.lock(orientationType);
|
|
33
|
-
call.resolve();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@PluginMethod
|
|
37
|
-
public void unlock(PluginCall call) {
|
|
38
|
-
implementation.unlock();
|
|
39
|
-
call.resolve();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@PluginMethod
|
|
43
|
-
public void getCurrentOrientation(PluginCall call) {
|
|
44
|
-
JSObject ret = new JSObject();
|
|
45
|
-
String orientationType = implementation.getCurrentOrientationType();
|
|
46
|
-
ret.put("type", orientationType);
|
|
47
|
-
call.resolve(ret);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private void updateOrientation() {
|
|
51
|
-
JSObject ret = new JSObject();
|
|
52
|
-
String orientationType = implementation.getCurrentOrientationType();
|
|
53
|
-
ret.put("type", orientationType);
|
|
54
|
-
notifyListeners(SCREEN_ORIENTATION_CHANGE_EVENT, ret);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.screenorientation;
|
|
2
|
+
|
|
3
|
+
import android.content.res.Configuration;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
|
|
10
|
+
@CapacitorPlugin(name = "ScreenOrientation")
|
|
11
|
+
public class ScreenOrientationPlugin extends Plugin {
|
|
12
|
+
|
|
13
|
+
public static final String SCREEN_ORIENTATION_CHANGE_EVENT = "screenOrientationChange";
|
|
14
|
+
|
|
15
|
+
private ScreenOrientation implementation;
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void load() {
|
|
19
|
+
implementation = new ScreenOrientation(getBridge());
|
|
20
|
+
implementation.setOrientationChangeListener(this::updateOrientation);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
public void handleOnConfigurationChanged(Configuration newConfig) {
|
|
25
|
+
super.handleOnConfigurationChanged(newConfig);
|
|
26
|
+
implementation.handleOnConfigurationChanged(newConfig);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@PluginMethod
|
|
30
|
+
public void lock(PluginCall call) {
|
|
31
|
+
String orientationType = call.getString("type");
|
|
32
|
+
implementation.lock(orientationType);
|
|
33
|
+
call.resolve();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@PluginMethod
|
|
37
|
+
public void unlock(PluginCall call) {
|
|
38
|
+
implementation.unlock();
|
|
39
|
+
call.resolve();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@PluginMethod
|
|
43
|
+
public void getCurrentOrientation(PluginCall call) {
|
|
44
|
+
JSObject ret = new JSObject();
|
|
45
|
+
String orientationType = implementation.getCurrentOrientationType();
|
|
46
|
+
ret.put("type", orientationType);
|
|
47
|
+
call.resolve(ret);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private void updateOrientation() {
|
|
51
|
+
JSObject ret = new JSObject();
|
|
52
|
+
String orientationType = implementation.getCurrentOrientationType();
|
|
53
|
+
ret.put("type", orientationType);
|
|
54
|
+
notifyListeners(SCREEN_ORIENTATION_CHANGE_EVENT, ret);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
package io.capawesome.
|
|
2
|
-
|
|
3
|
-
public class ScreenOrientationType {
|
|
4
|
-
|
|
5
|
-
public static final String LANDSCAPE = "landscape";
|
|
6
|
-
public static final String LANDSCAPE_PRIMARY = "landscape-primary";
|
|
7
|
-
public static final String LANDSCAPE_SECONDARY = "landscape-secondary";
|
|
8
|
-
public static final String PORTRAIT = "portrait";
|
|
9
|
-
public static final String PORTRAIT_PRIMARY = "portrait-primary";
|
|
10
|
-
public static final String PORTRAIT_SECONDARY = "portrait-secondary";
|
|
11
|
-
}
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.screenorientation;
|
|
2
|
+
|
|
3
|
+
public class ScreenOrientationType {
|
|
4
|
+
|
|
5
|
+
public static final String LANDSCAPE = "landscape";
|
|
6
|
+
public static final String LANDSCAPE_PRIMARY = "landscape-primary";
|
|
7
|
+
public static final String LANDSCAPE_SECONDARY = "landscape-secondary";
|
|
8
|
+
public static final String PORTRAIT = "portrait";
|
|
9
|
+
public static final String PORTRAIT_PRIMARY = "portrait-primary";
|
|
10
|
+
public static final String PORTRAIT_SECONDARY = "portrait-secondary";
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-screen-orientation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Capacitor plugin to lock/unlock the screen orientation.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -22,6 +22,16 @@
|
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/capawesome-team/capacitor-screen-orientation/issues"
|
|
24
24
|
},
|
|
25
|
+
"funding": [
|
|
26
|
+
{
|
|
27
|
+
"type": "github",
|
|
28
|
+
"url": "https://github.com/sponsors/capawesome-team/"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "opencollective",
|
|
32
|
+
"url": "https://opencollective.com/capawesome"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
25
35
|
"keywords": [
|
|
26
36
|
"capacitor",
|
|
27
37
|
"plugin",
|
|
@@ -77,5 +87,8 @@
|
|
|
77
87
|
"android": {
|
|
78
88
|
"src": "android"
|
|
79
89
|
}
|
|
90
|
+
},
|
|
91
|
+
"publishConfig": {
|
|
92
|
+
"access": "public"
|
|
80
93
|
}
|
|
81
94
|
}
|