expo-rotation-module 0.1.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/.eslintrc.js +5 -0
- package/README.md +77 -0
- package/android/.gradle/8.14.3/checksums/checksums.lock +0 -0
- package/android/.gradle/8.14.3/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.14.3/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.14.3/gc.properties +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
- package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1210 -0
- package/android/.idea/gradle.xml +12 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +63 -0
- package/android/build.gradle +43 -0
- package/android/kls_database.db +0 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/ktsierra/expo/rotationmodule/ExpoRotationModule.kt +131 -0
- package/app.plugin.js +3 -0
- package/build/ExpoRotationModule.d.ts +15 -0
- package/build/ExpoRotationModule.d.ts.map +1 -0
- package/build/ExpoRotationModule.js +76 -0
- package/build/ExpoRotationModule.js.map +1 -0
- package/build/ExpoRotationModule.types.d.ts +18 -0
- package/build/ExpoRotationModule.types.d.ts.map +1 -0
- package/build/ExpoRotationModule.types.js +2 -0
- package/build/ExpoRotationModule.types.js.map +1 -0
- package/build/ExpoRotationModule.web.d.ts +12 -0
- package/build/ExpoRotationModule.web.d.ts.map +1 -0
- package/build/ExpoRotationModule.web.js +17 -0
- package/build/ExpoRotationModule.web.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/index.js +2 -0
- package/ios/ExpoRotationModule.podspec +29 -0
- package/ios/ExpoRotationModule.swift +48 -0
- package/package.json +48 -0
- package/plugin/index.js +33 -0
- package/src/ExpoRotationModule.ts +86 -0
- package/src/ExpoRotationModule.types.ts +19 -0
- package/src/ExpoRotationModule.web.ts +21 -0
- package/src/index.d.ts +17 -0
- package/src/index.ts +2 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# expo-rotation-module
|
|
2
|
+
|
|
3
|
+
An Expo native module that controls the Android system rotation settings (ACCELEROMETER_ROTATION and USER_ROTATION).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
This package exposes a small API to check and request the WRITE_SETTINGS permission and to read/set the global rotation mode. This module is Android-only; iOS and web are no-ops.
|
|
7
|
+
|
|
8
|
+
## Install (local development with pnpm)
|
|
9
|
+
|
|
10
|
+
From the module repo:
|
|
11
|
+
|
|
12
|
+
- `pnpm install`
|
|
13
|
+
- (optional) `pnpm build` — runs the expo-module build scripts
|
|
14
|
+
|
|
15
|
+
From your Expo app project:
|
|
16
|
+
|
|
17
|
+
- Add the module locally: `pnpm add ../expo-rotation-module` (or `pnpm add file:../expo-rotation-module`)
|
|
18
|
+
- IMPORTANT: Add the plugin to your app config so the permission is injected during prebuild:
|
|
19
|
+
|
|
20
|
+
In `app.json` or `app.config.js` add the following to your `expo.plugins` array:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
"plugins": [
|
|
24
|
+
"expo-rotation-module"
|
|
25
|
+
]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Run `npx expo prebuild` to apply the config plugin and update `AndroidManifest.xml`.
|
|
29
|
+
- Rebuild the Android app (use EAS dev client or Android Studio):
|
|
30
|
+
- Recommended: `pnpm add expo-dev-client` then `eas build --profile development --platform android` and run with `expo start --dev-client`.
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
Import functions:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import Rotation, { canWrite, requestWritePermission, getRotationState, setRotationState } from 'expo-rotation-module';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- `canWrite(): Promise<boolean>` — true if WRITE_SETTINGS is granted (Android M+), otherwise true on older OS.
|
|
41
|
+
- `requestWritePermission(): void` — opens Settings where the user can grant WRITE_SETTINGS.
|
|
42
|
+
- `getRotationState(): Promise<'AUTOROTATE'|'PORTRAIT'|'LANDSCAPE'>` — reads current rotation state.
|
|
43
|
+
- `setRotationState(state): Promise<void>` — sets rotation. Rejects with an Error object that may include a `.code` property.
|
|
44
|
+
|
|
45
|
+
Error codes on the Error object (if available): `E_PERMISSION`, `E_INVALID_STATE`, `E_SET_ROTATION`, `E_GET_ROTATION`, `E_NO_MODULE`.
|
|
46
|
+
|
|
47
|
+
## Example
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import * as Rotation from 'expo-rotation-module';
|
|
51
|
+
|
|
52
|
+
async function example() {
|
|
53
|
+
if (!(await Rotation.canWrite())) {
|
|
54
|
+
Rotation.requestWritePermission();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await Rotation.setRotationState('PORTRAIT');
|
|
60
|
+
} catch (e: any) {
|
|
61
|
+
if (e.code === 'E_PERMISSION') {
|
|
62
|
+
console.warn('Permission missing');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Plugin
|
|
69
|
+
The package contains `plugin/index.js` that injects `android.permission.WRITE_SETTINGS` into the host app's AndroidManifest during `expo prebuild`.
|
|
70
|
+
|
|
71
|
+
## Package id and Android settings
|
|
72
|
+
The Android package/namespace used within module sources is `ktsierra.expo.rotationmodule`.
|
|
73
|
+
|
|
74
|
+
## Contributing & tests
|
|
75
|
+
If you want CI or tests added (TS checks, build smoke tests), I can add a GitHub Actions workflow that runs `pnpm install` and `pnpm build`.
|
|
76
|
+
|
|
77
|
+
---
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|