Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit d29dac9

Browse files
authored
Merge pull request #1 from Magic-Neko/sig
add Harmony
2 parents df4de3b + fe6c066 commit d29dac9

28 files changed

Lines changed: 494 additions & 11 deletions

KeepAwakeExample.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React, { useState, useEffect } from 'react';
2+
import {
3+
Text,
4+
Button,
5+
} from 'react-native';
6+
7+
import KeepAwake , { activateKeepAwake,deactivateKeepAwake,useKeepAwake} from 'react-native-keep-awake'
8+
9+
export function KeepAwakeExample() {
10+
useKeepAwake();
11+
12+
const handleClick = (buttonId: number) => {
13+
switch (buttonId) {
14+
case 1:
15+
deactivateKeepAwake();
16+
break;
17+
case 2:
18+
activateKeepAwake();
19+
break;
20+
case 3:
21+
deactivateKeepAwake();
22+
break;
23+
case 4:
24+
KeepAwake.activate();
25+
break;
26+
case 5:
27+
KeepAwake.deactivate();
28+
break;
29+
default:
30+
break;
31+
}
32+
};
33+
34+
return (
35+
<>
36+
<Text style={{color:"blue"}}>Button 1:hook默认方法开启(常亮),----useKeepAwake(),点击按键1关闭常亮</Text>
37+
<Button title='Button 1' onPress={() => handleClick(1)} ></Button>
38+
39+
<Text style={{color:"blue"}}>Button 2:functions方法开启----activateKeepAwake()</Text>
40+
<Button title='Button 2' onPress={() => handleClick(2)}></Button>
41+
42+
<Text style={{color:"blue"}}>Button 3:function方法关闭----deactivateKeepAwake()</Text>
43+
<Button title='Button 3' onPress={() => handleClick(3)}></Button>
44+
45+
<Text style={{color:"blue"}}>Button 4:老接口方法----KeepAwake.activate()</Text>
46+
<Button title='Button 4' onPress={() => handleClick(4)}></Button>
47+
48+
<Text style={{color:"blue"}}>Button 5:老接口方法----KeepAwake.deactivate()</Text>
49+
<Button title='Button 5' onPress={() => handleClick(5)}></Button>
50+
</>
51+
);
52+
53+
}

harmony/keep_awake.har

91.4 KB
Binary file not shown.

harmony/keep_awake/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/oh_modules
3+
/.preview
4+
/build
5+
/.cxx
6+
/.test
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default class BuildProfile {
2+
static readonly HAR_VERSION = '4.0.0-0.0.1';
3+
static readonly BUILD_MODE_NAME = 'debug';
4+
static readonly DEBUG = true;
5+
static readonly TARGET_NAME = 'default';
6+
}

harmony/keep_awake/Index.ets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./ts";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"apiType": "stageMode",
3+
"buildOption": {
4+
},
5+
"buildOptionSet": [
6+
{
7+
"name": "release",
8+
"arkOptions": {
9+
"obfuscation": {
10+
"ruleOptions": {
11+
"enable": true,
12+
"files": [
13+
"./obfuscation-rules.txt"
14+
]
15+
}
16+
}
17+
}
18+
},
19+
],
20+
"targets": [
21+
{
22+
"name": "default"
23+
},
24+
{
25+
"name": "ohosTest",
26+
}
27+
]
28+
}

harmony/keep_awake/hvigorfile.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
2+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Define project specific obfuscation rules here.
2+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
3+
#
4+
# For more details, see
5+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6+
7+
# Obfuscation options:
8+
# -disable-obfuscation: disable all obfuscations
9+
# -enable-property-obfuscation: obfuscate the property names
10+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
11+
# -compact: remove unnecessary blank spaces and all line feeds
12+
# -remove-log: remove all console.* statements
13+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
14+
# -apply-namecache: reuse the given cache file
15+
16+
# Keep options:
17+
# -keep-property-name: specifies property names that you want to keep
18+
# -keep-global-name: specifies names that you want to keep in the global scope
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@react-native-oh-tpl/react-native-keep-awake",
3+
"version": "4.0.0-0.0.1",
4+
"description": "Keep the screen from going to sleep. iOS , Android and Harmony",
5+
"main": "Index.ets",
6+
"author": "",
7+
"license": "Apache-2.0",
8+
"dependencies": {
9+
"@rnoh/react-native-openharmony": 'file:../react_native_openharmony'
10+
}
11+
}
12+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
import hilog from '@ohos.hilog';
26+
27+
class Logger {
28+
private domain: number;
29+
private prefix: string;
30+
private format: string = '%{public}s, %{public}s';
31+
private isDebug: boolean;
32+
33+
/**
34+
* constructor.
35+
*
36+
* @param Prefix Identifies the log tag.
37+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
38+
*/
39+
constructor(prefix: string = 'RNCToolbarAndroid', domain: number = 0xFF00, isDebug = false) {
40+
this.prefix = prefix;
41+
this.domain = domain;
42+
this.isDebug = isDebug;
43+
}
44+
45+
debug(...args: string[]): void {
46+
if (this.isDebug) {
47+
hilog.debug(this.domain, this.prefix, this.format, args);
48+
}
49+
}
50+
51+
info(...args: string[]): void {
52+
hilog.info(this.domain, this.prefix, this.format, args);
53+
}
54+
55+
warn(...args: string[]): void {
56+
hilog.warn(this.domain, this.prefix, this.format, args);
57+
}
58+
59+
error(...args: string[]): void {
60+
hilog.error(this.domain, this.prefix, this.format, args);
61+
}
62+
}
63+
64+
export default new Logger('RNTextSizeTurboModule', 0xFF00, false)

0 commit comments

Comments
 (0)