@react-native-ohos/react-native-qr-decode-image-camera 1.1.4-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.
Files changed (73) hide show
  1. package/COMMITTERS.md +7 -0
  2. package/LICENSE +21 -0
  3. package/OAT.xml +89 -0
  4. package/QrCode.podspec +14 -0
  5. package/README.OpenSource +11 -0
  6. package/README.md +13 -0
  7. package/SECURITY.md +21 -0
  8. package/harmony/qr_decode_image_camera/BuildProfile.ets +17 -0
  9. package/harmony/qr_decode_image_camera/Index.ets +8 -0
  10. package/harmony/qr_decode_image_camera/build-profile.json5 +28 -0
  11. package/harmony/qr_decode_image_camera/hvigorfile.ts +1 -0
  12. package/harmony/qr_decode_image_camera/obfuscation-rules.txt +18 -0
  13. package/harmony/qr_decode_image_camera/oh-package-lock.json5 +18 -0
  14. package/harmony/qr_decode_image_camera/oh-package.json5 +12 -0
  15. package/harmony/qr_decode_image_camera/src/main/cpp/CMakeLists.txt +9 -0
  16. package/harmony/qr_decode_image_camera/src/main/cpp/QrDecodeImageCameraPackage.h +19 -0
  17. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/BaseReactNativeQrDecodeImageCameraPackage.h +72 -0
  18. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/turbo_modules/QrDecodeImageCameraNativeModule.cpp +16 -0
  19. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/turbo_modules/QrDecodeImageCameraNativeModule.h +16 -0
  20. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ComponentDescriptors.h +24 -0
  21. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/EventEmitters.cpp +16 -0
  22. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/EventEmitters.h +17 -0
  23. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/Props.cpp +19 -0
  24. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/Props.h +18 -0
  25. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ShadowNodes.cpp +17 -0
  26. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ShadowNodes.h +23 -0
  27. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/States.cpp +16 -0
  28. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/States.h +19 -0
  29. package/harmony/qr_decode_image_camera/src/main/ets/Logger.ts +46 -0
  30. package/harmony/qr_decode_image_camera/src/main/ets/NativeScan.ets +150 -0
  31. package/harmony/qr_decode_image_camera/src/main/ets/RNQrDecodeImageCameraPackage.ts +29 -0
  32. package/harmony/qr_decode_image_camera/src/main/ets/RNQrDecodeImageCameraTurboModule.ts +46 -0
  33. package/harmony/qr_decode_image_camera/src/main/ets/generated/components/NativeScan.ts +125 -0
  34. package/harmony/qr_decode_image_camera/src/main/ets/generated/components/ts.ts +8 -0
  35. package/harmony/qr_decode_image_camera/src/main/ets/generated/index.ets +5 -0
  36. package/harmony/qr_decode_image_camera/src/main/ets/generated/ts.ts +6 -0
  37. package/harmony/qr_decode_image_camera/src/main/ets/generated/turboModules/QrDecodeImageCameraNativeModule.ts +16 -0
  38. package/harmony/qr_decode_image_camera/src/main/ets/generated/turboModules/ts.ts +5 -0
  39. package/harmony/qr_decode_image_camera/src/main/ets/pages/Index.ets +26 -0
  40. package/harmony/qr_decode_image_camera/src/main/ets/qr_decode_image_camera/qr_decode_image_camera.ets +47 -0
  41. package/harmony/qr_decode_image_camera/src/main/module.json5 +11 -0
  42. package/harmony/qr_decode_image_camera/src/main/resources/base/element/color.json +8 -0
  43. package/harmony/qr_decode_image_camera/src/main/resources/base/element/string.json +16 -0
  44. package/harmony/qr_decode_image_camera/src/main/resources/base/media/background.png +0 -0
  45. package/harmony/qr_decode_image_camera/src/main/resources/base/media/foreground.png +0 -0
  46. package/harmony/qr_decode_image_camera/src/main/resources/base/media/layered_image.json +7 -0
  47. package/harmony/qr_decode_image_camera/src/main/resources/base/media/startIcon.png +0 -0
  48. package/harmony/qr_decode_image_camera/src/main/resources/base/profile/main_pages.json +5 -0
  49. package/harmony/qr_decode_image_camera/src/main/resources/en_US/element/string.json +16 -0
  50. package/harmony/qr_decode_image_camera/src/main/resources/zh_CN/element/string.json +16 -0
  51. package/harmony/qr_decode_image_camera/src/mock/mock-config.json5 +2 -0
  52. package/harmony/qr_decode_image_camera/src/ohosTest/ets/test/Ability.test.ets +35 -0
  53. package/harmony/qr_decode_image_camera/src/ohosTest/ets/test/List.test.ets +5 -0
  54. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testability/TestAbility.ets +47 -0
  55. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testability/pages/Index.ets +17 -0
  56. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +90 -0
  57. package/harmony/qr_decode_image_camera/src/ohosTest/module.json5 +36 -0
  58. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/element/color.json +8 -0
  59. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/element/string.json +16 -0
  60. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/media/icon.png +0 -0
  61. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/profile/test_pages.json +5 -0
  62. package/harmony/qr_decode_image_camera/src/test/List.test.ets +5 -0
  63. package/harmony/qr_decode_image_camera/src/test/LocalUnit.test.ets +33 -0
  64. package/harmony/qr_decode_image_camera/ts.ts +8 -0
  65. package/harmony/qr_decode_image_camera.har +0 -0
  66. package/index.js +15 -0
  67. package/package.json +39 -0
  68. package/src/Camera.tsx +58 -0
  69. package/src/NativeQrDecodeImageCamera.ts +17 -0
  70. package/src/NativeScan.ts +25 -0
  71. package/src/QRScanner.harmony.jsx +225 -0
  72. package/src/QRScanner.jsx +281 -0
  73. package/src/QRScannerView.js +381 -0
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import hilog from '@ohos.hilog';
8
+
9
+ class Logger {
10
+ private domain: number;
11
+ private prefix: string;
12
+ private format: string = '%{public}s, %{public}s';
13
+ private isDebug: boolean;
14
+
15
+ /**
16
+ * constructor.
17
+ *
18
+ * @param Prefix Identifies the log tag.
19
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
20
+ */
21
+ constructor(prefix: string = 'blobUtil', domain: number = 0xFF00, isDebug = false) {
22
+ this.prefix = prefix;
23
+ this.domain = domain;
24
+ this.isDebug = isDebug;
25
+ }
26
+
27
+ debug(...args: string[]): void {
28
+ if (this.isDebug) {
29
+ hilog.debug(this.domain, this.prefix, this.format, args);
30
+ }
31
+ }
32
+
33
+ info(...args: string[]): void {
34
+ hilog.info(this.domain, this.prefix, this.format, args);
35
+ }
36
+
37
+ warn(...args: string[]): void {
38
+ hilog.warn(this.domain, this.prefix, this.format, args);
39
+ }
40
+
41
+ error(...args: string[]): void {
42
+ hilog.error(this.domain, this.prefix, this.format, args);
43
+ }
44
+ }
45
+
46
+ export default new Logger('RNShake', 0xFF00, false)
@@ -0,0 +1,150 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { RNOHContext ,ViewBaseProps,Descriptor} from '@rnoh/react-native-openharmony';
8
+ import { RNC } from "./generated";
9
+ import { scanCore, scanBarcode, customScan } from '@kit.ScanKit';
10
+ import { BusinessError } from '@kit.BasicServicesKit';
11
+ import { common, abilityAccessCtrl } from '@kit.AbilityKit';
12
+ import { JSON } from '@kit.ArkTS';
13
+ import Logger from "./Logger"
14
+ interface NativeScanProps extends ViewBaseProps {
15
+ text: string,
16
+ flashMode: boolean,
17
+ onRead:(result:string) => void,
18
+ zoom:number
19
+ }
20
+ export type NativeScanDescriptor = Descriptor<"NativeScan", NativeScanProps>
21
+ @Component
22
+ export struct NativeScan {
23
+ public static readonly NAME:String = RNC.NativeScan.NAME
24
+ public ctx!: RNOHContext
25
+ public tag: number = 0
26
+ @State @Watch("changeProps") descriptor: NativeScanDescriptor = {} as NativeScanDescriptor //监听闪光灯
27
+ @State userGrant: boolean = false
28
+ @State surfaceId: string = ''
29
+ @State isFlashLightEnable: boolean = false
30
+ // 设置预览流高度,默认单位:vp
31
+ @State cameraHeight: number = 200
32
+ // 设置预览流宽度,默认单位:vp
33
+ @State cameraWidth: number = 200
34
+
35
+
36
+ private mXComponentController: XComponentController = new XComponentController()
37
+ private TAG: string = '[customScanPage]';
38
+ private cleanUpCallbacks: (() => void)[] = [];
39
+ private eventEmitter: RNC.NativeScan.EventEmitter | undefined = undefined
40
+ async showScanResult(result: Array<scanBarcode.ScanResult>) {
41
+ if (result.length > 0) {
42
+ // 获取到扫描结果后暂停相机流
43
+ customScan.stop().then(() => {
44
+ Logger.info( this.TAG, 'Succeeded in stopping customScan by promise!');
45
+ }).catch((error: BusinessError) => {
46
+ Logger.error( this.TAG, `Failed to stop customScan by promise. Code: ${error.code}, message: ${error.message}`);
47
+ })
48
+ this.onRead(JSON.stringify(result)) //返回结果
49
+ }
50
+ }
51
+
52
+ changeProps(){
53
+ //监听闪光灯
54
+ if(this.descriptor.props.flashMode === true){
55
+ customScan.openFlashLight();
56
+ }else if (this.descriptor.props.flashMode === false){
57
+ customScan.closeFlashLight();
58
+ }
59
+ }
60
+
61
+ async reqPermissionsFromUser(): Promise<number[]> {
62
+ let context = getContext() as common.UIAbilityContext;
63
+ let atManager = abilityAccessCtrl.createAtManager();
64
+ let grantStatus = await atManager.requestPermissionsFromUser(context, ['ohos.permission.CAMERA']);
65
+ return grantStatus.authResults;
66
+ }
67
+
68
+ // 申请相机权限
69
+ async requestCameraPermission() {
70
+ let grantStatus = await this.reqPermissionsFromUser();
71
+ for (let i = 0; i < grantStatus.length; i++) {
72
+ if (grantStatus[i] === 0) {
73
+ // 用户授权,可以继续访问目标操作
74
+ this.userGrant = true;
75
+
76
+ }else{
77
+ Logger.info('permissions fail')
78
+ }
79
+ }
80
+ }
81
+
82
+ //扫描结果
83
+ onRead(result: string){
84
+ this.eventEmitter!.emit("read",{result})
85
+ }
86
+
87
+
88
+ build() {
89
+
90
+ if(this.userGrant){
91
+ XComponent({
92
+ id: 'component-nativeScan',
93
+ type: 'surface',
94
+ controller: this.mXComponentController
95
+ })
96
+ .onLoad( async () => {
97
+ let options: scanBarcode.ScanOptions = {
98
+ scanTypes: [scanCore.ScanType.ALL],
99
+ enableMultiMode: true,
100
+ enableAlbum: true
101
+ }
102
+
103
+ // 自定义初始化接口
104
+ customScan.init(options);
105
+ // 获取XComponent的surfaceId
106
+ let surfaceId: string = this.mXComponentController.getXComponentSurfaceId();
107
+ // 设置ViewControl相应字段
108
+ let viewControl: customScan.ViewControl = {
109
+ width: this.cameraWidth,
110
+ height: this.cameraHeight,
111
+ surfaceId: surfaceId
112
+ };
113
+ customScan.start(viewControl).then((scanResult: Array<scanBarcode.ScanResult>) => {
114
+ console.log("click``````````")
115
+ Logger.info( '[Scan Sample]', `start succeeded, ${JSON.stringify(scanResult)}`,'click');
116
+ this.showScanResult(scanResult);
117
+ }).catch((error: BusinessError) => {
118
+ Logger.info( '[Scan Sample]', `start failed, code: ${error.code}, message: ${error.message}`,'click');
119
+ });
120
+ if(this.descriptor.props.zoom){
121
+ customScan.setZoom(this.descriptor.props.zoom)
122
+ }
123
+ })
124
+ }
125
+
126
+ }
127
+ aboutToAppear() {
128
+ this.requestCameraPermission();
129
+ this.eventEmitter = new RNC.NativeScan.EventEmitter(this.ctx.rnInstance, this.tag)
130
+ this.descriptor = this.ctx.descriptorRegistry.getDescriptor<NativeScanDescriptor>(this.tag)
131
+ this.cleanUpCallbacks.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
132
+ (newDescriptor) => {
133
+ this.descriptor = (newDescriptor as NativeScanDescriptor)
134
+ }
135
+ ))
136
+ this.cleanUpCallbacks.push(this.ctx.componentCommandReceiver.registerCommandCallback(this.tag, (commandName) => {
137
+
138
+ }))
139
+ }
140
+
141
+ aboutToDisappear() {
142
+ this.cleanUpCallbacks.forEach(cb => cb())
143
+ }
144
+
145
+
146
+ }
147
+
148
+
149
+
150
+
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
8
+ import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
9
+ import { TM } from './generated/ts'
10
+ import { RNQrDecodeImageCameraTurboModule } from './RNQrDecodeImageCameraTurboModule';
11
+
12
+ class RNQrDecodeImageCameraTurboModuleFactory extends TurboModulesFactory {
13
+ createTurboModule(name: string): TurboModule | null {
14
+ if (this.hasTurboModule(name)) {
15
+ return new RNQrDecodeImageCameraTurboModule(this.ctx);
16
+ }
17
+ return null;
18
+ }
19
+
20
+ hasTurboModule(name: string): boolean {
21
+ return name === TM.QrDecodeImageCameraNativeModule.NAME;
22
+ }
23
+ }
24
+
25
+ export class RNQrDecodeImageCameraPackage extends RNPackage {
26
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
27
+ return new RNQrDecodeImageCameraTurboModuleFactory(ctx);
28
+ }
29
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { TurboModule } from '@rnoh/react-native-openharmony/ts';
8
+ import { TM } from './generated/ts';
9
+ import window from '@ohos.window';
10
+ import { scanCore, scanBarcode, detectBarcode } from '@kit.ScanKit';
11
+ import { BusinessError } from '@kit.BasicServicesKit';
12
+ import Logger from "./Logger"
13
+
14
+ export class RNQrDecodeImageCameraTurboModule extends TurboModule implements TM.QrDecodeImageCameraNativeModule.Spec {
15
+
16
+ constructor(ctx) {
17
+ super(ctx);
18
+ }
19
+
20
+ QRreader(path: TM.QrDecodeImageCameraNativeModule.IPath): Promise<unknown> {
21
+
22
+ return new Promise ((resolve,reject)=>{
23
+ // 定义识码参数options
24
+ let options: scanBarcode.ScanOptions = {
25
+ scanTypes: [scanCore.ScanType.ALL],
26
+ enableMultiMode: true,
27
+ enableAlbum: true
28
+ }
29
+ // 调用图片识码接口
30
+ detectBarcode.decode(path, options).then((result: Array<scanBarcode.ScanResult>) => {
31
+ Logger.info( '[Scan Sample]', `Succeeded in getting ScanResult by promise with options, result is ${JSON.stringify(result)}`,'click success');
32
+ resolve(result)
33
+ }).catch((error: BusinessError) => {
34
+ Logger.info( '[Scan Sample]', `Failed to get ScanResult by promise with options. Code: ${error.code}, message: ${error.message}`,"click fail");
35
+ reject(error)
36
+ });
37
+ })
38
+ }
39
+
40
+ }
41
+
42
+
43
+
44
+
45
+
46
+
@@ -0,0 +1,125 @@
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
+ import {
11
+ Descriptor as ComponentDescriptor,
12
+ ViewBaseProps,
13
+ ViewRawProps,
14
+ ViewDescriptorWrapperBase,
15
+ ColorValue,
16
+ Color,
17
+ RNInstance,
18
+ Tag,
19
+ RNComponentCommandReceiver,
20
+ ViewPropsSelector,
21
+ } from '@rnoh/react-native-openharmony/ts';
22
+
23
+
24
+ export namespace NativeScan {
25
+ export const NAME = "NativeScan" as const
26
+
27
+ export interface DirectRawProps {
28
+ text?: string;
29
+ flashMode?: boolean;
30
+ zoom?: number;
31
+ }
32
+
33
+ export interface Props extends ViewBaseProps {}
34
+
35
+ export interface State {}
36
+
37
+ export interface RawProps extends ViewRawProps, DirectRawProps {}
38
+
39
+ export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
40
+ get text() {
41
+ return this.rawProps.text;
42
+ }
43
+
44
+ get flashMode() {
45
+ return this.rawProps.flashMode ?? false;
46
+ }
47
+
48
+ get zoom() {
49
+ return this.rawProps.zoom ?? 0;
50
+ }
51
+
52
+
53
+ }
54
+
55
+ export type Descriptor = ComponentDescriptor<
56
+ typeof NAME,
57
+ Props,
58
+ State,
59
+ RawProps
60
+ >;
61
+
62
+ export class DescriptorWrapper extends ViewDescriptorWrapperBase<
63
+ typeof NAME,
64
+ Props,
65
+ State,
66
+ RawProps,
67
+ PropsSelector
68
+ > {
69
+ protected createPropsSelector() {
70
+ return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
71
+ }
72
+ }
73
+
74
+ export interface EventPayloadByName {
75
+ "read": {result: string}
76
+ }
77
+
78
+ export class EventEmitter {
79
+ constructor(private rnInstance: RNInstance, private tag: Tag) {}
80
+
81
+ emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
82
+ this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
83
+ }
84
+ }
85
+
86
+ export interface CommandArgvByName {
87
+ }
88
+
89
+ export class CommandReceiver {
90
+ private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
91
+ private cleanUp: (() => void) | undefined = undefined
92
+
93
+ constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
94
+ }
95
+
96
+ subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
97
+ if (!this.listenersByCommandName.has(commandName)) {
98
+ this.listenersByCommandName.set(commandName, new Set())
99
+ }
100
+ this.listenersByCommandName.get(commandName)!.add(listener)
101
+ const hasRegisteredCommandReceiver = !!this.cleanUp
102
+ if (!hasRegisteredCommandReceiver) {
103
+ this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
104
+ if (this.listenersByCommandName.has(commandName)) {
105
+ const listeners = this.listenersByCommandName.get(commandName)!
106
+ listeners.forEach(listener => {
107
+ listener(argv)
108
+ })
109
+ }
110
+ })
111
+ }
112
+
113
+ return () => {
114
+ this.listenersByCommandName.get(commandName)?.delete(listener)
115
+ if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
116
+ this.listenersByCommandName.delete(commandName)
117
+ }
118
+ if (this.listenersByCommandName.size === 0) {
119
+ this.cleanUp?.()
120
+ }
121
+ }
122
+ }
123
+ }
124
+
125
+ }
@@ -0,0 +1,8 @@
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 * from "./NativeScan"
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./ts"
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * as RNC from "./components/ts"
6
+ export * as TM from "./turboModules/ts"
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ import { Tag } from "@rnoh/react-native-openharmony/ts"
6
+
7
+ export namespace QrDecodeImageCameraNativeModule {
8
+ export const NAME = 'QrDecodeImageCameraNativeModule' as const
9
+
10
+ export type IPath = {uri: string}
11
+
12
+ export interface Spec {
13
+ QRreader(path: IPath): Promise<unknown>;
14
+
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./QrDecodeImageCameraNativeModule"
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ @Entry
8
+ @Component
9
+ struct Index {
10
+ @State message: string = 'Hello World';
11
+
12
+ build() {
13
+ RelativeContainer() {
14
+ Text(this.message)
15
+ .id('HelloWorld')
16
+ .fontSize(50)
17
+ .fontWeight(FontWeight.Bold)
18
+ .alignRules({
19
+ center: { anchor: '__container__', align: VerticalAlign.Center },
20
+ middle: { anchor: '__container__', align: HorizontalAlign.Center }
21
+ })
22
+ }
23
+ .height('100%')
24
+ .width('100%')
25
+ }
26
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
8
+ import { hilog } from '@kit.PerformanceAnalysisKit';
9
+ import { window } from '@kit.ArkUI';
10
+
11
+ export default class qr_decode_image_camera extends UIAbility {
12
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
13
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
14
+ }
15
+
16
+ onDestroy(): void {
17
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
18
+ }
19
+
20
+ onWindowStageCreate(windowStage: window.WindowStage): void {
21
+ // Main window is created, set main page for this ability
22
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
23
+
24
+ windowStage.loadContent('pages/Index', (err) => {
25
+ if (err.code) {
26
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
27
+ return;
28
+ }
29
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
30
+ });
31
+ }
32
+
33
+ onWindowStageDestroy(): void {
34
+ // Main window is destroyed, release UI related resources
35
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
36
+ }
37
+
38
+ onForeground(): void {
39
+ // Ability has brought to foreground
40
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
41
+ }
42
+
43
+ onBackground(): void {
44
+ // Ability has back to background
45
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
46
+ }
47
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "module": {
3
+ "name": "qr_decode_image_camera",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "default",
7
+ "tablet",
8
+ "2in1"
9
+ ]
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "color": [
3
+ {
4
+ "name": "start_window_background",
5
+ "value": "#FFFFFF"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "Qr_decode_image_cameraAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "Qr_decode_image_cameraAbility_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "layered-image":
3
+ {
4
+ "background" : "$media:background",
5
+ "foreground" : "$media:foreground"
6
+ }
7
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "Qr_decode_image_cameraAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "Qr_decode_image_cameraAbility_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "模块描述"
6
+ },
7
+ {
8
+ "name": "Qr_decode_image_cameraAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "Qr_decode_image_cameraAbility_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,35 @@
1
+ import { hilog } from '@kit.PerformanceAnalysisKit';
2
+ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3
+
4
+ export default function abilityTest() {
5
+ describe('ActsAbilityTest', () => {
6
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7
+ beforeAll(() => {
8
+ // Presets an action, which is performed only once before all test cases of the test suite start.
9
+ // This API supports only one parameter: preset action function.
10
+ })
11
+ beforeEach(() => {
12
+ // Presets an action, which is performed before each unit test case starts.
13
+ // The number of execution times is the same as the number of test cases defined by **it**.
14
+ // This API supports only one parameter: preset action function.
15
+ })
16
+ afterEach(() => {
17
+ // Presets a clear action, which is performed after each unit test case ends.
18
+ // The number of execution times is the same as the number of test cases defined by **it**.
19
+ // This API supports only one parameter: clear action function.
20
+ })
21
+ afterAll(() => {
22
+ // Presets a clear action, which is performed after all test cases of the test suite end.
23
+ // This API supports only one parameter: clear action function.
24
+ })
25
+ it('assertContain', 0, () => {
26
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28
+ let a = 'abc';
29
+ let b = 'b';
30
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31
+ expect(a).assertContain(b);
32
+ expect(a).assertEqual(a);
33
+ })
34
+ })
35
+ }
@@ -0,0 +1,5 @@
1
+ import abilityTest from './Ability.test';
2
+
3
+ export default function testsuite() {
4
+ abilityTest();
5
+ }