@react-native-ohos/react-native-system-setting 1.7.7-rc.1
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/API.md +58 -0
- package/LICENSE +21 -0
- package/LICENSE.md +21 -0
- package/RCTSystemSetting.podspec +20 -0
- package/README.OpenSource +11 -0
- package/README.md +15 -0
- package/SystemSetting.d.ts +81 -0
- package/SystemSetting.js +348 -0
- package/Utils.js +11 -0
- package/harmony/react_native_system_setting/BuildProfile.ets +6 -0
- package/harmony/react_native_system_setting/Index.ets +27 -0
- package/harmony/react_native_system_setting/build-profile.json5 +31 -0
- package/harmony/react_native_system_setting/consumer-rules.txt +0 -0
- package/harmony/react_native_system_setting/hvigorfile.ts +6 -0
- package/harmony/react_native_system_setting/obfuscation-rules.txt +18 -0
- package/harmony/react_native_system_setting/oh-package.json5 +11 -0
- package/harmony/react_native_system_setting/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/react_native_system_setting/src/main/cpp/RNSystemSettingPackage.h +76 -0
- package/harmony/react_native_system_setting/src/main/cpp/ReactNativeSystemSetting.cpp +54 -0
- package/harmony/react_native_system_setting/src/main/cpp/ReactNativeSystemSetting.h +21 -0
- package/harmony/react_native_system_setting/src/main/ets/Logger.ts +64 -0
- package/harmony/react_native_system_setting/src/main/ets/RNSystemSettingPackage.ts +52 -0
- package/harmony/react_native_system_setting/src/main/ets/RNSystemSettingTurboModule.ts +362 -0
- package/harmony/react_native_system_setting/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/react_native_system_setting/src/main/ets/generated/index.ets +8 -0
- package/harmony/react_native_system_setting/src/main/ets/generated/ts.ts +9 -0
- package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ReactNativeSystemSetting.ts +86 -0
- package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ts.ts +8 -0
- package/harmony/react_native_system_setting/src/main/module.json5 +9 -0
- package/harmony/react_native_system_setting/src/main/resources/base/element/string.json +8 -0
- package/harmony/react_native_system_setting/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/react_native_system_setting/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/react_native_system_setting/ts.ts +25 -0
- package/harmony/react_native_system_setting.har +0 -0
- package/package.json +47 -0
- package/src/ReactRNSystemSetting.ts +113 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * as RNC from "./components/ts"
|
|
9
|
+
export * as TM from "./turboModules/ts"
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generatorVersion: 1
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export namespace ReactNativeSystemSetting {
|
|
12
|
+
export const NAME = 'ReactNativeSystemSetting' as const
|
|
13
|
+
|
|
14
|
+
export type EmitterSubscription = {remove: Object, type: unknown}
|
|
15
|
+
|
|
16
|
+
export interface Spec {
|
|
17
|
+
getBrightness(): Promise<number>;
|
|
18
|
+
|
|
19
|
+
setBrightness(val: number): Promise<boolean>;
|
|
20
|
+
|
|
21
|
+
setBrightnessForce(val: number): Promise<boolean>;
|
|
22
|
+
|
|
23
|
+
getAppBrightness(): Promise<number>;
|
|
24
|
+
|
|
25
|
+
setAppBrightness(val: number): Promise<boolean>;
|
|
26
|
+
|
|
27
|
+
grantWriteSettingPremission(): void;
|
|
28
|
+
|
|
29
|
+
getScreenMode(): Promise<number>;
|
|
30
|
+
|
|
31
|
+
setScreenMode(val: number): Promise<boolean>;
|
|
32
|
+
|
|
33
|
+
saveBrightness(): Promise<void>;
|
|
34
|
+
|
|
35
|
+
restoreBrightness(): number;
|
|
36
|
+
|
|
37
|
+
getVolume(type: unknown): Promise<number>;
|
|
38
|
+
|
|
39
|
+
setVolume(value: number, config: Object): void;
|
|
40
|
+
|
|
41
|
+
addVolumeListener(): void;
|
|
42
|
+
|
|
43
|
+
removeVolumeListener(listener: EmitterSubscription): void;
|
|
44
|
+
|
|
45
|
+
isWifiEnabled(): Promise<boolean>;
|
|
46
|
+
|
|
47
|
+
switchWifiSilence(onComplete: () => void): void;
|
|
48
|
+
|
|
49
|
+
switchWifi(onComplete: () => void): void;
|
|
50
|
+
|
|
51
|
+
isLocationEnabled(): Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
getLocationMode(): Promise<number>;
|
|
54
|
+
|
|
55
|
+
switchLocation(onComplete: () => void): void;
|
|
56
|
+
|
|
57
|
+
isBluetoothEnabled(): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
switchBluetooth(onComplete: () => void): void;
|
|
60
|
+
|
|
61
|
+
switchBluetoothSilence(onComplete: () => void): void;
|
|
62
|
+
|
|
63
|
+
isAirplaneEnabled(): Promise<boolean>;
|
|
64
|
+
|
|
65
|
+
switchAirplane(onComplete: () => void): void;
|
|
66
|
+
|
|
67
|
+
openAppSystemSettings(): void;
|
|
68
|
+
|
|
69
|
+
addBluetoothListener(): void;
|
|
70
|
+
|
|
71
|
+
addWifiListener(callback: (wifiEnabled: boolean) => void): Promise<null | EmitterSubscription>;
|
|
72
|
+
|
|
73
|
+
addLocationListener(callback: (locationEnabled: boolean) => void): Promise<null | EmitterSubscription>;
|
|
74
|
+
|
|
75
|
+
addLocationModeListener(callback: (locationMode: number) => void): Promise<null | EmitterSubscription>;
|
|
76
|
+
|
|
77
|
+
addAirplaneListener(callback: (airplaneModeEnabled: boolean) => void): Promise<null | EmitterSubscription>;
|
|
78
|
+
|
|
79
|
+
removeListener(type: string): void;
|
|
80
|
+
|
|
81
|
+
addListener(eventName: string): void;
|
|
82
|
+
|
|
83
|
+
removeListeners(count: number): void;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export * from './src/main/ets/RNSystemSettingPackage'
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-system-setting",
|
|
3
|
+
"version": "1.7.7-rc.1",
|
|
4
|
+
"description": "provide some system setting APIs. Volume, brightness, wifi, location, bluetooth, airplane...",
|
|
5
|
+
"main": "SystemSetting.js",
|
|
6
|
+
"types": "SystemSetting.d.ts",
|
|
7
|
+
"homepage": "https://github.com/c19354837/react-native-system-setting",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/c19354837/react-native-system-setting/issues"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react-native",
|
|
16
|
+
"system",
|
|
17
|
+
"setting",
|
|
18
|
+
"volume",
|
|
19
|
+
"wifi",
|
|
20
|
+
"brightness",
|
|
21
|
+
"location",
|
|
22
|
+
"bluetooth",
|
|
23
|
+
"airplane"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"src/",
|
|
27
|
+
"SystemSetting.d.ts",
|
|
28
|
+
"SystemSetting.js",
|
|
29
|
+
"Utils.js",
|
|
30
|
+
"/*.podspec",
|
|
31
|
+
"API.md",
|
|
32
|
+
"harmony"
|
|
33
|
+
],
|
|
34
|
+
"author": {
|
|
35
|
+
"name": "Ninty",
|
|
36
|
+
"email": "c19354837@hotmail.com",
|
|
37
|
+
"url": "https://github.com/c19354837"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/c19354837/react-native-system-setting.git"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"harmony": {
|
|
45
|
+
"alias": "react-native-system-setting"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
getBrightness: () => Promise<number>;
|
|
6
|
+
|
|
7
|
+
setBrightness: (val: number) => Promise<boolean>;
|
|
8
|
+
|
|
9
|
+
setBrightnessForce: (val: number) => Promise<boolean>;
|
|
10
|
+
|
|
11
|
+
getAppBrightness: () => Promise<number>;
|
|
12
|
+
|
|
13
|
+
setAppBrightness: (val: number) => Promise<boolean>;
|
|
14
|
+
|
|
15
|
+
grantWriteSettingPremission: () => void;
|
|
16
|
+
|
|
17
|
+
getScreenMode: () => Promise<number>;
|
|
18
|
+
|
|
19
|
+
setScreenMode: (val: number) => Promise<boolean>;
|
|
20
|
+
|
|
21
|
+
saveBrightness: () => Promise<void>;
|
|
22
|
+
|
|
23
|
+
restoreBrightness: () => number;
|
|
24
|
+
|
|
25
|
+
getVolume: (type?: VolumeType) => Promise<number>;
|
|
26
|
+
|
|
27
|
+
setVolume: (value: number, config?: VolumeConfig | VolumeType) => void;
|
|
28
|
+
|
|
29
|
+
addVolumeListener: () => void;
|
|
30
|
+
|
|
31
|
+
removeVolumeListener: (listener?: EmitterSubscription) => void;
|
|
32
|
+
|
|
33
|
+
isWifiEnabled: () => Promise<boolean>;
|
|
34
|
+
|
|
35
|
+
switchWifiSilence: (onComplete?: CompleteFunc) => void;
|
|
36
|
+
|
|
37
|
+
switchWifi: (onComplete?: CompleteFunc) => void;
|
|
38
|
+
|
|
39
|
+
isLocationEnabled: () => Promise<boolean>;
|
|
40
|
+
|
|
41
|
+
getLocationMode: () => Promise<number>;
|
|
42
|
+
|
|
43
|
+
switchLocation: (onComplete?: CompleteFunc) => void;
|
|
44
|
+
|
|
45
|
+
isBluetoothEnabled: () => Promise<boolean>;
|
|
46
|
+
|
|
47
|
+
switchBluetooth: (onComplete?: CompleteFunc) => void;
|
|
48
|
+
|
|
49
|
+
switchBluetoothSilence: (onComplete?: CompleteFunc) => void;
|
|
50
|
+
|
|
51
|
+
isAirplaneEnabled: () => Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
switchAirplane: (onComplete?: CompleteFunc) => void;
|
|
54
|
+
|
|
55
|
+
openAppSystemSettings: () => void;
|
|
56
|
+
|
|
57
|
+
addBluetoothListener: () => void;
|
|
58
|
+
|
|
59
|
+
addWifiListener: (
|
|
60
|
+
callback: (wifiEnabled: boolean) => void
|
|
61
|
+
) => Promise<EmitterSubscription | null>;
|
|
62
|
+
|
|
63
|
+
addLocationListener: (
|
|
64
|
+
callback: (locationEnabled: boolean) => void
|
|
65
|
+
) => Promise<EmitterSubscription | null>;
|
|
66
|
+
|
|
67
|
+
addLocationModeListener: (
|
|
68
|
+
callback: (locationMode: number) => void
|
|
69
|
+
) => Promise<EmitterSubscription | null>;
|
|
70
|
+
|
|
71
|
+
addAirplaneListener: (
|
|
72
|
+
callback: (airplaneModeEnabled: boolean) => void
|
|
73
|
+
) => Promise<EmitterSubscription | null>;
|
|
74
|
+
|
|
75
|
+
removeListener: (type: string) => void;
|
|
76
|
+
|
|
77
|
+
addListener(eventName: string): void;
|
|
78
|
+
|
|
79
|
+
removeListeners(count: number): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type EmitterSubscription = {
|
|
83
|
+
remove: unknown;
|
|
84
|
+
type: 'bluetooth' | 'wifi' | 'location' | 'locationMode' | 'airplane'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type CompleteFunc = () => void
|
|
88
|
+
|
|
89
|
+
type VolumeType =
|
|
90
|
+
| "call"
|
|
91
|
+
| "system"
|
|
92
|
+
| "ring"
|
|
93
|
+
| "music"
|
|
94
|
+
| "alarm"
|
|
95
|
+
| "notification";
|
|
96
|
+
|
|
97
|
+
type VolumeConfig = {
|
|
98
|
+
type?: VolumeType;
|
|
99
|
+
playSound?: boolean;
|
|
100
|
+
showUI?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type VolumeData = {
|
|
104
|
+
value: number;
|
|
105
|
+
call?: number;
|
|
106
|
+
system?: number;
|
|
107
|
+
ring?: number;
|
|
108
|
+
music?: number;
|
|
109
|
+
alarm?: number;
|
|
110
|
+
notification?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default TurboModuleRegistry.get<Spec>('ReactNativeSystemSetting') as Spec | null;
|