已开启
同步rc.4代码 打包 #19
已开启
yunkai909创建于 2月2日
共 17 个文件变更+258-185
Binary files do not support preview
@@ -7,10 +7,10 @@
7namespace rnoh {7namespace rnoh {
8using namespace facebook;8using namespace facebook;
9 9 
10-OreitationLockerNativeModule::OreitationLockerNativeModule(const ArkTSTurboModule::Context ctx, const std::string name)10+OreitationLockerNativeModule::OreitationLockerNativeModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
11- : ArkTSTurboModule(ctx, name)
12-{
13 methodMap_ = {11 methodMap_ = {
12+ ARK_METHOD_METADATA(init, 0),
13+ ARK_METHOD_METADATA(removeInit, 0),
14 ARK_METHOD_METADATA(getInitialOrientation, 0),14 ARK_METHOD_METADATA(getInitialOrientation, 0),
15 ARK_METHOD_METADATA(lockToPortrait, 0),15 ARK_METHOD_METADATA(lockToPortrait, 0),
16 ARK_METHOD_METADATA(lockToLandscape, 0),16 ARK_METHOD_METADATA(lockToLandscape, 0),
@@ -9,8 +9,12 @@
9 */9 */
10#pragma once10#pragma once
11 11 
12+ 
13+ 
12namespace facebook {14namespace facebook {
13namespace react {15namespace react {
14 16 
17+ 
18+ 
15} // namespace react19} // namespace react
16} // namespace facebook20} // namespace facebook
@@ -13,5 +13,7 @@
13namespace facebook {13namespace facebook {
14namespace react {14namespace react {
15 15 
16+ 
17+ 
16} // namespace react18} // namespace react
17} // namespace facebook19} // namespace facebook
@@ -19,5 +19,7 @@
19namespace facebook {19namespace facebook {
20namespace react {20namespace react {
21 21 
22+ 
23+ 
22} // namespace react24} // namespace react
23} // namespace facebook25} // namespace facebook
@@ -8,8 +8,16 @@
8 */8 */
9#pragma once9#pragma once
10 10 
11+#ifdef ANDROID
12+#include <folly/dynamic.h>
13+#include <react/renderer/mapbuffer/MapBuffer.h>
14+#include <react/renderer/mapbuffer/MapBufferBuilder.h>
15+#endif
16+ 
11namespace facebook {17namespace facebook {
12namespace react {18namespace react {
13 19 
20+ 
21+ 
14} // namespace react22} // namespace react
15} // namespace facebook23} // namespace facebook
@@ -4,66 +4,26 @@
4 * found in the LICENSE file.4 * found in the LICENSE file.
5 */5 */
6 6 
7-import { TurboModule } from '@rnoh/react-native-openharmony/ts'7+import { TurboModule } from "@rnoh/react-native-openharmony/ts";
8-import { TM } from './generated/ts'8+import { TM } from "./generated/ts";
9-import window from '@ohos.window'9+import window from "@ohos.window";
10-import display from '@ohos.display'10+import display from "@ohos.display";
11-import { BusinessError } from '@kit.BasicServicesKit'11+import { BusinessError } from "@kit.BasicServicesKit";
12-import sensor from '@ohos.sensor';12+import sensor from "@ohos.sensor";
13 13 
14const ORIENTATION_UNKNOWN = -1;14const ORIENTATION_UNKNOWN = -1;
15 15 
16-export class RNOrientationLockerTurboModule extends TurboModule implements TM.OreitationLockerNativeModule.Spec {16+export class RNOrientationLockerTurboModule
17- private lastDeviceOrientationValue:string = this.getOrientationString(display.getDefaultDisplaySync().orientation);17+ extends TurboModule
18- private lastDeviceSensorOrientationValue:string = "";18+ implements TM.OreitationLockerNativeModule.Spec
19+{
20+ private lastDeviceOrientationValue: string = "";
21+ private lastDeviceSensorOrientationValue: string = "";
19 constructor(ctx) {22 constructor(ctx) {
20- super(ctx)23+ super(ctx);
21- display.on('change', () => {
22- let deviceOrientationValue = this.lastDeviceOrientationValue;
23- let displayValue = display.getDefaultDisplaySync();
24- let displayValueString = this.getOrientationString(displayValue.orientation);
25- deviceOrientationValue = displayValueString;
26- if(this.lastDeviceOrientationValue != deviceOrientationValue){
27- this.lastDeviceOrientationValue = deviceOrientationValue;
28- ctx.rnInstance.emitDeviceEvent('orientationDidChange', { orientation: displayValueString })
29- }
30- })
31- 
32- sensor.on(sensor.SensorId.ACCELEROMETER, (data: sensor.AccelerometerResponse) => {
33- const X = -data.x;
34- const Y = -data.y;
35- const Z = -data.z;
36- const xyMagnitude = X * X + Y * Y;
37- const zSquared = Z * Z;
38- let orientation = ORIENTATION_UNKNOWN;
39- if (xyMagnitude * 4 >= zSquared) {
40- const angleRad = Math.atan2(-Y, X);
41- let angleDeg = 90 - (angleRad * 180 / Math.PI);
42- while (angleDeg >= 360) angleDeg -= 360;
43- while (angleDeg < 0) angleDeg += 360;
44- orientation = Math.round(angleDeg);
45- }
46- 
47- let deviceOrientationValue:string = this.lastDeviceSensorOrientationValue;
48- if (orientation === ORIENTATION_UNKNOWN) {
49- deviceOrientationValue = "UNKNOWN";
50- } else if (orientation > 355 || orientation < 5) {
51- deviceOrientationValue = "PORTRAIT";
52- } else if (orientation > 85 && orientation < 95) {
53- deviceOrientationValue = "LANDSCAPE-RIGHT";
54- } else if (orientation > 175 && orientation < 185) {
55- deviceOrientationValue = "PORTRAIT-UPSIDEDOWN";
56- } else if (orientation > 265 && orientation < 275) {
57- deviceOrientationValue = "LANDSCAPE-LEFT";
58- }
59- if (this.lastDeviceSensorOrientationValue !== deviceOrientationValue) {
60- ctx.rnInstance.emitDeviceEvent('deviceOrientationDidChange', { deviceOrientation: deviceOrientationValue })
61- this.lastDeviceSensorOrientationValue = deviceOrientationValue;
62- }
63- }, { interval: 100000000 });
64 }24 }
65 25 
66- private windowClass: window.Window | undefined = undefined26+ private windowClass: window.Window | undefined = undefined;
67 27 
68 private async setWindowClass(): Promise<void> {28 private async setWindowClass(): Promise<void> {
69 let context = this.ctx.uiAbilityContext;29 let context = this.ctx.uiAbilityContext;
@@ -74,71 +34,143 @@ export class RNOrientationLockerTurboModule extends TurboModule implements TM.Or
74 34 
75 private getOrientationString(orientation: number): string {35 private getOrientationString(orientation: number): string {
76 if (orientation === 0) {36 if (orientation === 0) {
77- return 'PORTRAIT';37+ return "PORTRAIT";
78 } else if (orientation === 1) {38 } else if (orientation === 1) {
79- return 'LANDSCAPE-RIGHT';39+ return "LANDSCAPE-RIGHT";
80 } else if (orientation === 2) {40 } else if (orientation === 2) {
81- return 'PORTRAIT-UPSIDEDOWN';41+ return "PORTRAIT-UPSIDEDOWN";
82 } else if (orientation === 3) {42 } else if (orientation === 3) {
83- return 'LANDSCAPE-LEFT';43+ return "LANDSCAPE-LEFT";
84 } else {44 } else {
85- return 'UNKNOWN';45+ return "UNKNOWN";
86 }46 }
87 }47 }
88 48 
89- private sendLockEvent(orientation: number) {49+ private sendLockEvent(orientation: number) {
90- let orientationString = this.getOrientationString(orientation)50+ let orientationString = this.getOrientationString(orientation);
91- this.ctx.rnInstance.emitDeviceEvent('lockDidChange', { orientation: orientationString })51+ this.ctx.rnInstance.emitDeviceEvent("lockDidChange", {
52+ orientation: orientationString,
53+ });
92 }54 }
93 55 
94 private lockToOrientation(orientation) {56 private lockToOrientation(orientation) {
95 this.setWindowClass().then(() => {57 this.setWindowClass().then(() => {
96 if (this.windowClass) {58 if (this.windowClass) {
97 // let orientation: window.Orientation = window.Orientation.AUTO_ROTATION_PORTRAIT;59 // let orientation: window.Orientation = window.Orientation.AUTO_ROTATION_PORTRAIT;
98- this.windowClass.setPreferredOrientation(orientation, (err: BusinessError) => {60+ this.windowClass.setPreferredOrientation(
99- if (err.code) {61+ orientation,
100- return;62+ (err: BusinessError) => {
101- }63+ if (err.code) {
102- // window.Orientation属性与displayValue.orientation对齐需要 orientation - 164+ return;
103- this.sendLockEvent(orientation - 1)65+ }
66+ // window.Orientation属性与displayValue.orientation对齐需要 orientation - 1
67+ this.sendLockEvent(orientation - 1);
68+ },
69+ );
70+ }
71+ });
72+ }
73+ 
74+ init(): void {
75+ this.lastDeviceOrientationValue = this.getOrientationString(
76+ display.getDefaultDisplaySync().orientation,
77+ );
78+ display.on("change", () => {
79+ let deviceOrientationValue = this.lastDeviceOrientationValue;
80+ let displayValue = display.getDefaultDisplaySync();
81+ let displayValueString = this.getOrientationString(
82+ displayValue.orientation,
83+ );
84+ deviceOrientationValue = displayValueString;
85+ if (this.lastDeviceOrientationValue != deviceOrientationValue) {
86+ this.lastDeviceOrientationValue = deviceOrientationValue;
87+ this.ctx.rnInstance.emitDeviceEvent("orientationDidChange", {
88+ orientation: displayValueString,
104 });89 });
105 }90 }
106- })91+ });
92+ 
93+ sensor.on(
94+ sensor.SensorId.ACCELEROMETER,
95+ (data: sensor.AccelerometerResponse) => {
96+ const X = -data.x;
97+ const Y = -data.y;
98+ const Z = -data.z;
99+ const xyMagnitude = X * X + Y * Y;
100+ const zSquared = Z * Z;
101+ let orientation = ORIENTATION_UNKNOWN;
102+ if (xyMagnitude * 4 >= zSquared) {
103+ const angleRad = Math.atan2(-Y, X);
104+ let angleDeg = 90 - (angleRad * 180) / Math.PI;
105+ while (angleDeg >= 360) angleDeg -= 360;
106+ while (angleDeg < 0) angleDeg += 360;
107+ orientation = Math.round(angleDeg);
108+ }
109+ 
110+ let deviceOrientationValue: string =
111+ this.lastDeviceSensorOrientationValue;
112+ if (orientation === ORIENTATION_UNKNOWN) {
113+ deviceOrientationValue = "UNKNOWN";
114+ } else if (orientation > 355 || orientation < 5) {
115+ deviceOrientationValue = "PORTRAIT";
116+ } else if (orientation > 85 && orientation < 95) {
117+ deviceOrientationValue = "LANDSCAPE-RIGHT";
118+ } else if (orientation > 175 && orientation < 185) {
119+ deviceOrientationValue = "PORTRAIT-UPSIDEDOWN";
120+ } else if (orientation > 265 && orientation < 275) {
121+ deviceOrientationValue = "LANDSCAPE-LEFT";
122+ }
123+ if (this.lastDeviceSensorOrientationValue !== deviceOrientationValue) {
124+ this.ctx.rnInstance.emitDeviceEvent("deviceOrientationDidChange", {
125+ deviceOrientation: deviceOrientationValue,
126+ });
127+ this.lastDeviceSensorOrientationValue = deviceOrientationValue;
128+ }
129+ },
130+ { interval: 100000000 },
131+ );
132+ }
133+ 
134+ removeInit(): void {
135+ display.off("change");
136+ sensor.off(sensor.SensorId.ACCELEROMETER);
107 }137 }
108 138 
109 lockToPortrait(): void {139 lockToPortrait(): void {
110 let orientation: window.Orientation = window.Orientation.PORTRAIT;140 let orientation: window.Orientation = window.Orientation.PORTRAIT;
111- this.lockToOrientation(orientation)141+ this.lockToOrientation(orientation);
112 }142 }
113 143 
114 lockToLandscape(): void {144 lockToLandscape(): void {
115- let orientation: window.Orientation = window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED;145+ let orientation: window.Orientation =
116- this.lockToOrientation(orientation)146+ window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED;
147+ this.lockToOrientation(orientation);
117 }148 }
118 149 
119 lockToLandscapeLeft(): void {150 lockToLandscapeLeft(): void {
120 let orientation: window.Orientation = window.Orientation.LANDSCAPE;151 let orientation: window.Orientation = window.Orientation.LANDSCAPE;
121- this.lockToOrientation(orientation)152+ this.lockToOrientation(orientation);
122 }153 }
123 154 
124 lockToAllOrientationsButUpsideDown(): void {155 lockToAllOrientationsButUpsideDown(): void {
125- let orientation: window.Orientation = window.Orientation.AUTO_ROTATION_PORTRAIT;156+ let orientation: window.Orientation =
126- this.lockToOrientation(orientation)157+ window.Orientation.AUTO_ROTATION_PORTRAIT;
158+ this.lockToOrientation(orientation);
127 }159 }
128 160 
129 lockToLandscapeRight(): void {161 lockToLandscapeRight(): void {
130 let orientation: window.Orientation = window.Orientation.LANDSCAPE_INVERTED;162 let orientation: window.Orientation = window.Orientation.LANDSCAPE_INVERTED;
131- this.lockToOrientation(orientation)163+ this.lockToOrientation(orientation);
132 }164 }
133 165 
134 lockToPortraitUpsideDown(): void {166 lockToPortraitUpsideDown(): void {
135 let orientation: window.Orientation = window.Orientation.PORTRAIT_INVERTED;167 let orientation: window.Orientation = window.Orientation.PORTRAIT_INVERTED;
136- this.lockToOrientation(orientation)168+ this.lockToOrientation(orientation);
137 }169 }
138 170 
139 unlockAllOrientations(): void {171 unlockAllOrientations(): void {
140 let orientation: window.Orientation = window.Orientation.AUTO_ROTATION;172 let orientation: window.Orientation = window.Orientation.AUTO_ROTATION;
141- this.lockToOrientation(orientation)173+ this.lockToOrientation(orientation);
142 }174 }
143 175 
144 getOrientation(callback: (orientation: string) => void): void {176 getOrientation(callback: (orientation: string) => void): void {
@@ -158,9 +190,9 @@ export class RNOrientationLockerTurboModule extends TurboModule implements TM.Or
158 try {190 try {
159 displayClass = display.getDefaultDisplaySync();191 displayClass = display.getDefaultDisplaySync();
160 let AppOrientation = this.getOrientationString(displayClass.orientation);192 let AppOrientation = this.getOrientationString(displayClass.orientation);
161- return AppOrientation193+ return AppOrientation;
162 } catch (e) {194 } catch (e) {
163- return 'UNKNOWN'195+ return "UNKNOWN";
164 }196 }
165 }197 }
166 198 
@@ -174,12 +206,12 @@ export class RNOrientationLockerTurboModule extends TurboModule implements TM.Or
174 }206 }
175 207 
176 getAutoRotateState(callback: (state: boolean) => void): void {208 getAutoRotateState(callback: (state: boolean) => void): void {
177- callback(true)209+ callback(true);
178 }210 }
179 211 
180- __onDestroy__(): void {212+ __onDestroy__(): void {
181- super.__onDestroy__()213+ super.__onDestroy__();
182- display.off('change')214+ display.off("change");
183- sensor.off(sensor.SensorId.ACCELEROMETER)215+ sensor.off(sensor.SensorId.ACCELEROMETER);
184 }216 }
185-}217+}
@@ -8,6 +8,10 @@ export namespace OreitationLockerNativeModule {
8 export const NAME = 'OreitationLockerNativeModule' as const8 export const NAME = 'OreitationLockerNativeModule' as const
9 9 
10 export interface Spec {10 export interface Spec {
11+ init(): void;
12+
13+ removeInit(): void;
14+
11 getInitialOrientation(): string;15 getInitialOrientation(): string;
12 16
13 lockToPortrait(): void;17 lockToPortrait(): void;
@@ -1,42 +1,46 @@
1-import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';1+import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
2-import { TurboModuleRegistry} from 'react-native';2+import { TurboModuleRegistry } from "react-native";
3 3 
4export interface Spec extends TurboModule {4export interface Spec extends TurboModule {
5+ // 初始化
6+ init(): void;
5 7 
6- //获取应用程序方向8+ // 移除初始化
7- getInitialOrientation(): string;9+ removeInit(): void;
8 10 
9- //锁定应用程序方向为纵向(竖屏)11+ //获取应用程序方向
10- lockToPortrait(): void;12+ getInitialOrientation(): string;
11 13 
12- //锁定应用程序方向为横向(横屏)14+ //锁定应用程序方向为纵向(竖屏)
13- lockToLandscape(): void;15+ lockToPortrait(): void;
14 16 
15- //锁定应用程序的方向为横向,并且是向左旋转的方向。17+ //锁定应用程序方向为横向(横屏)
16- lockToLandscapeLeft(): void;18+ lockToLandscape(): void;
17 19 
18- // 锁定除了上下之外的方向20+ //锁定应用程序的方向为横向,并且是向左旋转的方向。
19- lockToAllOrientationsButUpsideDown(): void;21+ lockToLandscapeLeft(): void;
20 22 
21- //锁定应用程序方向为横向,并且是向右旋转的方向23+ // 锁定除了上下之外的方向
22- lockToLandscapeRight(): void;24+ lockToAllOrientationsButUpsideDown(): void;
23 25 
24- //锁定上下的方向26+ //锁定应用程序方向为横向,并且是向右旋转的方向
25- lockToPortraitUpsideDown(): void;27+ lockToLandscapeRight(): void;
26 28 
27- //解锁所有方向29+ //锁定上下的方向
28- unlockAllOrientations(): void;30+ lockToPortraitUpsideDown(): void;
29 31 
30- //获取应用程序方向32+ //解锁所有方向
31- getOrientation(callback: (orientation: string) => void): void;33+ unlockAllOrientations(): void;
32 34 
33- //获取设备方向35+ //获取应用程序方向
34- getDeviceOrientation(callback: (orientation: string) => void): void;36+ getOrientation(callback: (orientation: string) => void): void;
35 37 
36- // 获取自动旋转状态38+ //获取设备方向
37- getAutoRotateState(callback: (state: boolean) => void): void;39+ getDeviceOrientation(callback: (orientation: string) => void): void;
38 40 
41+ // 获取自动旋转状态
42+ getAutoRotateState(callback: (state: boolean) => void): void;
39}43}
40-export default TurboModuleRegistry.get<Spec>('OreitationLockerNativeModule') as Spec | null;44+export default TurboModuleRegistry.get<Spec>(
41- 45+ "OreitationLockerNativeModule",
42- 46+) as Spec | null;
@@ -41,6 +41,13 @@ export default class Orientation {
41 });41 });
42 };42 };
43 43 
44+ static init = () => {
45+ OrientationNative.init();
46+ };
47+ static removeInit = () => {
48+ OrientationNative.removeInit();
49+ };
50+ 
44 static getDeviceOrientation = (cb) => {51 static getDeviceOrientation = (cb) => {
45 OrientationNative.getDeviceOrientation((deviceOrientation) => {52 OrientationNative.getDeviceOrientation((deviceOrientation) => {
46 cb(deviceOrientation);53 cb(deviceOrientation);
@@ -94,7 +101,7 @@ export default class Orientation {
94 "orientationDidChange",101 "orientationDidChange",
95 (body) => {102 (body) => {
96 cb(body.orientation);103 cb(body.orientation);
97- }104+ },
98 );105 );
99 };106 };
100 107 
@@ -115,7 +122,7 @@ export default class Orientation {
115 "deviceOrientationDidChange",122 "deviceOrientationDidChange",
116 (body) => {123 (body) => {
117 cb(body.deviceOrientation);124 cb(body.deviceOrientation);
118- }125+ },
119 );126 );
120 };127 };
121 128 
@@ -9,10 +9,10 @@
9"use strict";9"use strict";
10 10 
11import { TurboModuleRegistry } from "react-native";11import { TurboModuleRegistry } from "react-native";
12-var OrientationNative = TurboModuleRegistry ? 12+var OrientationNative = TurboModuleRegistry
13-TurboModuleRegistry.get('OreitationLockerNativeModule') :13+ ? TurboModuleRegistry.get("OreitationLockerNativeModule")
14-require('react-native').NativeModules.Orientation;14+ : require("react-native").NativeModules.Orientation;
15-var deviceEventEmitter = require('react-native').DeviceEventEmitter;15+var deviceEventEmitter = require("react-native").DeviceEventEmitter;
16 16 
17var listeners = {};17var listeners = {};
18 18 
@@ -27,7 +27,7 @@ function getKey(listener) {
27 return "F";27 return "F";
28 }28 }
29 Object.defineProperty(listener, META, {29 Object.defineProperty(listener, META, {
30- value: "L" + (id+1)30+ value: "L" + (id + 1),
31 });31 });
32 }32 }
33 return listener[META];33 return listener[META];
@@ -38,14 +38,22 @@ export default class Orientation {
38 // OrientationNative.configure(options);38 // OrientationNative.configure(options);
39 };39 };
40 40 
41- static getOrientation = cb => {41+ static getOrientation = (cb) => {
42- OrientationNative.getOrientation(orientation => {42+ OrientationNative.getOrientation((orientation) => {
43 cb(orientation);43 cb(orientation);
44 });44 });
45 };45 };
46 46 
47- static getDeviceOrientation = cb => {47+ static init = () => {
48- OrientationNative.getDeviceOrientation(deviceOrientation => {48+ OrientationNative.init();
49+ };
50+ 
51+ static removeInit = () => {
52+ OrientationNative.removeInit();
53+ };
54+ 
55+ static getDeviceOrientation = (cb) => {
56+ OrientationNative.getDeviceOrientation((deviceOrientation) => {
49 cb(deviceOrientation);57 cb(deviceOrientation);
50 });58 });
51 };59 };
@@ -90,17 +98,17 @@ export default class Orientation {
90 OrientationNative.unlockAllOrientations();98 OrientationNative.unlockAllOrientations();
91 };99 };
92 100 
93- static addOrientationListener = cb => {101+ static addOrientationListener = (cb) => {
94 var key = getKey(cb);102 var key = getKey(cb);
95 listeners[key] = deviceEventEmitter.addListener(103 listeners[key] = deviceEventEmitter.addListener(
96 "orientationDidChange",104 "orientationDidChange",
97- body => {105+ (body) => {
98 cb(body.orientation);106 cb(body.orientation);
99- }107+ },
100 );108 );
101 };109 };
102 110 
103- static removeOrientationListener = cb => {111+ static removeOrientationListener = (cb) => {
104 var key = getKey(cb);112 var key = getKey(cb);
105 if (!listeners[key]) {113 if (!listeners[key]) {
106 return;114 return;
@@ -109,17 +117,17 @@ export default class Orientation {
109 listeners[key] = null;117 listeners[key] = null;
110 };118 };
111 119 
112- static addDeviceOrientationListener = cb => {120+ static addDeviceOrientationListener = (cb) => {
113 var key = getKey(cb);121 var key = getKey(cb);
114 listeners[key] = deviceEventEmitter.addListener(122 listeners[key] = deviceEventEmitter.addListener(
115 "deviceOrientationDidChange",123 "deviceOrientationDidChange",
116- body => {124+ (body) => {
117 cb(body.deviceOrientation);125 cb(body.deviceOrientation);
118- }126+ },
119 );127 );
120 };128 };
121 129 
122- static removeDeviceOrientationListener = cb => {130+ static removeDeviceOrientationListener = (cb) => {
123 var key = getKey(cb);131 var key = getKey(cb);
124 if (!listeners[key]) {132 if (!listeners[key]) {
125 return;133 return;
@@ -128,14 +136,14 @@ export default class Orientation {
128 listeners[key] = null;136 listeners[key] = null;
129 };137 };
130 138 
131- static addLockListener = cb => {139+ static addLockListener = (cb) => {
132 var key = getKey(cb);140 var key = getKey(cb);
133- listeners[key] = deviceEventEmitter.addListener("lockDidChange", body => {141+ listeners[key] = deviceEventEmitter.addListener("lockDidChange", (body) => {
134 cb(body.orientation);142 cb(body.orientation);
135 });143 });
136 };144 };
137 145 
138- static removeLockListener = cb => {146+ static removeLockListener = (cb) => {
139 var key = getKey(cb);147 var key = getKey(cb);
140 if (!listeners[key]) {148 if (!listeners[key]) {
141 return;149 return;
@@ -160,7 +168,7 @@ export default class Orientation {
160 // return 'PORTRAIT';168 // return 'PORTRAIT';
161 };169 };
162 170 
163- static getAutoRotateState = cb => {171+ static getAutoRotateState = (cb) => {
164 cb(true); // iOS not implement172 cb(true); // iOS not implement
165 };173 };
166}174}
@@ -24,7 +24,7 @@ function getKey(listener) {
24 return "F";24 return "F";
25 }25 }
26 Object.defineProperty(listener, META, {26 Object.defineProperty(listener, META, {
27- value: "L" + ++id27+ value: "L" + ++id,
28 });28 });
29 }29 }
30 return listener[META];30 return listener[META];
@@ -35,14 +35,18 @@ export default class Orientation {
35 OrientationNative.configure(options);35 OrientationNative.configure(options);
36 };36 };
37 37 
38- static getOrientation = cb => {38+ static getOrientation = (cb) => {
39- OrientationNative.getOrientation(orientation => {39+ OrientationNative.getOrientation((orientation) => {
40 cb(orientation);40 cb(orientation);
41 });41 });
42 };42 };
43 43 
44- static getDeviceOrientation = cb => {44+ static init = () => {};
45- OrientationNative.getDeviceOrientation(deviceOrientation => {45+ 
46+ static removeInit = () => {};
47+ 
48+ static getDeviceOrientation = (cb) => {
49+ OrientationNative.getDeviceOrientation((deviceOrientation) => {
46 cb(deviceOrientation);50 cb(deviceOrientation);
47 });51 });
48 };52 };
@@ -87,17 +91,17 @@ export default class Orientation {
87 OrientationNative.unlockAllOrientations();91 OrientationNative.unlockAllOrientations();
88 };92 };
89 93 
90- static addOrientationListener = cb => {94+ static addOrientationListener = (cb) => {
91 var key = getKey(cb);95 var key = getKey(cb);
92 listeners[key] = LocalEventEmitter.addListener(96 listeners[key] = LocalEventEmitter.addListener(
93 "orientationDidChange",97 "orientationDidChange",
94- body => {98+ (body) => {
95 cb(body.orientation);99 cb(body.orientation);
96- }100+ },
97 );101 );
98 };102 };
99 103 
100- static removeOrientationListener = cb => {104+ static removeOrientationListener = (cb) => {
101 var key = getKey(cb);105 var key = getKey(cb);
102 if (!listeners[key]) {106 if (!listeners[key]) {
103 return;107 return;
@@ -106,17 +110,17 @@ export default class Orientation {
106 listeners[key] = null;110 listeners[key] = null;
107 };111 };
108 112 
109- static addDeviceOrientationListener = cb => {113+ static addDeviceOrientationListener = (cb) => {
110 var key = getKey(cb);114 var key = getKey(cb);
111 listeners[key] = LocalEventEmitter.addListener(115 listeners[key] = LocalEventEmitter.addListener(
112 "deviceOrientationDidChange",116 "deviceOrientationDidChange",
113- body => {117+ (body) => {
114 cb(body.deviceOrientation);118 cb(body.deviceOrientation);
115- }119+ },
116 );120 );
117 };121 };
118 122 
119- static removeDeviceOrientationListener = cb => {123+ static removeDeviceOrientationListener = (cb) => {
120 var key = getKey(cb);124 var key = getKey(cb);
121 if (!listeners[key]) {125 if (!listeners[key]) {
122 return;126 return;
@@ -125,14 +129,14 @@ export default class Orientation {
125 listeners[key] = null;129 listeners[key] = null;
126 };130 };
127 131 
128- static addLockListener = cb => {132+ static addLockListener = (cb) => {
129 var key = getKey(cb);133 var key = getKey(cb);
130- listeners[key] = LocalEventEmitter.addListener("lockDidChange", body => {134+ listeners[key] = LocalEventEmitter.addListener("lockDidChange", (body) => {
131 cb(body.orientation);135 cb(body.orientation);
132 });136 });
133 };137 };
134 138 
135- static removeLockListener = cb => {139+ static removeLockListener = (cb) => {
136 var key = getKey(cb);140 var key = getKey(cb);
137 if (!listeners[key]) {141 if (!listeners[key]) {
138 return;142 return;
@@ -155,7 +159,7 @@ export default class Orientation {
155 return OrientationNative.initialOrientation;159 return OrientationNative.initialOrientation;
156 };160 };
157 161 
158- static getAutoRotateState = cb => {162+ static getAutoRotateState = (cb) => {
159 cb(true); // iOS not implement163 cb(true); // iOS not implement
160 };164 };
161}165}
@@ -9,13 +9,13 @@
9"use strict";9"use strict";
10 10 
11export default class Orientation {11export default class Orientation {
12- static configure = options => {}12+ static configure = (options) => {};
13 13 
14- static getOrientation = cb => {14+ static getOrientation = (cb) => {
15 cb("UNKNOWN");15 cb("UNKNOWN");
16 };16 };
17 17 
18- static getDeviceOrientation = cb => {18+ static getDeviceOrientation = (cb) => {
19 cb("UNKNOWN");19 cb("UNKNOWN");
20 };20 };
21 21 
@@ -24,6 +24,8 @@ export default class Orientation {
24 };24 };
25 25 
26 static lockToPortrait = () => {};26 static lockToPortrait = () => {};
27+ static init = () => {};
28+ static removeInit = () => {};
27 29 
28 static lockToPortraitUpsideDown = () => {};30 static lockToPortraitUpsideDown = () => {};
29 31 
@@ -38,17 +40,17 @@ export default class Orientation {
38 40 
39 static unlockAllOrientations = () => {};41 static unlockAllOrientations = () => {};
40 42 
41- static addOrientationListener = cb => {};43+ static addOrientationListener = (cb) => {};
42 44 
43- static removeOrientationListener = cb => {};45+ static removeOrientationListener = (cb) => {};
44 46 
45- static addDeviceOrientationListener = cb => {};47+ static addDeviceOrientationListener = (cb) => {};
46 48 
47- static removeDeviceOrientationListener = cb => {};49+ static removeDeviceOrientationListener = (cb) => {};
48 50 
49- static addLockListener = cb => {};51+ static addLockListener = (cb) => {};
50 52 
51- static removeLockListener = cb => {};53+ static removeLockListener = (cb) => {};
52 54 
53 static removeAllListeners = () => {};55 static removeAllListeners = () => {};
54 56 
@@ -56,7 +58,7 @@ export default class Orientation {
56 return "UNKNOWN";58 return "UNKNOWN";
57 };59 };
58 60 
59- static getAutoRotateState = cb => {61+ static getAutoRotateState = (cb) => {
60 cb(true);62 cb(true);
61 };63 };
62}64}