diff --git a/OAT.xml b/OAT.xml index fb2b2507c7e18d6f832870e95c5c39323ce4b8a2..816d3172ef5f1185494228a678a139b4f3049912 100644 --- a/OAT.xml +++ b/OAT.xml @@ -400,7 +400,7 @@ Note:If the text contains special characters, please escape them according to th - + @@ -430,6 +430,8 @@ Note:If the text contains special characters, please escape them according to th + + @@ -1248,7 +1250,7 @@ Note:If the text contains special characters, please escape them according to th - + @@ -1354,16 +1356,16 @@ Note:If the text contains special characters, please escape them according to th - - - - - - - - - - + + + + + + + + + + @@ -2407,7 +2409,7 @@ Note:If the text contains special characters, please escape them according to th - + @@ -2478,7 +2480,7 @@ Note:If the text contains special characters, please escape them according to th - + diff --git a/README.md b/README.md index f90e84ec4e4c27b40f1d7dff0b0da0d16fd468d1..c658001fa43f8720b8d3b5786844529b6a9f7e15 100755 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ We provide a series of app samples to help you quickly get familiar with the API - [`SimManager`:SIM Card Manager(ArkTS)(API9)](code/BasicFeature/Telephony/SimManager) - [`MobileNetwork`:Cellular Network(ArkTS)(API9)](code/BasicFeature/Telephony/MobileNetwork) - thread - - [`JsWorker`:Launch a worker(API12)](code/LaunguageBaseClassLibrary/ConcurrentModule) + - [`JsWorker`:Launch a worker(API12)](code/LanguageBaseClassLibrary/ConcurrentModule) - CompleteApps - [`KikaInput`:Lite Input Method(JS)(API10)](code/Solutions/InputMethod/KikaInput) - [`FlipClock`:Flip Clock(ArkTS)(API9)](code/Solutions/Tools/FlipClock) @@ -76,7 +76,7 @@ We provide a series of app samples to help you quickly get familiar with the API - [`ArkTSDistributeCalc`:Distributed Calculator(ArkTS)(API9)](code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc) - [`ArkTSDistributedMusicPlayer`:Distributed Music Player (ArkTS)(API9)](code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer) - PackageManagement - - [`ZipLib`:zip&unzip(ArkTS)(API9)](code/LaunguageBaseClassLibrary/ZipLib) + - [`ZipLib`:zip&unzip(ArkTS)(API9)](code/LanguageBaseClassLibrary/ZipLib) - ResourcesSchedule - [`Flybird`:Game(ArkTS)(API9)](code/SystemFeature/TaskManagement/Flybird) diff --git a/README_zh.md b/README_zh.md index 9ff123ac8d66f93973ebbd7d122f2263e9dc41c9..9081e675076769317da846a5ec55034ca01565c5 100644 --- a/README_zh.md +++ b/README_zh.md @@ -597,9 +597,9 @@ 语言基础类库 语言基础类库 - 多线程任务 - 语言基础类库(API 10) - 压缩与解压 + 多线程任务 + 语言基础类库(API 10) + 压缩与解压 @@ -709,9 +709,9 @@ code |---ApplicationHap # 应用程序包 |---HapBuild # 流水线预测试工具 |---Test # 测试框架 -|---LaunguageBaseClassLibrary # 语言基础类库 +|---LanguageBaseClassLibrary # 语言基础类库 |---ConcurrentModule # 多线程任务 - |---LaunguageBaseClassLibrary # 语言基础类库 + |---LanguageBaseClassLibrary # 语言基础类库 |---ZipLib # 解压与压缩 |---Performance # 性能 |---ArkRuntime # 方舟运行时 diff --git a/changelog.md b/changelog.md index 059c5af5ceba998e4ed73b68ea5b726fccaf77d4..1a3b396dd841749a0873a2b5998d0a80178c2bc4 100644 --- a/changelog.md +++ b/changelog.md @@ -19,7 +19,7 @@ # 6月6日-6月9日新增sample (总计26个分类,146个sample) 1.[`MissionManager`:系统任务管理(ArkTS)(API9)](code/SystemFeature/ApplicationModels/MissionManager) -2.[`ZipLib`:压缩与解压(ArkTS)(API9)](code/LaunguageBaseClassLibrary/ZipLib) +2.[`ZipLib`:压缩与解压(ArkTS)(API9)](code/LanguageBaseClassLibrary/ZipLib) 3.[`ArkTSDistributedMusicPlayer`:分布式音乐(ArkTS)(API9)](code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer) # 6月9日-6月18日新增sample (总计27个分类,155个sample) diff --git a/code/BasicFeature/Ads/OAIDSample/README_ZH.md b/code/BasicFeature/Ads/OAIDSample/README_ZH.md index 2e06036b41092a85cd0b3423f79fe0ebba0c10b9..c7993339a4aa3aa529562fc7e5782462adff7fdd 100644 --- a/code/BasicFeature/Ads/OAIDSample/README_ZH.md +++ b/code/BasicFeature/Ads/OAIDSample/README_ZH.md @@ -24,8 +24,18 @@ 3.点击“通过异步callback获取OAID”,上方文本框显示OAID。 -4.重置功能需安装[ResetOAID](/code/BasicFeature/Ads/OAIDSample/lib/ResetOAID-1.0.0.hap),点击“重置OAID”,上方文本框OAID重置。 - +4.重置功能需安装[ResetOAID](/code/BasicFeature/Ads/OAIDSample/lib/ResetOAID-1.0.0.hap),此外还需将应用包名配置到设备侧系统配置文件中,具体操作步骤如下,点击“重置OAID”,重新获取OAID上方文本框OAID改变。 +``` +hdc shell mount -o rw,remount / +hdc file recv etc/advertising/oaid/oaid_service_config.json +// 修改oaid_service_config.json文件,添加包名 +{ + "resetOAIDBundleName": ["com.samples.resetOAID"], + "providerBundleName": "", + "providerAbilityName": "" +} +hdc file send oaid_service_config.json etc/advertising/oaid/oaid_service_config.json +``` ### 工程目录 ``` diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md index dfa8f9b39859ac0e542ef70688f1e7abf953e5be..88ce0146e6242a785bc3079ac9a107a7aa884706 100755 --- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md +++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 -本示例使用[@ohos.bundle.bundleManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.bundleManager.d.ts),[@ohos.bundle.defaultAppManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.defaultAppManager.d.ts),[@ohos.bundle.overlay](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.bundle.overlay.d.ts) +本示例使用[@ohos.bundle.bundleManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-bundleManager.md),[@ohos.bundle.defaultAppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-defaultAppManager.md),[@ohos.bundle.overlay](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-overlay.md) 等接口,展示了向开发者如何调用包管理提供的public接口,验证其功能。 ### 效果预览 diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md index a5e7b5a88257babe4b9a7265b5c1a971ee18c7b0..96dda84b854f57fe93d984aef97d5fc98c6989bb 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md @@ -5,15 +5,15 @@ ### 效果预览 -| 主页 | 上传 | 片段上传 | 下载 | 证书锁定 | -| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- | -| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![cert_lock](screenshots/devices/zh/cert_lock.jpg) | +| 主页 | 上传 | 片段上传 | 下载 | 下载到用户目录 | 证书锁定 | +| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- | +| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![convertxml](screenshots/devices/zh/download_user.jpg) | ![cert_lock](screenshots/devices/zh/cert_lock.jpg) | 使用说明 1.本示例功能需要先配置服务器环境后使用,具体配置见[上传下载服务配置](./environment)。 -2.首页展示上传、下载和证书锁定三个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。 +2.首页展示上传、下载、下载到用户目录和证书锁定四个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。 3.上传页面: @@ -103,9 +103,9 @@ UploadAndDownload * 下载模块 - * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。 + * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建下载任务,调用@ohos.request中的Task相关接口实现下载任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载,下载到用户目录只支持前台下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。使用[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)进行用户文件的目录路径选择和查看。 * 源码链接:[RequestDownload.ets](./features/uploadanddownload/src/main/ets/download/RequestDownload.ets),[Download.ets](./entry/src/main/ets/pages/Download.ets),[FileUtils.ets](./features/uploadanddownload/src/main/ets/utils/FileUtils.ets),[FileBrowse.ets](./features/uploadanddownload/src/main/ets/components/FileBrowse.ets) - * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) + * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) * 证书锁定模块 @@ -133,9 +133,9 @@ UploadAndDownload 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0) +2.本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0) -3.本示例需要使用DevEco Studio 版本号(4.1 Release)及以上版本才可编译运行。 +3.本示例需要使用DevEco Studio 版本号(5.0.5 Release)及以上版本才可编译运行。 4.运行本示例需全程联网。 diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 index 49dfabaaebd6ee47414f91c55299f79b16629226..875dfdc5350b40a55965a4d52b663394ba85139a 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 @@ -21,8 +21,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, "runtimeOS": "OpenHarmony" } ] diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/build-profile.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/build-profile.json5 index 6ebd7bd06c2022dfa7a8fd08b0d983476bf08252..74bd2c087893b6e7ea5471d82b35f454b7751c43 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/build-profile.json5 +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/build-profile.json5 @@ -20,8 +20,6 @@ "targets": [ { "name": "default" - , - "runtimeOS":"OpenHarmony" } , { diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets index 86f662222dd22f84372d6ee674273b61a430513b..46e6cbaf4ac07a6c23e8f2c0d6ba8b3b21d47154 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets @@ -27,25 +27,32 @@ import { TOAST_BOTTOM } from '@ohos/uploaddownload'; import { SelectFolderDialog } from '../components/SelectFolderDialog'; +import { common } from '@kit.AbilityKit'; +import { picker } from '@kit.CoreFileKit'; +import { BusinessError } from '@kit.BasicServicesKit'; const TAG: string = 'DownloadSample'; +const userDir: string = 'file://docs/storage/Users/currentUser'; @Entry @Component struct Download { private fileData: CustomDataSource = new CustomDataSource([]); + private documentSelectOptions = new picker.DocumentSelectOptions(); @StorageLink('isBackground') isBackground: boolean = false; @StorageLink('backDownTaskState') backDownTaskState: BackgroundTaskState = BackgroundTaskState.NONE; + @StorageLink('downloadServer') downloadServerStr: string = './'; @Provide downloadFolder: Array = []; @State isGetData: boolean = false; @State checkFile: Array = []; @State checkList: Array = []; @State isRunning: boolean = false; + @State isUserFolder: boolean = true; @State isPause: boolean = false; @State progress: number = 0; private selectFolder = (folder: string) => { logger.info(TAG, `selectFolder = ${folder}`); - this.download(folder); + this.download('./' + folder); } private folderDialogController: CustomDialogController = new CustomDialogController({ builder: SelectFolderDialog({ selectFolder: this.selectFolder }), @@ -53,6 +60,56 @@ struct Download { alignment: DialogAlignment.Bottom, offset: { dx: 0, dy: -12 } }); + async selectUserFolder() { + const documentSaveOptions = new picker.DocumentSaveOptions(); + logger.info(TAG, `documentSaveOptions: ${JSON.stringify(documentSaveOptions)}`) + logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) + this.checkFile = []; + if (this.checkList === undefined) { + return; + } + logger.info(TAG, `checkList = ${JSON.stringify(this.checkList)}`); + for (let i = 0; i < this.checkList.length; i++) { + if (this.checkList[i]) { + let fileModel = this.fileData.getData(i); + logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`); + fileModel.files.forEach((url: string) => { + let splitUrl = url.split('//')[1].split('/'); + if (splitUrl[splitUrl.length-1] !== '') { + this.checkFile.push(url); + documentSaveOptions.newFileNames = [splitUrl[splitUrl.length-1]]; + } + }); + } + } + + logger.info(TAG, `checkFile = ${JSON.stringify(this.checkFile)}`); + + if (this.checkFile.length === 0) { + promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM }); + return; + } + + logger.info(TAG, `documentSaveOptions: ${documentSaveOptions}`) + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + logger.info(TAG, `context: ${JSON.stringify(context)}`) + const documentViewPicker = new picker.DocumentViewPicker(context); + logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) + await documentViewPicker.save(documentSaveOptions).then((documentSaveResult: Array) => { + logger.info(TAG, `documentSaveResult: ${documentSaveResult}`) + let splitUrl = documentSaveResult[0].split('/'); + logger.info(TAG, `splitUrl: ${splitUrl}`) + splitUrl.pop(); + logger.info(TAG, `splitUrl: ${splitUrl}`) + let splitUrl1=splitUrl.join('/'); + logger.info(TAG, `selectFolder = ${splitUrl1}`); + this.documentSelectOptions.defaultFilePathUri = splitUrl1 + this.download(splitUrl1); + logger.info(TAG, `selectFolder = ${splitUrl1}`); + }).catch((err: BusinessError) => { + logger.error(TAG, `code : ${err.code} message : ${err.message}`) + }); + } build() { Navigation() { @@ -91,7 +148,7 @@ struct Download { .mode(NavigationMode.Stack) .backgroundColor($r('app.color.light_gray')) .hideToolBar(false) - .title($r('app.string.download')) + .title(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) } @Builder @@ -192,7 +249,7 @@ struct Download { .fontSize(16) .margin({ left: 12 }) } else { - Text($r('app.string.download')) + Text(this.isUserFolder?$r('app.string.downloadToUser'):$r('app.string.download')) .fontColor(Color.White) .fontSize(16) } @@ -203,9 +260,13 @@ struct Download { .height(45) .width('100%') .backgroundColor($r('app.color.button_blue')) - .onClick(() => { + .onClick(async () => { if (!this.isRunning) { - this.folderDialogController.open(); + if (this.isUserFolder ) { + await this.selectUserFolder(); + } else { + this.folderDialogController.open(); + } } }) } @@ -218,9 +279,22 @@ struct Download { .margin({ bottom: 12 }) .fontColor($r('app.color.btn_text_blue')) .onClick(() => { - router.pushUrl({ - url: 'pages/DownloadFiles' - }); + if (this.isUserFolder ) { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + logger.info(TAG, `context: ${JSON.stringify(context)}`) + const documentViewPicker = new picker.DocumentViewPicker(context); + logger.info(TAG, `documentViewPicker: ${JSON.stringify(documentViewPicker)}`) + logger.info(TAG, `documentSelectOptions: ${JSON.stringify(this.documentSelectOptions)}`) + documentViewPicker.select(this.documentSelectOptions).then((documentSelectResult: Array) =>{ + logger.info(TAG, `documentSelectResult: ${documentSelectResult}`) + }) + } else { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + AppStorage.setOrCreate('downloadDir', context.cacheDir); + router.pushUrl({ + url: 'pages/DownloadFiles' + }) + } }) } .margin({ top: 12, left: 12, right: 12 }) @@ -231,19 +305,45 @@ struct Download { this.isRunning = false; this.isPause = false; this.isGetData = true; - requestFiles.requestFiles().then((data: FileModel[]) => { + const params = router.getParams(); + logger.info(`router.params: ${params}`); + if (params) { + this.isUserFolder=true; this.checkList = []; - this.isRunning = false; - this.fileData.dataArray = data; + this.isRunning = false; + let itemtxt:FileModel = new FileModel('test.txt',false,[this.downloadServerStr + 'test.txt']); + let itemjpg:FileModel = new FileModel('edge_picture.jpg',false,[this.downloadServerStr + 'edge_picture.jpg']); + let itemmp3:FileModel = new FileModel('audio_test.mp3',false,[this.downloadServerStr + 'audio_test.mp3']); + let itemmp4:FileModel = new FileModel('video_media.mp4',false,[this.downloadServerStr + 'video_media.mp4']); + this.fileData.dataArray = [itemtxt,itemjpg,itemmp3,itemmp4] ; this.fileData.dataArray.forEach((item: FileModel) => { + logger.debug(TAG, `item:${JSON.stringify(item)}`); this.checkList.push(false); }) this.isGetData = false; this.fileData.notifyDataReload(); - }) - fileUtils.listFolders().then((folders: Array) => { - this.downloadFolder = folders; - }) + fileUtils.listFolders(userDir).then((folders: Array) => { + logger.debug(TAG, `folders:${JSON.stringify(folders)}`); + this.downloadFolder = folders; + }) + } else { + this.isUserFolder=false; + requestFiles.requestFiles().then((data: FileModel[]) => { + this.checkList = []; + this.isRunning = false; + this.fileData.dataArray = data; + this.fileData.dataArray.forEach((item: FileModel) => { + this.checkList.push(false); + }) + this.isGetData = false; + this.fileData.notifyDataReload(); + }) + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + fileUtils.listFolders(context.cacheDir).then((folders: Array) => { + logger.debug(TAG, `folders:${JSON.stringify(folders)}`); + this.downloadFolder = folders; + }) + } } fileCheck(index: number) { diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/DownloadFiles.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/DownloadFiles.ets index 490bb2661208f0a54d359994c9c4b7c8fa03e10d..212b3c24f0785ccefa3ee6871b69205c42bd1f21 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/DownloadFiles.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/DownloadFiles.ets @@ -18,9 +18,10 @@ import { FileBrowse } from '@ohos/uploaddownload'; @Entry @Component struct DownLoadFiles { + @StorageLink('downloadDir') downloadDir: string = './'; build() { Column() { - FileBrowse() + FileBrowse({downloadDir:this.downloadDir}) } .width('100%') .height('100%') diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets index a2ed4f2e8e9a7474c0a19f792de9ef08d864266c..cfcacb89500e90e4aab037d1cc1061f9091e2fe5 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets @@ -17,7 +17,8 @@ import notificationManager from '@ohos.notificationManager'; import router from '@ohos.router'; import common from '@ohos.app.ability.common'; import { urlUtils } from '@ohos/uploaddownload'; -import util from '@ohos.util'; +import { promptAction } from '@kit.ArkUI'; + @Styles function itemStyle() { @@ -65,6 +66,11 @@ struct Index { .itemStyle() .margin({ top: 20 }) + TextInput({ text: $r('app.string.downloadServer') }) + .visibility(Visibility.Hidden) + .height(0) + .onChange((downloadServer) => AppStorage.setOrCreate('downloadServer', downloadServer)) + Row() { Text($r('app.string.HFS_tips')) .textStyle() @@ -87,8 +93,21 @@ struct Index { this.CapabilityView($r('app.media.ic_download'), $r('app.string.download'), 'btn_download', () => { router.pushUrl({ url: 'pages/Download' + }) + }) + this.CapabilityView($r('app.media.ic_download'), $r('app.string.downloadToUser'), 'btn_downloadToUser', + () => { + if (this.isBackground == false ) { + router.pushUrl({ + url: 'pages/Download', + params: { + action: 'ToUser' + } + }) + } else { + promptAction.showToast({ message: '不支持后台下载到用户目录', duration: 5000 }); + } }) - }) this.CapabilityView($r('app.media.ic_certified'), $r('app.string.cert_lock'), 'btn_cert_lock', () => { router.pushUrl({ url: 'pages/CertLock' diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets index 33bb2eb4adad8c8e5493bfcba1eff8c30e5d6f67..d47bf2c71ac492adbf9290f384100b79ff223731 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets @@ -168,7 +168,7 @@ struct Upload { this.progress = 0; let index = this.chunkImgIndex; let fileUris = this.imageList.slice(index); - console.debug(TAG + 'fileuri:' + fileUris); + logger.debug(TAG + 'fileuri:' + fileUris); requestUpload.uploadFileChunk(fileUris, this.chunkParaBegins, this.chunkParaEnds, (progress: number, isSucceed: boolean) => { this.progress = progress; if (this.progress === 100 && isSucceed) { @@ -191,7 +191,7 @@ struct Upload { }); return; } - console.debug(TAG + ':imageList:' + this.imageList); + logger.debug(TAG + ':imageList:' + this.imageList); if (this.isBackground) { AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING); requestUpload.uploadFilesBackground(this.imageList); diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json index f2f3603345c9a27a841d2e68c39898a5f00ad1d2..15f5c8c4107a8068047055cab00d3de6bbcbd02a 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json @@ -68,6 +68,18 @@ "name": "download", "value": "Download" }, + { + "name": "downloadToApplication", + "value": "downloadToApplication" + }, + { + "name": "downloadToUser", + "value": "DownloadToUser" + }, + { + "name": "downloadServer", + "value": "https://gitee.com/tiga-ultraman/downloadTests/releases/download/v1.01/" + }, { "name": "download_to", "value": "Select a download location" diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json index 751ab62d304e701efd05b5e01b206a67ef66f67c..ab355f1e970b4266db34061ebc2b5cee7fb35f7c 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json @@ -139,6 +139,14 @@ { "name": "cert_lock", "value": "Cert lock" + }, + { + "name": "downloadToUser", + "value": "DownloadToUser" + }, + { + "name": "downloadToApplication", + "value": "DownloadToApplication" } ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json index 94ea0de964e570fad3648c6e35964bb2f15a1e72..3e42b66c3fb38c550c6b1e150c122191e109761e 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json @@ -139,6 +139,14 @@ { "name": "cert_lock", "value": "证书锁定" + }, + { + "name": "downloadToUser", + "value": "下载到用户目录" + }, + { + "name": "downloadToApplication", + "value": "下载到应用目录" } ] } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/components/FileBrowse.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/components/FileBrowse.ets index e8fd253d4cde3ad9e0a022cf7610d1d5add62ae5..c476c471683db4dd94b757c950b6f34b3743aaea 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/components/FileBrowse.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/components/FileBrowse.ets @@ -21,9 +21,10 @@ export struct FileBrowse { @State folders: Array = ['folder']; @State files: Array = []; @State currentFolder: string = ''; + @Link downloadDir: string; aboutToAppear() { - fileUtils.listFolders().then((folders: Array) => { + fileUtils.listFolders(this.downloadDir).then((folders: Array) => { this.folders = folders; }) } @@ -57,7 +58,7 @@ export struct FileBrowse { .onStateChange(async (isActivated: boolean) => { if (isActivated) { this.currentFolder = item; - this.files = await fileUtils.listFiles(item); + this.files = await fileUtils.listFiles(this.downloadDir,item); } }) } @@ -132,7 +133,7 @@ export struct FileBrowse { } .margin({ bottom: 24, top: 6 }) .onClick(() => { - fileUtils.clearFolder(this.currentFolder); + fileUtils.clearFolder(this.downloadDir,this.currentFolder); this.files = []; }) } diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets index 4c58ce38c62dbc61c13e7468a701277fd0721275..8e1f1051f33c8d131368658587e61af1d3a1ac1b 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets @@ -99,7 +99,7 @@ class RequestDownload { } async downloadFile(folder: string, url: string, callback: (progress: number, isSuccess: boolean) => void) { - logger.info(TAG, 'downloadFile'); + logger.info(TAG, `downloadFile folder:${folder} url:${url}`); // 查询到存在正在执行的下载任务,提示并返回 let tasks = await request.agent.search({ state: request.agent.State.RUNNING, @@ -111,15 +111,16 @@ class RequestDownload { return; } let splitUrl = url.split('//')[1].split('/'); + let saveas = `${folder}/${splitUrl[splitUrl.length-1]}` let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; let downloadConfig: request.agent.Config = { action: request.agent.Action.DOWNLOAD, url: url, - method: 'POST', + method: 'GET', title: 'download', mode: request.agent.Mode.FOREGROUND, network: request.agent.Network.ANY, - saveas: `./${folder}/${splitUrl[splitUrl.length-1]}`, + saveas: saveas, overwrite: true } logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`); @@ -142,7 +143,8 @@ class RequestDownload { this.downloadTask.on('failed', async (progress: request.agent.Progress) => { if (this.downloadTask) { let taskInfo = await request.agent.show(this.downloadTask.tid); - logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); + logger.error(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`); + promptAction.showToast({ message: `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`, bottom: TOAST_BOTTOM }); } callback(100, false); this.deleteTask(); @@ -150,6 +152,7 @@ class RequestDownload { await this.downloadTask.start(); } catch (err) { logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + promptAction.showToast({ message: JSON.stringify(err), bottom: TOAST_BOTTOM }); callback(100, false); } } diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/FileUtils.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/FileUtils.ets index 44e0ed2ac74492c9e52a8f6e2d98481fd0acd3c6..f97ad290bb8c8ee7b02abeeca9ce20aeb62d8129 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/FileUtils.ets +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/FileUtils.ets @@ -24,41 +24,38 @@ class FileUtil { constructor() { } - async initDownloadDir(): Promise { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; - logger.info(TAG, `initDownloadDir cacheDir=${context.cacheDir}`); + async initDownloadDir(downloadDir: string): Promise { + logger.info(TAG, `initDownloadDir downloadDir=${downloadDir}`); try { - fs.mkdirSync(`${context.cacheDir}/${ALBUMS[0]}`); - fs.mkdirSync(`${context.cacheDir}/${ALBUMS[1]}`); - fs.mkdirSync(`${context.cacheDir}/${ALBUMS[2]}`); + fs.mkdirSync(`${downloadDir}/${ALBUMS[0]}`); + fs.mkdirSync(`${downloadDir}/${ALBUMS[1]}`); + fs.mkdirSync(`${downloadDir}/${ALBUMS[2]}`); } catch (err) { logger.info(TAG, `initDownloadDir err =${JSON.stringify(err)}`); } } - async listFolders(): Promise> { - await this.initDownloadDir(); + async listFolders(downloadDir: string): Promise> { + await this.initDownloadDir(downloadDir); return ALBUMS; } - async clearFolder(folderName: string): Promise { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + async clearFolder(downloadDir: string,folderName: string): Promise { try { - let files: string[] = fs.listFileSync(`${context.cacheDir}/${folderName}`); + let files: string[] = fs.listFileSync(`${downloadDir}/${folderName}`); logger.info(TAG, `listFiles listFileSync =${JSON.stringify(files)}`); for (let i = 0; i < files.length; i++) { - fs.unlinkSync(`${context.cacheDir}/${folderName}/${files[i]}`); + fs.unlinkSync(`${downloadDir}/${folderName}/${files[i]}`); } } catch (err) { logger.info(TAG, `listFiles err =${JSON.stringify(err)}`); } } - async listFiles(folderName: string): Promise> { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + async listFiles(downloadDir:string,folderName: string): Promise> { let files: string[] = []; try { - files = fs.listFileSync(`${context.cacheDir}/${folderName}`); + files = fs.listFileSync(`${downloadDir}/${folderName}`); logger.info(TAG, `listFiles listFileSync =${JSON.stringify(files)}`); } catch (err) { logger.info(TAG, `listFiles err =${JSON.stringify(err)}`); diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/oh-package.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/oh-package.json5 index 5e3779b038dac86ae420dcbe71fac54bab468ab7..f301b514512bcc5b50d6f5c9137a9dd0eccc7568 100644 --- a/code/BasicFeature/Connectivity/UploadAndDownLoad/oh-package.json5 +++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/oh-package.json5 @@ -14,6 +14,7 @@ */ { + "modelVersion": "5.0.5", "license": "", "devDependencies": { "@ohos/hypium": "1.0.6" diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_folder_user.jpg b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_folder_user.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b76f9a7d8942e84f8d0fe734883e15cf2b27bfec Binary files /dev/null and b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_folder_user.jpg differ diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_user.jpg b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_user.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0035e0aca52877a90ea2ef6fe90d716daf599404 Binary files /dev/null and b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/download_user.jpg differ diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/home.jpg b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/home.jpg index e19c858103eda3d17307bbed6d3a9558f8a780c9..8f143b1be64d7d3dd3d0cf5b48492582b18bc8a3 100644 Binary files a/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/home.jpg and b/code/BasicFeature/Connectivity/UploadAndDownLoad/screenshots/devices/zh/home.jpg differ diff --git a/code/BasicFeature/DataManagement/UDMF/UDMFDemo/README_zh.md b/code/BasicFeature/DataManagement/UDMF/UDMFDemo/README_zh.md index be75358ab8ec236ada08504c298302a61c8a2d58..1fa706b9d7735fa010921cade7cfe7024ee20305 100644 --- a/code/BasicFeature/DataManagement/UDMF/UDMFDemo/README_zh.md +++ b/code/BasicFeature/DataManagement/UDMF/UDMFDemo/README_zh.md @@ -3,7 +3,7 @@ ### 介绍 本示例主要使用[@ohos.data.uniformTypeDescriptor](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-uniformTypeDescriptor.md) -[@ohos.data.unifiedDataChannel](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.data.unifiedDataChannel.d.ts)展示了标准化数据定义与描述的功能,在新增预置文件后,对文件的utd标准类型获取、utd类型归属类型查询、获取文件对应的utd类型的默认图标等功能。 实现过程中还使用到[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) 等接口。 +[@ohos.data.unifiedDataChannel](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-unifiedDataChannel.md)展示了标准化数据定义与描述的功能,在新增预置文件后,对文件的utd标准类型获取、utd类型归属类型查询、获取文件对应的utd类型的默认图标等功能。 实现过程中还使用到[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) 等接口。 另外,展示了ArkTS控件[拖拽事件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-events-drag-drop.md)中使用UDMF数据结构相关实现。 diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md index 1153a84dfb9b151f551be514edb77e3359d73223..d5e5ea3fc1b5a39bab1509c52c7ed4d2139fa825 100755 --- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md +++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md @@ -109,7 +109,7 @@ entry/src/main/ets/ 2. 本示例为Stage模型,仅支持API11版本SDK,SDK版本号(API Version 11 Release),镜像版本号(4.0Release)。 3. 本示例涉及使用系统接口:@ohos.file.fs中的openSync接口,需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md) 。 4. 本示例需要使用DevEco Studio 版本号(4.0Release)及以上版本才可编译运行。 -5. 本示例涉及调用系统权限的接口,需要配置允许权限列表,可以参考[特殊权限配置方法](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/) ,在配置文件中的“allowed-acls”字段中增加"ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA", "ohos.permission.FILE_ACCESS_MANAGER", "ohos.permission.STORAGE_MANAGER"四个权限。 +5. 本示例涉及调用系统权限的接口,需要配置允许权限列表,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) ,在配置文件中的“allowed-acls”字段中增加"ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA", "ohos.permission.FILE_ACCESS_MANAGER", "ohos.permission.STORAGE_MANAGER"四个权限。 ### 下载 如需单独下载本工程,执行如下命令: diff --git a/code/BasicFeature/DataManagement/pasteboard/README_zh.md b/code/BasicFeature/DataManagement/pasteboard/README_zh.md index 7769bc9a3db1522a5a86b8d6dcad7720a47f88eb..ad0454a0e27e0a6b2df0089d0149cb0f9390a21b 100644 --- a/code/BasicFeature/DataManagement/pasteboard/README_zh.md +++ b/code/BasicFeature/DataManagement/pasteboard/README_zh.md @@ -84,7 +84,7 @@ entry/src/main/ets/ 1. 本示例仅支持标准系统上运行,支持设备:RK3568。 2. 本示例为Stage模型,仅支持API12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(OpenHarmony 5.0.0.25及更高版本)。 3. 本示例需要使用DevEco Studio 版本号(4.1Release)及以上版本才可编译运行。 -4. 本示例涉及调用系统权限的接口,需要配置允许权限列表,可以参考[特殊权限配置方法](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/) ,在配置文件中的“allowed-acls”字段中增加"ohos.permission.READ_PASTEBOARD"权限,ohos.permission.REQUIRE_FORM为system_basic级别。 +4. 本示例涉及调用系统权限的接口,需要配置允许权限列表,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) ,在配置文件中的“allowed-acls”字段中增加"ohos.permission.READ_PASTEBOARD"权限,ohos.permission.REQUIRE_FORM为system_basic级别。 ### 下载 diff --git a/code/BasicFeature/Graphics/Graphics2d/ExpandText/Readme.md b/code/BasicFeature/Graphics/Graphics2d/ExpandText/Readme.md index 1a6a2be02f2475ee9dc0a40366172bd875fdd5d3..c5e3fc8e8e0cf18c70773915e12a42e741a40879 100644 --- a/code/BasicFeature/Graphics/Graphics2d/ExpandText/Readme.md +++ b/code/BasicFeature/Graphics/Graphics2d/ExpandText/Readme.md @@ -2,7 +2,7 @@ ### 介绍 -本实例主要测试了当前2D引擎提供的接口功能,主要调用了[@ohos.graphics.drawing](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.graphics.drawing.d.ts)和[@kit.ArkGraphics2D](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-effectKit.md)中的接口,测试了每一个接口的功能。2D引擎渲染的画面会被显示在[Text](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@internal/component/ets/text.d.ts)这一控件中。点击“...展开”会有评论区展开效果,点击“...收起”会展示收起效果。 +本实例主要测试了当前2D引擎提供的接口功能,主要调用了[@ohos.graphics.drawing](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-graphics-drawing.md)和[@kit.ArkGraphics2D](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-effectKit.md)中的接口,测试了每一个接口的功能。2D引擎渲染的画面会被显示在[Text](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-text.md)这一控件中。点击“...展开”会有评论区展开效果,点击“...收起”会展示收起效果。 ### 使用说明 diff --git a/code/BasicFeature/Graphics/Graphics2d/PaintVerbatim/README.md b/code/BasicFeature/Graphics/Graphics2d/PaintVerbatim/README.md index 7db859cd4771b24282257ab56006fa4ec46154fc..6f8934e5ef556912fc75e61442b43ea624705ccc 100644 --- a/code/BasicFeature/Graphics/Graphics2d/PaintVerbatim/README.md +++ b/code/BasicFeature/Graphics/Graphics2d/PaintVerbatim/README.md @@ -2,7 +2,7 @@ ### 介绍 -本实例主要测试了当前2D引擎提供的接口功能,主要调用了[@ohos.graphics.drawing](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.graphics.drawing.d.ts)中的接口,测试了每一个接口的功能。实现文字逐字绘制。 +本实例主要测试了当前2D引擎提供的接口功能,主要调用了[@ohos.graphics.drawing](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics2d/js-apis-graphics-drawing.md)中的接口,测试了每一个接口的功能。实现文字逐字绘制。 ### 效果预览 | 效果 | diff --git a/code/BasicFeature/Graphics/Graphics3d/Readme.md b/code/BasicFeature/Graphics/Graphics3d/Readme.md index ded1ef257b2848f5abac4eb85f70ee3b85213ee3..08934bea7787272cb202aee4fe472ea740bc3e47 100644 --- a/code/BasicFeature/Graphics/Graphics3d/Readme.md +++ b/code/BasicFeature/Graphics/Graphics3d/Readme.md @@ -2,7 +2,7 @@ ### 介绍 -本实例主要测试了当前3D引擎提供的接口功能,调用了[@ohos.graphics.scene](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.graphics.scene.d.ts)中的接口,测试了每一个接口的功能。3D引擎渲染的画面会被显示在[Component3D](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@internal/component/ets/component3d.d.ts)这一控件中。点击按钮触发不同的功能,用户可以观察渲染画面的改变;此外,许多接口将不会直接导致渲染效果的改变,因此应用将会打印日志来检测这些接口是否正常,可以用“lume_api_test"来过滤。 +本实例主要测试了当前3D引擎提供的接口功能,调用了[@ohos.graphics.scene](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-scene.md)中的接口,测试了每一个接口的功能。3D引擎渲染的画面会被显示在[Component3D](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-component3d.md)这一控件中。点击按钮触发不同的功能,用户可以观察渲染画面的改变;此外,许多接口将不会直接导致渲染效果的改变,因此应用将会打印日志来检测这些接口是否正常,可以用“lume_api_test"来过滤。 ### 效果预览 @@ -79,7 +79,7 @@ entry/src/main/ ``` ### 具体实现 -* 添加、移除、遍历节点的功能接口封装在graphics3d/[SceneNodes.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneNodes.d.ts),源码参考:container.ets +* 添加、移除、遍历节点的功能接口封装在graphics3d/[SceneNodes](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-nodes.md),源码参考:container.ets * 初始时会使用深度优先的方式遍历并打印场景中每一个节点的信息,从场景的root节点开始; * 删除节点:调用remove方法删除指定节点,不会重复删除,在本示例中删除了头盔节点; * 添加节点:调用append方法在子节点列表的末尾添加指定节点,不会重复添加,在本示例中添加了头盔节点; @@ -87,14 +87,14 @@ entry/src/main/ * 清除子节点:调用clear方法清除子节点列表的所有节点,本示例中清除了root的子节点; * 获取子节点:调用get方法获取子节点列表中的指定节点; * 获取子节点个数:调用count方法获取子节点列表的大小。 -* 对节点的基础属性如位置、旋转、大小等操作的功能接口封装在graphics3d/[SceneNodes.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneNodes.d.ts),源码参考:node_base.ets +* 对节点的基础属性如位置、旋转、大小等操作的功能接口封装在graphics3d/[SceneNodes](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-nodes.md),源码参考:node_base.ets * 修改scale属性改变节点的大小,本示例中改变了头盔的大小; * 修改position属性改变节点的位置,本示例中改变了头盔的x轴坐标; * 修改rotation属性改变节点的旋转方向,改变子节点的父节点的rotation同样会改变子节点的旋转方向(position同理),本示例中改变了头盔的旋转方向; * 修改节点的visible属性改变节点的可见性,本示例中改变了头盔的可见性; * 使用getEnabled和setEnabled操作节点的layerMask,本示例中将layerMask的信息打印在界面上。 -* 对相机的属性如投影、后处理等进行操作的功能接口封装在graphics3d/[SceneNodes.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneNodes.d.ts),源码参考:node_camera.ets +* 对相机的属性如投影、后处理等进行操作的功能接口封装在graphics3d/[SceneNodes](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-nodes.md),源码参考:node_camera.ets * 修改fov属性改变投影的视场角,本示例中设置了45/60/90三种; * 修改nearPlane和farPlane属性投影的近平面和远平面; * 修改enabled属性改变相机是否启用,设为false之后控件中的画面将不再刷新; @@ -102,14 +102,14 @@ entry/src/main/ * 修改postProcess.toneMapping.exposure属性可以改变用于色调映射的曝光参数; * 修改clearColor属性可以设置每一帧的刷新背景色,设置a通道为零可以获得一个透明的背景,设置为null时不会刷新全部背景像素。 -* 对灯光的类型、颜色、强度、阴影等进行操作的功能接口封装在graphics3d/[SceneNodes.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneNodes.d.ts),源码参考:node_light.ets +* 对灯光的类型、颜色、强度、阴影等进行操作的功能接口封装在graphics3d/[SceneNodes](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-nodes.md),源码参考:node_light.ets * lightType属性为只读,表示灯光的种类,目前有DIRECTIONAL和SPOT两种,分别为平行光和点光源; * 修改enabled属性改变灯光是否启用; * 修改color属性可以改变灯光的颜色,本示例中有三种可以变化; * 修改intensity属性可以改变灯光的强度; * 修改shadowEnabled属性可以设置灯光是否产生阴影。 -* 对背景进行操作的功能接口封装在graphics3d/[SceneResources.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneResources.d.ts),源码参考:scene_environment.ets +* 对背景进行操作的功能接口封装在graphics3d/[SceneResources](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-resources.md),源码参考:scene_environment.ets * 同时修改backgroundType和environmentImage可以设置背景图片,backgroundType为BACKGROUND_IMAGE或BACKGROUND_EQUIRECTANGULAR时对应png或者jpeg格式的图片;类型为BACKGROUND_CUBEMAP时对应ktx格式的图片;类型为BACKGROUND_NONE时不设置背景图片,需要同时将camera的clearColor的a通道设置为0以获得透明背景; * 修改radianceImage属性改变PBR中的环境贴图; * 修改indirectDiffuseFactor属性改变PBR中的相应参数; @@ -117,7 +117,7 @@ entry/src/main/ * 修改irradianceCoefficients属性改变PBR中的相应参数; * 修改environmentMapFactor属性改变背景图的相应参数。 -* 对动画的播放、暂停等进行操作的功能接口封装在graphics3d/[SceneResources.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneResources.d.ts),源码参考:scene_animation.ets +* 对动画的播放、暂停等进行操作的功能接口封装在graphics3d/[SceneResources](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-resources.md),源码参考:scene_animation.ets * 修改enabled属性改变动画是否启用; * 只读属性duration、running、progress为动画的时长、进行状态、已经进行的比例; * 调用start方法控制动画开启; @@ -129,7 +129,7 @@ entry/src/main/ * onStarted方法在动画开始时执行传入的回调; * onFinished方法在动画结束时执行传入的回调。 -- 对纹理材质进行操作的功能接口封装在graphics3d/[SceneResources.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/graphics3d/SceneResources.d.ts),源码参考:scene_shader.ets +- 对纹理材质进行操作的功能接口封装在graphics3d/[SceneResources](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkgraphics3d/js-apis-inner-scene-resources.md),源码参考:scene_shader.ets * 首先创建一个shader作为ShaderMaterial的colorShader,再创建一个material作为纹理的ShaderMaterial; * 使用Geometry获取相应的带有Material的Mesh节点; * 修改shader的input参数; diff --git a/code/BasicFeature/Media/Audio/AppScope/resources/base/element/string.json b/code/BasicFeature/Media/Audio/AppScope/resources/base/element/string.json index a868186d3eb14b1e53f7704139b5cf0773171d57..151449bec52e7a8293a28a2606fbb9e8859abed1 100644 --- a/code/BasicFeature/Media/Audio/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/Media/Audio/AppScope/resources/base/element/string.json @@ -218,7 +218,7 @@ }, { "name": "LIVE_CAPTURER", - "value": "并行录制" + "value": "直播录制" }, { "name": "CONTINUE", diff --git a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/AudioDecoder.cpp b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/AudioDecoder.cpp index 4a87502ec5f9c09876a9de59fa39f99131597391..a454c155c9499950fa6354345d4b520ed4a1794b 100644 --- a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/AudioDecoder.cpp +++ b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/AudioDecoder.cpp @@ -48,8 +48,22 @@ int32_t AudioDecoder::Configure(const SampleInfo &sampleInfo) OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, sampleInfo.audioChannelCount); OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleInfo.audioSampleRate); OH_AVFormat_SetLongValue(format, OH_MD_KEY_CHANNEL_LAYOUT, sampleInfo.audioChannelLayout); + if (sampleInfo.codecConfigLen > 0) { + AVCODEC_SAMPLE_LOGI("====== AudioDecoder config ====== codecConfig:%{public}p, len:%{public}i, " + "adts:${public}i, 0:0x%{public}02x, 1:0x%{public}02x", + sampleInfo.codecConfig, sampleInfo.codecConfigLen, sampleInfo.aacAdts, + sampleInfo.codecConfig[0], sampleInfo.codecConfig[1]); + uint8_t tmpCodecConfig[2]; + tmpCodecConfig[0] = 0x13; // 0x11 + tmpCodecConfig[1] = 0x10; // 0x90 + tmpCodecConfig[0] = sampleInfo.codecConfig[0]; // 0x11 + tmpCodecConfig[1] = sampleInfo.codecConfig[1]; // 0x90 + AVCODEC_SAMPLE_LOGI("====== AudioDecoder config ====== 0:0x%{public}02x, 1:0x%{public}02x", tmpCodecConfig[0], + tmpCodecConfig[1]); + OH_AVFormat_SetBuffer(format, OH_MD_KEY_CODEC_CONFIG, sampleInfo.codecConfig, sampleInfo.codecConfigLen); + } + AVCODEC_SAMPLE_LOGI("====== AudioDecoder config ======"); - int ret = OH_AudioCodec_Configure(decoder, format); AVCODEC_SAMPLE_LOGI("====== AudioDecoder config ======"); CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, AVCODEC_SAMPLE_ERR_ERROR, "Config failed, ret: %{public}d", ret); diff --git a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/Demuxer.cpp b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/Demuxer.cpp index 10e4e0546db3ce9a90134794efaab0db33c3765b..0564a4b29891765eeccdb0742ad6efa7b3d10622 100644 --- a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/Demuxer.cpp +++ b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/capbilities/Demuxer.cpp @@ -23,11 +23,12 @@ Demuxer::~Demuxer() { Release(); } int32_t Demuxer::Create(SampleInfo &info) { source = OH_AVSource_CreateWithFD(info.inputFd, info.inputFileOffset, info.inputFileSize); - + CHECK_AND_RETURN_RET_LOG(source != nullptr, AVCODEC_SAMPLE_ERR_ERROR, - "Create demuxer source failed, fd: %{public}d, offset: %{public}PRId64, " - "file size: %{public}PRId64", info.inputFd, info.inputFileOffset, info.inputFileSize); - + "Create demuxer source failed, fd: %{public}d, offset: %{public}PRId64, " + "file size: %{public}PRId64", + info.inputFd, info.inputFileOffset, info.inputFileSize); + demuxer = OH_AVDemuxer_CreateWithSource(source); CHECK_AND_RETURN_RET_LOG(demuxer != nullptr, AVCODEC_SAMPLE_ERR_ERROR, "Create demuxer failed"); @@ -99,15 +100,26 @@ int32_t Demuxer::GetTrackInfo(std::shared_ptr sourceFormat, SampleI char *audioCodecMime; OH_AVFormat_GetStringValue(trackFormat.get(), OH_MD_KEY_CODEC_MIME, const_cast(&audioCodecMime)); + uint8_t *codecConfig = nullptr; + OH_AVFormat_GetBuffer(trackFormat.get(), OH_MD_KEY_CODEC_CONFIG, &codecConfig, &info.codecConfigLen); + if (info.codecConfigLen > 0 && info.codecConfigLen < sizeof(info.codecConfig)) { + memcpy(info.codecConfig, codecConfig, info.codecConfigLen); + AVCODEC_SAMPLE_LOGI( + "codecConfig:%{public}p, len:%{public}i, 0:0x%{public}02x 1:0x:%{public}02x, bufLen:%{public}u", + info.codecConfig, (int)info.codecConfigLen, info.codecConfig[0], info.codecConfig[1], + sizeof(info.codecConfig)); + } + OH_AVFormat_GetIntValue(trackFormat.get(), OH_MD_KEY_AAC_IS_ADTS, &info.aacAdts); info.audioCodecMime = audioCodecMime; audioTrackId = index; AVCODEC_SAMPLE_LOGI("====== Demuxer Audio config ======"); AVCODEC_SAMPLE_LOGI("Mime: %{public}s", audioCodecMime); - AVCODEC_SAMPLE_LOGI("audioMime:%{public}s sampleForamt:%{public}d " - "sampleRate:%{public}d channelCount:%{public}d channelLayout:%{public}d", - info.audioCodecMime.c_str(), info.audioSampleForamt, info.audioSampleRate, - info.audioChannelCount, (int)info.audioChannelLayout); + AVCODEC_SAMPLE_LOGI( + "audioMime:%{public}s sampleForamt:%{public}d " + "sampleRate:%{public}d channelCount:%{public}d channelLayout:%{public}d adts:%{public}i", + info.audioCodecMime.c_str(), info.audioSampleForamt, info.audioSampleRate, info.audioChannelCount, + info.audioChannelLayout, info.aacAdts); AVCODEC_SAMPLE_LOGI("====== Demuxer Audio config ======"); } } diff --git a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/common/SampleInfo.h b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/common/SampleInfo.h index 234d4837c2b36ad466ff6ee4a24aebd658fcf8a9..1f91fb5f3624fa8be45fb73c59ff1bf599cd906e 100644 --- a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/common/SampleInfo.h +++ b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/common/SampleInfo.h @@ -64,6 +64,9 @@ struct SampleInfo { void (*playDoneCallback)(void *context) = nullptr; void *playDoneCallbackData = nullptr; + uint8_t codecConfig[1024]; + size_t codecConfigLen = 0; + int32_t aacAdts = -1; }; struct CodecBufferInfo { diff --git a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/player/Player.cpp b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/player/Player.cpp index 51ebec05a3fb15d7c009da69e1c09f0b841fe028..7e32753d6bafc75b4984c0361f43a2136b19853a 100644 --- a/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/player/Player.cpp +++ b/code/BasicFeature/Media/AudioToVideoSync/entry/src/main/cpp/player/Player.cpp @@ -208,11 +208,6 @@ void Player::Release() { std::lock_guard lock(mutex); isStarted = false; - - // Clear the queue - while (audioDecContext && !audioDecContext->renderQueue.empty()) { - audioDecContext->renderQueue.pop(); - } if (audioRenderer != nullptr) { OH_AudioRenderer_Release(audioRenderer); audioRenderer = nullptr; @@ -246,6 +241,10 @@ void Player::Release() doneCond.notify_all(); // Trigger the callback sampleInfo.playDoneCallback(sampleInfo.playDoneCallbackData); + // Clear the queue + while (audioDecContext && !audioDecContext->renderQueue.empty()) { + audioDecContext->renderQueue.pop(); + } AVCODEC_SAMPLE_LOGI("Succeed"); } diff --git a/code/BasicFeature/Media/QRCodeScan/README_zh.md b/code/BasicFeature/Media/QRCodeScan/README_zh.md index 89b5241ed5544d834a23a734a4971f3cc78f2572..6ffc160743e83d2ad71c5c859c9fac7417d03fc9 100644 --- a/code/BasicFeature/Media/QRCodeScan/README_zh.md +++ b/code/BasicFeature/Media/QRCodeScan/README_zh.md @@ -62,7 +62,7 @@ Feature/src/main/ets/ 2. 本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(5.0 Release),需要手动替换Full SDK(5.0 Release)才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 3. 本示例需要使用DevEco Studio NEXT Beta1(5.0.3.800)及以上版本才可编译运行。 -4. 本示例所配置的权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案]( https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/ ))。 +4. 本示例所配置的权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案]( https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md ))。 5. 本示例类型为系统应用,需要手动配置对应级别的应用类型("app-feature": "hos_system_app")。具体可参考profile配置文件[bundle-info对象内部结构]( https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/application-dev/security/app-provision-structure.md#bundle-info%E5%AF%B9%E8%B1%A1%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84 ) ### 下载 diff --git a/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/pages/VideoUpload.ets b/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/pages/VideoUpload.ets index 85268a7cda6133061d0e83310ba91cd12a874e21..8db5dc6e80c054e7562aa20f87d002bad8824a41 100644 --- a/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/pages/VideoUpload.ets +++ b/code/BasicFeature/Media/VideoTrimmer/entry/src/main/ets/pages/VideoUpload.ets @@ -67,7 +67,7 @@ export struct VideoUpload { /** * 获取视频第一张图片 */ - async getVideoFirstImage(): Promise { + async getVideoFirstImage(videoSrc: string): Promise { let callBack: ICallBack = { // 回调函数 callBackResult: (code: number) => { @@ -96,7 +96,7 @@ export struct VideoUpload { } } // TODO: 知识点:设置MP4Parser视频源地址及回调函数 - MP4Parser.setDataSource(this.workItem.videoSrc, callBack); + MP4Parser.setDataSource(videoSrc, callBack); } // 配置服务器地址 @@ -188,7 +188,7 @@ export struct VideoUpload { this.workItem.trimmerSrc = ''; logger.info(TAG, 'the source video path is:' + this.workItem.videoSrc); // 获取视频第一张图片 - await this.getVideoFirstImage(); + await this.getVideoFirstImage(this.workItem.videoSrc); // 视频剪辑参数选项 let tempOption = new VideoTrimmerOption(); tempOption.listener = this.initListener; @@ -217,10 +217,11 @@ export struct VideoUpload { logger.info(TAG, '开始裁剪'); this.dialogController.open(); }, - onFinishTrim: (outVideoPath: string) => { + onFinishTrim: async (outVideoPath: string) => { this.dialogController.close(); // 更新上传视频地址 this.workItem.trimmerSrc = outVideoPath; + await this.getVideoFirstImage(this.workItem.trimmerSrc); this.isTrimmer = false; logger.info(TAG, '裁剪成功 path=' + this.workItem.trimmerSrc) }, @@ -323,8 +324,7 @@ export struct VideoUpload { // 背景图 Stack({ alignContent: Alignment.Center }) { - Image($r('app.media.video_trimmer_autoplay_preview2')) - + Image(this.workItem.firstImage) .id('image_to_trimmer') .height($r('app.integer.video_trimmer_upload_video_height')) .onClick(() => { diff --git a/code/BasicFeature/Native/NdkNativeFence/.gitignore b/code/BasicFeature/Native/NdkNativeFence/.gitignore new file mode 100755 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 b/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 new file mode 100755 index 0000000000000000000000000000000000000000..5381586847d907861a4d383f57ec29efa062d7d9 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.ndknativefence", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..84dbccd48b7fd01125c81d9f788a597cd2f1a2e7 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NdkNativeFence" + } + ] +} diff --git a/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/BasicFeature/Native/NdkNativeFence/AppScope/resources/base/media/app_icon.png differ diff --git a/code/BasicFeature/Native/NdkNativeFence/README_zh.md b/code/BasicFeature/Native/NdkNativeFence/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..14e53eac1a1afedb9b60e9e8307e0f678b466dfb --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/README_zh.md @@ -0,0 +1,76 @@ +# 基于NdkNativeFence的接口调用示例 + +### 介绍 + +本示例主要演示如何在 OpenHarmony 系统中,使用 Native C++ 代码,通过 `OH_NativeFence_IsValid`、`OH_NativeFence_Wait` 、`OH_NativeFence_WaitForever`和 `OH_NativeFence_Close` API,实现接口功能调用。示例展示了如何对fenceFd进行 `OH_NativeFence_Wait`和`OH_NativeFence_WaitForever`操作。 + +## 效果预览 + +| 主页面 | +| | + +### 使用说明 + +1. **编译安装**:使用 DevEco Studio 编译生成应用的 hap 包,并将其安装到设备上。 + +2. **运行应用**:打开应用后,您将看到屏幕上显示SyncFenceWait和SyncFenceWaitForever按钮。 + +### 工程目录 +``` +├──entry/src/main +│ ├──cpp // C++代码区 +│ │ ├──CMakeLists.txt // CMake配置文件 +│ │ ├──napi_init.cpp // Napi模块注册 +│ │ ├──common +│ │ │ └──log_common.h // 日志封装定义文件 +│ ├──ets // ets代码区 +│ │ ├──entryability +│ │ │ ├──EntryAbility.ts // 程序入口类 +| | | └──EntryAbility.ets +│ │ └──pages // 页面文件 +│ │ └──Index.ets // 主界面 +| ├──resources // 资源文件目录 +``` +### 具体实现 + +本示例通过在 DevEco Studio 中创建 Native C++ 工程,通过 `OH_NativeFence_IsValid`、`OH_NativeFence_Wait` 、`OH_NativeFence_WaitForever`和 `OH_NativeFence_Close` API,实现接口功能调用。 + +主要步骤如下: + +1. **调用SyncFenceWait接口**:(1)在接口SyncFenceWait中,调用OH_NativeFence_Wait接口,传入非法fenceFd。(2)利用signalfd函数创建信号,在waitThread线程中调用OH_NativeFence_Wait接口阻塞fenceFd。(3)3s后在主线程中使用kill函数模拟信号触发。(4)观察OH_NativeFence_Wait接口是否解除阻塞。 + +1. **调用SyncFenceWaitForever接口**:(1)在接口SyncFenceWaitForever中,调用OH_NativeFence_WaitForever接口,传入非法fenceFd。(2)利用signalfd函数创建信号,在waitThread线程中调用OH_NativeFence_WaitForever接口阻塞fenceFd。(3)3s后在主线程中使用kill函数模拟信号触发。(4)观察OH_NativeFence_WaitForever接口是否解除阻塞。 + +| 接口名 | 描述 | +| -------- | -------- | +| `OH_NativeFence_IsValid(int fenceFd)` | 检查fenceFd是否有效。 | +| `OH_NativeFence_Wait(int fenceFd, uint32_t timeout)` |阻塞传入的fenceFd。最大阻塞时间由超时参数决定。 | +| `OH_NativeFence_WaitForever(int fenceFd)` | 永久阻塞传入的fenceFd。 | +| `OH_NativeFence_Close(int fenceFd)` | 关闭fenceFd。如果传入的是无效的fenceFd,则该函数会直接返回。 | + +### 相关权限 + +本示例不涉及特殊权限。 + +### 依赖 +本示例不涉及特殊依赖。 + +### 约束与限制 + +1. **运行环境**:本示例仅支持在 OpenHarmony 标准系统上运行。 + +2. **SDK 版本**:本示例已适配 API Version 20 版本 SDK,适用于 SDK 版本号(API Version 20 Release)、镜像版本号(5.0.0 Release)。 + +3. **开发工具**:本示例需要使用 DevEco Studio 版本号(5.0.0 Release)及以上版本进行编译和运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```bash +git init +git config core.sparsecheckout true +echo code/BasicFeature/Native/NdkNativeFence > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 b/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..c6a7ec09c5cbf1f2d9f4eeba8b178039e6a40aff --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + // 指定OpenHarmony应用/服务编译时的版本 + "compatibleSdkVersion": 19, + // 指定OpenHarmony应用/服务兼容的最低版本。 + "targetSdkVersion": 20, + // 指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion + "runtimeOS": "OpenHarmony", + // 指定为OpenHarmony + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/code-linter.json5 b/code/BasicFeature/Native/NdkNativeFence/code-linter.json5 new file mode 100755 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/code-linter.json5 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/.gitignore b/code/BasicFeature/Native/NdkNativeFence/entry/.gitignore old mode 100644 new mode 100755 similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/.gitignore rename to code/BasicFeature/Native/NdkNativeFence/entry/.gitignore diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..29d984235f050a1886245e83e46bfa9057ab8f8f --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/build-profile.json5 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "armeabi-v7a", "x86_64"] + } + }, + "targets": [ + { + "name": "default", + "runtimeOS": "OpenHarmony" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts b/code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt b/code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt new file mode 100755 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..5d993e5251fd56950970aa593aefef1b8d71e976 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..2017e5d3f883d3a74a292f5d983a1c3a6b1ab4aa --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,26 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(456) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) + +find_library( + # Sets the name of the path variable. + hilog-lib + # Specifies the name of the NDK library that + # you want CMake to locate. + hilog_ndk.z +) + +target_link_libraries(entry PUBLIC libace_napi.z.so) +target_link_libraries(entry PUBLIC ${hilog-lib}) +target_link_libraries(entry PUBLIC libnative_fence.so) \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h new file mode 100755 index 0000000000000000000000000000000000000000..21aaa407073002b6999e9dae6ff8c0c1826fca73 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/common/log_common.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LOG_COMMON_H +#define LOG_COMMON_H +#include +#undef LOG_DOMAIN +#undef LOG_TAG +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "DrawingSample" + +constexpr const char *APP_LOG_TAG = "DrawingSample"; +#define DRAWING_LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define DRAWING_LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define DRAWING_LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARN, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define DRAWING_LOGE(...) ((void)OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) + +#endif // LOG_COMMON_H diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp new file mode 100755 index 0000000000000000000000000000000000000000..ce78552d583d43962c6c1541ce876b78c0d40cab --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common/log_common.h" + +constexpr int INVALID_FD = -1; +constexpr uint32_t TIMEOUT_MS = 5000; + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; +} + +static napi_value SyncFenceWait(napi_env env, napi_callback_info info) +{ + bool result = OH_NativeFence_Wait(INVALID_FD, TIMEOUT_MS); + DRAWING_LOGI("get result %{public}d", result); + bool isValid = OH_NativeFence_IsValid(INVALID_FD); + DRAWING_LOGI("input fenceFd is: %{public}d", isValid); + + std::atomic signaled(false); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) + sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) + sigprocmask(SIG_BLOCK, &mask, NULL); + int sfd = signalfd(-1, &mask, 0); + DRAWING_LOGI("input fenceFd is: %{public}d", sfd); + if (sfd == -1) { + perror("signalfd failed"); + exit(1); + } + isValid = OH_NativeFence_IsValid(sfd); + DRAWING_LOGI("input fenceFd is: %{public}d", isValid); + std::thread waitThread([&]() { + bool result2 = false; + auto startTime = std::chrono::steady_clock::now(); + result2 = OH_NativeFence_Wait(sfd, TIMEOUT_MS); + auto endTime = std::chrono::steady_clock::now(); + auto duration = std::chrono::duration_cast(endTime - startTime).count(); + DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); + signaled.store(true); + }); + std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. + pid_t target_pid = getpid(); + int ret = kill(target_pid, SIGINT); + if (ret < 0) { + DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); + } + // Waiting for waitThread to complete + waitThread.join(); + // checks the signaled variable to ensure that OH_NativeFence_Wait has returned + DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); + OH_NativeFence_Close(sfd); +} + +static napi_value SyncFenceWaitForever(napi_env env, napi_callback_info info) +{ + bool result = OH_NativeFence_WaitForever(INVALID_FD); + DRAWING_LOGI("get result %{public}d", result); + + std::atomic signaled(false); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGINT); // Monitor SIGINT signal (Ctrl C) + sigaddset(&mask, SIGTERM); // Monitor SIGTERM signal (kill command) + sigprocmask(SIG_BLOCK, &mask, NULL); + int sfd = signalfd(-1, &mask, 0); + if (sfd == -1) { + perror("signalfd failed"); + exit(1); + } + std::thread waitThread([&]() { + bool result2 = false; + auto startTime = std::chrono::steady_clock::now(); + result2 = OH_NativeFence_WaitForever(sfd); + auto endTime = std::chrono::steady_clock::now(); + auto duration = std::chrono::duration_cast(endTime - startTime).count(); + DRAWING_LOGI("get result2 %{public}d, cost_time: %{public}d", result2, duration); + signaled.store(true); + }); + std::this_thread::sleep_for(std::chrono::seconds(3)); // 3 means main thread sleep 3 seconds. + pid_t target_pid = getpid(); + int ret = kill(target_pid, SIGINT); + if (ret < 0) { + DRAWING_LOGI("kill failed: %{public}d", strerror(errno)); + } + // Waiting for waitThread to complete + waitThread.join(); + // checks the signaled variable to ensure that OH_NativeFence_Wait has returned + DRAWING_LOGI("get signaled.load() %{public}d", signaled.load()); + OH_NativeFence_Close(sfd); +} + +// EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "syncFence_wait", nullptr, SyncFenceWait, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "syncFence_waitForever", nullptr, SyncFenceWaitForever, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +// EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3a942ca1ec1f093b56cf0bcca43a3995c2489ff7 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const add: (a: number, b: number) => number; +export const syncFence_wait: () => void; +export const syncFence_waitForever: () => void; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..846e4c7e13ead48abe6019bd40f3a13bf8f9c083 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..252b7dad746191e35c874f2fc83685e3c8ae115b --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +}; diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100755 index 0000000000000000000000000000000000000000..1504a74f09dfdcfae408be979f99369a2c5affab --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets new file mode 100755 index 0000000000000000000000000000000000000000..369e76b2798ec2bc05540bfbe044940d78a65973 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + build() { + Column() { + Row() { + Button($r("app.string.Button_label1")) + .fontSize('16fp') + .fontWeight(500) + .margin({ right: 82 }) + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test sync fence wait: ', testNapi.syncFence_wait()); + }) + .width('33.6%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + + Button($r("app.string.Button_label2")) + .fontSize('16fp') + .fontWeight(500) + .margin({ left: 12 }) + .onClick(() => { + hilog.info(0x0000, 'testTag', 'Test sync fence waitForever: ', testNapi.syncFence_waitForever()); + }) + .width('43.6%') + .height(40) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + .width('100%') + .justifyContent(FlexAlign.Center) + .shadow(ShadowStyle.OUTER_DEFAULT_SM) + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + } + } +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..776ce01475229d674487a2830790c4c87b777379 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json old mode 100644 new mode 100755 similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/color.json rename to code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/color.json diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..8f46642db862b5906614fb5f951e9593dbe95114 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "NdkNativeFence" + }, + { + "name": "Button_label1", + "value": "SyncFenceWait" + }, + { + "name": "Button_label2", + "value": "SyncFenceWaitForever" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png new file mode 100755 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/background.png differ diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png new file mode 100755 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json new file mode 100755 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png new file mode 100755 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json new file mode 100755 index 0000000000000000000000000000000000000000..d742c2f96e7dd0f406f499941f3147345e998f95 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..9bf65b1808b0cef68b5112ffd3bcedaac0a8e886 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "NdkNativeFence" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ff996759279f16098c1eb211c23c08f3a0cbd1a4 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "NdkNativeFence" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets new file mode 100755 index 0000000000000000000000000000000000000000..eebf1ed910f6a8f2a9e7e565aa71b179b7b8b537 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 new file mode 100755 index 0000000000000000000000000000000000000000..2c7d2ba82b796a2850ced0a277d261d7d7355416 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/mock/mock-config.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..b564fe7a5f2dba3e502e0310cd60eb386d84bb94 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +const TAG = '[Sample_ API]'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + + /** + * 点击按钮,测试SyncFenceWait + */ + it('SyncFenceWait_001', 2, async () => { + hilog.info(0x0001, TAG, 'SyncFenceWait_001 begin'); + let driver = Driver.create(); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + try { + await abilityDelegator.startAbility({ + bundleName: 'com.samples.ndknativefence', + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SyncFenceWait')); + let syncFenceBtn1 = await driver.findComponent(ON.text('SyncFenceWait')); + // 点击'syncFenceWait'按钮 + // await syncFenceBtn1.click(); 注释掉,因为点击按钮后,会直接退出应用(接口调用后,会直接退出应用,所以这里不进行点击操作) + await driver.delayMs(1000); + }) + + /** + * 点击按钮,测试syncFenceWaitForever + */ + it('syncFenceWaitForever_001', 2, async () => { + hilog.info(0x0001, TAG, 'syncFenceWaitForever_001 begin'); + let driver = Driver.create(); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + try { + await abilityDelegator.startAbility({ + bundleName: 'com.samples.ndknativefence', + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + await driver.delayMs(1000); + await driver.assertComponentExist(ON.text('SyncFenceWaitForever')); + let syncFenceBtn2 = await driver.findComponent(ON.text('SyncFenceWaitForever')); + // 点击'syncFenceWaitForever'按钮 + // await syncFenceBtn2.click(); 注释掉,因为点击按钮后,会直接退出应用(接口调用后,会直接退出应用,所以这里不进行点击操作) + await driver.delayMs(1000); + hilog.info(0x0001, TAG, 'syncFenceWaitForever_001 end'); + }) + + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..c8bd24faff0ff0064a57435f74662f1db5865f88 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 b/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 new file mode 100755 index 0000000000000000000000000000000000000000..c61d3eed60978a00d9a67b754ec36c0c9dcde929 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/hvigorfile.ts b/code/BasicFeature/Native/NdkNativeFence/hvigorfile.ts new file mode 100755 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 b/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 new file mode 100755 index 0000000000000000000000000000000000000000..4c8bad9bdbdd8da17793a0e43f29d9e7232dce00 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/BasicFeature/Native/NdkNativeFence/ohosTest.md b/code/BasicFeature/Native/NdkNativeFence/ohosTest.md new file mode 100755 index 0000000000000000000000000000000000000000..8e0836832c3f7142de4c8affdcf16aef2f26e700 --- /dev/null +++ b/code/BasicFeature/Native/NdkNativeFence/ohosTest.md @@ -0,0 +1,6 @@ +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|:-------:|:------------:|:--------------:|:---------------:|:----:|:----:| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 主页展示 | 设备正常运行 | | 展示 SyncFenceWait 和 SyncFenceWaitForever 按钮 | 是 | Pass | +| 主页按钮点击 | 位于主页 | 点击 SyncFenceWait 按钮 | 等待3s后退出 | 是 | Pass | +| 主页按钮点击 | 位于主页 | 点击 SyncFenceWaitForever 按钮 | 等待5s后退出 | 是 | Pass | \ No newline at end of file diff --git a/code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg b/code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg new file mode 100755 index 0000000000000000000000000000000000000000..e6484fffa9ba7b8eb12e8e70e1a6a5cf4e770031 Binary files /dev/null and b/code/BasicFeature/Native/NdkNativeFence/screenshots/SyncFence.jpeg differ diff --git a/code/DocsSample/ArkUISample/Animation/.gitignore b/code/DocsSample/ArkUISample/Animation/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/AppScope/app.json5 b/code/DocsSample/ArkUISample/Animation/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1e01400f30809cb5d43a42816db5eaf8d22ca7b6 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.animation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b86e4d568762b2d514c1bf734000d12e6a04e9d1 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "animation" + } + ] +} diff --git a/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/background.png b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/README_zh.md b/code/DocsSample/ArkUISample/Animation/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..34235df004e369b2c7f0f65997dc16fd9354bd08 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/README_zh.md @@ -0,0 +1,165 @@ +# ArkUI使用动效组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [显示动画(animateTo)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-explicit-animation.md)。 +2. [属性动画(animation)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-animatorproperty.md)。 +3. [动画衔接](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-animation-smoothing.md)。 +4. [关键帧动画](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-keyframeAnimateTo.md)。 +5. [页面间转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-page-transition-animation.md)。 +6. [组件内转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-transition-animation-component.md)。 +7. [共享元素转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-transition-animation-shared-elements.md)。 +8. [路径动画](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-motion-path-animation.md)。 +9. [粒子动画](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-particle-animation.md)。 +10. [帧动画](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-animator.md)。 +11. [显式动画立即下发](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-explicit-animatetoimmediately.md)。 +12. [旋转屏动画](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-rotation-transition-animation.md)。 + + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---animateTo // 显示动画(animateTo) +| | |---template1 +| | | |---Index.ets // 示例1(在组件出现时创建动画) +| | |---template2 +| | | |---Index.ets // 示例2(动画执行结束后组件消失) +| | |---template3 +| | | |---Index.ets // 示例3(在状态管理V2中使用animateTo) +| |---animateToImmediately // 显式动画立即下发 +| | |---template1 +| | | |---Index.ets +| |---animation // 属性动画(animation) +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets // 示例2(使用animateTo产生属性动画) +| | |---template3 +| | | |---Index.ets // 示例3(使用animation产生属性动画) +| | |---template4 +| | | |---Index.ets // 示例4(使用keyframeAnimateTo产生属性动画) +| |---animator // 帧动画 +| | |---template1 // 示例1(基于ArkTS扩展的声明式开发范式) +| | | |---Index.ets +| | |---template2 // 示例2(位移动画示例) +| | | |---Index.ets +| | |---template3 // 示例3(使用帧动画实现小球抛物运动) +| | | |---Index.ets +| |---cohesion // 动画衔接 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---compTransition // 组件内转场 +| | |---template1 +| | | |---Index.ets // 示例1(使用同一接口实现图片出现消失) +| | |---template2 +| | | |---Index.ets // 示例2(使用不同接口实现图片出现消失) +| | |---template3 +| | | |---Index.ets // 示例3(设置父子组件为transition) +| | |---template4 +| | | |---Index.ets // 示例4(出现/消失转场) +| | |---template5 +| | | |---Index.ets // 示例5(多个组件渐次出现消失) +| |---keyframeAnimateTo // 关键帧动画 +| | |---template1 +| | | |---Index.ets +| |---motionPath // 路径动画 +| | |---template1 +| | | |---Index.ets +| |---pageTransition // 页面间转场 +| | |---template1 +| | | |---Index.ets // 示例1(设置退入场动画) +| | |---template2 +| | | |---Index.ets // 示例2(设置退入场平移效果) +| | |---template3 +| | | |---Index.ets // 示例3(不推荐)(利用pushUrl跳转能力) +| | |---template4 +| | | |---Index.ets // 示例4(不推荐)(type为None的页面转场) +| |---particle // 粒子动画 +| | |---template1 +| | | |---Index.ets // 示例1(圆形初始化粒子) +| | |---template2 +| | | |---Index.ets // 示例2(图片初始化粒子) +| | |---template3 +| | | |---Index.ets // 示例3(粒子扰动场的干扰下运动轨迹发生变化) +| | |---template4 +| | | |---Index.ets // 示例4(调整粒子发射器位置) +| | |---template5 +| | | |---Index.ets // 示例5(环形发射器创建) +| | |---template6 +| | | |---Index.ets // 示例6(环形发射器更新) +| |---rotation // 旋转屏动画 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---shareTransition // 共享元素转场 +| | |---template1 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---AnimateTo.test.ets // 显示动画(animateTo)示例代码测试代码 +| | |---AnimateToImmediately.test.ets // 显式动画立即下发示例代码测试代码 +| | |---Animation.test.ets // 属性动画(animation)示例代码测试代码 +| | |---Animator.test.ets // 帧动画示例代码测试代码 +| | |---Cohesion.test.ets // 动画衔接示例代码测试代码 +| | |---ComponentTransition.test.ets // 组件内转场示例代码测试代码 +| | |---KeyFrameAnimateTo.test.ets // 关键帧动画示例代码测试代码 +| | |---MotionPath.test.ets // 路径动画示例代码测试代码 +| | |---PageTransition.test.ets // 页面间转场示例代码测试代码 +| | |---Particle.test.ets // 粒子动画示例代码测试代码 +| | |---Rotation.test.ets // 旋转屏动画示例代码测试代码 +| | |---ShareTransition.test.ets // 共享元素转场示例代码测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.33,镜像版本号:OpenHarmony_6.0.0.33。 + +3.本示例需要使用DevEco Studio 6.0.0 Canary1 (Build Version: 6.0.0.270, built on May 9, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/Animation > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/build-profile.json5 b/code/DocsSample/ArkUISample/Animation/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e1244ceecbe969910aa0eb4f5ec4543c58ee4225 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/code-linter.json5 b/code/DocsSample/ArkUISample/Animation/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/.gitignore b/code/DocsSample/ArkUISample/Animation/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/build-profile.json5 b/code/DocsSample/ArkUISample/Animation/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/hvigorfile.ts b/code/DocsSample/ArkUISample/Animation/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/Animation/entry/obfuscation-rules.txt b/code/DocsSample/ArkUISample/Animation/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/oh-package.json5 b/code/DocsSample/ArkUISample/Animation/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/common/resource.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/common/resource.ets new file mode 100644 index 0000000000000000000000000000000000000000..723a394265ee2e6bf6d895e9503c4b2d8e49207a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/common/resource.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { display, uiObserver, window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +function callBackFunc2(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag2 navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + uiObserver.on('navDestinationSwitch', this.context, callBackFunc); + uiObserver.on('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc2); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + uiObserver.off('navDestinationSwitch', this.context, callBackFunc); + uiObserver.off('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let mainWindow: window.Window; + try { + mainWindow = windowStage.getMainWindowSync(); + let displayClass: display.Display = display.getDefaultDisplaySync(); + AppStorage.setOrCreate('orientation', displayClass.orientation); + // 监听窗口的windowsSizeChange事件,旋转屏时会触发该事件 + mainWindow.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let displayClass: display.Display | null = null; + try { + displayClass = display.getDefaultDisplaySync(); + console.info('display orientation is ' + JSON.stringify(displayClass.orientation)); + // 获取屏幕的显示方向 + AppStorage.set('orientation', displayClass.orientation); + } catch { + return; + } + }) + } catch { + hilog.info(0x0000, 'testTag', '%{public}s', 'error'); + return; + } + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..95665e92fe385e0b9c308e320101d63fd1eedabb --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import curves from '@ohos.curves'; +import { Route, RouteGroup } from './common/Index'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; +import router from '@ohos.router'; + +@Styles +function cardPressedStyle() { + .backgroundColor('rgba(0,0,0,0.1)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardNormalStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardDisabledStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(0.5) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + + +@Entry +@Component +struct AnimateIndex { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: "animateTo", + label: $r('app.string.animate_to_label'), + children: [ + { name: 'template1/Index', label: $r('app.string.animate_to_temp_label1') }, + { name: 'template2/Index', label: $r('app.string.animate_to_temp_label2') }, + { name: 'template3/Index', label: $r('app.string.animate_to_temp_label3') } + ] + },{ + name: "animation", + label: $r("app.string.animation_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.temp1") }, + { name: 'template2/Index', label: $r("app.string.animation_temp_label2") }, + { name: 'template3/Index', label: $r("app.string.animation_temp_label3") }, + { name: 'template4/Index', label: $r("app.string.animation_temp_label4") } + ] + }, { + name: "cohesion", + label: $r("app.string.cohesion_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.cohesion_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.cohesion_temp_label2") } + ] + }, { + name: "keyframeAnimateTo", + label: $r("app.string.keyframeAnimateTo_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.temp1") } + ] + }, { + name: "pageTransition", + label: $r("app.string.pageTransition_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.pageTransition_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.pageTransition_temp_label2") }, + { name: 'template3/pageTransitionSrc1', label: $r("app.string.pageTransition_temp_label3") }, + { name: 'template4/pageTransitionSrc2', label: $r("app.string.pageTransition_temp_label4") } + ] + }, { + name: "compTransition", + label: $r("app.string.compTransition_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.compTransition_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.compTransition_temp_label2") }, + { name: 'template3/Index', label: $r("app.string.compTransition_temp_label3") }, + { name: 'template4/Index', label: $r("app.string.compTransition_temp_label4") }, + { name: 'template5/Index', label: $r("app.string.compTransition_temp_label5") } + ] + }, { + name: "shareTransition", + label: $r("app.string.shareTransition_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.temp1") } + ] + }, { + name: "motionPath", + label: $r("app.string.motionPath_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.temp1") } + ] + }, { + name: "particle", + label: $r("app.string.particle_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.particle_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.particle_temp_label2") }, + { name: 'template3/Index', label: $r("app.string.particle_temp_label3") }, + { name: 'template4/Index', label: $r("app.string.particle_temp_label4") }, + { name: 'template5/Index', label: $r("app.string.particle_temp_label5") }, + { name: 'template6/Index', label: $r("app.string.particle_temp_label6") } + ] + }, { + name: "animator", + label: $r("app.string.animator_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.animator_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.animator_temp_label2") }, + { name: 'template3/Index', label: $r("app.string.animator_temp_label3") } + ] + }, { + name: "animateToImmediately", + label: $r("app.string.animateToImmediately_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.temp1") } + ] + }, { + name: "rotation", + label: $r("app.string.rotation_label"), + children:[ + { name: 'template1/Index', label: $r("app.string.rotation_temp_label1") }, + { name: 'template2/Index', label: $r("app.string.rotation_temp_label2") } + ] + } + ]; + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(route: RouteGroup) { + Row() { + Text(route.label) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Medium) + + Blank() + + Text(`${route.children.length}`) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .opacity(this.selection === route.name ? 0 : 1) + + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + .rotate({ angle: this.selection === route.name ? 90 : 0 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 30) }) + } + .borderRadius(20) + .width('100%') + .padding(8) + .enabled(!!route.children.length) + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .onClick(() => { + animateTo( + { curve: curves.interpolatingSpring(0, 1, 228, 25) }, + () => { + if (this.selection === route.name) { + this.selection = null; + } else { + this.selection = route.name; + } + }); + }) + } + + aboutToAppear(): void{ + this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + } + build() { + Column() { + Text("AnimateIndex") + List() { + ForEach(this.routes, (routeGroup: RouteGroup) => { + ListItemGroup({ + header: this.ListItemGroupHeader(routeGroup), + style: ListItemGroupStyle.CARD, + }) { + if (routeGroup.name === this.selection) { + ForEach(routeGroup.children, (route: Route) => { + ListItem() { + Row() { + Text(route.label).fontSize(16) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + } + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .borderRadius(20) + .padding(8) + .transition( + TransitionEffect.OPACITY.animation({ + curve: curves.interpolatingSpring(0, 1, 228, 30) + }) + ) + .width('100%') + .onClick(() => { + const name = `pages/${routeGroup.name}/${route.name}`; + router.pushUrl({url: name}) + }) + } + .width('100%') + }) + } + } + .padding(2) + .divider({ strokeWidth: 0.5 }) + }) + }.padding({bottom: 10}) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c487840e0060b57cb9a879f83058e8fd7d72fd06 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template1/Index.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct AnimateToExample { + @State widthSize: number = 250; + @State heightSize: number = 100; + @State rotateAngle: number = 0; + private flag: boolean = true; + + build() { + Column() { + Button('change size') + .width(this.widthSize) + .height(this.heightSize) + .margin(30) + .onClick(() => { + if (this.flag) { + // 建议使用this.getUIContext()?.animateTo() + this.getUIContext()?.animateTo({ + duration: 2000, + curve: Curve.EaseOut, + iterations: 3, + playMode: PlayMode.Normal, + onFinish: () => { + console.info('play end'); + } + }, () => { + this.widthSize = 150; + this.heightSize = 60; + }) + } else { + // 建议使用this.getUIContext()?.animateTo() + this.getUIContext()?.animateTo({}, () => { + this.widthSize = 250; + this.heightSize = 100; + }) + } + this.flag = !this.flag; + }) + Button('stop rotating') + .margin(50) + .rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }) + .onAppear(() => { + // 组件出现时开始做动画 + // 建议使用this.getUIContext()?.animateTo() + this.getUIContext()?.animateTo({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + iterations: -1, // 设置-1表示动画无限循环 + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 10, + max: 120, + expected: 60, + } + }, () => { + this.rotateAngle = 90; + }) + }) + .onClick(() => { + // 建议使用this.getUIContext()?.animateTo() + this.getUIContext()?.animateTo({ duration: 0 }, () => { + // this.rotateAngle之前为90,在duration为0的动画中修改属性,可以停止该属性之前的动画,按新设置的属性显示 + this.rotateAngle = 0; + }) + }) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff96a620d84ad792704f5d7453a7228c3c7706f9 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template2/Index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct AnimateToExample2 { + @State heightSize: number = 100; + @State isShow: boolean= true; + @State count: number= 0; + private isToBottom: boolean = true; // 向下 + + build() { + Column() { + if (this.isShow) { + Column() + .width(200) + .height(this.heightSize) + .backgroundColor('blue') + .onClick(() => { + // 建议使用this.getUIContext()?.animateTo() + this.getUIContext()?.animateTo({ + duration: 2000, + curve: Curve.EaseOut, + iterations: 1, + playMode: PlayMode.Normal, + onFinish: () => { + this.count--; + if (this.count == 0 && !this.isToBottom) { // 组件只有在向下做完动画才会消失 + this.isShow = false; + } + } + }, () => { + this.count++; + if (this.isToBottom) { + this.heightSize = 60; + } else { + this.heightSize = 100; + } + this.isToBottom = !this.isToBottom; + }) + }) + } + }.width('100%').height('100%').margin({ top: 5 }) + .justifyContent(FlexAlign.End) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template3/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6041d21080aeaff67b3441021df03899d849fc4 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateTo/template3/Index.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@ComponentV2 +struct AnimateToExample3 { + @Local w: number = 50; // 宽度 + @Local h: number = 50; // 高度 + @Local message: string = 'Hello'; + + build() { + Column() { + Button('change size') + .margin(20) + .onClick(() => { + // 在执行动画前,存在额外的修改 + this.w = 100; + this.h = 100; + this.message = 'Hello Word'; + animateToImmediately({ + duration: 0 + }, () => { + }) + this.getUIContext().animateTo({ + duration: 1000 + }, () => { + this.w = 200; + this.h = 200; + this.message = 'Hello ArkUI'; + }) + }) + Column() { + Text(`${this.message}`) + } + .backgroundColor('#ff17a98d') + .width(this.w) + .height(this.h) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateToImmediately/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateToImmediately/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d32df74972df165757f680aa7ba3d5528c2f86ec --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animateToImmediately/template1/Index.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct AnimateToImmediatelyExample { + @State widthSize: number = 250; + @State heightSize: number = 100; + @State opacitySize: number = 0; + private flag: boolean = true; + + build() { + Column() { + Column() + .width(this.widthSize) + .height(this.heightSize) + .backgroundColor(Color.Green) + .opacity(this.opacitySize) + Button('change size') + .margin(30) + .onClick(() => { + if (this.flag) { + animateToImmediately({ + delay: 0, + duration: 1000 + }, () => { + this.opacitySize = 1; + }) + this.getUIContext()?.animateTo({ + delay: 1000, + duration: 1000 + }, () => { + this.widthSize = 150; + this.heightSize = 60; + }) + } else { + animateToImmediately({ + delay: 0, + duration: 1000 + }, () => { + this.widthSize = 250; + this.heightSize = 100; + }) + this.getUIContext()?.animateTo({ + delay: 1000, + duration: 1000 + }, () => { + this.opacitySize = 0; + }) + } + this.flag = !this.flag; + }) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e9fa69304ba32657ed5ab8a6cc67a34139fb51d --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template1/Index.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct AttrAnimationExample { + @State widthSize: number = 250; + @State heightSize: number = 100; + @State rotateAngle: number = 0; + @State flag: boolean = true; + + build() { + Column() { + Button('change size') + .onClick(() => { + if (this.flag) { + this.widthSize = 150 + this.heightSize = 60 + } else { + this.widthSize = 250 + this.heightSize = 100 + } + this.flag = !this.flag + }) + .margin(30) + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.EaseOut, + iterations: 3, + playMode: PlayMode.Normal + }) + Button('change rotate angle') + .onClick(() => { + this.rotateAngle = 90 + }) + .margin(50) + .rotate({ angle: this.rotateAngle }) + .animation({ + duration: 1200, + curve: Curve.Friction, + delay: 500, + iterations: -1, // 设置-1表示动画无限循环 + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: 20, + max: 120, + expected: 90, + } + }) + }.width('100%').margin({ top: 20 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa2721ce7f1711946abd17ced205b3170370c3a8 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template2/Index.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct attrAnimateToDemo2 { + @State animate: boolean = false; + // 第一步: 声明相关状态变量 + @State rotateValue: number = 0; // 组件一旋转角度 + @State translateX: number = 0; // 组件二偏移量 + @State opacityValue: number = 1; // 组件二透明度 + + // 第二步:将状态变量设置到相关可动画属性接口 + build() { + Row() { + // 组件一 + Column() { + } + .rotate({ angle: this.rotateValue }) + .backgroundColor('#317AF7') + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .borderRadius(30) + .onClick(() => { + this.getUIContext()?.animateTo({ curve: curves.springMotion() }, () => { + this.animate = !this.animate; + // 第三步:闭包内通过状态变量改变UI界面 + // 这里可以写任何能改变UI的逻辑比如数组添加,显隐控制,系统会检测改变后的UI界面与之前的UI界面的差异,对有差异的部分添加动画 + // 组件一的rotate属性发生变化,所以会给组件一添加rotate旋转动画 + this.rotateValue = this.animate ? 90 : 0; + // 组件二的透明度发生变化,所以会给组件二添加透明度的动画 + this.opacityValue = this.animate ? 0.6 : 1; + // 组件二的translate属性发生变化,所以会给组件二添加translate偏移动画 + this.translateX = this.animate ? 50 : 0; + }) + }) + + // 组件二 + Column() { + } + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .backgroundColor('#D94838') + .borderRadius(30) + .opacity(this.opacityValue) + .translate({ x: this.translateX }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template3/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5709dc86b4edfdc1f5dbd63d40d0fc1f659295d8 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template3/Index.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct attrAnimationDemo3 { + @State animate: boolean = false; + // 第一步: 声明相关状态变量 + @State rotateValue: number = 0; // 组件一旋转角度 + @State translateX: number = 0; // 组件二偏移量 + @State opacityValue: number = 1; // 组件二透明度 + + // 第二步:将状态变量设置到相关可动画属性接口 + build() { + Row() { + // 组件一 + Column() { + } + .opacity(this.opacityValue) + .rotate({ angle: this.rotateValue }) + // 第三步:通过属性动画接口开启属性动画 + .animation({ curve: curves.springMotion() }) + .backgroundColor('#317AF7') + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .borderRadius(30) + .onClick(() => { + this.animate = !this.animate; + // 第四步:闭包内通过状态变量改变UI界面 + // 这里可以写任何能改变UI的逻辑比如数组添加,显隐控制,系统会检测改变后的UI界面与之前的UI界面的差异,对有差异的部分添加动画 + // 组件一的rotate属性发生变化,所以会给组件一添加rotate旋转动画 + this.rotateValue = this.animate ? 90 : 0; + // 组件二的translate属性发生变化,所以会给组件二添加translate偏移动画 + this.translateX = this.animate ? 50 : 0; + // 父组件column的opacity属性有变化,会导致其子节点的透明度也变化,所以这里会给column和其子节点的透明度属性都加动画 + this.opacityValue = this.animate ? 0.6 : 1; + }) + + // 组件二 + Column() { + } + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .backgroundColor('#D94838') + .borderRadius(30) + .opacity(this.opacityValue) + .translate({ x: this.translateX }) + .animation({ curve: curves.springMotion() }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template4/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ffd8960a3cb3d7221b7b11bbd794a847be7a49f --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animation/template4/Index.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct KeyframeAnimateToDemo { + // 第一步: 声明相关状态变量 + @State rotateValue: number = 0; // 组件一旋转角度 + @State translateX: number = 0; // 组件二偏移量 + @State opacityValue: number = 1; // 组件二透明度 + // 第二步:将状态变量设置到相关可动画属性接口 + build() { + Row() { + // 组件一 + Column() { + } + .rotate({ angle: this.rotateValue }) + .backgroundColor('#317AF7') + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .borderRadius(30) + .onClick(() => { + // 第三步:调用keyframeAnimateTo接口 + this.getUIContext()?.keyframeAnimateTo({ + iterations: 1 + }, [ + { + // 第一段关键帧动画时长为800ms,组件一顺时针旋转90度,组件二的透明度变从1变为0.6,组件二的translate从0位移到50 + duration: 800, + event: () => { + this.rotateValue = 90; + this.opacityValue = 0.6; + this.translateX = 50; + } + }, + { + // 第二段关键帧动画时长为500ms,组件一逆时针旋转90度恢复至0度,组件二的透明度变从0.6变为1,组件二的translate从50位移到0 + duration: 500, + event: () => { + this.rotateValue = 0; + this.opacityValue = 1; + this.translateX = 0; + } + } + ]); + }) + // 组件二 + Column() { + } + .justifyContent(FlexAlign.Center) + .width(100) + .height(100) + .backgroundColor('#D94838') + .borderRadius(30) + .opacity(this.opacityValue) + .translate({ x: this.translateX }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4650375cfeec49f1b5db75086089cc5d6d0c2ab --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template1/Index.ets @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Animator as animator, AnimatorResult } from '@kit.ArkUI'; + +@Entry +@Component +struct AnimatorTest { + private TAG: string = '[AnimatorTest]'; + private backAnimator: AnimatorResult | undefined = undefined; + private flag: boolean = false; + @State wid: number = 100; + @State hei: number = 100; + + create() { + this.backAnimator = animator.create({ + // 建议使用 this.getUIContext.createAnimator()接口 + duration: 2000, + easing: "ease", + delay: 0, + fill: "forwards", + direction: 'normal', + iterations: 1, + begin: 100, + end: 200 + }) + this.backAnimator.onFinish = () => { + this.flag = true + console.info(this.TAG, 'backAnimator onFinish') + } + this.backAnimator.onRepeat = () => { + console.info(this.TAG, 'backAnimator repeat') + } + this.backAnimator.onCancel = () => { + console.info(this.TAG, 'backAnimator cancel') + } + this.backAnimator.onFrame = (value: number) => { + this.wid = value + this.hei = value + } + } + + aboutToDisappear() { + // 自定义组件消失时调用finish使未完成的动画结束,避免动画继续运行。 + // 由于backAnimator在onframe中引用了this, this中保存了backAnimator, + // 在自定义组件消失时应该将保存在组件中的backAnimator置空,避免内存泄漏 + this.backAnimator?.finish(); + this.backAnimator = undefined; + } + + build() { + Column() { + Column() { + Column() + .width(this.wid) + .height(this.hei) + .backgroundColor(Color.Red) + } + .width('100%') + .height(300) + + Column() { + Row() { + Button('create') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.create() + }) + } + .padding(10) + + Row() { + Button('play') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.flag = false + if (this.backAnimator) { + this.backAnimator.play() + } + }) + } + .padding(10) + + Row() { + Button('pause') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + if (this.backAnimator) { + this.backAnimator.pause() + } + }) + } + .padding(10) + + Row() { + Button('finish') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.flag = true + if (this.backAnimator) { + this.backAnimator.finish() + } + }) + } + .padding(10) + + Row() { + Button('reverse') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.flag = false + if (this.backAnimator) { + this.backAnimator.reverse() + } + }) + } + .padding(10) + + Row() { + Button('cancel') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + if (this.backAnimator) { + this.backAnimator.cancel() + } + }) + } + .padding(10) + + Row() { + Button('reset') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + if (this.flag) { + this.flag = false + if (this.backAnimator) { + this.backAnimator.reset({ + duration: 3000, + easing: "ease-in", + delay: 0, + fill: "forwards", + direction: "alternate", + iterations: 3, + begin: 100, + end: 300 + }) + } + } else { + console.info(this.TAG, 'Animation not ended') + } + }) + } + .padding(10) + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2fe7a514330fc64ff8f90c1d61287146178236d --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template2/Index.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AnimatorResult, SimpleAnimatorOptions } from '@kit.ArkUI'; + +@Entry +@Component +struct AnimatorTest { + private TAG: string = '[AnimatorTest]'; + private backAnimator: AnimatorResult | undefined = undefined; + private flag: boolean = false; + @State translate_: number = 0; + + create() { + this.backAnimator = this.getUIContext()?.createAnimator( + new SimpleAnimatorOptions(0, 100) + ) + this.backAnimator.onFinish = ()=> { + this.flag = true + console.info(this.TAG, 'backAnimator onFinish') + } + this.backAnimator.onFrame = (value:number)=> { + this.translate_ = value + } + } + + aboutToDisappear() { + // 由于backAnimator在onFrame中引用了this, this中保存了backAnimator, + // 在自定义组件消失时应该将保存在组件中的backAnimator置空,避免内存泄漏 + this.backAnimator = undefined; + } + + build() { + Column() { + Column() { + Column() + .width(100) + .height(100) + .translate({x: this.translate_}) + .backgroundColor(Color.Green) + } + .width('100%') + .height(300) + + Column() { + Column() { + Button('create') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.create() + }) + } + .padding(10) + + Column() { + Button('play') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + this.flag = false + if(this.backAnimator){ + this.backAnimator.play() + } + }) + } + .padding(10) + + Column() { + Button('reset') + .fontSize(30) + .fontColor(Color.Black) + .onClick(() => { + if (this.flag) { + this.flag = false + if(this.backAnimator){ + this.backAnimator.reset( + new SimpleAnimatorOptions(0, -100) + .duration(2000) + .easing("ease-in") + .fill(FillMode.Forwards) + .direction(PlayMode.Alternate) + .iterations(2) + ) + } + } else { + console.info(this.TAG, 'Animation not ended') + } + }) + } + .padding(10) + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template3/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7828bbb49678c43375d785d5fd44d32493c6441e --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/animator/template3/Index.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AnimatorOptions, AnimatorResult } from '@kit.ArkUI'; +import resource from '../../../common/resource'; + +@Entry +@Component +struct Index { + @State animatorOptions: AnimatorResult | undefined = undefined; + @State animatorStatus: Resource = $r('app.string.create'); + begin: number = 0; + end: number = 300; + topWidth: number = 150; + bottomHeight: number = 100; + g: number = 0.18; + animatorOption: AnimatorOptions = { + duration: 4000, + delay: 0, + easing: 'linear', + iterations: 1, + fill: "forwards", + direction: 'normal', + begin: this.begin, + end: this.end + }; + @State translateX: number = 0; + @State translateY: number = 0; + + onPageShow(): void { + this.animatorOptions = this.getUIContext().createAnimator(this.animatorOption); + this.animatorOptions.onFrame = (progress: number) => { + this.translateX = progress; + if (progress > this.topWidth && this.translateY < this.bottomHeight) { + this.translateY = Math.pow(progress - this.topWidth, 2) * this.g; + } + } + this.animatorOptions.onCancel = () => { + this.animatorStatus = $r('app.string.cancel'); + } + this.animatorOptions.onFinish = () => { + this.animatorStatus = $r('app.string.complete'); + } + this.animatorOptions.onRepeat = () => { + console.log('repeat play'); + } + } + + onPageHide(): void { + this.animatorOptions = undefined; + } + + build() { + Column() { + Column({ space: 30 }) { + Button($r('app.string.play')).onClick(() => { + this.animatorOptions?.play(); + this.animatorStatus = $r('app.string.playing'); + }).width(80).height(35) + Button($r('app.string.reset')).onClick(() => { + this.translateX = 0; + this.translateY = 0; + }).width(80).height(35) + Button($r('app.string.pause')).onClick(() => { + this.animatorOptions?.pause(); + this.animatorStatus = $r('app.string.pause'); + }).width(80).height(35) + }.width('100%').height('25%') + + Stack() { + Button() + .width(60) + .height(60) + .translate({ x: this.translateX, y: this.translateY }) + } + .width('100%') + .height('45%') + .align(Alignment.Start) + + Text(resource.resourceToString($r('app.string.animatorStatus')) + resource.resourceToString(this.animatorStatus)) + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..217dd8dcc21b98ac1bdf6274be98c5972b329bae --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template1/Index.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +class SetSlt { + isAnimation: boolean = true + + set(): void { + this.isAnimation = !this.isAnimation; + } +} + +@Entry +@Component +struct AnimationToAnimationDemo { + // 第一步:声明相关状态变量 + @State setAnimation: SetSlt = new SetSlt(); + + build() { + Column() { + Text('ArkUI') + .fontWeight(FontWeight.Bold) + .fontSize(12) + .fontColor(Color.White) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xf56c6c) + .width(100) + .height(100) + .scale({ + // 第二步:将状态变量设置到相关可动画属性接口 + x: this.setAnimation.isAnimation ? 2 : 1, + y: this.setAnimation.isAnimation ? 2 : 1 + }) + .animation({ curve: curves.springMotion(0.4, 0.8) }) // 第四步:通过animation接口开启动画,动画终点值改变时,系统自动添加衔接动画 + + Button('Click') + .margin({ top: 200 }) + .onClick(() => { + // 第三步:通过点击事件改变状态变量值,影响可动画属性值 + this.setAnimation.set() + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ab6bb78d82bc15c33ae51db1e2bbc1d1a1cc978 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/cohesion/template2/Index.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct SpringMotionDemo { + // 第一步:声明相关状态变量 + @State positionX: number = 100; + @State positionY: number = 100; + diameter: number = 50; + + build() { + Column() { + Row() { + Circle({ width: this.diameter, height: this.diameter }) + .fill(Color.Blue) + .position({ x: this.positionX, y: this.positionY })// 第二步:将状态变量设置到相关可动画属性接口 + .onTouch((event?: TouchEvent) => { + // 第三步:在跟手过程改变状态变量值,并且采用responsiveSpringMotion动画运动到新的值 + if (event) { + if (event.type === TouchType.Move) { + // 跟手过程,使用responsiveSpringMotion曲线 + this.getUIContext()?.animateTo({ curve: curves.responsiveSpringMotion() }, () => { + // 减去半径,以使球的中心运动到手指位置 + this.positionX = event.touches[0].windowX - this.diameter / 2; + this.positionY = event.touches[0].windowY - this.diameter / 2; + console.info(`move, animateTo x:${this.positionX}, y:${this.positionY}`); + }) + } else if (event.type === TouchType.Up) { + // 第四步:在离手过程设定状态变量终点值,并且用springMotion动画运动到新的值,springMotion动画将继承跟手阶段的动画速度 + this.getUIContext()?.animateTo({ curve: curves.springMotion() }, () => { + this.positionX = 100; + this.positionY = 100; + console.info(`touchUp, animateTo x:100, y:100`); + }) + } + } + }) + } + .width('100%').height("80%") + .clip(true) // 如果球超出父组件范围,使球不可见 + .backgroundColor(Color.Orange) + + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Center }) { + Text("拖动小球").fontSize(16) + } + .width('100%') + + Row() { + Text('点击位置: [x: ' + Math.round(this.positionX) + ', y:' + Math.round(this.positionY) + ']').fontSize(16) + } + .padding(10) + .width('100%') + }.height('100%').width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/common/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..02c5c6b987280c6731d3e40af7c56c416176a3af --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/common/Index.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Route { + name: string; + label: ResourceStr; +} + +export interface RouteGroup extends Route { + children: Route[]; +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3882e01414f1fdf48b5df9b45993c783f3025342 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template1/Index.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct TransitionEffectExample1 { + @State flag: boolean = true; + @State show: string = 'show'; + + build() { + Column() { + Button(this.show).width(80).height(30).margin(30) + .onClick(() => { + // 点击Button控制Image的显示和消失 + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + this.flag = !this.flag; + }) + if (this.flag) { + // Image的显示和消失配置为相同的过渡效果(出现和消失互为逆过程) + // 出现时从指定的透明度为0、绕z轴旋转180°的状态,变为默认的透明度为1、旋转角为0的状态,透明度与旋转动画时长都为2000ms + // 消失时从默认的透明度为1、旋转角为0的状态,变为指定的透明度为0、绕z轴旋转180°的状态,透明度与旋转动画时长都为2000ms + Image($r('app.media.testImg')).width(200).height(200) + .transition(TransitionEffect.OPACITY.animation({ duration: 2000, curve: Curve.Ease }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }) + )) + } + }.width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..784df84f6931e39aad853f4b492d469d6f1d7492 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template2/Index.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct TransitionEffectExample2 { + @State flag: boolean = true; + @State show: string = 'show'; + + build() { + Column() { + Button(this.show).width(80).height(30).margin(30) + .onClick(() => { + // 点击Button控制Image的显示和消失 + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + this.getUIContext().animateTo({ duration: 2000 }, () => { + // 第一张图的TransitionEffect包含了animation,transition的动画参数由TransitionEffect指定 + // 第二张图的TransitionEffect不包含animation,transition的动画参数由animateTo指定 + this.flag = !this.flag; + }); + }) + if (this.flag) { + // Image的显示和消失配置为不同的过渡效果 + // 出现时做从指定的透明度为0变为默认的透明度1的动画,该动画时长为1000ms,以及做从指定的绕z轴旋转180°变为默认的旋转角为0的动画,该动画1000ms后播放,时长为1000ms + // 消失时做从默认的透明度为1变为指定的透明度0的动画,该动画1000ms后播放,时长为1000ms,以及做从默认的旋转角0变为指定的绕z轴旋转180°的动画,该动画时长为1000ms + Image($r('app.media.testImg')).width(200).height(200) + .transition( + TransitionEffect.asymmetric( + TransitionEffect.OPACITY.animation({ duration: 1000 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ delay: 1000, duration: 1000 })) + , + TransitionEffect.OPACITY.animation({ delay: 1000, duration: 1000 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ duration: 1000 })) + ) + ) + // 出现时做从x方向和y方向scale都为0变为默认的x方向和y方向scale都为1的动画,该动画时长为animateTo中指定的2000ms + // 消失时无转场效果 + Image($r('app.media.testImg')).width(200).height(200).margin({ top: 100 }) + .transition( + TransitionEffect.asymmetric( + TransitionEffect.scale({ x: 0, y: 0 }), + TransitionEffect.IDENTITY + ) + ) + } + }.width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template3/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a6234142ee5974171548614189043059137822f --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template3/Index.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct TransitionEffectExample3 { + @State flag: boolean = true; + @State show: string = 'show'; + + build() { + Column() { + Button(this.show).width(80).height(30).margin(30) + .onClick(() => { + // 点击Button控制Image的显示和消失 + if (this.flag) { + this.show = 'hide'; + } else { + this.show = 'show'; + } + this.flag = !this.flag; + }) + if (this.flag) { + // 改flag条件时,会触发id为"column1"、"image1"、"image2"的transition动画。 + // id为"column1"的组件是这棵新出现/消失的子树的根节点。 + Column() { + Row() { + Image($r('app.media.testImg')).width(150).height(150).id("image1") + .transition(TransitionEffect.OPACITY.animation({ duration: 1000 })) + } + + Image($r('app.media.testImg')) + .width(150) + .height(150) + .margin({ top: 50 }) + .id("image2") + .transition(TransitionEffect.scale({ x: 0, y: 0 }).animation({ duration: 1000 })) + Text("view").margin({ top: 50 }) + } + .id("column1") + .transition(TransitionEffect.opacity(0.99).animation({ duration: 1000 }), + // 结束回调设置在消失的第一层节点上,确保能有消失的结束回调 + (transitionIn: boolean) => { + console.info("transition finish, transitionIn:" + transitionIn); + } + ) + } + }.width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template4/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..270b39e18f0460e40bcaa49cab71e302f1dab72a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template4/Index.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct TransitionEffectDemo { + @State isPresent: boolean = false; + // 第一步,创建TransitionEffect + private effect: TransitionEffect = + // 创建默认透明度转场效果,并指定了springMotion(0.6, 0.8)曲线 + TransitionEffect.OPACITY.animation({ + curve: curves.springMotion(0.6, 0.8) + })// 通过combine方法,这里的动画参数会跟随上面的TransitionEffect,也就是springMotion(0.6, 0.8) + .combine(TransitionEffect.scale({ + x: 0, + y: 0 + }))// 添加旋转转场效果,这里的动画参数会跟随上面带animation的TransitionEffect,也就是springMotion(0.6, 0.8) + .combine(TransitionEffect.rotate({ angle: 90 }))// 添加平移转场效果,这里的动画参数使用指定的springMotion() + .combine(TransitionEffect.translate({ y: 150 }) + .animation({ curve: curves.springMotion() }))// 添加move转场效果,这里的动画参数会跟随上面的TransitionEffect,也就是springMotion() + .combine(TransitionEffect.move(TransitionEdge.END)); + + build() { + Stack() { + if (this.isPresent) { + Column() { + Text('ArkUI') + .fontWeight(FontWeight.Bold) + .fontSize(20) + .fontColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .width(150) + .height(150) + .borderRadius(10) + .backgroundColor(0xf56c6c) + // 第二步:将转场效果通过transition接口设置到组件 + .transition(this.effect) + } + + // 边框 + Column() + .width(155) + .height(155) + .border({ + width: 5, + radius: 10, + color: Color.Black + }) + + // 第三步:新增或者删除组件触发转场,控制新增或者删除组件 + Button('Click') + .margin({ top: 320 }) + .onClick(() => { + this.isPresent = !this.isPresent; + }) + } + .width('100%') + .height('60%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template5/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bed356b71ee31b2c286d6597fa4cc6479476c73 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/compTransition/template5/Index.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const ITEM_COUNTS = 9; +const ITEM_COLOR = '#ED6F21'; +const INTERVAL = 30; +const DURATION = 300; + +@Entry +@Component +struct Index1 { + @State isGridShow: boolean = false; + private dataArray: number[] = new Array(ITEM_COUNTS); + + aboutToAppear(): void { + for (let i = 0; i < ITEM_COUNTS; i++) { + this.dataArray[i] = i; + } + } + + build() { + Stack() { + if (this.isGridShow) { + Grid() { + ForEach(this.dataArray, (item: number, index: number) => { + GridItem() { + Stack() { + Text((item + 1).toString()) + } + .size({ width: 50, height: 50 }) + .backgroundColor(ITEM_COLOR) + .transition(TransitionEffect.OPACITY + .combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }))// 对每个方格的转场添加delay,实现组件的渐次出现消失效果 + .animation({ duration: DURATION, curve: Curve.Friction, delay: INTERVAL * index })) + .borderRadius(10) + } + // 消失时,如果不对方格的所有父控件添加转场效果,则方格的消失转场不会生效 + // 此处让方格的父控件在出现消失转场时一直以0.99的透明度显示,使得方格的转场效果不受影响 + .transition(TransitionEffect.opacity(0.99)) + }, (item: number) => item.toString()) + } + .columnsTemplate('1fr 1fr 1fr') + .rowsGap(15) + .columnsGap(15) + .size({ width: 180, height: 180 }) + // 消失时,如果不对方格的所有父控件添加转场效果,则方格的消失转场不会生效 + // 此处让父控件在出现消失转场时一直以0.99的透明度显示,使得方格的转场效果不受影响 + .transition(TransitionEffect.opacity(0.99)) + } + } + .size({ width: '100%', height: '100%' }) + .onClick(() => { + this.getUIContext()?.animateTo({ + duration: DURATION + INTERVAL * (ITEM_COUNTS - 1), + curve: Curve.Friction + }, () => { + this.isGridShow = !this.isGridShow; + }) + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/keyframeAnimateTo/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/keyframeAnimateTo/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..18b29a34b679e15637ec2f60a6d4486fc8ff6d51 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/keyframeAnimateTo/template1/Index.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UIContext } from '@kit.ArkUI'; + +@Entry +@Component +struct KeyframeDemo { + @State myScale: number = 1.0; + uiContext: UIContext | undefined = undefined; + + aboutToAppear() { + this.uiContext = this.getUIContext?.(); + } + + build() { + Column() { + Circle() + .width(100) + .height(100) + .fill("#46B1E3") + .margin(100) + .scale({ x: this.myScale, y: this.myScale }) + .onClick(() => { + if (!this.uiContext) { + console.info("no uiContext, keyframe failed"); + return; + } + this.myScale = 1; + // 设置关键帧动画整体播放3次 + this.uiContext.keyframeAnimateTo({ + iterations: 3, + expectedFrameRateRange: { + min: 10, + max: 120, + expected: 60, + } + }, [ + { + // 第一段关键帧动画时长为800ms,scale属性做从1到1.5的动画 + duration: 800, + event: () => { + this.myScale = 1.5; + } + }, + { + // 第二段关键帧动画时长为500ms,scale属性做从1.5到1的动画 + duration: 500, + event: () => { + this.myScale = 1; + } + } + ]); + }) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/motionPath/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/motionPath/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..97db6e2734688969e1f36cee799bea3a3e9de205 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/motionPath/template1/Index.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct MotionPathExample { + @State toggle: boolean = true; + + build() { + Column() { + Button('click me').margin(50) + .motionPath({ + path: 'Mstart.x start.y L300 200 L300 500 Lend.x end.y', + from: 0.0, + to: 1.0, + rotatable: true + }) // 执行动画:从起点移动到(300,200),再到(300,500),再到终点 + .onClick(() => { + this.getUIContext()?.animateTo({ duration: 4000, curve: Curve.Linear }, () => { + this.toggle = !this.toggle; // 通过this.toggle变化组件的位置 + }); + }) + }.width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..985716355150f40b4fdb091fd4a4920617d7143a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Index.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct pageTransition1 { + @State scale1: number = 1; + @State opacity1: number = 1; + + build() { + Column() { + Image($r("app.media.transition_image1")).width('100%').height('100%') + } + .width('100%') + .height('100%') + .scale({ x: this.scale1 }) + .opacity(this.opacity1) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template1/Page1' }); + }) + } + + pageTransition() { + PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) + .onEnter((type: RouteType, progress: number) => { + if (type == RouteType.Push || type == RouteType.Pop) { + this.scale1 = progress; + this.opacity1 = progress; + } + }) + PageTransitionExit({ duration: 1200, curve: Curve.Ease }) + .onExit((type: RouteType, progress: number) => { + if (type == RouteType.Push) { + this.scale1 = 1 - progress; + this.opacity1 = 1 - progress; + } + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Page1.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Page1.ets new file mode 100644 index 0000000000000000000000000000000000000000..02727ee0ffd1579b5fadf0e76435ff40f06a42c9 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template1/Page1.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct pageTransitionPage1 { + @State scale2: number = 1; + @State opacity2: number = 1; + + build() { + Column() { + Image($r("app.media.transition_image2")).width('100%').height('100%') // 图片存放在media文件夹下 + } + .width('100%') + .height('100%') + .scale({ x: this.scale2 }) + .opacity(this.opacity2) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template1/Index' }); + }) + } + + pageTransition() { + PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) + .onEnter((type: RouteType, progress: number) => { + if (type == RouteType.Push || type == RouteType.Pop) { + this.scale2 = progress; + } + this.opacity2 = progress; + }) + PageTransitionExit({ duration: 1200, curve: Curve.Ease }) + .onExit((type: RouteType, progress: number) => { + if (type == RouteType.Pop) { + this.scale2 = 1 - progress; + this.opacity2 = 1 - progress; + } + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b334a8f43305046339d2df7f507fc039f319e213 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Index.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct pageTransition2 { + @State scale1: number = 1; + @State opacity1: number = 1; + + build() { + Column() { + Button($r('app.string.page1')).onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: "pages/pageTransition/template2/Page1" + }) + }) + .width(200) + .height(60) + .fontSize(36) + Text("START") + .fontSize(36) + .textAlign(TextAlign.Center) + } + .scale({ x: this.scale1 }) + .opacity(this.opacity1) + .height('100%') + .width('100%') + .justifyContent(FlexAlign.Center) + } + + // 自定义方式2:使用系统提供的多种默认效果(平移、缩放、透明度等) + pageTransition() { + //设置入场动效 + PageTransitionEnter({ duration: 200 }) + .slide(SlideEffect.START) + //设置退场动效 + PageTransitionExit({ delay: 100 }) + .slide(SlideEffect.START) //Left + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Page1.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Page1.ets new file mode 100644 index 0000000000000000000000000000000000000000..61f33307bd9b70d150a4f18163967bc8f9b43f4b --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template2/Page1.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Page1 { + @State scale1: number = 1; + @State opacity1: number = 1; + + build() { + Column() { + Button($r('app.string.page2')).onClick(() => { + this.getUIContext().getRouter().pushUrl({ + url: "pages/pageTransition/template2/Index" + }); + }) + .width(200) + .height(60) + .fontSize(36) + Text("END") + .fontSize(36) + .textAlign(TextAlign.Center) + } + .scale({ x: this.scale1 }) + .opacity(this.opacity1) + .height('100%') + .width('100%') + .justifyContent(FlexAlign.Center) + } + + // 自定义方式2:使用系统提供的多种默认效果(平移、缩放、透明度等) + pageTransition() { + PageTransitionEnter({ duration: 200 }) + .slide(SlideEffect.END) //Right + PageTransitionExit({ delay: 100 }) + .slide(SlideEffect.END) //Right + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionDst1.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionDst1.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbab53fbd2d24268b341982673d4634e2f4ca332 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionDst1.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct PageTransitionDst1 { + build() { + Column() { + Image($r('app.media.forest')) + .width('90%') + .height('80%') + .objectFit(ImageFit.Fill) + .syncLoad(true) // 同步加载图片,使页面出现时图片已经加载完成 + .margin(30) + + Row({ space: 10 }) { + Button("pushUrl") + .onClick(() => { + // 路由到下一页面,push操作 + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template3/pageTransitionSrc1' }); + }) + Button("back") + .onClick(() => { + // 返回到上一页面,相当于pop操作 + this.getUIContext().getRouter().back(); + }) + }.justifyContent(FlexAlign.Center) + } + .width('100%').height('100%') + .alignItems(HorizontalAlign.Center) + } + + pageTransition() { + // 定义页面进入时的效果,从右侧滑入,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Push, duration: 1000 }) + .slide(SlideEffect.Right) + // 定义页面进入时的效果,从左侧滑入,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Pop, duration: 1000 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向左侧滑出,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionExit({ type: RouteType.Push, duration: 1000 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向右侧滑出,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionExit({ type: RouteType.Pop, duration: 1000 }) + .slide(SlideEffect.Right) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionSrc1.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionSrc1.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b037962b68a865cabf738dab0d29b4f141219df --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template3/pageTransitionSrc1.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct PageTransitionSrc1 { + build() { + Column() { + Image($r('app.media.mountain')) + .width('90%') + .height('80%') + .objectFit(ImageFit.Fill) + .syncLoad(true) // 同步加载图片,使页面出现时图片已经加载完成 + .margin(30) + + Row({ space: 10 }) { + Button("pushUrl") + .onClick(() => { + // 路由到下一个页面,push操作 + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template3/pageTransitionDst1' }); + }) + Button("back") + .onClick(() => { + // 返回到上一页面,相当于pop操作 + this.getUIContext().getRouter().back(); + }) + }.justifyContent(FlexAlign.Center) + } + .width('100%').height('100%') + .alignItems(HorizontalAlign.Center) + } + + pageTransition() { + // 定义页面进入时的效果,从右侧滑入,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Push, duration: 1000 }) + .slide(SlideEffect.Right) + // 定义页面进入时的效果,从左侧滑入,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionEnter({ type: RouteType.Pop, duration: 1000 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向左侧滑出,时长为1000ms,页面栈发生push操作时该效果才生效 + PageTransitionExit({ type: RouteType.Push, duration: 1000 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,向右侧滑出,时长为1000ms,页面栈发生pop操作时该效果才生效 + PageTransitionExit({ type: RouteType.Pop, duration: 1000 }) + .slide(SlideEffect.Right) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionDst2.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionDst2.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1f8574084b1d42f093e706238810ccf5b03ac75 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionDst2.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct PageTransitionDst2 { + build() { + Column() { + Image($r('app.media.forest')) + .width('90%') + .height('80%') + .objectFit(ImageFit.Fill) + .syncLoad(true) // 同步加载图片,使页面出现时图片已经加载完成 + .margin(30) + + Row({ space: 10 }) { + Button("pushUrl") + .onClick(() => { + // 路由到下一页面,push操作 + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template4/pageTransitionSrc2' }); + }) + Button("back") + .onClick(() => { + // 返回到上一页面,相当于pop操作 + this.getUIContext().getRouter().back(); + }) + }.justifyContent(FlexAlign.Center) + } + .width('100%').height('100%') + .alignItems(HorizontalAlign.Center) + } + + pageTransition() { + // 定义页面进入时的效果,从左侧滑入,时长为1200ms,无论页面栈发生push还是pop操作均可生效 + PageTransitionEnter({ duration: 1200 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,相对于正常页面位置x方向平移100vp,y方向平移100vp,透明度变为0,时长为1000ms,无论页面栈发生push还是pop操作均可生效 + PageTransitionExit({ duration: 1000 }) + .translate({ x: 100.0, y: 100.0 }) + .opacity(0) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionSrc2.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionSrc2.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2e11e676b27b465f7d1d599ebc6afd00847e729 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/pageTransition/template4/pageTransitionSrc2.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct PageTransitionSrc2 { + build() { + Column() { + Image($r('app.media.mountain')) + .width('90%') + .height('80%') + .objectFit(ImageFit.Fill) + .syncLoad(true) // 同步加载图片,使页面出现时图片已经加载完成 + .margin(30) + + Row({ space: 10 }) { + Button("pushUrl") + .onClick(() => { + // 路由到下一页面,push操作 + this.getUIContext().getRouter().pushUrl({ url: 'pages/pageTransition/template4/pageTransitionDst2' }); + }) + Button("back") + .onClick(() => { + // 返回到上一页面,相当于pop操作 + this.getUIContext().getRouter().back(); + }) + }.justifyContent(FlexAlign.Center) + } + .width('100%').height('100%') + .alignItems(HorizontalAlign.Center) + } + + pageTransition() { + // 定义页面进入时的效果,从左侧滑入,时长为1000ms,无论页面栈发生push还是pop操作均可生效 + PageTransitionEnter({ duration: 1000 }) + .slide(SlideEffect.Left) + // 定义页面退出时的效果,相对于正常页面位置x方向平移100vp,y方向平移100vp,透明度变为0,时长为1200ms,无论页面栈发生push还是pop操作均可生效 + PageTransitionExit({ duration: 1200 }) + .translate({ x: 100.0, y: 100.0 }) + .opacity(0) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..66873f88f674aa93306ed9a3e40d54e58f742ae1 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template1/Index.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ParticleExample { + build() { + Stack() { + Text() + .width(300).height(300).backgroundColor(Color.Black) + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.POINT, //粒子类型 + config: { + radius: 10//圆点半径 + }, + count: 500, //粒子总数 + lifetime: 10000, //粒子生命周期,单位ms + lifetimeRange: 100//粒子生命周期取值范围,单位ms + }, + emitRate: 10, //每秒发射粒子数 + position: [0, 0], + shape: ParticleEmitterShape.RECTANGLE//发射器形状 + }, + color: { + range: [Color.Red, Color.Yellow], //初始颜色范围 + updater: { + type: ParticleUpdater.CURVE, //变化方式为曲线变化 + config: [ + { + from: Color.White, //变化起始值 + to: Color.Pink, //变化终点值 + startMillis: 0, //开始时间 + endMillis: 3000, //结束时间 + curve: Curve.EaseIn//变化曲线 + }, + { + from: Color.Pink, + to: Color.Orange, + startMillis: 3000, + endMillis: 5000, + curve: Curve.EaseIn + }, + { + from: Color.Orange, + to: Color.Pink, + startMillis: 5000, + endMillis: 8000, + curve: Curve.EaseIn + }, + ] + } + }, + opacity: { + range: [0.0, 1.0], //粒子透明度的初始值从【0.0到1.0】随机产生 + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 1.0, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 1.0, + to: 0.0, + startMillis: 5000, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + }, + scale: { + range: [0.0, 0.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 0.5, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + } + ] + } + }, + acceleration: { + //加速度的配置,从大小和方向两个维度变化,speed表示加速度大小,angle表示加速度方向 + speed: { + range: [3, 9], + updater: { + type: ParticleUpdater.RANDOM, //Speed的变化方式是随机变化 + config: [1, 20] + } + }, + angle: { + range: [90, 90] + } + } + + } + ] + }).width(300).height(300) + }.width('100%').height('100%').align(Alignment.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..77952169301832567b14abaf53a802248ad68558 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template2/Index.ets @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ParticleExample2 { + @State + myCount: number = 100; + flag: boolean = false; + + build() { + Column() { + Stack() { + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.IMAGE, + config: { + src: $r("app.media.book"), + size: [10, 10] + }, + count: this.myCount, + lifetime: 10000, + lifetimeRange: 100 + }, + emitRate: 3, + shape: ParticleEmitterShape.CIRCLE + }, + color: { + range: [Color.White, Color.White] + }, + opacity: { + range: [1.0, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 1.0, + startMillis: 0, + endMillis: 6000 + }, + { + from: 1.0, + to: 0, + startMillis: 6000, + endMillis: 10000 + } + ] + } + }, + scale: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 1.5, + startMillis: 0, + endMillis: 8000, + curve: Curve.EaseIn + } + + ] + } + }, + acceleration: { + speed: { + range: [3, 9], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 10, + to: 20, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 10, + to: 2, + startMillis: 3000, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + }, + angle: { + range: [0, 180], + updater: { + type: ParticleUpdater.CURVE, + config: [{ + from: 1, + to: 2, + startMillis: 0, + endMillis: 1000, + curve: Curve.EaseIn + }, + { + from: 50, + to: -50, + startMillis: 1000, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 3, + to: 5, + startMillis: 3000, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + } + }, + spin: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 360, + startMillis: 0, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + }, + } + , { + emitter: { + particle: { + type: ParticleType.IMAGE, + config: { + src: $r('app.media.heart'), + size: [10, 10] + }, + count: this.myCount, + lifetime: 10000, + lifetimeRange: 100 + }, + emitRate: 3, + shape: ParticleEmitterShape.CIRCLE + }, + color: { + range: [Color.White, Color.White] + }, + opacity: { + range: [1.0, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 1.0, + startMillis: 0, + endMillis: 6000 + }, + { + from: 1.0, + to: 0, + startMillis: 6000, + endMillis: 10000 + } + ] + } + }, + scale: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 2.0, + startMillis: 0, + endMillis: 10000, + curve: Curve.EaseIn + } + + ] + } + }, + acceleration: { + speed: { + range: [3, 9], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 10, + to: 20, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 10, + to: 2, + startMillis: 3000, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + }, + angle: { + range: [0, 180], + updater: { + type: ParticleUpdater.CURVE, + config: [{ + from: 1, + to: 2, + startMillis: 0, + endMillis: 1000, + curve: Curve.EaseIn + }, + { + from: 50, + to: -50, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 3, + to: 5, + startMillis: 3000, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + } + }, + spin: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 360, + startMillis: 0, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + }, + }, { + emitter: { + particle: { + type: ParticleType.IMAGE, + config: { + src: $r('app.media.sun'), + size: [10, 10] + }, + count: this.myCount, + lifetime: 10000, + lifetimeRange: 100 + }, + emitRate: 3, + shape: ParticleEmitterShape.CIRCLE + }, + color: { + range: [Color.White, Color.White] + }, + opacity: { + range: [1.0, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 1.0, + startMillis: 0, + endMillis: 6000 + }, + { + from: 1.0, + to: 0, + startMillis: 6000, + endMillis: 10000 + } + ] + } + }, + scale: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 2.0, + startMillis: 0, + endMillis: 10000, + curve: Curve.EaseIn + } + + ] + } + }, + acceleration: { + speed: { + range: [3, 9], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 10, + to: 20, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 10, + to: 2, + startMillis: 3000, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + }, + angle: { + range: [0, 180], + updater: { + type: ParticleUpdater.CURVE, + config: [{ + from: 1, + to: 2, + startMillis: 0, + endMillis: 1000, + curve: Curve.EaseIn + }, + { + from: 50, + to: -50, + startMillis: 1000, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 3, + to: 5, + startMillis: 3000, + endMillis: 8000, + curve: Curve.EaseIn + } + ] + } + } + }, + spin: { + range: [0.1, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0, + to: 360, + startMillis: 0, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + }, + } + ] + }).width(300).height(300) + + }.width(500).height(500).align(Alignment.Center) + }.width('100%').height('100%') + + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template3/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..599a29139fae91ce5b7a44707736de0a7945c453 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template3/Index.ets @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ParticleExample3 { + build() { + Stack() { + Text() + .width(300).height(300).backgroundColor(Color.Black) + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.POINT, //粒子类型 + config: { + radius: 10//圆点半径 + }, + count: 500, //粒子总数 + lifetime: 10000//粒子生命周期,单位ms + }, + emitRate: 10, //每秒发射粒子数 + position: [0, 0], + shape: ParticleEmitterShape.RECTANGLE//发射器形状 + }, + color: { + range: [Color.Red, Color.Yellow], //初始颜色范围 + updater: { + type: ParticleUpdater.CURVE, //变化方式为曲线变化 + config: [ + { + from: Color.White, //变化起始值 + to: Color.Pink, //变化终点值 + startMillis: 0, //开始时间 + endMillis: 3000, //结束时间 + curve: Curve.EaseIn//变化曲线 + }, + { + from: Color.Pink, + to: Color.Orange, + startMillis: 3000, + endMillis: 5000, + curve: Curve.EaseIn + }, + { + from: Color.Orange, + to: Color.Pink, + startMillis: 5000, + endMillis: 8000, + curve: Curve.EaseIn + }, + ] + } + }, + opacity: { + range: [0.0, 1.0], //粒子透明度的初始值从[0.0,1.0]随机产生 + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 1.0, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 1.0, + to: 0.0, + startMillis: 5000, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + }, + scale: { + range: [0.0, 0.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 0.5, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + } + ] + } + }, + acceleration: { + //加速度的配置,从大小和方向两个维度变化,speed表示加速度大小,angle表示加速度方向 + speed: { + range: [3, 9], + updater: { + type: ParticleUpdater.RANDOM, + config: [1, 20] + } + }, + angle: { + range: [90, 90] + } + } + + } + ] + }).width(300).height(300).disturbanceFields([{ + strength: 10, + shape: DisturbanceFieldShape.RECT, + size: { width: 100, height: 100 }, + position: { x: 100, y: 100 }, + feather: 15, + noiseScale: 10, + noiseFrequency: 15, + noiseAmplitude: 5 + }]) + }.width('100%').height('100%').align(Alignment.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template4/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..63b91468f7adefaa9f584588d4db01236bbb84ce --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template4/Index.ets @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ParticleExample4 { + @State emitterProperties: Array = [ + { + index: 0, + emitRate: 100, + position: { x: 60, y: 80 }, + size: { width: 200, height: 200 } + } + ]; + + build() { + Stack() { + Text() + .width(300).height(300).backgroundColor(Color.Black) + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.POINT, // 粒子类型 + config: { + radius: 5// 圆点半径 + }, + count: 400, // 粒子总数 + lifetime: -1// 粒子的生命周期,-1表示粒子生命周期无限大 + }, + emitRate: 10, // 每秒发射粒子数 + position: [0, 0], // 粒子发射位置 + shape: ParticleEmitterShape.CIRCLE// 发射器形状 + }, + color: { + range: [Color.Red, Color.Yellow], // 初始颜色范围 + updater: { + type: ParticleUpdater.CURVE, // 变化方式为曲线变化 + config: [ + { + from: Color.White, + to: Color.Pink, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: Color.Pink, + to: Color.Orange, + startMillis: 3000, + endMillis: 5000, + curve: Curve.EaseIn + }, + { + from: Color.Orange, + to: Color.Pink, + startMillis: 5000, + endMillis: 8000, + curve: Curve.EaseIn + }, + ] + } + }, + }, + ] + }) + .width(300) + .height(300) + .emitter(this.emitterProperties) + }.width('100%').height('100%').align(Alignment.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template5/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..671ed22d43cd855da23b1544adbc34bb8e74d0f4 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template5/Index.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct ParticleExample5 { + build() { + Stack() { + Text() + .width(300).height(300).backgroundColor(Color.Black) + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.POINT, //粒子类型 + config: { + radius: 5//圆点半径 + }, + count: 2000, //粒子总数 + lifetime: 10000, //粒子生命周期,单位ms + lifetimeRange: 100//粒子生命周期取值范围,单位ms + }, + emitRate: 100, //每秒发射粒子数 + shape: ParticleEmitterShape.ANNULUS,//环形发射器 + annulusRegion:{ + center:{x:LengthMetrics.percent(0.5),y:LengthMetrics.percent(0.5)}, // 圆环的圆心坐标 + innerRadius:LengthMetrics.vp(100), // 圆环的外圆半径 + outerRadius:LengthMetrics.vp(120), // 圆环的内圆半径 + startAngle:0, // 圆环的起始角度 + endAngle:360 // 圆环的结束角度 + } + }, + color: { + range: [Color.Pink, Color.White], + }, + opacity: { + range: [0.0, 1.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 1.0, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + }, + { + from: 1.0, + to: 0.0, + startMillis: 5000, + endMillis: 10000, + curve: Curve.EaseIn + } + ] + } + }, + scale: { + range: [0.0, 0.0], + updater: { + type: ParticleUpdater.CURVE, + config: [ + { + from: 0.0, + to: 0.5, + startMillis: 0, + endMillis: 3000, + curve: Curve.EaseIn + } + ] + } + }, + } + ] + }).width(300).height(300) + }.width('100%').height('100%').align(Alignment.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template6/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ab83a65df9c150d2c6a17f6542d2f0b8ea6a684 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/particle/template6/Index.ets @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI' + +@Entry +@Component +struct ParticleExample6 { + + @State radius: number = 1; + @State shape: ParticleEmitterShape = ParticleEmitterShape.ANNULUS; + @State emitRate: number = 200; + @State count: number = 2000; + private timerID: number = -1; + private centerX: LengthMetrics = LengthMetrics.percent(0.5); + private centerY: LengthMetrics = LengthMetrics.percent(0.5); + private inRadius: LengthMetrics = LengthMetrics.vp(120); + private outRadius: LengthMetrics = LengthMetrics.vp(120); + private startAngle: number = 0; + private endAngle: number = 90; + @State emitterProperties: Array = [ + { + index: 0, + emitRate: 100, + annulusRegion: { + center:{x:this.centerX, y: this.centerY}, // 圆环的圆心坐标 + outerRadius: this.outRadius, // 圆环的外圆半径 + innerRadius: this.inRadius, // 圆环的内圆半径 + startAngle: -90, // 圆环的起始角度 + endAngle: 0 // 圆环的结束角度 + } + } + ]; + @State region: ParticleAnnulusRegion = { + center:{x:this.centerX, y: this.centerY}, + outerRadius: this.outRadius, + innerRadius: this.inRadius, + startAngle: -90, + endAngle: 0 + }; + + aboutToDisappear(): void { + // 页面销毁时清除计时器 + if (this.timerID != -1) { + clearInterval(this.timerID); + } + } + + build() { + Column({ space: 10}) { + Stack() { + Text() + .width(300).height(300).backgroundColor(Color.Black) + + Particle({ + particles: [ + { + emitter: { + particle: { + type: ParticleType.POINT, // 粒子类型 + config: { + radius: this.radius // 圆点半径 + }, + count: this.count, // 粒子总数 + lifetime: -1 // 粒子的生命周期,-1表示粒子生命周期无限大 + }, + emitRate: this.emitRate, // 每秒发射粒子数 + shape: this.shape, //发射器形状 + annulusRegion: this.region + }, + color: { + range: [Color.White, Color.Pink], // 初始颜色范围 + }, + }, + ] + }).width('100%') + .height('100%') + .emitter(this.emitterProperties) + .onClick(()=>{ + // 清除已有定时器 + if (this.timerID != -1) { + clearInterval(this.timerID); + } + + // 创建定时器(每秒更新) + this.timerID = setInterval(() => { + this.emitterProperties = [ + { + index: 0, + emitRate: this.emitRate, + annulusRegion: { + center:{x:this.centerX, y: this.centerY}, + outerRadius: this.outRadius, + innerRadius: this.inRadius, + startAngle: this.startAngle, + endAngle: this.endAngle + } + } + ]; + if (this.endAngle >= 270) { + if (this.timerID != -1) { + clearInterval(this.timerID); + } + return; + } + // 更新角度值(5度/秒) + this.startAngle += 30; + this.endAngle += 30; + }, 1000); + + }) + } + .width('100%') + .height('100%') + .align(Alignment.Center) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec7946947d9710cb03e48463203c133899e82866 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template1/Index.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { display } from '@kit.ArkUI'; + +@Entry +@Component +struct rotation { + + build() { + Stack() { + Image($r('app.media.tree')) + .position({ x: 0, y: 0 }) + .size({ width: 100, height: 100 }) + .id('image1') + } + .backgroundColor(Color.White) + .size({ width: '100%', height: '100%' }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template2/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..29f6df2372d6e936055ff5a0d10091c2c4fb4d9e --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/rotation/template2/Index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { display } from '@kit.ArkUI'; + +@Entry +@Component +struct rotation { + + // 获取通过监听窗口的windowsSizeChange事件得到的屏幕显示方向 + @StorageLink('orientation') myOrientation: display.Orientation = display.Orientation.PORTRAIT; + + build() { + Stack() { + + // 当屏幕显示方向变化时,切换组件的视图效果 + if (this.myOrientation == display.Orientation.PORTRAIT || this.myOrientation == display.Orientation.PORTRAIT_INVERTED) { + Image($r('app.media.sky')) + .size({ width: 100, height: 100 }) + .id('image1') + + // 开发者也可以通过自行设置transition的TransitionEffect.OPACITY转场效果来实现旋转屏动画的透明度变化 + // .transition(TransitionEffect.OPACITY) + } else { + Image($r('app.media.tree')) + .position({ x: 0, y: 0 }) + .size({ width: 200, height: 200 }) + .id('image2') + + // 开发者也可以通过自行设置transition的TransitionEffect.OPACITY来实现旋转屏动画的透明度变化 + // .transition(TransitionEffect.OPACITY) + } + } + .backgroundColor(Color.White) + .size({ width: '100%', height: '100%' }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/Index.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..520b62a1a3b93bab55d1c0cf8c1346253909ea71 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/Index.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SharedTransitionExample { + + build() { + Column() { + Image($r('app.media.ic_health_heart')).width(50).height(50).margin({ left: 20, top: 20 }) + .sharedTransition('sharedImage', { duration: 800, curve: Curve.Linear, delay: 100 }) + }.width('100%').height('100%').alignItems(HorizontalAlign.Start) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/shareTransition/template1/PageB' }) + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/PageB.ets b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/PageB.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fa35ab5e86e2a2dfeeaf34f60aafa9aa1ccad58 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/ets/pages/shareTransition/template1/PageB.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct pageBExample { + build() { + Stack() { + Image($r('app.media.ic_health_heart')).width(150).height(150) + .sharedTransition('sharedImage', { duration: 800, curve: Curve.Linear, delay: 100 }) + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/Animation/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..196e6b3978857f196aa334edffc3c5b431c6bc83 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "orientation": "auto_rotation", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json rename to code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/color.json diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/float.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/float.json @@ -0,0 +1,17 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, { + "name": "size_16", + "value": "16" + }, { + "name": "size_100", + "value": "100" + }, { + "name": "size_64", + "value": "64" + } + ] +} diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e5f0207d763e6602f3417ccda3fb5cdfed04d0bc --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/element/string.json @@ -0,0 +1,232 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Animation" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "page1", + "value": "页面1" + }, + { + "name": "page2", + "value": "页面2" + }, + { + "name": "create", + "value": "创建" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "complete", + "value": "完成" + }, + { + "name": "playing", + "value": "播放中" + }, + { + "name": "animatorStatus", + "value": "当前动画状态为:" + }, + { + "name": "play", + "value": "播放" + }, + { + "name": "reset", + "value": "重置" + }, + { + "name": "pause", + "value": "暂停" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, + { + "name": "temp1", + "value": "示例1" + }, + { + "name": "animate_to_label", + "value": "显示动画(animateTo)" + }, + { + "name": "animate_to_temp_label1", + "value": "示例1(在组件出现时创建动画)" + }, + { + "name": "animate_to_temp_label2", + "value": "示例2(动画执行结束后组件消失)" + }, + { + "name": "animate_to_temp_label3", + "value": "示例3(在状态管理V2中使用animateTo)" + }, + { + "name": "animation_label", + "value": "属性动画(animation)" + }, + { + "name": "animation_temp_label2", + "value": "示例2(使用animateTo产生属性动画)" + }, + { + "name": "animation_temp_label3", + "value": "示例3(使用animation产生属性动画)" + }, + { + "name": "animation_temp_label4", + "value": "示例4(使用keyframeAnimateTo产生属性动画)" + }, + { + "name": "cohesion_label", + "value": "动画衔接" + }, + { + "name": "cohesion_temp_label1", + "value": "示例1(动画衔接)" + }, + { + "name": "cohesion_temp_label2", + "value": "示例2(手势与动画的衔接)" + }, + { + "name": "keyframeAnimateTo_label", + "value": "关键帧动画" + }, + { + "name": "pageTransition_label", + "value": "页面间转场" + }, + { + "name": "pageTransition_temp_label1", + "value": "示例1(设置退入场动画)" + }, + { + "name": "pageTransition_temp_label2", + "value": "示例2(设置退入场平移效果)" + }, + { + "name": "pageTransition_temp_label3", + "value": "示例3(不推荐)(利用pushUrl跳转能力)" + }, + { + "name": "pageTransition_temp_label4", + "value": "示例4(不推荐)(type为None的页面转场)" + }, + { + "name": "compTransition_label", + "value": "组件内转场" + }, + { + "name": "compTransition_temp_label1", + "value": "示例1(使用同一接口实现图片出现消失)" + }, + { + "name": "compTransition_temp_label2", + "value": "示例2(使用不同接口实现图片出现消失)" + }, + { + "name": "compTransition_temp_label3", + "value": "示例3(设置父子组件为transition)" + }, + { + "name": "compTransition_temp_label4", + "value": "示例4(出现/消失转场)" + }, + { + "name": "compTransition_temp_label5", + "value": "示例5(多个组件渐次出现消失)" + }, + { + "name": "shareTransition_label", + "value": "共享元素转场" + }, + { + "name": "motionPath_label", + "value": "路径动画" + }, + { + "name": "particle_label", + "value": "粒子动画" + }, + { + "name": "particle_temp_label1", + "value": "示例1(圆形初始化粒子)" + }, + { + "name": "particle_temp_label2", + "value": "示例2(图片初始化粒子)" + }, + { + "name": "particle_temp_label3", + "value": "示例3(粒子扰动场的干扰下运动轨迹发生变化)" + }, + { + "name": "particle_temp_label4", + "value": "示例4(调整粒子发射器位置)" + }, + { + "name": "particle_temp_label5", + "value": "示例5(环形发射器创建)" + }, + { + "name": "particle_temp_label6", + "value": "示例6(环形发射器更新)" + }, + { + "name": "animator_label", + "value": "帧动画" + }, + { + "name": "animator_temp_label1", + "value": "示例1(基于ArkTS扩展的声明式开发范式)" + }, + { + "name": "animator_temp_label2", + "value": "示例2(位移动画示例)" + }, + { + "name": "animator_temp_label3", + "value": "示例3(使用帧动画实现小球抛物运动)" + }, + { + "name": "animateToImmediately_label", + "value": "显式动画立即下发" + }, + { + "name": "rotation_label", + "value": "旋转屏动画" + }, + { + "name": "rotation_temp_label1", + "value": "示例1(布局切换的旋转屏动画)" + }, + { + "name": "rotation_temp_label2", + "value": "示例2(透明度变化的旋转屏动画)" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/bg.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/bg.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/book.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/book.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/drawer.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/drawer.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/forest.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/forest.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/heart.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/heart.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_health_heart.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlights.svg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlights.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collect + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/ic_public_highlightsed.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collected + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon_2.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/icon_2.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image_1.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/image_1.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/img_1.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/mountain.jpg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/r.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/r.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sky.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sky.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sun.jpg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/sun.jpg differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/test.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/test.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImage.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImg.jpg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image1.jpg b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image2.png b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/tree.JPG b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/media/tree.JPG differ diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec03f97d5d6d11b3ca3d50ab362fceebce1e460 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,43 @@ +{ + "src": [ + "pages/Index", + "pages/animateTo/template1/Index", + "pages/animateTo/template2/Index", + "pages/animateTo/template3/Index", + "pages/animation/template1/Index", + "pages/animation/template2/Index", + "pages/animation/template3/Index", + "pages/animation/template4/Index", + "pages/animator/template1/Index", + "pages/animator/template2/Index", + "pages/animator/template3/Index", + "pages/particle/template1/Index", + "pages/particle/template2/Index", + "pages/particle/template3/Index", + "pages/particle/template4/Index", + "pages/particle/template5/Index", + "pages/particle/template6/Index", + "pages/keyframeAnimateTo/template1/Index", + "pages/pageTransition/template1/Index", + "pages/pageTransition/template1/Page1", + "pages/pageTransition/template2/Index", + "pages/pageTransition/template2/Page1", + "pages/pageTransition/template3/pageTransitionDst1", + "pages/pageTransition/template3/pageTransitionSrc1", + "pages/pageTransition/template4/pageTransitionDst2", + "pages/pageTransition/template4/pageTransitionSrc2", + "pages/compTransition/template1/Index", + "pages/compTransition/template2/Index", + "pages/compTransition/template3/Index", + "pages/compTransition/template4/Index", + "pages/compTransition/template5/Index", + "pages/shareTransition/template1/Index", + "pages/shareTransition/template1/PageB", + "pages/motionPath/template1/Index", + "pages/animateToImmediately/template1/Index", + "pages/rotation/template1/Index", + "pages/rotation/template2/Index", + "pages/cohesion/template1/Index", + "pages/cohesion/template2/Index" + ] +} diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkUISample/Animation/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..aed4de76e80ab8b0faebfb534695eec8911ad966 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + /* + * @tc.number: Animation_assertContain + * @tc.name: Test ability + * @tc.desc: Test ability + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + hilog.info(0x0000, 'testTag', '%{public}s', 'it end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateTo.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateTo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..77b70639c521d91c92f3d33abd8469d0755dfc45 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateTo.test.ets @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function AnimateToTest() { + describe('Animation_AnimateToTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.animate_to_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_AnimateToTest_001 + * @tc.name: Set animate + * @tc.desc: Set animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimateToTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.animate_to_temp_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change size')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_001_end'); + }) + + /* + * @tc.number: Animation_AnimateToTest_002 + * @tc.name: component disappear in animate + * @tc.desc: component disappear in animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimateToTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.animate_to_temp_label2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + let columns = await driver.findComponents(ON.type('Column')) + await columns[1].click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_002_end'); + }) + + /* + * @tc.number: Animation_AnimateToTest_003 + * @tc.name: Set animate in componentV2 + * @tc.desc: Set animate in componentV2 + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimateToTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.animate_to_temp_label3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change size')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimateToTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateToImmediately.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateToImmediately.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c96cf0018a67be47b7659442c3cd2844ddd7551d --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/AnimateToImmediately.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function AnimateToImmediatelyTest() { + describe('Animation_AnimateToImmediatelyTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animateToImmediately_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_AnimateToImmediatelyTest_001 + * @tc.name: Set animate Immediately + * @tc.desc: Set animate Immediately + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimateToImmediatelyTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimateToImmediatelyTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.temp1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change size')); + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimateToImmediatelyTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animation.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animation.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2af2bf3a5b62377950038e0009781f2d683ef816 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animation.test.ets @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function AnimationTest() { + describe('Animation_AnimationTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animation_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_AnimationTest_001 + * @tc.name: Set attribute animate use animation + * @tc.desc: Set attribute animate use animation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimationTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.temp1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change size')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change rotate angle')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_001_end'); + }) + + /* + * @tc.number: Animation_AnimationTest_002 + * @tc.name: Set attribute animate use animationTo + * @tc.desc: Set attribute animate use animationTo + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimationTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animation_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Column')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_002_end'); + }) + + /* + * @tc.number: Animation_AnimationTest_003 + * @tc.name: Set attribute animate use animation + * @tc.desc: Set attribute animate use animation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimationTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animation_temp_label3")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Column')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_003_end'); + }) + + /* + * @tc.number: Animation_AnimationTest_004 + * @tc.name: Set attribute animate use keyframeAnimateTo + * @tc.desc: Set attribute animate use keyframeAnimateTo + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimationTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animation_temp_label4")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Column')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_AnimationTest_004_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animator.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animator.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7192e0ba46fb723f088b8a85b3fff0db0c979c9f --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Animator.test.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function AnimatorTest() { + describe('Animation_AnimatorTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animator_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_AnimatorTest_001 + * @tc.name: Set frame animate in arkTs + * @tc.desc: Set frame animate in arkTs + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimatorTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animator_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('create')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('play')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pause')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('finish')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('reverse')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('play')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('cancel')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('reset')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('play')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_001_end'); + }) + + /* + * @tc.number: Animation_AnimatorTest_002 + * @tc.name: Set frame animate + * @tc.desc: Set frame animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimatorTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animator_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('create')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('play')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('reset')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('play')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_002_end'); + }) + + /* + * @tc.number: Animation_AnimatorTest_003 + * @tc.name: Show ball moving with frame animate + * @tc.desc: Show ball moving with frame animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'AnimatorTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.animator_temp_label3")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.play')))); + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.reset')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.play')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.pause')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Animation_AnimatorTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Cohesion.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Cohesion.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..92f43ce2dd1aa18b0b5c8ac1af2a5008bcc3a630 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Cohesion.test.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function CohesionTest() { + describe('Animation_CohesionTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.cohesion_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_CohesionTest_001 + * @tc.name: Set Cohesion animate + * @tc.desc: Set Cohesion animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'CohesionTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_CohesionTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.cohesion_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Click')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Animation_CohesionTest_001_end'); + }) + + /* + * @tc.number: Animation_CohesionTest_002 + * @tc.name: Set Cohesion animate with gesture + * @tc.desc: Set Cohesion animate with gesture + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'CohesionTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_CohesionTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.cohesion_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let x = Math.floor(size.x * 0.284) + + await driver.swipe(x, Math.floor(size.y * 0.2013), x, Math.floor(size.y * 0.5544)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Animation_CohesionTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ComponentTransition.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ComponentTransition.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..366862440cc398fcc11a478018bfa0ea5a42e835 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ComponentTransition.test.ets @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function ComponentTransitionTest() { + describe('Animation_ComponentTransitionTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_ComponentTransitionTest_001 + * @tc.name: Set image animate with one api + * @tc.desc: Set image animate with one api + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ComponentTransitionTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('show')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('hide')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_001_end'); + }) + + /* + * @tc.number: Animation_ComponentTransitionTest_002 + * @tc.name: Set image animate with different api + * @tc.desc: Set image animate with different api + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ComponentTransitionTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('show')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('hide')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_002_end'); + }) + + /* + * @tc.number: Animation_ComponentTransitionTest_003 + * @tc.name: Set Parent component transition + * @tc.desc: Set Parent component transition + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ComponentTransitionTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_temp_label3")))); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('show')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('hide')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_003_end'); + }) + + /* + * @tc.number: Animation_ComponentTransitionTest_004 + * @tc.name: Transition in show and disappear + * @tc.desc: Transition in show and disappear + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ComponentTransitionTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_temp_label4")))); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('Click')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('Click')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_004_end'); + }) + + /* + * @tc.number: Animation_ComponentTransitionTest_005 + * @tc.name: Show components and disappear + * @tc.desc: Show components and disappear + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ComponentTransitionTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.compTransition_temp_label5")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.type('root')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ComponentTransitionTest_005_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/KeyFrameAnimateTo.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/KeyFrameAnimateTo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..21c1ff6bf3195aaa8a4bbb1d1c9532a2a1529e4c --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/KeyFrameAnimateTo.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function KeyFrameAnimateToTest() { + describe('Animation_KeyFrameAnimateToTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.keyframeAnimateTo_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_KeyFrameAnimateToTest_001 + * @tc.name: Set keyFrameAnimate + * @tc.desc: Set keyFrameAnimate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'KeyFrameAnimateToTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_KeyFrameAnimateToTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.temp1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Circle')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_KeyFrameAnimateToTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..07ec779dd0efc1492add195b6cb32db00c3b6821 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AnimateToTest } from './AnimateTo.test'; +import { AnimationTest } from './Animation.test'; +import { CohesionTest } from './Cohesion.test'; +import { KeyFrameAnimateToTest } from './KeyFrameAnimateTo.test'; +import { PageTransitionTest } from './PageTransition.test'; +import { ComponentTransitionTest } from './ComponentTransition.test'; +import { ShareTransitionTest } from './ShareTransition.test'; +import { MotionPathTest } from './MotionPath.test'; +import { ParticleTest } from './Particle.test'; +import { AnimatorTest } from './Animator.test'; +import { AnimateToImmediatelyTest } from './AnimateToImmediately.test'; +import { RotationTest } from './Rotation.test'; + +export default function testsuite() { + AnimateToTest(); + AnimationTest(); + CohesionTest(); + KeyFrameAnimateToTest(); + PageTransitionTest(); + ComponentTransitionTest(); + ShareTransitionTest(); + MotionPathTest(); + ParticleTest(); + AnimatorTest(); + AnimateToImmediatelyTest(); + RotationTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/MotionPath.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/MotionPath.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..60eede8e336a3854be774d46ac5592f0173cc637 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/MotionPath.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function MotionPathTest() { + describe('Animation_MotionPathTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.motionPath_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_MotionPathTest_001 + * @tc.name: Set motionPath + * @tc.desc: Set motionPath + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'MotionPathTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_MotionPathTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.temp1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('click me')); + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_MotionPathTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/PageTransition.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/PageTransition.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3fff5d9cb140f2dbcdc7a7ed8da7e141537e867 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/PageTransition.test.ets @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function PageTransitionTest() { + describe('Animation_PageTransitionTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.pageTransition_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_PageTransitionTest_001 + * @tc.name: Set pageTransition + * @tc.desc: Set pageTransition + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'PageTransitionTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.pageTransition_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_001_end'); + }) + + /* + * @tc.number: Animation_PageTransitionTest_002 + * @tc.name: Set move effect + * @tc.desc: Set move effect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'PageTransitionTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.pageTransition_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.page1')))); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r('app.string.page2')))); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_002_end'); + }) + + /* + * @tc.number: Animation_PageTransitionTest_003 + * @tc.name: Set pageTransition with pushUrl + * @tc.desc: Set pageTransition with pushUrl + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'PageTransitionTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.pageTransition_temp_label3")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushUrl')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('back')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_003_end'); + }) + + /* + * @tc.number: Animation_PageTransitionTest_004 + * @tc.name: Set none type pageTransition + * @tc.desc: Set none type pageTransition + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'PageTransitionTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.pageTransition_temp_label4")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushUrl')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('back')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_PageTransitionTest_004_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Particle.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Particle.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0234306984dcf8672dbeaaef77dd267f9a3af85f --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Particle.test.ets @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function ParticleTest() { + describe('Animation_ParticleTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_ParticleTest_001 + * @tc.name: Set circle particle + * @tc.desc: Set circle particle + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 20; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_001_end'); + }) + + /* + * @tc.number: Animation_ParticleTest_002 + * @tc.name: Set image particle + * @tc.desc: Set image particle + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 20; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_002_end'); + }) + + /* + * @tc.number: Animation_ParticleTest_003 + * @tc.name: Set particle animate + * @tc.desc: Set particle animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label3")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 20; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_003_end'); + }) + + /* + * @tc.number: Animation_ParticleTest_004 + * @tc.name: Set particle position + * @tc.desc: Set particle position + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label4")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_004_end'); + }) + + /* + * @tc.number: Animation_ParticleTest_005 + * @tc.name: Create circle launcher + * @tc.desc: Create circle launcher + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label5")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_005_end'); + }) + + /* + * @tc.number: Animation_ParticleTest_006 + * @tc.name: Update circle launcher + * @tc.desc: Update circle launcher + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ParticleTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.particle_temp_label6")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'Animation_ParticleTest_006_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Rotation.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Rotation.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0dfda62ca99569dc819c8652eef5580b9b5b2f5 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/Rotation.test.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, DisplayRotation, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function RotationTest() { + describe('Animation_RotationTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.rotation_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_RotationTest_001 + * @tc.name: Set rotate animate + * @tc.desc: Set rotate animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'RotationTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_RotationTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.rotation_temp_label1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + await driver.delayMs(1000); + await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Animation_RotationTest_001_end'); + }) + + /* + * @tc.number: Animation_RotationTest_002 + * @tc.name: Set rotate animate with opacity + * @tc.desc: Set rotate animate with opacity + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'RotationTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_RotationTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.rotation_temp_label2")))); + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + await driver.delayMs(1000); + await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Animation_RotationTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ShareTransition.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ShareTransition.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee41e1c9de7eb37557a0f418eb5c3f07fdb5b251 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/ets/test/ShareTransition.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import resource from '../../../main/ets/common/resource'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Animation_' +const TAG = '[Sample_Animation]'; +const DOMAIN = 0xF811 + +let aimComponent : Component + +export function ShareTransitionTest() { + describe('Animation_ShareTransitionTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.animation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.shareTransition_label")))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('AnimateIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Animation_ShareTransitionTest_001 + * @tc.name: Set share transition animate + * @tc.desc: Set share transition animate + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ShareTransitionTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Animation_ShareTransitionTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resource.resourceToString($r("app.string.temp1")))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('root')); + await aimComponent.click(); + await driver.delayMs(3000); + hilog.info(DOMAIN, TAG, 'Animation_ShareTransitionTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cafc28b86d7d9f2b34f24d26a75c0dbd7299715 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/test/List.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkUISample/Animation/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Animation/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/Animation/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a3a86df0cd5b8fbf375409dc5825e13202ab2284 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/ArkUISample/Animation/hvigorfile.ts b/code/DocsSample/ArkUISample/Animation/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/Animation/oh-package.json5 b/code/DocsSample/ArkUISample/Animation/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..41b8b63948628728b745e7be8cd53d68d9345b75 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkUISample/Animation/ohosTest.md b/code/DocsSample/ArkUISample/Animation/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..5e4a5cff507f79631563b306640e95c002d7ca79 --- /dev/null +++ b/code/DocsSample/ArkUISample/Animation/ohosTest.md @@ -0,0 +1,18 @@ +# Animation 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 显示动画示例代码验证 | 设备正常运行 | 进入各个示例代码页面,触发不同的动画效果 | 动画效果正常 | 是 | Pass | +| 显式动画立即下发示例代码验证 | 设备正常运行 | 点击各种动画按钮,触发不同的动画效果 | 动画效果正常 | 是 | Pass | +| 属性动画(animation)示例代码测试代码 | 设备正常运行 | 点击页面,触发属性动画效果 | 动画效果正常 | 是 | Pass | +| 帧动画示例代码验证 | 设备正常运行 | 点击目标组件,触发动画效果 | 动画效果正常 | 是 | Pass | +| 动画衔接示例代码验证 | 设备正常运行 | 点击Click按钮 | 控件缩放的动画效果正常 | 是 | Pass | +| 组件内转场示例代码验证 | 设备正常运行 | 点击show按钮 | 动画效果正常 | 是 | Pass | +| 关键帧动画示例代码测试代码 | 设备正常运行 | 点击目标组件,触发动画效果 | 动画效果正常 | 是 | Pass | +| 路径动画示例代码测试代码 | 设备正常运行 | 点击目标组件,触发路径动画效果 | 动画效果正常 | 是 | Pass | +| 页面间转场示例代码测试代码 | 设备正常运行 | 点击目标组件,触发页面转场动画效果 | 动画效果正常 | 是 | Pass | +| 粒子动画示例代码验证 | 设备正常运行 | 点击各种动画按钮,触发不同的动画效果 | 动画效果正常 | 是 | Pass | +| 旋转屏动画示例代码验证 | 设备正常运行 | 旋转屏幕 | 目标控件的动画效果正常 | 否 | Pass | +| 共享元素转场示例代码验证 | 设备正常运行 | 点击页面触发动画 | 动画效果正常 | 是 | Pass | diff --git a/code/DocsSample/ArkUISample/Animation/screenshots/device/image1.png b/code/DocsSample/ArkUISample/Animation/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..21beca22c8e570fa4534a29e9b60402c53adf0b6 Binary files /dev/null and b/code/DocsSample/ArkUISample/Animation/screenshots/device/image1.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/.gitignore b/code/DocsSample/ArkUISample/BindSheet/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/AppScope/app.json5 b/code/DocsSample/ArkUISample/BindSheet/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..867532eb9a552b283ee74bd5fc009dec4733a4fa --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.bindsheet", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..53a288c841496a30f98c0bf0d583722c7d91fa09 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "BindSheet" + } + ] +} diff --git a/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/background.png b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/README_zh.md b/code/DocsSample/ArkUISample/BindSheet/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..2aea995151dd39ba9440cd8ae64631d892a97810 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/README_zh.md @@ -0,0 +1,114 @@ +# ArkUI使用模态组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [全模态转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-modal-transition.md)。 +2. [半模态转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-sheet-transition.md)。 +3. [命令式打开半模态](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-arkui-UIContext.md#openbindsheet12)。 +4. [模态转场](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-modal-transition.md)。 +5. [绑定全模态页面](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-contentcover-page.md)。 + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---bindContentCover // 全模态转场 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| |---bindSheet // 半模态转场 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| | |---template8 +| | | |---Index.ets +| | |---template9 +| | | |---Index.ets +| | |---template10 +| | | |---Index.ets +| |---bindSheetCmd // 命令式打开半模态 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---BindContentCover.test.ets // 全模态转场示例代码测试代码 +| | |---BindSheet.test.ets // 半模态转场示例代码测试代码 +| | |---OpenSheet.test.ets // 命令式打开半模态示例代码测试代码 + +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.33,镜像版本号:OpenHarmony_6.0.0.33。 + +3.本示例需要使用DevEco Studio 6.0.0 Canary1 (Build Version: 6.0.0.270, built on May 9, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/BindSheet > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/build-profile.json5 b/code/DocsSample/ArkUISample/BindSheet/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e1244ceecbe969910aa0eb4f5ec4543c58ee4225 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/code-linter.json5 b/code/DocsSample/ArkUISample/BindSheet/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/.gitignore b/code/DocsSample/ArkUISample/BindSheet/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/build-profile.json5 b/code/DocsSample/ArkUISample/BindSheet/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/hvigorfile.ts b/code/DocsSample/ArkUISample/BindSheet/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/obfuscation-rules.txt b/code/DocsSample/ArkUISample/BindSheet/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/oh-package.json5 b/code/DocsSample/ArkUISample/BindSheet/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { display, uiObserver, window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +function callBackFunc2(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag2 navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + uiObserver.on('navDestinationSwitch', this.context, callBackFunc); + uiObserver.on('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc2); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + uiObserver.off('navDestinationSwitch', this.context, callBackFunc); + uiObserver.off('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let mainWindow: window.Window; + try { + mainWindow = windowStage.getMainWindowSync(); + let displayClass: display.Display = display.getDefaultDisplaySync(); + AppStorage.setOrCreate('orientation', displayClass.orientation); + // 监听窗口的windowsSizeChange事件,旋转屏时会触发该事件 + mainWindow.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let displayClass: display.Display | null = null; + try { + displayClass = display.getDefaultDisplaySync(); + console.info('display orientation is ' + JSON.stringify(displayClass.orientation)); + // 获取屏幕的显示方向 + AppStorage.set('orientation', displayClass.orientation); + } catch { + return; + } + }) + } catch { + hilog.info(0x0000, 'testTag', '%{public}s', 'error'); + return; + } + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f66347f114c366fe07800c07dfcaee6694ce1482 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import curves from '@ohos.curves'; +import { Route, RouteGroup } from './common/Index'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; +import router from '@ohos.router'; + +@Styles +function cardPressedStyle() { + .backgroundColor('rgba(0,0,0,0.1)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardNormalStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardDisabledStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(0.5) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + + +@Entry +@Component +struct Index { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: "bindContentCover", + label: $r('app.string.bindContentCover_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindContentCover_label1') }, + { name:"template2/Index", label: $r('app.string.bindContentCover_label2') }, + { name:"template3/Index", label: $r('app.string.bindContentCover_label3') }, + { name:"template4/Index", label: $r('app.string.bindContentCover_label4') }, + { name:"template5/Index", label: $r('app.string.bindContentCover_label5') }, + { name:"template6/Index", label: $r('app.string.bindContentCover_label6') }, + { name:"template7/Index", label: $r('app.string.bindContentCover_label7') }, + + ] + }, { + name: "bindSheet", + label: $r('app.string.bindSheet_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindSheet_label1') }, + { name:"template2/Index", label: $r('app.string.bindSheet_label2') }, + { name:"template3/Index", label: $r('app.string.bindSheet_label3') }, + { name:"template4/Index", label: $r('app.string.bindSheet_label4') }, + { name:"template5/Index", label: $r('app.string.bindSheet_label5') }, + { name:"template6/Index", label: $r('app.string.bindSheet_label6') }, + { name:"template7/Index", label: $r('app.string.bindSheet_label7') }, + { name:"template8/Index", label: $r('app.string.bindSheet_label8') }, + { name:"template9/Index", label: $r('app.string.bindSheet_label9') }, + { name:"template10/Index", label: $r('app.string.bindSheet_label10') }, + ] + }, { + name: "bindSheetCmd", + label: $r('app.string.bindSheetCmd_label'), + children: [ + { name:"template1/Index", label: $r('app.string.bindSheetCmd_label1') }, + { name:"template2/Index", label: $r('app.string.bindSheetCmd_label2') }, + { name:"template3/Index", label: $r('app.string.bindSheetCmd_label3') }, + ] + } + ]; + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(route: RouteGroup) { + Row() { + Text(route.label) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Medium) + + Blank() + + Text(`${route.children.length}`) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .opacity(this.selection === route.name ? 0 : 1) + + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + .rotate({ angle: this.selection === route.name ? 90 : 0 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 30) }) + } + .borderRadius(20) + .width('100%') + .padding(8) + .enabled(!!route.children.length) + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .onClick(() => { + animateTo( + { curve: curves.interpolatingSpring(0, 1, 228, 25) }, + () => { + if (this.selection === route.name) { + this.selection = null; + } else { + this.selection = route.name; + } + }); + }) + } + + aboutToAppear(): void{ + this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + } + build() { + Column() { + Text('Index') + List() { + ForEach(this.routes, (routeGroup: RouteGroup) => { + ListItemGroup({ + header: this.ListItemGroupHeader(routeGroup), + style: ListItemGroupStyle.CARD, + }) { + if (routeGroup.name === this.selection) { + ForEach(routeGroup.children, (route: Route) => { + ListItem() { + Row() { + Text(route.label).fontSize(16) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + } + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .borderRadius(20) + .padding(8) + .transition( + TransitionEffect.OPACITY.animation({ + curve: curves.interpolatingSpring(0, 1, 228, 30) + }) + ) + .width('100%') + .onClick(() => { + const name = `pages/${routeGroup.name}/${route.name}`; + router.pushUrl({url: name}) + }) + } + .width('100%') + }) + } + } + .padding(2) + .divider({ strokeWidth: 0.5 }) + }) + }.padding({bottom: 10}) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..925dcbbfd91be7aad5e144c0daa75e6710d25e8b --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template1/Index.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ModalTransitionExample { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button("close modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button("transition modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Orange, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button("close modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor("#ff49c8ab") + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..475d8793a3084697d707d7e05fb3a848b47d8a15 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template2/Index.ets @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct ModalTransitionExample2 { + @State @Watch("isShow1Change") isShow: boolean = false; + @State @Watch("isShow2Change") isShow2: boolean = false; + @State isScale1: number = 1; + @State isScale2: number = 1; + + isShow1Change() { + this.isShow ? this.isScale1 = 0.95 : this.isScale1 = 1; + } + + isShow2Change() { + this.isShow2 ? this.isScale2 = 0.95 : this.isScale2 = 1; + } + + @Builder + myBuilder2() { + Column() { + Button("close modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button("transition modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Orange, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button("close modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + .scale({ x: this.isScale2, y: this.isScale2 }) + .animation({ curve: curves.springMotion() }) + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.NONE, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor("#ff49c8ab") + .width('100%') + .height('100%') + .scale({ x: this.isScale1, y: this.isScale1 }) + .animation({ curve: curves.springMotion() }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64547766fd0cf6a2615252e54f69df9fd6fc8d51 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template3/Index.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ModalTransitionExample3 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button("close modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + } + + @Builder + myBuilder() { + Column() { + Button("transition modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Gray, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button("close modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b8564911dd5840f803520fe09f2c20628a44f95 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template4/Index.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ModalTransitionExample4 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button("close modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + @Builder + myBuilder() { + Column() { + Button("transition modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }).bindContentCover(this.isShow2, this.myBuilder2(), { + modalTransition: ModalTransition.ALPHA, + backgroundColor: Color.Gray, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + + Button("close modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover(this.isShow, this.myBuilder(), { + modalTransition: ModalTransition.ALPHA, + backgroundColor: Color.Pink, + onWillAppear: () => { + console.log('BindContentCover onWillAppear.'); + }, + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onWillDisappear: () => { + console.log('BindContentCover onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1d8beba7a58ececa3f6554469e2158ed98ad254 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template5/Index.ets @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ModalTransitionExample5 { + @State isShow: boolean = false; + @State isShow2: boolean = false; + + @Builder + myBuilder2() { + Column() { + Button('Close Modal 2') + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + @Builder + myBuilder() { + Column() { + Button("Transition Modal 2") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow2 = true; + }) + .bindContentCover( + this.isShow2, + this.myBuilder2(), + { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Gray, + transition: TransitionEffect.SLIDE.animation({ duration: 5000, curve: Curve.LinearOutSlowIn }), + onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => { + if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) { + console.log('BindContentCover dismiss reason is back pressed'); + } + dismissContentCoverAction.dismiss(); + }), + onAppear: () => { + console.info('BindContentCover onAppear.'); + }, + onDisappear: () => { + this.isShow2 = false; + console.info('BindContentCover onDisappear.'); + } + }) + + Button("Close Modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } + + build() { + Column() { + Button("Transition Modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindContentCover( + this.isShow, + this.myBuilder(), + { + modalTransition: ModalTransition.DEFAULT, + backgroundColor: Color.Pink, + transition: TransitionEffect.asymmetric( + TransitionEffect.OPACITY.animation({ duration: 1100 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ delay: 1000, duration: 1000 })) + , + TransitionEffect.OPACITY.animation({ duration: 1200 }).combine( + TransitionEffect.rotate({ z: 1, angle: 180 }).animation({ duration: 1300 })) + ), + onWillDismiss: ((dismissContentCoverAction: DismissContentCoverAction) => { + if (dismissContentCoverAction.reason == DismissReason.PRESS_BACK) { + console.log('back pressed'); + } + dismissContentCoverAction.dismiss(); + }), + onAppear: () => { + console.log('BindContentCover onAppear.'); + }, + onDisappear: () => { + this.isShow = false; + console.log('BindContentCover onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a5ebb287efeb5f5a56ee29f6a0201cad62923db --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template6/Index.ets @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +interface PersonList { + name: string, + cardnum: string +} + +@Entry +@Component +struct BindContentCoverDemo { + private personList: Array = [ + { name: 'wang**', cardnum: '1234***********789' }, + { name: 'song*', cardnum: '2345***********789' }, + { name: 'xu**', cardnum: '3456***********789' }, + { name: 'tang*', cardnum: '4567***********789' } + ]; + // 半模态转场控制变量 + @State isSheetShow: boolean = false; + // 全模态转场控制变量 + @State isPresent: boolean = false; + + @Builder + MyContentCoverBuilder() { + Column() { + Row() { + Text($r('app.string.bindSheetCmd_label1')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 15 }) + } + .backgroundColor(0x007dfe) + + Row() { + Text($r('app.string.bindSheetCmd_label2')) + .fontSize(16) + .fontColor(0x333333) + .margin({ top: 10 }) + .padding({ top: 20, bottom: 20 }) + .width('92%') + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + } + + Column() { + ForEach(this.personList, (item: PersonList, index: number) => { + Row() { + Column() { + if (index % 2 == 0) { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + .backgroundColor(0x007dfe) + } else { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + } + } + .width('20%') + + Column() { + Text(item.name) + .fontColor(0x333333) + .fontSize(18) + Text(item.cardnum) + .fontColor(0x666666) + .fontSize(14) + } + .width('60%') + .alignItems(HorizontalAlign.Start) + + Column() { + Text($r('app.string.bindSheetCmd_label3')) + .fontColor(0x007dfe) + .fontSize(16) + } + .width('20%') + } + .padding({ top: 10, bottom: 10 }) + .border({ width: { bottom: 1 }, color: 0xf1f1f1 }) + .width('92%') + .backgroundColor(Color.White) + }) + } + .padding({ top: 20, bottom: 20 }) + + Text($r('app.string.bindSheetCmd_label4')) + .width('90%') + .height(40) + .textAlign(TextAlign.Center) + .borderRadius(10) + .fontColor(Color.White) + .backgroundColor(0x007dfe) + .onClick(() => { + this.isPresent = !this.isPresent; + }) + } + .size({ width: '100%', height: '100%' }) + .backgroundColor(0xf5f5f5) + } + + @Builder + TripInfo() { + Row() { + Column() { + Text('00:25') + Text($r('app.string.bindSheetCmd_label5')) + } + .width('25%') + + Column() { + Text('G1234') + Text($r('app.string.bindSheetCmd_label6')) + } + .width('25%') + + Column() { + Text('08:26') + Text($r('app.string.bindSheetCmd_label7')) + } + .width('25%') + } + } + + // 第二步:定义半模态展示界面 + // 通过@Builder构建模态展示界面 + @Builder + MySheetBuilder() { + Column() { + Column() { + this.TripInfo() + } + .width('92%') + .margin(15) + .backgroundColor(Color.White) + .shadow({ radius: 30, color: '#aaaaaa' }) + .borderRadius(10) + + Column() { + Text($r('app.string.MySheetBuilder_text1')) + .fontSize(18) + .fontColor(Color.Orange) + .fontWeight(FontWeight.Bold) + .padding({ top: 10, bottom: 10 }) + .width('60%') + .textAlign(TextAlign.Center) + .borderRadius(15) + .onClick(() => { + // 第三步:通过全模态接口调起全模态展示界面,新拉起的模态面板默认显示在最上层 + this.isPresent = !this.isPresent; + }) + // 通过全模态接口,绑定模态展示界面MyContentCoverBuilder。transition属性支持自定义转场效果,此处定义了x轴横向入场 + .bindContentCover($$this.isPresent, this.MyContentCoverBuilder(), { + transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) }) + }) + } + .padding({ top: 60 }) + } + } + + build() { + Column() { + Row() { + this.TripInfo() + Text($r('app.string.MySheetBuilder_text2')) + .fontColor(Color.Blue) + .width('25%') + } + .width('100%') + .margin({top: 200, bottom: 30}) + .borderRadius(10) + .backgroundColor(Color.White) + .onClick(()=>{ + this.isSheetShow = !this.isSheetShow; + }) + // 第一步:定义半模态转场效果 + .bindSheet($$this.isSheetShow, this.MySheetBuilder(), { + height: SheetSize.MEDIUM, + title: {title: $r('app.string.MySheetBuilder_text3')}, + }) + } + .width('100%') + .height('100%') + .backgroundColor('#30aaaaaa') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..487b87b042a4fd6e49975459ac1e59f537eaaaea --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindContentCover/template7/Index.ets @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +interface PersonList { + name: string, + cardnum: string +} + +@Entry +@Component +struct BindContentCoverDemo { + private personList: Array = [ + { name: 'wang**', cardnum: '1234***********789' }, + { name: 'song*', cardnum: '2345***********789' }, + { name: 'xu**', cardnum: '3456***********789' }, + { name: 'tang*', cardnum: '4567***********789' } + ]; + // 第一步:定义全屏模态转场效果bindContentCover + // 模态转场控制变量 + @State isPresent: boolean = false; + + // 第二步:定义模态展示界面 + // 通过@Builder构建模态展示界面 + @Builder + MyBuilder() { + Column() { + Row() { + Text($r('app.string.MyContentCoverBuilder_text1')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 15 }) + } + .backgroundColor(0x007dfe) + + Row() { + Text($r('app.string.MyContentCoverBuilder_text2')) + .fontSize(16) + .fontColor(0x333333) + .margin({ top: 10 }) + .padding({ top: 20, bottom: 20 }) + .width('92%') + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(Color.White) + } + + Column() { + ForEach(this.personList, (item: PersonList, index: number) => { + Row() { + Column() { + if (index % 2 == 0) { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + .backgroundColor(0x007dfe) + } else { + Column() + .width(20) + .height(20) + .border({ width: 1, color: 0x007dfe }) + } + } + .width('20%') + + Column() { + Text(item.name) + .fontColor(0x333333) + .fontSize(18) + Text(item.cardnum) + .fontColor(0x666666) + .fontSize(14) + } + .width('60%') + .alignItems(HorizontalAlign.Start) + + Column() { + Text($r('app.string.MyContentCoverBuilder_text3')) + .fontColor(0x007dfe) + .fontSize(16) + } + .width('20%') + } + .padding({ top: 10, bottom: 10 }) + .border({ width: { bottom: 1 }, color: 0xf1f1f1 }) + .width('92%') + .backgroundColor(Color.White) + }) + } + .padding({ top: 20, bottom: 20 }) + + Text($r('app.string.MyContentCoverBuilder_text4')) + .width('90%') + .height(40) + .textAlign(TextAlign.Center) + .borderRadius(10) + .fontColor(Color.White) + .backgroundColor(0x007dfe) + .onClick(() => { + this.isPresent = !this.isPresent; + }) + } + .size({ width: '100%', height: '100%' }) + .backgroundColor(0xf5f5f5) + // 通过转场动画实现出现消失转场动画效果 + .transition(TransitionEffect.translate({ y: 1000 }).animation({ curve: curves.springMotion(0.6, 0.8) })) + } + + build() { + Column() { + Row() { + Text($r('app.string.MySheetBuilder_text')) + .fontSize(20) + .fontColor(Color.White) + .width('100%') + .textAlign(TextAlign.Center) + .padding({ top: 30, bottom: 60 }) + } + .backgroundColor(0x007dfe) + + Column() { + Row() { + Column() { + Text('00:25') + Text($r('app.string.MyContentCoverBuilder_text5')) + } + .width('30%') + + Column() { + Text('G1234') + Text($r('app.string.MyContentCoverBuilder_text6')) + } + .width('30%') + + Column() { + Text('08:26') + Text($r('app.string.MyContentCoverBuilder_text7')) + } + .width('30%') + } + } + .width('92%') + .padding(15) + .margin({ top: -30 }) + .backgroundColor(Color.White) + .shadow({ radius: 30, color: '#aaaaaa' }) + .borderRadius(10) + + Column() { + Text($r('app.string.MyContentCoverBuilder_text2')) + .fontSize(18) + .fontColor(Color.Orange) + .fontWeight(FontWeight.Bold) + .padding({ top: 10, bottom: 10 }) + .width('60%') + .textAlign(TextAlign.Center) + .borderRadius(15) + .bindContentCover(this.isPresent, this.MyBuilder(), { + modalTransition: ModalTransition.DEFAULT, + onDisappear: () => { + if (this.isPresent) { + this.isPresent = !this.isPresent; + } + } + }) + .onClick(() => { + // 第三步:通过模态接口调起模态展示界面,通过转场动画或者共享元素动画去实现对应的动画效果 + // 改变状态变量,显示模态界面 + this.isPresent = !this.isPresent; + }) + } + .padding({ top: 60 }) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template1/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..67b71f53a078cd28cd53cef0c81c40ef7b9eb29f --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template1/Index.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SheetTransitionExample1 { + @State isShow: boolean = false; + @State sheetHeight: number = 300; + + @Builder + myBuilder() { + Column() { + Button("change height") + .margin(10) + .fontSize(20) + .onClick(() => { + this.sheetHeight = 500; + }) + + Button("Set Illegal height") + .margin(10) + .fontSize(20) + .onClick(() => { + this.sheetHeight = -1; + }) + + Button("close modal 1") + .margin(10) + .fontSize(20) + .onClick(() => { + this.isShow = false; + }) + } + .width('100%') + .height('100%') + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: this.sheetHeight, + backgroundColor: Color.Green, + onWillAppear: () => { + console.log('BindSheet onWillAppear.'); + }, + onAppear: () => { + console.log('BindSheet onAppear.'); + }, + onWillDisappear: () => { + console.log('BindSheet onWillDisappear.'); + }, + onDisappear: () => { + console.log('BindSheet onDisappear.'); + } + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template10/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template10/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..30a02872d9f2efb7c3318ffeedc8667c3164030f --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template10/Index.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SheetDemo { + @State isShowSheet: boolean = false; + private items: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + @Builder + SheetBuilder() { + Column() { + // 第一步:自定义滚动容器 + List({ space: '10vp' }) { + ForEach(this.items, (item: number) => { + ListItem() { + Text(String(item)).fontSize(16).fontWeight(FontWeight.Bold) + }.width('90%').height('80vp').backgroundColor('#ff53ecd9').borderRadius(10) + }) + } + .alignListItem(ListItemAlign.Center) + .margin({ top: '10vp' }) + .width('100%') + .height('900px') + // 第二步:设置滚动组件的嵌套滚动属性 + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.SELF_FIRST, + }) + + Text($r('app.string.tSheetBuilder_text1')) + .width('100%') + .backgroundColor(Color.Gray) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .align(Alignment.Top) + }.width('100%').height('100%') + } + + build() { + Column() { + Button('Open Sheet').width('90%').height('80vp') + .onClick(() => { + this.isShowSheet = !this.isShowSheet; + }) + .bindSheet($$this.isShowSheet, this.SheetBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 600], + preferType: SheetType.BOTTOM, + title: { title: $r('app.string.tSheetBuilder_text2') }, + }) + }.width('100%').height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template2/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..13f38bf423c231e961dce70267c34ec4fe353d23 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template2/Index.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SheetTransitionExample2 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button("content1") + .margin(10) + .fontSize(20) + + Button("content2") + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: "title", subtitle: "subtitle" }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template3/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d53283df1b550ce2f597706e5b3a09977364a2af --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template3/Index.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetTransitionExample3 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button("content1") + .margin(10) + .fontSize(20) + + Button("content2") + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + backgroundColor: Color.Gray, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: "title", subtitle: "subtitle" }, + borderWidth: { top: LengthMetrics.vp(10), start: LengthMetrics.vp(10), end: LengthMetrics.vp(20) }, + borderColor: { top: Color.Pink, start: Color.Blue, end: Color.Yellow }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template4/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3765b5f1a2825364f1c444c9e6aadfdbefc96ba3 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template4/Index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct bindSheetExample4 { + @State isShow: Boolean = false; + + @Builder + myBuilder() { + Column() { + Button("CONTEXT") + .margin(10) + .fontSize(20) + } + } + + build() { + Column() { + Button("NoRegisterSpringback") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: SheetSize.MEDIUM, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: "title", subtitle: "subtitle" }, + preferType: SheetType.CENTER, + + onWillDismiss: ((DismissSheetAction: DismissSheetAction) => { + if (DismissSheetAction.reason == DismissReason.SLIDE_DOWN) { + DismissSheetAction.dismiss(); //注册dismiss行为 + } + }), + + onWillSpringBackWhenDismiss: ((springBackAction: SpringBackAction) => { + //没有注册springBack,下拉半模态页面无回弹行为 + //springBackAction.springBack(); + }), + }) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template5/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf546bd157c670c231c56b922d5a7a4bf6ae1886 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template5/Index.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct bindSheetExample5 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Column() + .backgroundColor(Color.Blue) + .height(200) + .width('100%') + Column() + .backgroundColor(Color.Green) + .height(200) + .width('100%') + } + } + + build() { + Column() { + Button('BindSheet') + .onClick(() => { + this.isShow = true; + }) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [300, 600, 900], + uiContext: this.getUIContext(), + mode: SheetMode.OVERLAY, + scrollSizeMode: ScrollSizeMode.CONTINUOUS, + backgroundColor: Color.Orange, + title: { title: 'Title', subtitle: 'Subtitle' } + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template6/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..73706191b362382eb6331d85ef3fe7ca0157de42 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template6/Index.ets @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base'; + +@Entry +@Component +struct ListenKeyboardHeightChange { + @State isShow: boolean = false; + @State avoidMode: SheetKeyboardAvoidMode = SheetKeyboardAvoidMode.RESIZE_ONLY; + scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6]; + windowClass: window.Window | undefined = undefined; + + aboutToAppear(): void { + try { + window.getLastWindow(this.getUIContext().getHostContext(), (err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the top window, Cause code: ${err.code}, message: ${err.message}`); + return; + } + this.windowClass = data; + try { + if (this.windowClass !== undefined) { + console.log('success in listen height change'); + this.windowClass.on('keyboardHeightChange', this.callback); + } + } catch (exception) { + console.error(`Failed to enable the listener for keyboard height changes, Cause code: ${exception.code}, message: ${exception.message}`); + } + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }); + } catch (exception) { + console.error(`Failed to obtain the top window, Cause code: ${exception.code}, message: ${exception.message}`); + } + } + + callback = (height: number) => { + console.log('height change: ' + height); + if (height !== 0) { + this.scroller.scrollTo({ + xOffset: 0, yOffset: height + this.scroller.currentOffset().yOffset, + animation: { duration: 1000, curve: Curve.Ease, canOverScroll: false } + }); + } + } + + @Builder + myBuilder() { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item: number) => { + Row() { + Text(item.toString()) + .width('80%') + .height(60) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, (item: number) => item.toString()) + + TextInput().height('100') + + Flex({ alignItems: ItemAlign.End }) { + Row() { + Button("click") + .margin(10) + .fontSize(20) + .width('45%') + + Button("cancel") + .margin(10) + .fontSize(20) + .width('45%') + }.width('100%') + }.height(100) + }.margin({ right: 15, bottom: 50 }) + } + .height('100%') + .scrollBar(BarState.On) + .scrollable(ScrollDirection.Vertical) + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + height: 750, + backgroundColor: Color.Gray, + blurStyle: BlurStyle.Thick, + showClose: true, + title: { title: "title", subtitle: "subtitle" }, + keyboardAvoidMode: SheetKeyboardAvoidMode.RESIZE_ONLY, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template7/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..70c9812a477de1b6704ca0e4fa3f962f88125bb6 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template7/Index.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetTransitionExample7 { + @State isShow: boolean = false; + + @Builder + myBuilder() { + Column() { + Button("content1") + .margin(10) + .fontSize(20) + + Button("content2") + .margin(10) + .fontSize(20) + } + .width('100%') + } + + build() { + Column() { + Button("transition modal 1") + .onClick(() => { + this.isShow = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShow, this.myBuilder(), { + detents: [SheetSize.MEDIUM, SheetSize.LARGE, 200], + title: { title: "title", subtitle: "subtitle" }, + radius: { topStart: LengthMetrics.vp(50), topEnd: LengthMetrics.vp(10) }, + }) + } + .justifyContent(FlexAlign.Start) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template8/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template8/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ec718f1e11b2e500499db051cc37f9678b26d18 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template8/Index.ets @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI'; + +@Entry +@Component +struct SheetSideExample8 { + @State isShowSide: boolean = false; + @State enableOutsideInteractive: boolean = false; + @State borderWidths: LocalizedEdgeWidths | undefined = undefined; + @State borderColors: Resource | undefined = undefined; + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + @Builder + sideBuilder() { + Column() { + ForEach(this.arr, (item: number) => { + Row() { + Text(item.toString()) + .width('90%') + .height(60) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, (item: number) => item.toString()) + TextInput() + .margin({ top: 5 }) + Text($r('app.string.sideBuilder_text1')) + .fontSize(22).fontColor(0xFFFFFF).fontWeight(FontWeight.Bold).textAlign(TextAlign.Center) + .width('100%').height(50).backgroundColor('#2ebd82') + Button("change enableOutsideInteractive = " + this.enableOutsideInteractive) + .margin({ top: 5 }) + .onClick(() => { + this.enableOutsideInteractive = !this.enableOutsideInteractive; + if (this.enableOutsideInteractive) { + this.borderWidths = {start : LengthMetrics.vp(1)}; + this.borderColors = $r('sys.color.comp_divider'); + } else { + this.borderWidths = undefined; + this.borderColors = undefined; + } + }) + } + .width('100%') + .height('auto') + } + + + build() { + Column({space:3}) { + Button($r('app.string.sideBuilder_text2')) + .onClick(() => { + this.isShowSide = true; + }) + .fontSize(20) + .margin(10) + .bindSheet($$this.isShowSide, this.sideBuilder(), { + title: { title: "SideSheet", subtitle: $r('app.string.sideBuilder_text3') }, + backgroundColor: Color.Grey, + onWillAppear: () => { + console.log('SideSheet onWillAppear.'); + }, + onAppear: () => { + console.log('SideSheet onAppear.'); + }, + onWillDisappear: () => { + console.log('SideSheet onWillDisappear.'); + }, + onDisappear: () => { + console.log('SideSheet onDisappear.'); + }, + + preferType: SheetType.SIDE, + blurStyle: BlurStyle.Regular, + maskColor: "#4bffc62d", // 自定义蒙层颜色 + enableOutsideInteractive: this.enableOutsideInteractive, + + borderWidth: this.borderWidths, + borderColor: this.borderColors, + + onHeightDidChange: (height: number)=>{ + console.log('SideSheet eight change:' + height); + }, + onTypeDidChange: (type: SheetType) => { + console.log('SideSheet type change:' + type); + }, + }) + } + .justifyContent(FlexAlign.Center) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template9/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template9/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e3b7b5738e61956bd9f82a2dce374661f9bc4df --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheet/template9/Index.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BindSheetDemo9 { + // 半模态转场显示隐藏控制 + @State isShowSheet: boolean = false; + private menuList: string[] = ['No spicy food', 'Put less chili', 'Add more chili', 'No coriander, please', 'No chives, please', 'No disposable tableware, please', 'Disposable tableware is needed']; + + // 通过@Builder构建半模态展示界面 + @Builder + mySheet() { + Column() { + Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap }) { + ForEach(this.menuList, (item: string) => { + Text(item) + .fontSize(16) + .fontColor(0x333333) + .backgroundColor(0xf1f1f1) + .borderRadius(8) + .margin(10) + .padding(10) + }) + } + .padding({ top: 18 }) + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } + + build() { + Column() { + Text($r('app.string.temp9string_text8')) + .fontSize(28) + .padding({ top: 30, bottom: 30 }) + Column() { + Row() { + Row() + .width(10) + .height(10) + .backgroundColor('#a8a8a8') + .margin({ right: 12 }) + .borderRadius(20) + + Column() { + Text($r('app.string.temp9string_text9')) + .fontSize(16) + .fontWeight(FontWeight.Medium) + } + .alignItems(HorizontalAlign.Start) + + Blank() + + Row() + .width(12) + .height(12) + .margin({ right: 15 }) + .border({ + width: { top: 2, right: 2 }, + color: 0xcccccc + }) + .rotate({ angle: 45 }) + } + .borderRadius(15) + .shadow({ radius: 100, color: '#ededed' }) + .width('90%') + .alignItems(VerticalAlign.Center) + .padding({ left: 15, top: 15, bottom: 15 }) + .backgroundColor(Color.White) + .bindSheet(this.isShowSheet, this.mySheet(), { + height: 300, + dragBar: false, + onDisappear: () => { + this.isShowSheet = !this.isShowSheet; + } + }) + .onClick(() => { + this.isShowSheet = !this.isShowSheet; + }) + } + .width('100%') + } + .width('100%') + .height('100%') + .backgroundColor(0xf1f1f1) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..25e9b19ee43ad3edd1289b1dbd670a10f272c9ed --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template1/Index.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FrameNode, ComponentContent } from "@kit.ArkUI"; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + text: string = ""; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: "Title", subtitle: "subtitle" } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..25e9b19ee43ad3edd1289b1dbd670a10f272c9ed --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template2/Index.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FrameNode, ComponentContent } from "@kit.ArkUI"; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + text: string = ""; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: "Title", subtitle: "subtitle" } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..25e9b19ee43ad3edd1289b1dbd670a10f272c9ed --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/bindSheetCmd/template3/Index.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { FrameNode, ComponentContent } from "@kit.ArkUI"; +import { BusinessError } from '@kit.BasicServicesKit'; + +class Params { + text: string = ""; + + constructor(text: string) { + this.text = text; + } +} + +let contentNode: ComponentContent; +let gUIContext: UIContext; + +@Builder +function buildText(params: Params) { + Column() { + Text(params.text) + Button('Update BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.updateBindSheet(contentNode, { + backgroundColor: Color.Pink, + }, true) + .then(() => { + console.info('updateBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('updateBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + + Button('Close BindSheet') + .fontSize(20) + .onClick(() => { + gUIContext.closeBindSheet(contentNode) + .then(() => { + console.info('closeBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('closeBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } +} + +@Entry +@Component +struct UIContextBindSheet { + @State message: string = 'BindSheet'; + + aboutToAppear() { + gUIContext = this.getUIContext(); + contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(buildText), new Params(this.message)); + } + + build() { + RelativeContainer() { + Column() { + Button('Open BindSheet') + .fontSize(20) + .onClick(() => { + let uiContext = this.getUIContext(); + let uniqueId = this.getUniqueId(); + let frameNode: FrameNode | null = uiContext.getFrameNodeByUniqueId(uniqueId); + let targetId = frameNode?.getFirstChild()?.getUniqueId(); + uiContext.openBindSheet(contentNode, { + height: SheetSize.MEDIUM, + backgroundColor: Color.Green, + title: { title: "Title", subtitle: "subtitle" } + }, targetId) + .then(() => { + console.info('openBindSheet success'); + }) + .catch((err: BusinessError) => { + console.info('openBindSheet error: ' + err.code + ' ' + err.message); + }) + }) + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/common/Index.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..02c5c6b987280c6731d3e40af7c56c416176a3af --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/ets/pages/common/Index.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Route { + name: string; + label: ResourceStr; +} + +export interface RouteGroup extends Route { + children: Route[]; +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..196e6b3978857f196aa334edffc3c5b431c6bc83 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "orientation": "auto_rotation", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json rename to code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/color.json diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/float.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/float.json @@ -0,0 +1,17 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, { + "name": "size_16", + "value": "16" + }, { + "name": "size_100", + "value": "100" + }, { + "name": "size_64", + "value": "64" + } + ] +} diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d9f32b95ddc3f0be155a6d64068c4d5b1d13964e --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/element/string.json @@ -0,0 +1,187 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "BindSheet" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, { + "name": "please_click_button", + "value": "请点击按钮" + }, { + "name": "bindContentCover_label", + "value": "全模态转场" + }, { + "name": "bindContentCover_label1", + "value": "示例1(使用全屏模态转场)" + }, { + "name": "bindContentCover_label2", + "value": "示例2(自定义转场动画)" + }, { + "name": "bindContentCover_label3", + "value": "示例3(上下切换转场)" + }, { + "name": "bindContentCover_label4", + "value": "示例4(透明度渐变转场)" + }, { + "name": "bindContentCover_label5", + "value": "示例5(设置不同效果的自定义转场)" + }, { + "name": "bindContentCover_label6", + "value": "示例6(使用bindContentCover构建全屏模态内容覆盖半模态)" + }, { + "name": "bindContentCover_label7", + "value": "示例7(使用bindContentCover构建全屏模态转场效果)" + }, { + "name": "bindSheet_label", + "value": "半模态转场" + }, { + "name": "bindSheet_label1", + "value": "示例1(不同高度的半模态弹窗)" + }, { + "name": "bindSheet_label2", + "value": "示例2(设置三个不同高度的档位)" + }, { + "name": "bindSheet_label3", + "value": "示例3(使用边框宽度和颜色)" + }, { + "name": "bindSheet_label4", + "value": "示例4(使用关闭回调函数)" + }, { + "name": "bindSheet_label5", + "value": "示例5(设置内容区刷新时机)" + }, { + "name": "bindSheet_label6", + "value": "示例6(设置压缩模态内容)" + }, { + "name": "bindSheet_label7", + "value": "示例7(镜像场景下如何设置圆角属性)" + }, { + "name": "bindSheet_label8", + "value": "示例8(半模态Side侧边样式)" + }, { + "name": "bindSheet_label9", + "value": "示例9(使用bindSheet构建半模态转场效果)" + }, { + "name": "bindSheet_label10", + "value": "示例10(使用嵌套滚动交互)" + }, { + "name": "bindSheetCmd_label", + "value": "命令式打开半模态" + }, { + "name": "bindSheetCmd_label1", + "value": "示例1(openBindSheet)" + }, { + "name": "bindSheetCmd_label2", + "value": "示例2(updateBindSheet)" + }, { + "name": "bindSheetCmd_label3", + "value": "示例3(closeBindSheet)" + }, { + "name": "MyContentCoverBuilder_text1", + "value": "选择乘车人" + }, { + "name": "MyContentCoverBuilder_text2", + "value": "+ 添加乘车人" + }, { + "name": "MyContentCoverBuilder_text3", + "value": "编辑" + }, { + "name": "MyContentCoverBuilder_text4", + "value": "确认" + }, { + "name": "MyContentCoverBuilder_text5", + "value": "始发站" + }, { + "name": "MyContentCoverBuilder_text6", + "value": "8时1分" + }, { + "name": "MyContentCoverBuilder_text7", + "value": "终点站" + }, { + "name": "MySheetBuilder_text1", + "value": "+ 选择乘车人" + }, { + "name": "MySheetBuilder_text2", + "value": "有票" + }, { + "name": "sideBuilder_text1", + "value": "改变半模态交互模式" + }, { + "name": "sideBuilder_text2", + "value": "半模态弹窗-Side" + }, { + "name": "sideBuilder_text3", + "value": "默认宽度" + }, { + "name": "temp9string_text1", + "value": "不要辣" + }, { + "name": "temp9string_text2", + "value": "少放辣" + }, { + "name": "temp9string_text3", + "value": "多放辣" + }, { + "name": "temp9string_text4", + "value": "不要香菜" + }, { + "name": "temp9string_text5", + "value": "不要香葱" + }, { + "name": "temp9string_text6", + "value": "不要一次性餐具" + }, { + "name": "temp9string_text7", + "value": "需要一次性餐具" + }, { + "name": "temp9string_text8", + "value": "口味与餐具" + }, { + "name": "temp9string_text9", + "value": "选择点餐口味和餐具" + }, { + "name": "tSheetBuilder_text1", + "value": "非滚动区域" + }, { + "name": "tSheetBuilder_text2", + "value": "嵌套滚动场景" + }, { + "name": "MySheetBuilder_text", + "value": "确认订单" + }, { + "name": "MySheetBuilder_text3", + "value": "确认订单" + }, { + "name": "bindSheetCmd_label5", + "value": "始发站" + }, { + "name": "bindSheetCmd_label6", + "value": "8时1分" + }, { + "name": "bindSheetCmd_label7", + "value": "终点站" + }, { + "name": "bindSheetCmd_label4", + "value": "确认" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/bg.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/bg.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/book.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/book.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/drawer.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/drawer.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/forest.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/forest.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/heart.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/heart.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlights.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collect + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/ic_public_highlightsed.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collected + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon_2.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/icon_2.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image_1.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/image_1.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/img_1.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/mountain.jpg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/r.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/r.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sky.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sky.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sun.jpg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/sun.jpg differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/test.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/test.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImage.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImg.jpg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image2.png b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/tree.JPG b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/media/tree.JPG differ diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..423fc421780c3319595d4ee9b1e4af44cbdd9f66 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,25 @@ +{ + "src": [ + "pages/Index", + "pages/bindContentCover/template1/Index", + "pages/bindContentCover/template2/Index", + "pages/bindContentCover/template3/Index", + "pages/bindContentCover/template4/Index", + "pages/bindContentCover/template5/Index", + "pages/bindContentCover/template6/Index", + "pages/bindContentCover/template7/Index", + "pages/bindSheet/template1/Index", + "pages/bindSheet/template2/Index", + "pages/bindSheet/template3/Index", + "pages/bindSheet/template4/Index", + "pages/bindSheet/template5/Index", + "pages/bindSheet/template6/Index", + "pages/bindSheet/template7/Index", + "pages/bindSheet/template8/Index", + "pages/bindSheet/template9/Index", + "pages/bindSheet/template10/Index", + "pages/bindSheetCmd/template1/Index", + "pages/bindSheetCmd/template2/Index", + "pages/bindSheetCmd/template3/Index" + ] +} diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkUISample/BindSheet/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f30942b81554a399e89aa253c7089eca4f8d8d1 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..33e94cd44182c6638d18d29080f5afe3fe926620 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindContentCover.test.ets @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; + +let aimComponent : Component + +export function BindContentCoverTest() { + describe('BindSheet_BindContentCoverTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_001 + * @tc.name: example_one_BindContentCover + * @tc.desc: example_one_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_001_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_002 + * @tc.name: example_two_BindContentCover + * @tc.desc: example_two_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label2')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_002_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_003 + * @tc.name: example_three_BindContentCover + * @tc.desc: example_three_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label3')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_003_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_004 + * @tc.name: example_four_BindContentCover + * @tc.desc: example_four_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label4')))); + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('transition modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 2')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_004_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_005 + * @tc.name: example_five_BindContentCover + * @tc.desc: example_five_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label5')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Transition Modal 1')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Transition Modal 2')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Close Modal 2')) + await aimComponent.click(); + await driver.delayMs(5000); + + aimComponent = await driver.findComponent(ON.text('Close Modal 1')) + await aimComponent.click(); + await driver.delayMs(5000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_005_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_006 + * @tc.name: example_six_BindContentCover + * @tc.desc: example_six_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label6')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MySheetBuilder_text2')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MySheetBuilder_text1')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text4')))) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_006_end'); + }) + + /* + * @tc.number: BindSheet_BindContentCoverTest_007 + * @tc.name: example_seven_BindContentCover + * @tc.desc: example_seven_BindContentCover + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindContentCoverTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindContentCover_label7')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text2')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.MyContentCoverBuilder_text4')))) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindContentCoverTest_007_end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..33efd28be2fbb2c6d73977a68048406559c5a34f --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/BindSheet.test.ets @@ -0,0 +1,332 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function BindSheetTest() { + describe('BindSheet_BindSheetTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_BindSheetTest_001 + * @tc.name: example_one_BindSheet + * @tc.desc: example_one_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Set Illegal height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change height')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('close modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_001_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_002 + * @tc.name: example_two_BindSheet + * @tc.desc: example_two_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.565) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.21186) + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(endX, endY, startX, Math.floor(size.y * 0.53)); + await driver.delayMs(1000); + + await driver.swipe(endX, endY, startX, Math.floor(size.y * 0.883)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_002_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_003 + * @tc.name: example_three_BindSheet + * @tc.desc: example_three_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_003_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_004 + * @tc.name: example_four_BindSheet + * @tc.desc: example_four_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label4')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('NoRegisterSpringback')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let x = Math.floor(size.x * 0.5) + await driver.swipe(x, Math.floor(size.y * 0.4125), x, Math.floor(size.y * 0.95)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_004_end'); + }) + + + /* + * @tc.number: BindSheet_BindSheetTest_005 + * @tc.name: example_five_BindSheet + * @tc.desc: example_five_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label5')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let x = Math.floor(size.x * 0.5) + + await driver.swipe(x, Math.floor(size.y * 0.706), x, Math.floor(size.y * 0.353)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_005_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_006 + * @tc.name: example_six_BindSheet + * @tc.desc: example_six_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label6')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('TextInput')) + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.pressBack(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_006_end'); + + }) + + /* + * @tc.number: BindSheet_BindSheetTest_007 + * @tc.name: example_seven_BindSheet + * @tc.desc: example_seven_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label7')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('transition modal 1')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_007_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_008 + * @tc.name: example_eight_BindSheet + * @tc.desc: example_eight_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_008', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_008_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label8')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.sideBuilder_text2')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_008_end'); + }) + + + /* + * @tc.number: BindSheet_BindSheetTest_009 + * @tc.name: example_nine_BindSheet + * @tc.desc: example_nine_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_009', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_009_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label9')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.temp9string_text9')))); + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.pressBack(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_009_end'); + }) + + /* + * @tc.number: BindSheet_BindSheetTest_0010 + * @tc.name: example_ten_BindSheet + * @tc.desc: example_ten_BindSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BindSheetTest_0010', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_010_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheet_label10')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open Sheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.353) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.106) + + await driver.swipe(startX, Math.floor(size.y * 0.6356), endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + + await driver.swipe(startX, Math.floor(size.y * 0.282), endX, Math.floor(size.y * 0.6356)); + await driver.delayMs(1000); + + await driver.swipe(startX, Math.floor(size.y * 0.53), endX, Math.floor(size.y * 0.8828)); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_BindSheetTest_010_end'); + }) + + }) + +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..873936a37bce082d47eeada32a07cb2274e87c39 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BindSheetTest } from './BindSheet.test'; +import { BindContentCoverTest } from './BindContentCover.test'; +import { OpenSheetTest } from './OpenSheet.test'; + +export default function testsuite() { + BindSheetTest(); + BindContentCoverTest(); + OpenSheetTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca58826991bafd98e9d2d98ab6b0d9db992f99a9 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/ets/test/OpenSheet.test.ets @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'BindSheet_' +const TAG = '[Sample_BindSheet_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function OpenSheetTest() { + describe('BindSheet_OpenSheetTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.bindsheet', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_001 + * @tc.name: example_one_OpenSheet + * @tc.desc: example_one_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_001_end'); + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_002 + * @tc.name: example_two_OpenSheet + * @tc.desc: example_two_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Update BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_002_end'); + + }) + + /* + * @tc.number: BindSheet_OpenSheetTest_003 + * @tc.name: example_three_OpenSheet + * @tc.desc: example_three_OpenSheet + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpenSheetTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.bindSheetCmd_label3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Open BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Close BindSheet')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'BindSheet_OpenSheetTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cafc28b86d7d9f2b34f24d26a75c0dbd7299715 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/test/List.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkUISample/BindSheet/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/BindSheet/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/BindSheet/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a3a86df0cd5b8fbf375409dc5825e13202ab2284 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/ArkUISample/BindSheet/hvigorfile.ts b/code/DocsSample/ArkUISample/BindSheet/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/BindSheet/oh-package.json5 b/code/DocsSample/ArkUISample/BindSheet/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..41b8b63948628728b745e7be8cd53d68d9345b75 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkUISample/BindSheet/ohosTest.md b/code/DocsSample/ArkUISample/BindSheet/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..11efe52ebecd2768d1daa51e242a99faa1a14fd3 --- /dev/null +++ b/code/DocsSample/ArkUISample/BindSheet/ohosTest.md @@ -0,0 +1,9 @@ +# BindSheet 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 全模态转场示例代码验证 | 设备正常运行 | 进入各个示例页面,唤起全模态 | 全模态行为正常,布局正确 | 是 | Pass | +| 半模态转场示例代码验证 | 设备正常运行 | 进入各个示例页面,唤起半模态 | 半模态行为正常,布局正确 | 是 | Pass | +| 命令式打开半模态示例代码验证 | 设备正常运行 | 进入各个示例页面,通过命令式打开半模态 | 半模态行为正常,布局正确 | 是 | Pass | diff --git a/code/DocsSample/ArkUISample/BindSheet/screenshots/device/image1.png b/code/DocsSample/ArkUISample/BindSheet/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..5c18b3a39d518f752050fd5193355d5a3884eea4 Binary files /dev/null and b/code/DocsSample/ArkUISample/BindSheet/screenshots/device/image1.png differ diff --git a/code/DocsSample/ArkUISample/ImageComponent/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/ImageComponent/entry/src/main/ets/pages/Index.ets index be1564aa78756c18822f640f3debca82c171dac9..e91dc73ff96d039e8ad1a1de3c94d90cb7a828a0 100644 --- a/code/DocsSample/ArkUISample/ImageComponent/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkUISample/ImageComponent/entry/src/main/ets/pages/Index.ets @@ -78,7 +78,7 @@ struct Index { Column() { Text($r('app.string.ImageShow')) .height('8.00%') - .width("100%") + .width('100%') .textAlign(TextAlign.Center) .fontSize(20) .fontWeight(FontWeight.Bold) @@ -96,7 +96,7 @@ struct Index { .maxLines(1) Text(listitem.description) - .width("100%") + .width('100%') } .margin({ bottom: index >= demandList.length - 1 ? 100 : 0 }) .padding({ diff --git a/code/DocsSample/ArkUISample/Navigation/.gitignore b/code/DocsSample/ArkUISample/Navigation/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/AppScope/app.json5 b/code/DocsSample/ArkUISample/Navigation/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f89fd6f71567e9d32e05e1d5a1dc2d7638db531e --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.navigation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03ada0a8e4aaf97e7e46249cd02c9bc407d865fe --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Navigation" + } + ] +} diff --git a/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/background.png b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/README_zh.md b/code/DocsSample/ArkUISample/Navigation/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..abf2fb7b653fd2166720f0db5b84be28146b11cb --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/README_zh.md @@ -0,0 +1,133 @@ +# ArkUI使用导航组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [Navigation](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-navigation.md)。 +2. [NavDestination](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-navdestination.md)。 +3. [无感监听](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-arkui-observer.md)。 +4. [SideBarContainer](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-container-sidebarcontainer.md) +5. [NavPathStack派生类](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-custom-component-api.md) +6. [Router](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-router.md) +7. [Stepper](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-stepper.md) + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---navDestination // NavDestination +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| |---navigation // Navigation +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| | |---template8 +| | | |---Index.ets +| | |---template9 +| | | |---Index.ets +| | |---template10 +| | | |---Index.ets +| | |---template11 +| | | |---Index.ets +| | |---template12 +| | | |---Index.ets +| | |---template13 +| | | |---Index.ets +| |---navPathStackExtend // NavPathStack派生类 +| | |---template1 +| | | |---Index.ets +| |---observer // 无感监听 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| |---router // Router +| | |---template1 +| | | |---Index.ets +| |---sideBarContainer // SideBarContainer +| | |---template1 +| | | |---Index.ets +| |---stepper // Stepper +| | |---template1 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---NavDestination.test.ets // NavDestination示例代码测试代码 +| | |---Navigation.test.ets // Navigation示例代码测试代码 +| | |---QueryNavDestinationInfo.test.ets // NavPathStack派生类示例代码测试代码 +| | |---Router.test.ets // Router示例代码测试代码 +| | |---SideBarContainer.test.ets // SideBarContainer示例代码测试代码 +| | |---Stepper.test.ets // Stepper示例代码测试代码 +| | |---UiObserver.test.ets // 无感监听示例代码测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API18版本SDK,版本号:5.1.0.56,镜像版本号:OpenHarmony_5.1.0.56。 + +3.本示例需要使用DevEco Studio 6.0.0 Canary1 (Build Version: 6.0.0.270, built on May 9, 2025)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/Navigation > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/build-profile.json5 b/code/DocsSample/ArkUISample/Navigation/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e1244ceecbe969910aa0eb4f5ec4543c58ee4225 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/code-linter.json5 b/code/DocsSample/ArkUISample/Navigation/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/.gitignore b/code/DocsSample/ArkUISample/Navigation/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/build-profile.json5 b/code/DocsSample/ArkUISample/Navigation/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/hvigorfile.ts b/code/DocsSample/ArkUISample/Navigation/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/Navigation/entry/obfuscation-rules.txt b/code/DocsSample/ArkUISample/Navigation/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/oh-package.json5 b/code/DocsSample/ArkUISample/Navigation/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { display, uiObserver, window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +function callBackFunc2(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag2 navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + uiObserver.on('navDestinationSwitch', this.context, callBackFunc); + uiObserver.on('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc2); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + uiObserver.off('navDestinationSwitch', this.context, callBackFunc); + uiObserver.off('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let mainWindow: window.Window; + try { + mainWindow = windowStage.getMainWindowSync(); + let displayClass: display.Display = display.getDefaultDisplaySync(); + AppStorage.setOrCreate('orientation', displayClass.orientation); + // 监听窗口的windowsSizeChange事件,旋转屏时会触发该事件 + mainWindow.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let displayClass: display.Display | null = null; + try { + displayClass = display.getDefaultDisplaySync(); + console.info('display orientation is ' + JSON.stringify(displayClass.orientation)); + // 获取屏幕的显示方向 + AppStorage.set('orientation', displayClass.orientation); + } catch { + return; + } + }) + } catch { + hilog.info(0x0000, 'testTag', '%{public}s', 'error'); + return; + } + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..780b1537c307dfbb5c6b3ccb5dcf930de6542fc7 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import curves from '@ohos.curves'; +import { Route, RouteGroup } from './common/Index'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; +import router from '@ohos.router'; + +@Styles +function cardPressedStyle() { + .backgroundColor('rgba(0,0,0,0.1)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardNormalStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardDisabledStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(0.5) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + + +@Entry +@Component +struct Index { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: 'navigation', + label: 'Navigation', + children: [ + { name: 'template1/Index', label: $r('app.string.stepperIndex_text1') }, + { name: 'template2/Index', label: $r('app.string.stepperIndex_text2') }, + { name: 'template3/Index', label: $r('app.string.stepperIndex_text3') }, + { name: 'template4/Index', label: $r('app.string.stepperIndex_text4') }, + { name: 'template5/Index', label: $r('app.string.stepperIndex_text5') }, + { name: 'template6/Index', label: $r('app.string.stepperIndex_text6') }, + { name: 'template7/Index', label: $r('app.string.stepperIndex_text7') }, + { name: 'template8/Index', label: $r('app.string.stepperIndex_text8') }, + { name: 'template9/Index', label: $r('app.string.stepperIndex_text9') }, + { name: 'template10/Index', label: $r('app.string.stepperIndex_text10') }, + { name: 'template11/Index', label: $r('app.string.stepperIndex_text11') }, + { name: 'template12/Index', label: $r('app.string.stepperIndex_text12') }, + { name: 'template13/Index', label: $r('app.string.stepperIndex_text13') }, + ] + }, + { + name: 'navDestination', + label: 'NavDestination', + children: [ + { name: 'template1/Index', label: $r('app.string.stepperIndex_text14') }, + { name: 'template2/Index', label: $r('app.string.stepperIndex_text15') }, + { name: 'template3/Index', label: $r('app.string.stepperIndex_text16') }, + { name: 'template4/Index', label: $r('app.string.stepperIndex_text17') }, + ] + }, { + name: 'observer', + label: $r('app.string.stepperIndex_text18'), + children: [ + { name: 'template1/Index', label: "uiObserver.on('navDestinationUpdate')" }, + { name: 'template2/Index', label: $r('app.string.stepperIndex_text19') }, + { name: 'template3/Index', label: "uiObserver.on('navDestinationSwitch')" }, + { name: 'template4/Index', label: $r('app.string.stepperIndex_text20') }, + ] + }, { + name: 'sideBarContainer', + label: 'SideBarContainer', + children: [ + { name: 'template1/Index', label: $r('app.string.stepperIndex_text21') }, + ] + }, { + name: "navPathStackExtend", + label: $r('app.string.stepperIndex_text22'), + children: [ + { name: 'template1/Index', label: "queryNavDestinationInfo18+" }, + ] + }, { + name: 'router', + label: 'Router', + children: [ + { name: 'template1/Index', label: $r('app.string.stepperIndex_text23') }, + ] + }, { + name: 'stepper', + label: 'Stepper', + children: [ + { name: 'template1/Index', label: $r('app.string.stepperIndex_text21') }, + ] + } + ]; + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(route: RouteGroup) { + Row() { + Text(route.label) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Medium) + + Blank() + + Text(`${route.children.length}`) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .opacity(this.selection === route.name ? 0 : 1) + + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + .rotate({ angle: this.selection === route.name ? 90 : 0 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 30) }) + } + .borderRadius(20) + .width('100%') + .padding(8) + .enabled(!!route.children.length) + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .onClick(() => { + animateTo( + { curve: curves.interpolatingSpring(0, 1, 228, 25) }, + () => { + if (this.selection === route.name) { + this.selection = null; + } else { + this.selection = route.name; + } + }); + }) + } + + aboutToAppear(): void{ + this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + } + build() { + Column() { + Text('Index') + List() { + ForEach(this.routes, (routeGroup: RouteGroup) => { + ListItemGroup({ + header: this.ListItemGroupHeader(routeGroup), + style: ListItemGroupStyle.CARD, + }) { + if (routeGroup.name === this.selection) { + ForEach(routeGroup.children, (route: Route) => { + ListItem() { + Row() { + Text(route.label).fontSize(16) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + } + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .borderRadius(20) + .padding(8) + .transition( + TransitionEffect.OPACITY.animation({ + curve: curves.interpolatingSpring(0, 1, 228, 30) + }) + ) + .width('100%') + .onClick(() => { + const name = `pages/${routeGroup.name}/${route.name}`; + router.pushUrl({url: name}) + }) + } + .width('100%') + }) + } + } + .padding(2) + .divider({ strokeWidth: 0.5 }) + }) + }.padding({bottom: 10}) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..31b7114eab8bd18fa9090568829e80a6e1e3ae31 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/common/Index.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Route { + name: string; + label: ResourceStr; +} + +export interface RouteGroup extends Route { + children: Route[]; +} + +export class P2PManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let p2pManager = new P2PManager(); + +export default p2pManager as P2PManager; \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c010a77d33c4922be054e741464e6ee37fddc654 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template1/Index.ets @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SymbolGlyphModifier } from '@kit.ArkUI'; + +@Component +struct MyPageOne { + private listScroller: Scroller = new Scroller(); + private scrollScroller: Scroller = new Scroller(); + private arr: number[] = []; + + aboutToAppear(): void { + for (let i = 0; i < 30; i++) { + this.arr.push(i); + } + } + + build() { + NavDestination() { + Scroll(this.scrollScroller) { + Column() { + List({ space: 0, initialIndex: 0, scroller: this.listScroller }) { + ForEach(this.arr, (item: number, index: number) => { + ListItem() { + Text('' + item) + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ left: '5%' }) + .borderRadius(10) + .backgroundColor(Color.Gray) + } + }, (item: string) => item); + }.width('100%').height('80%').scrollBar(BarState.Off) + .nestedScroll({ scrollForward: NestedScrollMode.SELF_FIRST, scrollBackward: NestedScrollMode.SELF_FIRST }) + + ForEach(this.arr, (item: number, index: number) => { + ListItem() { + Text('' + item) + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ top: '5%' }) + .borderRadius(10) + .backgroundColor(Color.Pink) + } + }, (item: string) => item); + } + } + .width('100%') + .scrollBar(BarState.Off) + .scrollable(ScrollDirection.Vertical) + .edgeEffect(EdgeEffect.Spring) + } + .title('PageOne', { backgroundColor: Color.Yellow, barStyle: BarStyle.STACK }) + .toolbarConfiguration([ + { + value: 'item1', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.phone_badge_star')) + } + ], { backgroundColor: Color.Orange, barStyle: BarStyle.STACK }) + // 绑定有父子关系的可滚动容器组件 + .bindToNestedScrollable([{ parent: this.scrollScroller, child: this.listScroller }]) + } +} + +@Component +struct MyPageTwo { + private listScroller: Scroller = new Scroller(); + private arr: number[] = []; + + aboutToAppear(): void { + for (let i = 0; i < 30; i++) { + this.arr.push(i); + } + } + + build() { + NavDestination() { + List({ scroller: this.listScroller }) { + ForEach(this.arr, (item: number, index: number) => { + ListItem() { + Text('' + item) + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .width('90%') + .margin({ left: '5%' }) + .borderRadius(10) + .backgroundColor(Color.Gray) + } + }, (item: string) => item); + }.width('100%') + } + .title('PageTwo', { backgroundColor: Color.Yellow, barStyle: BarStyle.STACK }) + .toolbarConfiguration([ + { + value: 'item1', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.phone_badge_star')) + } + ], { backgroundColor: Color.Orange, barStyle: BarStyle.STACK }) + // 绑定可滚动容器组件 + .bindToScrollable([this.listScroller]) + } +} + +@Entry +@Component +struct Index { + private stack: NavPathStack = new NavPathStack(); + + @Builder + MyPageMap(name: string) { + if (name === 'myPageOne') { + MyPageOne(); + } else { + MyPageTwo(); + } + } + + build() { + Navigation(this.stack) { + Column() { + Button('push PageOne').onClick(() => { + this.stack.pushPath({ name: 'myPageOne' }); + }) + Button('push PageTwo').onClick(() => { + this.stack.pushPath({ name: 'myPageTwo' }); + }) + }.height('40%').justifyContent(FlexAlign.SpaceAround) + }.width('100%') + .height('100%') + .title({ main: 'MainTitle', sub: 'subTitle' }) + .navDestination(this.MyPageMap) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template2/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d079e388f44f7db45f5dc6bdc650e7805cfd2946 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template2/Index.ets @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavDestinationCustomTransition { + stack: NavPathStack = new NavPathStack(); + + @Builder + pageMap(name: string) { + if (name) { + NavDest(); + } + } + + aboutToAppear(): void { + this.stack.pushPath({name: 'dest0'}); + } + + build() { + Navigation(this.stack) { + // empty + } + .navDestination(this.pageMap) + .hideNavBar(true) + .title('Main Page') + .titleMode(NavigationTitleMode.Mini) + } +} + +declare type voidFunc = () => void; + +@Component +struct NavDest { + @State name: string = 'NA'; + @State destWidth: string = '100%'; + stack: NavPathStack = new NavPathStack(); + @State y: string = '0'; + + build() { + NavDestination() { + Column() { + Button('push next page', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.stack.pushPath({ name: this.name == 'PageOne' ? 'PageTwo' : 'PageOne' }); + }) + } + .size({ width: '100%', height: '100%' }) + } + .title(this.name) + .translate({ y: this.y }) + .onReady((context) => { + this.name = context.pathInfo.name; + this.stack = context.pathStack; + }) + .backgroundColor(this.name == 'PageOne' ? '#F1F3F5' : '#ff11dee5') + .customTransition( + (op: NavigationOperation, isEnter: boolean) + : Array | undefined => { + console.log('[NavDestinationTransition]', 'reached delegate in frontend, op: ' + op + ', isEnter: ' + isEnter); + + let transitionOneEvent: voidFunc = () => { console.log('[NavDestinationTransition]', 'reached transitionOne, empty now!'); } + let transitionOneFinishEvent: voidFunc = () => { console.log('[NavDestinationTransition]', 'reached transitionOneFinish, empty now!'); } + let transitionOneDuration: number = 500; + if (op === NavigationOperation.PUSH) { + if (isEnter) { + // ENTER_PUSH + this.y = '100%'; + transitionOneEvent = () => { + console.log('[NavDestinationTransition]', 'transitionOne, push & isEnter'); + this.y = '0'; + } + } else { + // EXIT_PUSH + this.y = '0'; + transitionOneEvent = () => { + console.log('[NavDestinationTransition]', 'transitionOne, push & !isEnter'); + this.y = '0'; + } + transitionOneDuration = 450; + } + } else if (op === NavigationOperation.POP) { + if (isEnter) { + // ENTER_POP + this.y = '0'; + transitionOneEvent = () => { + console.log('[NavDestinationTransition]', 'transitionOne, pop & isEnter'); + this.y = '0'; + } + } else { + // EXIT_POP + this.y = '0'; + transitionOneEvent = () => { + console.log('[NavDestinationTransition]', 'transitionOne, pop & !isEnter'); + this.y = '100%'; + } + } + } else { + console.log('[NavDestinationTransition]', '----- NOT-IMPL BRANCH of NAV-DESTINATION CUSTOM TRANSITION -----'); + } + + let transitionOne: NavDestinationTransition = { + duration: transitionOneDuration, + delay: 0, + curve: Curve.Friction, + event: transitionOneEvent, + onTransitionEnd: transitionOneFinishEvent + }; + + let transitionTwoEvent: voidFunc = () => { console.log('[NavDestinationTransition]', 'reached transitionTwo, empty now!'); } + let transitionTwo: NavDestinationTransition = { + duration: 1000, + delay: 0, + curve: Curve.EaseInOut, + event: transitionTwoEvent, + onTransitionEnd: () => { console.log('[NavDestinationTransition]', 'reached Two\'s finish'); } + }; + + return [ + transitionOne, + transitionTwo, + ]; + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template3/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..68ac1ba301cd1929e7a204e0b6f00b5f9f542872 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template3/Index.ets @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavDestinationSystemTransition { + @Provide stack: NavPathStack = new NavPathStack() + @Provide homePageTransitionType: NavigationSystemTransitionType = NavigationSystemTransitionType.DEFAULT; + + @Builder + pageMap(name: string) { + if (name === 'Fade') { + Fade(); + } else if (name === 'Explode') { + Explode(); + } else if (name === 'SlideRight') { + SlideRight(); + } else if (name === 'SlideBottom') { + SlideBottom(); + } else { + Dest(); + } + } + + aboutToAppear(): void { + this.stack.pushPath({name: 'Dest'}); + } + + build() { + Navigation(this.stack) { + // empty + } + .navDestination(this.pageMap) + .hideNavBar(true) + } +} + +@Component +struct Dest { + @Consume stack: NavPathStack; + @Consume homePageTransitionType: NavigationSystemTransitionType; + @State name: string = 'NA'; + + build() { + NavDestination() { + HomeBody(); + } + .title('Navigation System Animation') + .onReady((context) => { + this.name = context.pathInfo.name; + }) + .systemTransition(this.homePageTransitionType) + } +} + +@Component +struct Fade { + @Consume stack: NavPathStack; + @State name: string = 'NA'; + + build() { + NavDestination() { + DestBody({ + name: this.name + }) + } + .title(this.name) + .onReady((context) => { + this.name = context.pathInfo.name; + }) + .systemTransition(NavigationSystemTransitionType.FADE) + } +} + +@Component +struct Explode { + @Consume stack: NavPathStack; + @State name: string = 'NA'; + + build() { + NavDestination() { + DestBody({ + name: this.name + }) + } + .title(this.name) + .onReady((context) => { + this.name = context.pathInfo.name; + }) + .systemTransition(NavigationSystemTransitionType.EXPLODE) + } +} + +@Component +struct SlideRight { + @Consume stack: NavPathStack; + @State name: string = 'NA'; + + build() { + NavDestination() { + DestBody({ + name: this.name + }) + } + .title(this.name) + .onReady((context) => { + this.name = context.pathInfo.name; + }) + .systemTransition(NavigationSystemTransitionType.SLIDE_RIGHT) + } +} + +@Component +struct SlideBottom { + @Consume stack: NavPathStack; + @State name: string = 'NA'; + + build() { + NavDestination() { + DestBody({ + name: this.name + }) + } + .title(this.name) + .onReady((context) => { + this.name = context.pathInfo.name; + }) + .systemTransition(NavigationSystemTransitionType.SLIDE_BOTTOM) + } +} + +@Component +struct DestBody { + name: string = 'NA'; + + columnTextSize: number = 22; + columnTextFontWeight: FontWeight = FontWeight.Bolder; + columnWidth: string = '65%'; + columnPadding: number = 22; + columnMargin: number = 10; + columnBorderRadius: number = 10; + + build() { + Column() { + Column() + .width('85') + .height(50) + .backgroundColor(Color.White) + Column() { + Text(this.name) + .fontSize(this.columnTextSize) + .fontWeight(this.columnTextFontWeight) + } + .width(this.columnWidth) + .padding(this.columnPadding) + .margin(this.columnMargin) + .borderRadius(this.columnBorderRadius) + .shadow(ShadowStyle.OUTER_DEFAULT_LG) + } + } +} + +@Component +struct HomeBody { + @Consume stack: NavPathStack; + @Consume homePageTransitionType: NavigationSystemTransitionType; + + columnTextSize: number = 22; + columnTextFontWeight: FontWeight = FontWeight.Bolder; + columnWidth: string = '85%'; + columnPadding: number = 22; + columnMargin: number = 10; + columnBorderRadius: number = 10; + columnShadow: ShadowStyle = ShadowStyle.OUTER_DEFAULT_MD; + + build() { + Column() { + Search({ value: 'Search' }) + .width(this.columnWidth) + + Column() { + Text('fade') + .fontSize(this.columnTextSize) + .fontWeight(this.columnTextFontWeight) + } + .width(this.columnWidth) + .padding(this.columnPadding) + .margin(this.columnMargin) + .borderRadius(this.columnBorderRadius) + .shadow(this.columnShadow) + .onClick(() => { + this.homePageTransitionType = NavigationSystemTransitionType.FADE; + this.stack.pushPath({name: 'Fade'}); + }) + + Column() { + Text('explode') + .fontSize(this.columnTextSize) + .fontWeight(this.columnTextFontWeight) + } + .width(this.columnWidth) + .padding(this.columnPadding) + .margin(this.columnMargin) + .borderRadius(this.columnBorderRadius) + .shadow(this.columnShadow) + .onClick(() => { + this.homePageTransitionType = NavigationSystemTransitionType.EXPLODE; + this.stack.pushPath({name: 'Explode'}); + }) + + Column() { + Text('slide right') + .fontSize(this.columnTextSize) + .fontWeight(this.columnTextFontWeight) + } + .width(this.columnWidth) + .padding(this.columnPadding) + .margin(this.columnMargin) + .borderRadius(this.columnBorderRadius) + .shadow(this.columnShadow) + .onClick(() => { + this.homePageTransitionType = NavigationSystemTransitionType.SLIDE_RIGHT; + this.stack.pushPath({name: 'SlideRight'}); + }) + + Column() { + Text('slide bottom') + .fontSize(this.columnTextSize) + .fontWeight(this.columnTextFontWeight) + } + .width(this.columnWidth) + .padding(this.columnPadding) + .margin(this.columnMargin) + .borderRadius(this.columnBorderRadius) + .shadow(this.columnShadow) + .onClick(() => { + this.homePageTransitionType = NavigationSystemTransitionType.SLIDE_BOTTOM; + this.stack.pushPath({name: 'SlideBottom'}); + }) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template4/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..78ec74b946b720b50e08dd4d6c971481356f1d57 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navDestination/template4/Index.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { window } from '@kit.ArkUI'; + +@Component +struct PortraitPage { + private stack: NavPathStack | undefined = undefined; + build() { + NavDestination() { + Stack({alignContent: Alignment.Center}) { + Button('push LANDSCAPE page').onClick(() => { + this.stack?.pushPath({name: 'landscape'}); + }) + }.width('100%').height('100%') + } + .width('100%').height('100%') + .title('PortraitPage') + .preferredOrientation(window.Orientation.PORTRAIT) // 竖屏方向 + .enableStatusBar(true) // 显示状态栏 + .enableNavigationIndicator(true) // 显示导航条 + .backgroundColor('#ffbaece9') + .onReady((ctx: NavDestinationContext) => { + this.stack = ctx.pathStack; + }) + } +} + +@Component +struct LandscapePage { + private stack: NavPathStack | undefined = undefined; + build() { + NavDestination() { + Stack({alignContent: Alignment.Center}) { + Button('push PORTRAIT page').onClick(() => { + this.stack?.pushPath({name: 'portrait'}); + }) + }.width('100%').height('100%') + } + .width('100%').height('100%') + .title('LandscapePage') + .preferredOrientation(window.Orientation.LANDSCAPE) // 横屏方向 + .enableStatusBar(false) // 隐藏状态栏 + .enableNavigationIndicator(false) // 隐藏导航条 + .backgroundColor('#ffecb8b8') + .ignoreLayoutSafeArea([LayoutSafeAreaType.SYSTEM], [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM]) + .onReady((ctx: NavDestinationContext) => { + this.stack = ctx.pathStack; + }) + } +} + +@Entry +@Component +struct ExamplePage { + private stack: NavPathStack = new NavPathStack(); + + aboutToAppear(): void { + this.stack.pushPath({name: "portrait"}); + } + + @Builder + MyPageMap(name: string) { + if (name === 'portrait') { + PortraitPage(); + } else { + LandscapePage(); + } + } + + build() { + Navigation(this.stack) { + } + .width('100%') + .height('100%') + .hideNavBar(true) + .navDestination(this.MyPageMap) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..60bb0af102985a7559b2128b49768ec68964b5be --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/Index.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavPathStackExtendExample { + pageInfo: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pageInfo) { + Column() { + Button('pageOne', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfo.pushPath({ name: 'navPath-pageOne' }); // 将name指定的NavDestination页面信息入栈。 + }) + } + }.title('NavIndex') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..15fcd5b2be442b5d8e786e7ff977b4c2a2705adf --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navPathStackExtend/template1/PageOne.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver } from '@kit.ArkUI'; +import resource from '../../common/Index'; + +@Builder +export function PageOneBuilder() { + PageOneComponent() +} + +@Component +export struct PageOneComponent { + navDesInfo: uiObserver.NavDestinationInfo | undefined; + @State text: string = ''; + build() { + NavDestination() { + Column() { + Button($r('app.string.navStackTemp1PageOne_text1')) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + // 向内查询PageOne的NavDestination信息 + this.navDesInfo = this.queryNavDestinationInfo(true); + this.text = JSON.stringify(this.navDesInfo?.name); + }) + Text(resource.resourceToString($r('app.string.navStackTemp1PageOne_text2')) + this.text) + .width('80%') + .height(50) + .margin(50) + .fontSize(20) + MyComponent() + }.width('100%').height('100%') + } + .title('pageOne') + } +} + +@Component +struct MyComponent { + navDesInfo: uiObserver.NavDestinationInfo | undefined; + @State text: string = ''; + + build() { + Column() { + Button($r('app.string.navStackTemp1PageOne_text3')) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + // 向外查询PageOne的NavDestination信息 + this.navDesInfo = this.queryNavDestinationInfo(false); + this.text = JSON.stringify(this.navDesInfo?.name); + }) + Text(resource.resourceToString($r('app.string.navStackTemp1PageOne_text4')) + this.text) + .width('80%') + .height(50) + .margin(50) + .fontSize(20) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..527e65866b25b77ddc8f4ddaf8e63ae6d3178ab3 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template1/Index.ets @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class A { + text: string = ''; + num: number = 0; +} + +@Entry +@Component +struct NavigationExample1 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State currentIndex: number = 0; + + @Builder + NavigationTitle() { + Column() { + Text('Title') + .fontColor('#182431') + .fontSize(30) + .lineHeight(41) + .fontWeight(700) + Text('subtitle') + .fontColor('#182431') + .fontSize(14) + .lineHeight(19) + .opacity(0.4) + .margin({ top: 2, bottom: 20 }) + }.alignItems(HorizontalAlign.Start) + } + + @Builder + NavigationMenus() { + Row() { + Image('resources/base/media/ic_public_add.svg') + .width(24) + .height(24) + Image('resources/base/media/ic_public_add.svg') + .width(24) + .height(24) + .margin({ left: 24 }) + Image('common/ic_public_more.svg') + .width(24) + .height(24) + .margin({ left: 24 }) + } + } + + build() { + Column() { + Navigation() { + TextInput({ placeholder: 'search...' }) + .width('90%') + .height(40) + .backgroundColor('#FFFFFF') + .margin({ top: 8 }) + + List({ space: 12, initialIndex: 0 }) { + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('90%') + .height(72) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .fontSize(16) + .fontWeight(500) + .textAlign(TextAlign.Center) + } + }, (item: number) => item.toString()) + } + .height(324) + .width('100%') + .margin({ top: 12, left: '10%' }) + } + .title(this.NavigationTitle) + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Full) + .toolbarConfiguration([ + { + value: $r("app.string.navigation_toolbar_add"), + icon: $r("app.media.ic_public_highlightsed") + }, + { + value: $r("app.string.navigation_toolbar_app"), + icon: $r("app.media.ic_public_highlights") + }, + { + value: $r("app.string.navigation_toolbar_collect"), + icon: $r("app.media.ic_public_highlights") + } + ]) + .hideTitleBar(false) + .hideToolBar(false) + .onTitleModeChange((titleModel: NavigationTitleMode) => { + console.info('titleMode' + titleModel) + }) + }.width('100%').height('100%').backgroundColor('#F1F3F5') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template10/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template10/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..dff172ab459c5128d9e55e94fbed51678481d725 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template10/Index.ets @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class DerivedNavPathStack extends NavPathStack { + // usr defined property 'id' + id: string = "__default__"; + + // new function in derived class + setId(id: string) { + this.id = id; + } + + // new function in derived class + getInfo(): string { + return 'this page used Derived NavPathStack, id: ' + this.id; + } + + // overwrite function of NavPathStack + pushPath(info: NavPathInfo, animated?: boolean): void + pushPath(info: NavPathInfo, options?: NavigationOptions): void + pushPath(info: NavPathInfo, secArg?: boolean | NavigationOptions): void { + console.log('[derive-test] reached DerivedNavPathStack\'s pushPath'); + if (typeof secArg === 'boolean') { + super.pushPath(info, secArg); + } else { + super.pushPath(info, secArg); + } + } + + // overwrite and overload function of NavPathStack + pop(animated?: boolean | undefined): NavPathInfo | undefined + pop(result: Object, animated?: boolean | undefined): NavPathInfo | undefined + pop(result?: Object, animated?: boolean | undefined): NavPathInfo | undefined { + console.log('[derive-test] reached DerivedNavPathStack\'s pop'); + return super.pop(result, animated); + } + + // other function of base class... +} + +class param { + info: string = "__default_param__"; + + constructor(info: string) { + this.info = info; + } +} + +@Entry +@Component +struct NavigationExample10 { + derivedStack: DerivedNavPathStack = new DerivedNavPathStack(); + + aboutToAppear(): void { + this.derivedStack.setId('origin stack'); + } + + @Builder + pageMap(name: string) { + PageOne(); + } + + build() { + Navigation(this.derivedStack) { + Button('to Page One').margin(20).onClick(() => { + this.derivedStack.pushPath({ + name: 'pageOne', + param: new param('push pageOne in homePage when stack size: ' + this.derivedStack.size()) + }); + }) + }.navDestination(this.pageMap) + .title('Home Page') + } +} + +@Component +struct PageOne { + derivedStack: DerivedNavPathStack = new DerivedNavPathStack(); + curStringifyParam: string = "NA"; + + build() { + NavDestination() { + Column() { + Text(this.derivedStack.getInfo()) + .margin(10) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + Text('current page param info:') + .margin(10) + .fontSize(25) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + Text(this.curStringifyParam) + .margin(20) + .fontSize(20) + .textAlign(TextAlign.Start) + }.backgroundColor(Color.Pink) + + Button('to Page One').margin(20).onClick(() => { + this.derivedStack.pushPath({ + name: 'pageOne', + param: new param('push pageOne in pageOne when stack size: ' + this.derivedStack.size()) + }); + }) + }.title('Page One') + .onReady((context: NavDestinationContext) => { + console.log('[derive-test] reached PageOne\'s onReady'); + // get derived stack from navdestinationContext + this.derivedStack = context.pathStack as DerivedNavPathStack; + console.log('[derive-test] -- got derivedStack: ' + this.derivedStack.id); + this.curStringifyParam = JSON.stringify(context.pathInfo.param); + console.log('[derive-test] -- got param: ' + this.curStringifyParam); + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template11/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template11/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b94914fb690fbb9209a63b3e7b359ed2e007352 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template11/Index.ets @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { SymbolGlyphModifier } from '@kit.ArkUI'; + +@Entry +@Component +struct NavigationExample11 { + @Provide('navPathStack') navPathStack: NavPathStack = new NavPathStack(); + @State menuItems: Array = [ + { + value: 'menuItem1', + icon: 'resources/base/media/ic_public_ok.svg' // 图标资源路径 + }, + { + value: 'menuItem2', + icon: 'resources/base/media/ic_public_ok.svg', // 图标资源路径 + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_folder_badge_plus')).fontColor([Color.Red, Color.Green]) + .renderingStrategy(SymbolRenderingStrategy.MULTIPLE_COLOR), + }, + { + value: 'menuItem3', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_lungs')), + }, + ]; + @State toolItems: Array = [ + { + value: 'toolItem1', + icon: 'resources/base/media/ic_public_ok.svg', // 图标资源路径 + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_lungs')), + status: ToolbarItemStatus.ACTIVE, + activeSymbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_folder_badge_plus')).fontColor([Color.Red, + Color.Green]).renderingStrategy(SymbolRenderingStrategy.MULTIPLE_COLOR), + action: () => { + } + }, + { + value: 'toolItem2', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_star')), + status: ToolbarItemStatus.ACTIVE, + activeIcon: 'resources/base/media/ic_public_more.svg', // 图标资源路径 + action: () => { + } + }, + { + value: 'toolItem3', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_star')), + status: ToolbarItemStatus.ACTIVE, + activeSymbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_lungs')), + action: () => { + } + } + ]; + + @Builder + myRouter(name: string, param?: Object) { + if (name === 'NavigationMenu') { + NavigationMenu(); + } + } + + build() { + Navigation(this.navPathStack) { + Column() { + Button('跳转').onClick(() => { + this.navPathStack.pushPathByName('NavigationMenu', null); + }) + } + } + .backButtonIcon(new SymbolGlyphModifier($r('sys.symbol.ohos_wifi'))) + .titleMode(NavigationTitleMode.Mini) + .menus(this.menuItems) + .toolbarConfiguration(this.toolItems) + .title('一级页面') + .navDestination(this.myRouter) + } +} + +@Component +export struct NavigationMenu { + @Consume('navPathStack') navPathStack: NavPathStack; + @State menuItems: Array = [ + { + value: 'menuItem1', + icon: 'resources/base/media/ic_public_ok.svg', // 图标资源路径 + action: () => { + } + }, + { + value: 'menuItem2', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.ohos_folder_badge_plus')).fontColor([Color.Red, Color.Green]) + .renderingStrategy(SymbolRenderingStrategy.MULTIPLE_COLOR), + action: () => { + } + }, + { + value: 'menuItem3', + symbolIcon: new SymbolGlyphModifier($r('sys.symbol.repeat_1')), + action: () => { + } + }, + ]; + + build() { + NavDestination() { + Row() { + Column() { + } + .width('100%') + } + .height('100%') + } + .hideTitleBar(false) + .title('NavDestination title') + .backgroundColor($r('sys.color.ohos_id_color_titlebar_sub_bg')) + .backButtonIcon(new SymbolGlyphModifier($r('sys.symbol.ohos_star')).fontColor([Color.Blue])) + .menus(this.menuItems) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template12/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template12/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b91c58e0cd8dc6eb0c69b7670e596b37fb1fbb00 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template12/Index.ets @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { LengthMetrics } from '@kit.ArkUI'; +import { TextModifier } from '@ohos.arkui.modifier'; + +class MainTitleTextModfier extends TextModifier { + useStyle1: boolean = true; + + applyNormalAttribute(instance: TextModifier): void { + if (this.useStyle1) { + console.log(`testTag mainTitle use style1`); + instance.fontColor('#FFFFC000'); + instance.fontSize(35); + instance.fontWeight(FontWeight.Bolder); + instance.fontStyle(FontStyle.Normal); + instance.textShadow({ radius: 5, offsetX: 9 }); + } else { + console.log(`testTag mainTitle use style2`); + instance.fontColor('#FF23A98D'); + instance.fontSize(20); + instance.heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST); + instance.fontWeight(FontWeight.Lighter); + instance.fontStyle(FontStyle.Italic); + instance.textShadow({ radius: 3, offsetX: 3 }); + } + } +} + +class SubTitleTextModfier extends TextModifier { + useStyle1: boolean = true; + + applyNormalAttribute(instance: TextModifier): void { + if (this.useStyle1) { + console.log(`testTag subTitle use style1`); + instance.fontColor('#FFFFC000'); + instance.fontSize(15); + instance.fontWeight(FontWeight.Bolder); + instance.fontStyle(FontStyle.Normal); + instance.textShadow({ radius: 5, offsetX: 9 }); + } else { + console.log(`testTag subTitle use style2`); + instance.fontColor('#FF23A98D'); + instance.fontSize(10); + instance.fontWeight(FontWeight.Lighter); + instance.fontStyle(FontStyle.Italic); + instance.textShadow({ radius: 3, offsetX: 3 }); + } + } +} + +@Entry +@Component +struct NavigationExample12 { + private navPathStack: NavPathStack = new NavPathStack(); + // 初始化标题栏起始端内间距 + @State paddingStart: LengthMetrics = LengthMetrics.vp(0); + // 初始化标题栏结束端内间距 + @State paddingEnd: LengthMetrics = LengthMetrics.vp(0); + // 主标题样式修改器 + @State mainTitleModifier: MainTitleTextModfier = new MainTitleTextModfier(); + // 副标题样式修改器 + @State subTitleModifier: SubTitleTextModfier = new SubTitleTextModfier(); + @State applyModifier: boolean = false; + @State useStyle1: boolean = true; + + @Builder + myRouter(name: string, param?: Object) { + if (name === 'NavDestinationExample') { + NavDestinationExample(); + } + } + + build() { + Navigation(this.navPathStack) { + Column() { + // 标题栏内间距切换 + Button('apply padding 32vp') + .onClick(() => { + this.paddingStart = LengthMetrics.vp(32); + this.paddingEnd = LengthMetrics.vp(32); + }) + .margin({ top: 70 }) + .width(180) + Button('apply padding 20vp') + .onClick(() => { + this.paddingStart = LengthMetrics.vp(20); + this.paddingEnd = LengthMetrics.vp(20); + }) + .margin({ top: 40 }) + .width(180) + Button('pushPage') + .onClick(() => { + this.navPathStack.pushPath({ name: 'NavDestinationExample' }); + }) + .margin({ top: 40 }) + .width(180) + Row() { + Text(`apply Modifier`) + Toggle({ isOn: this.applyModifier, type: ToggleType.Switch }).onChange((isOn: boolean) => { + this.applyModifier = isOn; + }) + } + .padding({ top: 95, left: 5, right: 5 }) + .width(180) + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Text(`use Style1`) + Toggle({ isOn: this.useStyle1, type: ToggleType.Switch }).onChange((isOn: boolean) => { + this.mainTitleModifier.useStyle1 = isOn; + this.subTitleModifier.useStyle1 = isOn; + this.useStyle1 = isOn; + }) + } + .padding({ top: 40, left: 5, right: 5 }) + .width(180) + .justifyContent(FlexAlign.SpaceBetween) + } + .width('100%') + .height('100%') + } + .titleMode(NavigationTitleMode.Full) + .title( + { main: "Title", sub: "subTitle" }, + this.applyModifier ? + { + paddingStart: this.paddingStart, + paddingEnd: this.paddingEnd, + mainTitleModifier: this.mainTitleModifier, + subTitleModifier: this.subTitleModifier, + } : { + paddingStart: this.paddingStart, + paddingEnd: this.paddingEnd + }) + .navDestination(this.myRouter) + } +} + +@Component +export struct NavDestinationExample { + @State menuItems: Array = [ + { + value: 'menuItem1', + icon: 'resources/base/media/ic_public_ok.svg', // 图标资源路径 + action: () => { + } + } + ]; + @State paddingStart: LengthMetrics = LengthMetrics.vp(0); + @State paddingEnd: LengthMetrics = LengthMetrics.vp(0); + // 主标题样式修改器 + @State mainTitleModifier: MainTitleTextModfier = new MainTitleTextModfier(); + // 副标题样式修改器 + @State subTitleModifier: SubTitleTextModfier = new SubTitleTextModfier(); + @State applyModifier: boolean = false; + @State useStyle1: boolean = true; + + build() { + NavDestination() { + Column() { + // 标题栏内间距切换 + Button('apply padding 32vp') + .onClick(() => { + this.paddingStart = LengthMetrics.vp(32); + this.paddingEnd = LengthMetrics.vp(32); + }) + .margin({ top: 150 }) + .width(180) + Button('apply padding 20vp') + .onClick(() => { + this.paddingStart = LengthMetrics.vp(20); + this.paddingEnd = LengthMetrics.vp(20); + }) + .margin({ top: 40 }) + .width(180) + Row() { + Text(`apply Modifier`) + Toggle({ isOn: this.applyModifier, type: ToggleType.Switch }).onChange((isOn: boolean) => { + this.applyModifier = isOn; + }) + } + .padding({ top: 95, left: 5, right: 5 }) + .width(180) + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Text(`use Style1`) + Toggle({ isOn: this.useStyle1, type: ToggleType.Switch }).onChange((isOn: boolean) => { + this.mainTitleModifier.useStyle1 = isOn; + this.subTitleModifier.useStyle1 = isOn; + this.useStyle1 = isOn; + }) + } + .padding({ top: 40, left: 5, right: 5 }) + .width(180) + .justifyContent(FlexAlign.SpaceBetween) + } + .width('100%') + .height('90%') + } + .hideTitleBar(false) + .title( + { main: "Title", sub: "subTitle" }, + this.applyModifier ? + { + paddingStart: this.paddingStart, + paddingEnd: this.paddingEnd, + mainTitleModifier: this.mainTitleModifier, + subTitleModifier: this.subTitleModifier, + } : { + paddingStart: this.paddingStart, + paddingEnd: this.paddingEnd + }) + .menus(this.menuItems) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/CustomTransitionUtils.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/CustomTransitionUtils.ets new file mode 100644 index 0000000000000000000000000000000000000000..3fbdf84261fefde046f9b30317010debaab1336a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/CustomTransitionUtils.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface AnimateCallback { + start: ((isPush: boolean, isExit: boolean) => void | undefined) | undefined; + finish: ((isPush: boolean, isExit: boolean) => void | undefined) | undefined; +} + +const customTransitionMap: Map = new Map(); + +export class CustomTransition { + static delegate = new CustomTransition(); + + static getInstance() { + return CustomTransition.delegate; + } + + registerNavParam(name: string, startCallback: (isPush: boolean, isExit: boolean) => void, + endCallback: (isPush: boolean, isExit: boolean) => void): void { + if (customTransitionMap.has(name)) { + let param = customTransitionMap.get(name); + if (param != undefined) { + param.start = startCallback; + param.finish = endCallback; + return; + } + } + let params: AnimateCallback = { start: startCallback, finish: endCallback }; + customTransitionMap.set(name, params); + } + + unRegisterNavParam(name: string): void { + customTransitionMap.delete(name); + } + + getAnimateParam(name: string): AnimateCallback { + let result: AnimateCallback = { + start: customTransitionMap.get(name)?.start, + finish: customTransitionMap.get(name)?.finish + }; + return result; + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0fea22b7ed5c0aae413ac6152734ad4638cba48 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template13/Index.ets @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AnimateCallback, CustomTransition } from './CustomTransitionUtils' + +@Entry +@Component +struct NavigationCustomTransitionExample { + pageInfos: NavPathStack = new NavPathStack(); + + aboutToAppear() { + this.pageInfos.pushPath({ name: 'temp13-PageOne' }, false); + } + + build() { + Navigation(this.pageInfos) { + } + .hideNavBar(true) + .customNavContentTransition((from: NavContentInfo, to: NavContentInfo, operation: NavigationOperation) => { + // 首页不进行自定义动画 + if (from.index === -1 || to.index === -1) { + return undefined; + } + + let customAnimation: NavigationAnimatedTransition = { + timeout: 2000, + // 转场开始时系统调用该方法,并传入转场上下文代理对象 + transition: (transitionProxy: NavigationTransitionProxy) => { + if (!from.navDestinationId || !to.navDestinationId) { + return; + } + // 从封装类CustomTransition中根据子页面的序列获取对应的转场动画回调 + let fromParam: AnimateCallback = CustomTransition.getInstance().getAnimateParam(from.navDestinationId); + let toParam: AnimateCallback = CustomTransition.getInstance().getAnimateParam(to.navDestinationId); + // Push动画 + if (operation == NavigationOperation.PUSH) { + if (fromParam.start && toParam.start) { + // 设置Push转场的两个页面的动画起点 + fromParam.start(true, true); + toParam.start(true, false); + } + this.getUIContext()?.animateTo({ + duration: 500, curve: Curve.Friction, onFinish: () => { + // 动画结束后需要手动调用finishTransition,否则在timeout时间后由系统调用 + transitionProxy.finishTransition(); + } + }, () => { + if (fromParam.finish && toParam.finish) { + // 设置Push转场的两个页面的动画终点 + fromParam.finish(true, true); + toParam.finish(true, false); + } + + }) + } else if (operation == NavigationOperation.POP) { + // Pop动画 + if (fromParam.start && toParam.start) { + // 设置Pop转场的两个页面的动画起点 + fromParam.start(false, true); + toParam.start(false, false); + } + this.getUIContext()?.animateTo({ + duration: 500, curve: Curve.Friction, onFinish: () => { + // 动画结束后需要手动调用finishTransition,否则在timeout时间后由系统调用 + transitionProxy.finishTransition(); + } + }, () => { + if (fromParam.finish && toParam.finish) { + // 设置Pop转场的两个页面的动画终点 + fromParam.finish(false, true); + toParam.finish(false, false); + } + }) + } else { + // Replace不做动画 + } + } + }; + return customAnimation; + }) + } +} + + +// PageOne +@Builder +export function PageOneBuilder() { + PageContainer({ title: 'PageOne' }); +} + +// PageTwo +@Builder +export function PageTwoBuilder() { + PageContainer({ title: 'PageTwo' }); +} + +@Component +export struct PageContainer { + pageInfos: NavPathStack = new NavPathStack(); + @State translateY: string = '0'; + pageId: string = ''; + title: string = '' + + registerCallback() { + CustomTransition.getInstance().registerNavParam(this.pageId, + // 设置转场动画起点,根据不同的转场类型分别设置 + (isPush: boolean, isExit: boolean) => { + if (isPush) { + if (isExit) { + this.translateY = '0'; + } else { + this.translateY = '100%'; + } + } else { + if (isExit) { + this.translateY = '0'; + } else { + this.translateY = '0'; + } + } + }, + // 设置转场动画终点,根据不同的转场类型分别设置 + (isPush: boolean, isExit: boolean) => { + if (isPush) { + if (isExit) { + this.translateY = '0'; + } else { + this.translateY = '0'; + } + } else { + if (isExit) { + this.translateY = '100%'; + } else { + this.translateY = '0'; + } + } + }); + } + + build() { + NavDestination() { + Column() { + Button('push next page', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.pushPath({ name: this.title == 'PageOne' ? "temp13-PageTwo" : "temp13-PageOne" }); + }) + } + .size({ width: '100%', height: '100%' }) + } + .title(this.title) + .onDisAppear(() => { + // 页面销毁时解注册自定义转场动画参数 + CustomTransition.getInstance().unRegisterNavParam(this.pageId); + }) + .onReady((context: NavDestinationContext) => { + this.pageInfos = context.pathStack; + if (context.navDestinationId) { + this.pageId = context.navDestinationId; + // 页面创建时注册自定义转场动画参数 + this.registerCallback(); + } + }) + .translate({ y: this.translateY }) + .backgroundColor(this.title == 'PageOne' ? '#F1F3F5' : '#ff11dee5') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f97f0f56dbca1f139fa02da7b4a51b71b90cc4a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/Index.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavigationExample2 { + pageInfos: NavPathStack = new NavPathStack(); + isUseInterception: boolean = false; + + registerInterception() { + this.pageInfos.setInterception({ + // 页面跳转前拦截,允许操作栈,在当前跳转中生效。 + willShow: (from: NavDestinationContext | "navBar", to: NavDestinationContext | "navBar", + operation: NavigationOperation, animated: boolean) => { + if (!this.isUseInterception) { + return; + } + if (typeof to === "string") { + console.log('target page is navigation home'); + return; + } + // 重定向目标页面,更改为pageTwo页面到pageOne页面。 + let target: NavDestinationContext = to as NavDestinationContext; + if (target.pathInfo.name === 'pageTwo') { + target.pathStack.pop(); + target.pathStack.pushPathByName('pageOne', null); + } + }, + // 页面跳转后回调,在该回调中操作栈在下一次跳转中刷新。 + didShow: (from: NavDestinationContext | "navBar", to: NavDestinationContext | "navBar", + operation: NavigationOperation, isAnimated: boolean) => { + if (!this.isUseInterception) { + return; + } + if (typeof from === "string") { + console.log('current transition is from navigation home'); + } else { + console.log(`current transition is from ${(from as NavDestinationContext).pathInfo.name}`); + } + if (typeof to === "string") { + console.log('current transition to is navBar'); + } else { + console.log(`current transition is to ${(to as NavDestinationContext).pathInfo.name}`); + } + }, + // Navigation单双栏显示状态发生变更时触发该回调。 + modeChange: (mode: NavigationMode) => { + if (!this.isUseInterception) { + return; + } + console.log(`current navigation mode is ${mode}`); + } + }) + } + + build() { + Navigation(this.pageInfos) { + Column() { + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.pushPath({ name: 'pageOne' }); //将name指定的NavDestination页面信息入栈 + }) + Button('use interception', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.isUseInterception = !this.isUseInterception; + if (this.isUseInterception) { + this.registerInterception(); + } else { + this.pageInfos.setInterception(undefined); + } + }) + } + }.title('NavIndex') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..be41e252e07868859e71adcf40b1d50ecb62caf8 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageOne.ets @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class TmpClass { + count: number = 10; +} + +@Builder +export function PageOneBuilder(name: string, param: Object) { + PageOne() +} + +@Component +export struct PageOne { + pageInfos: NavPathStack = new NavPathStack(); + + build() { + NavDestination() { + Column() { + Button('pushPathByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let tmp = new TmpClass(); + this.pageInfos.pushPathByName('pageTwo', tmp); //将name指定的NavDestination页面信息入栈,传递的数据为param + }) + Button('singletonLaunchMode', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.pushPath({ name: 'pageOne' }, + { launchMode: LaunchMode.MOVE_TO_TOP_SINGLETON }); //从栈底向栈顶查找,如果指定的名称已经存在,则将对应的NavDestination页面移到栈顶 + }) + Button('popToname', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.popToName('pageTwo'); //回退路由栈到第一个名为name的NavDestination页面 + console.log('popToName' + JSON.stringify(this.pageInfos), + 'Return value' + JSON.stringify(this.pageInfos.popToName('pageTwo'))); + }) + Button('popToIndex', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.popToIndex(1); // 回退路由栈到index指定的NavDestination页面 + console.log('popToIndex' + JSON.stringify(this.pageInfos)); + }) + Button('moveToTop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.moveToTop('pageTwo'); // 将第一个名为name的NavDestination页面移到栈顶 + console.log('moveToTop' + JSON.stringify(this.pageInfos), + 'Return value' + JSON.stringify(this.pageInfos.moveToTop('pageTwo'))); + }) + Button('moveIndexToTop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.moveIndexToTop(1); // 将index指定的NavDestination页面移到栈顶 + console.log('moveIndexToTop' + JSON.stringify(this.pageInfos)); + }) + Button('clear', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfos.clear(); //清除栈中所有页面 + }) + Button('get', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + console.log('-------------------'); + console.log('Get the names of all NavDestination pages in the stack.', JSON.stringify(this.pageInfos.getAllPathName())); + console.log('Get the parameter information of the NavDestination page specified by index.', + JSON.stringify(this.pageInfos.getParamByIndex(1))); + console.log('Get all parameter information of NavDestination pages named "name"', + JSON.stringify(this.pageInfos.getParamByName('pageTwo'))); + console.log('Get the position indices of all NavDestination pages named "name"', + JSON.stringify(this.pageInfos.getIndexByName('pageOne'))); + console.log('Get the stack size', JSON.stringify(this.pageInfos.size())); + }) + }.width('100%').height('100%') + }.title('pageOne') + .onBackPressed(() => { + const popDestinationInfo = this.pageInfos.pop(); // 弹出路由栈栈顶元素 + console.log('pop' + 'Return value' + JSON.stringify(popDestinationInfo)); + return true; + }).onReady((context: NavDestinationContext) => { + this.pageInfos = context.pathStack; + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageTwo.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..936d5ea8d8280f19ecd67d70b05bd6ff4f966cce --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template2/PageTwo.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Builder +export function PageTwoBuilder(name: string, param: Object) { + PageTwo() +} + +@Component +export struct PageTwo { + pathStack: NavPathStack = new NavPathStack(); + private menuItems: Array = [ + { + value: "1", + icon: 'resources/base/media/undo.svg', + }, + { + value: "2", + icon: 'resources/base/media/redo.svg', + isEnabled: false, + }, + { + value: "3", + icon: 'resources/base/media/ic_public_ok.svg', + isEnabled: true, + } + ]; + + build() { + NavDestination() { + Column() { + Button('pushPathByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.pushPathByName('pageOne', null); + }) + }.width('100%').height('100%') + }.title('pageTwo') + .menus(this.menuItems) + .onBackPressed(() => { + this.pathStack.pop(); + return true; + }) + .onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack; + console.log('current page config info is ' + JSON.stringify(context.getConfigInRouteMap())); + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/CustomNavigationUtils.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/CustomNavigationUtils.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9f4a40f163197f40b78b1953883a2b01b66c72b --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/CustomNavigationUtils.ets @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface AnimateCallback { + finish: ((isPush: boolean, isExit: boolean) => void | undefined) | undefined; + start: ((isPush: boolean, isExit: boolean) => void | undefined) | undefined; + onFinish: ((isPush: boolean, isExit: boolean) => void | undefined) | undefined; + interactive: ((operation: NavigationOperation) => void | undefined) | undefined; + timeout: (number | undefined) | undefined; +} + +const customTransitionMap: Map = new Map(); + +export class CustomTransition { + static delegate = new CustomTransition(); + public interactive: boolean = false; + proxy: NavigationTransitionProxy | undefined = undefined; + private animationId: number = 0; + public operation: NavigationOperation = NavigationOperation.PUSH; + + static getInstance() { + return CustomTransition.delegate; + } + + registerNavParam(name: string, startCallback: (operation: boolean, isExit: boolean) => void, + endCallback: (operation: boolean, isExit: boolean) => void, + onFinish: (operation: boolean, isExit: boolean) => void, + interactiveCallback: (operation: NavigationOperation) => void, + timeout: number): void { + if (customTransitionMap.has(name)) { + let param = customTransitionMap.get(name); + if (param != undefined) { + param.start = startCallback; + param.finish = endCallback; + param.timeout = timeout; + param.onFinish = onFinish; + param.interactive = interactiveCallback; + return; + } + } + let params: AnimateCallback = { + timeout: timeout, + start: startCallback, + finish: endCallback, + onFinish: onFinish, + interactive: interactiveCallback + }; + customTransitionMap.set(name, params); + } + + getAnimationId() { + return Date.now(); + } + + unRegisterNavParam(name: string): void { + customTransitionMap.delete(name); + } + + fireInteractiveAnimation(id: string, operation: NavigationOperation) { + let animation = customTransitionMap.get(id)?.interactive; + if (!animation) { + return; + } + animation(operation); + } + + updateProgress(progress: number) { + if (!this.proxy?.updateTransition) { + return; + } + progress = this.operation == NavigationOperation.PUSH ? 1 - progress : progress; + this.proxy?.updateTransition(progress); + } + + cancelTransition() { + if (this.proxy?.cancelTransition) { + this.proxy.cancelTransition(); + } + } + + recoverState() { + if (!this.proxy?.from.navDestinationId || !this.proxy?.to.navDestinationId) { + return; + } + let fromParam = customTransitionMap.get(this.proxy.from.navDestinationId); + if (fromParam?.onFinish) { + fromParam.onFinish(false, false); + } + let toParam = customTransitionMap.get(this.proxy?.to.navDestinationId); + if (toParam?.onFinish) { + toParam.onFinish(true, true); + } + } + + finishTransition() { + this.proxy?.finishTransition(); + } + + finishInteractiveAnimation(rate: number) { + if (this.operation == NavigationOperation.PUSH) { + if (rate > 0.5) { + if (this.proxy?.cancelTransition) { + this.proxy.cancelTransition(); + } + } else { + this.proxy?.finishTransition(); + } + } else { + if (rate > 0.5) { + this.proxy?.finishTransition(); + } else { + if (this.proxy?.cancelTransition) { + this.proxy.cancelTransition(); + } + } + } + } + + getAnimateParam(name: string): AnimateCallback { + let result: AnimateCallback = { + start: customTransitionMap.get(name)?.start, + finish: customTransitionMap.get(name)?.finish, + timeout: customTransitionMap.get(name)?.timeout, + onFinish: customTransitionMap.get(name)?.onFinish, + interactive: customTransitionMap.get(name)?.interactive, + }; + return result; + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2dc00b88c59669bf176cb5e0218a852ae050e9b --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/Index.ets @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomTransition, AnimateCallback } from './CustomNavigationUtils' + +@Entry +@Component +export struct NavigationExample3 { + pageInfos: NavPathStack = new NavPathStack(); + + aboutToAppear() { + if (this.pageInfos === undefined) { + this.pageInfos = new NavPathStack(); + } + this.pageInfos.pushPath({ name: 'temp3-pageOne', param: CustomTransition.getInstance().getAnimationId() }); + } + + build() { + Navigation(this.pageInfos) { + } + .title('NavIndex') + .hideNavBar(true) + .customNavContentTransition((from: NavContentInfo, to: NavContentInfo, operation: NavigationOperation) => { + if (from.mode == NavDestinationMode.DIALOG || to.mode == NavDestinationMode.DIALOG) { + return undefined; + } + + // 首页不进行自定义动画 + if (from.index === -1 || to.index === -1) { + return undefined; + } + + CustomTransition.getInstance().operation = operation; + if (CustomTransition.getInstance().interactive) { + let customAnimation: NavigationAnimatedTransition = { + onTransitionEnd: (isSuccess: boolean) => { + console.log('===== current transition is ' + isSuccess); + CustomTransition.getInstance().recoverState(); + CustomTransition.getInstance().proxy = undefined; + }, + transition: (transitionProxy: NavigationTransitionProxy) => { + CustomTransition.getInstance().proxy = transitionProxy; + let targetIndex: string | undefined = operation == NavigationOperation.PUSH ? + (to.navDestinationId) : (from.navDestinationId); + if (targetIndex) { + CustomTransition.getInstance().fireInteractiveAnimation(targetIndex, operation); + } + }, + isInteractive: CustomTransition.getInstance().interactive + } + return customAnimation; + } + let customAnimation: NavigationAnimatedTransition = { + onTransitionEnd: (isSuccess: boolean) => { + console.log(`current transition result is ${isSuccess}`); + }, + timeout: 7000, + // 转场开始时系统调用该方法,并传入转场上下文代理对象 + transition: (transitionProxy: NavigationTransitionProxy) => { + if (!from.navDestinationId || !to.navDestinationId) { + return; + } + // 从封装类CustomTransition中根据子页面的序列获取对应的转场动画回调 + let fromParam: AnimateCallback = CustomTransition.getInstance().getAnimateParam(from.navDestinationId); + let toParam: AnimateCallback = CustomTransition.getInstance().getAnimateParam(to.navDestinationId); + if (operation == NavigationOperation.PUSH) { + if (toParam.start) { + toParam.start(true, false); + } + this.getUIContext()?.animateTo({ + duration: 500, onFinish: () => { + transitionProxy.finishTransition(); + } + }, () => { + if (toParam.finish) { + toParam.finish(true, false); + } + }) + } else { + if (fromParam.start) { + fromParam.start(true, true); + } + this.getUIContext()?.animateTo({ + duration: 500, onFinish: () => { + transitionProxy.finishTransition(); + } + }, () => { + if (fromParam.finish) { + fromParam.finish(true, true); + } + }) + } + } + }; + return customAnimation; + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..476e83b7c87aecf8668be957fa181b81423b9c29 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageOne.ets @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomTransition } from './CustomNavigationUtils'; + +@Builder +export function PageOneBuilder(name: string, param: Object) { + PageOne() +} + +@Component +export struct PageOne { + pageInfos: NavPathStack = new NavPathStack(); + @State translateX: string = '0'; + pageId: string = ''; + rectWidth: number = 0; + interactive: boolean = false; + + registerCallback() { + CustomTransition.getInstance().registerNavParam(this.pageId, (isPush: boolean, isExit: boolean) => { + if (isPush) { + this.translateX = '100%'; + } else { + this.translateX = '0'; + } + }, (isPush: boolean, isExit: boolean) => { + if (isPush) { + this.translateX = '0'; + } else { + this.translateX = '100%'; + } + }, (isPush: boolean, isExit: boolean) => { + this.translateX = '0'; + }, (operation: NavigationOperation) => { + if (operation == NavigationOperation.PUSH) { + this.translateX = '100%'; + this.getUIContext()?.animateTo({ + duration: 1000, + onFinish: () => { + this.translateX = '0'; + } + }, () => { + this.translateX = '0'; + }) + } else { + this.translateX = '0'; + this.getUIContext()?.animateTo({ + duration: 1000, + onFinish: () => { + this.translateX = '0'; + } + }, () => { + this.translateX = '100%'; + }) + } + }, 200); + } + + build() { + NavDestination() { + Column() { + Button(`setInteractive`) + .onClick(() => { + CustomTransition.getInstance().interactive = !CustomTransition.getInstance().interactive; + this.interactive = CustomTransition.getInstance().interactive; + }) + + Button('pushPathByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + //将name指定的NavDestination页面信息入栈,传递的数据为param + this.pageInfos.pushDestinationByName('temp3-pageTwo', CustomTransition.getInstance().getAnimationId()); + }) + } + .size({ width: '100%', height: '100%' }) + } + .title('pageOne') + .onDisAppear(() => { + CustomTransition.getInstance().unRegisterNavParam(this.pageId); + }) + .onReady((context: NavDestinationContext) => { + this.pageInfos = context.pathStack; + if (context.navDestinationId) { + this.pageId = context.navDestinationId; + this.registerCallback(); + } + }) + .translate({ x: this.translateX }) + .backgroundColor('#F1F3F5') + .gesture(PanGesture() + .onActionStart((event: GestureEvent) => { + this.rectWidth = event.target.area.width as number; + if (event.offsetX < 0) { + this.pageInfos.pushPath({ name: 'temp3-pageTwo', param: CustomTransition.getInstance().getAnimationId() }); + } else { + this.pageInfos.pop(); + } + }) + .onActionUpdate((event: GestureEvent) => { + let rate = event.fingerList[0].localX / this.rectWidth; + CustomTransition.getInstance().updateProgress(rate); + }) + .onActionEnd((event: GestureEvent) => { + let rate: number = event.fingerList[0].localX / this.rectWidth; + CustomTransition.getInstance().finishInteractiveAnimation(rate); + })) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageTwo.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1fbd15fa9143dba6adf101e5855c5299aae70c0 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template3/PageTwo.ets @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomTransition } from './CustomNavigationUtils' + +@Builder +export function PageTwoBuilder(name: string, param: Object) { + PageTwo({ param: param as number }) +} + +@Component +export struct PageTwo { + pageInfos: NavPathStack = new NavPathStack(); + @State translateX: string = '0'; + pageId: string = ''; + rectWidth: number = 0; + param: number = 0; + + registerCallback() { + CustomTransition.getInstance().registerNavParam(this.pageId, (isPush: boolean, isExit: boolean) => { + if (isPush) { + this.translateX = '100%' + } else { + this.translateX = '0'; + } + }, (isPush: boolean, isExit: boolean) => { + if (isPush) { + this.translateX = '0'; + } else { + this.translateX = '100%'; + } + }, (isPush: boolean, isExit: boolean) => { + this.translateX = '0'; + }, (operation: NavigationOperation) => { + if (operation == NavigationOperation.PUSH) { + this.translateX = '100%'; + this.getUIContext()?.animateTo({ + duration: 500, onFinish: () => { + this.translateX = '0'; + } + }, () => { + this.translateX = '0'; + }) + } else { + this.translateX = '0'; + this.getUIContext()?.animateTo({ + duration: 500, onFinish: () => { + this.translateX = '0'; + } + }, () => { + this.translateX = '100%'; + }) + } + }, 2000) + } + + build() { + NavDestination() { + Column() { + Button('pushPathByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + //将name指定的NavDestination页面信息入栈,传递的数据为param + this.pageInfos.pushPath({ name: 'temp3-pageOne', param: CustomTransition.getInstance().getAnimationId() }); + }) + } + .size({ width: '100%', height: '100%' }) + } + .title('pageTwo') + .gesture(PanGesture() + .onActionStart((event: GestureEvent) => { + this.rectWidth = event.target.area.width as number; + if (event.offsetX < 0) { + this.pageInfos.pushPath({ name: 'temp3-pageOne', param: CustomTransition.getInstance().getAnimationId() }); + } else { + this.pageInfos.pop(); + } + }) + .onActionUpdate((event: GestureEvent) => { + let rate = event.fingerList[0].localX / this.rectWidth; + CustomTransition.getInstance().updateProgress(rate); + }) + .onActionEnd((event: GestureEvent) => { + let rate = event.fingerList[0].localX / this.rectWidth; + CustomTransition.getInstance().finishInteractiveAnimation(rate); + })) + .onAppear(() => { + this.registerCallback(); + }) + .onDisAppear(() => { + CustomTransition.getInstance().unRegisterNavParam(this.pageId); + }) + .onReady((context: NavDestinationContext) => { + this.pageInfos = context.pathStack; + if (context.navDestinationId) { + this.pageId = context.navDestinationId; + this.registerCallback(); + } + }) + .translate({ x: this.translateX }) + .backgroundColor(Color.Yellow) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..db408cbe1619e5f8cd03de6566582e289856eb12 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/Index.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavigationExample4 { + pageInfo: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pageInfo) { + Column() { + Button('StartTest', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pageInfo.pushPath({ name: 'temp4-pageOne' }); // 将name指定的NavDestination页面信息入栈。 + }) + } + }.title('NavIndex') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..a823ef1e880b01a02e96754ae176ffc82b488ffe --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageOne.ets @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { BusinessError } from '@kit.BasicServicesKit'; + +class TmpClass { + count: number = 10; +} + +class ParamWithOp { + public operation: number = 1; + public count: number = 10; +} + +@Builder +export function PageOneBuilder(name: string, param: Object) { + PageOne() +} + +@Component +export struct PageOne { + pageInfo: NavPathStack = new NavPathStack(); + @State message: string = 'Hello World'; + + build() { + NavDestination() { + Column() { + Text(this.message) + .width('80%') + .height(50) + .margin(10) + + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + this.pageInfo.pushPath({ + name: 'temp4-pageTwo', param: new ParamWithOp(), onPop: (popInfo: PopInfo) => { + this.message = + '[pushPath]last page is: ' + popInfo.info.name + ', result: ' + JSON.stringify(popInfo.result); + } + }); // 将name指定的NavDestination页面信息入栈,传递的数据为param,添加接收处理结果的onPop回调。 + }) + + Button('pushPathByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + this.pageInfo.pushPathByName('temp4-pageTwo', tmp, (popInfo) => { + this.message = + '[pushPathByName]last page is: ' + popInfo.info.name + ', result: ' + JSON.stringify(popInfo.result); + }); // 将name指定的NavDestination页面信息入栈,传递的数据为param,添加接收处理结果的onPop回调。 + }) + + Button('pushDestination', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + // 将name指定的NavDestination页面信息入栈,传递的数据为param,添加接收处理结果的onPop回调。 + this.pageInfo.pushDestination({ + name: 'temp4-pageTwo', param: new ParamWithOp(), onPop: (popInfo: PopInfo) => { + this.message = + '[pushDestination]last page is: ' + popInfo.info.name + ', result: ' + JSON.stringify(popInfo.result); + } + }).catch((error: BusinessError) => { + console.error(`[pushDestination]failed, error code = ${error.code}, error.message = ${error.message}.`); + }).then(() => { + console.error('[pushDestination]success.'); + }); + }) + + Button('pushDestinationByName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + // 将name指定的NavDestination页面信息入栈,传递的数据为param,添加接收处理结果的onPop回调。 + this.pageInfo.pushDestinationByName('temp4-pageTwo', tmp, (popInfo) => { + this.message = '[pushDestinationByName]last page is: ' + popInfo.info.name + ', result: ' + + JSON.stringify(popInfo.result); + }).catch((error: BusinessError) => { + console.error(`[pushDestinationByName]failed, error code = ${error.code}, error.message = ${error.message}.`); + }).then(() => { + console.error('[pushDestinationByName]success.'); + }); + }) + + Button('pushPathWithoutOnPop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + this.pageInfo.pushPath({ name: 'temp4-pageTwo', param: new ParamWithOp() }); // 将name指定的NavDestination页面信息入栈。 + }) + + Button('pushPathByNameWithoutOnPop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + this.pageInfo.pushPathByName('temp4-pageTwo', tmp); // 将name指定的NavDestination页面信息入栈,传递的数据为param。 + }) + + Button('pushDestinationWithoutOnPop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + // 将name指定的NavDestination页面信息入栈,传递的数据为param,添加接收处理结果的onPop回调。 + this.pageInfo.pushDestination({ name: 'temp4-pageTwo', param: new ParamWithOp() }) + .catch((error: BusinessError) => { + console.error(`[pushDestinationWithoutOnPop]failed, error code = ${error.code}, error.message = ${error.message}.`); + }).then(() => { + console.error('[pushDestinationWithoutOnPop]success.'); + }); + }) + + Button('pushDestinationByNameWithoutOnPop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + let tmp = new TmpClass(); + // 将name指定的NavDestination页面信息入栈,传递的数据为param。 + this.pageInfo.pushDestinationByName('temp4-pageTwo', tmp) + .catch((error: BusinessError) => { + console.error(`[pushDestinationByNameWithoutOnPop]failed, error code = ${error.code}, error.message = ${error.message}.`); + }).then(() => { + console.error('[pushDestinationByNameWithoutOnPop]success.'); + }); + }) + + Button('clear', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(10) + .onClick(() => { + this.pageInfo.clear(); // 清除栈中所有页面。 + }) + }.width('100%').height('100%') + }.title('pageOne') + .onBackPressed(() => { + this.pageInfo.pop({ number: 1 }); // 弹出路由栈栈顶元素。 + return true; + }).onReady((context: NavDestinationContext) => { + this.pageInfo = context.pathStack; + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageTwo.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..70a0015d58b24ef5d3ea3238cca95da4d6f9b3e1 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template4/PageTwo.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class ResultClass { + constructor(count: number) { + this.count = count; + } + + public count: number = 10; +} + +@Builder +export function PageTwoBuilder() { + PageTwo(); +} + +@Component +export struct PageTwo { + pathStack: NavPathStack = new NavPathStack(); + + build() { + NavDestination() { + Column() { + Button('pop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.pop(new ResultClass(1)); // 回退到上一个页面,将处理结果传入push的onPop回调中。 + }) + + Button('popToName', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.popToName('temp4-pageOne', + new ResultClass(11)); // 将第一个名为name的NavDestination页面移到栈顶,将处理结果传入push的onPop回调中。 + }) + + Button('popToIndex', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.popToIndex(0, new ResultClass(111)); // 将index指定的NavDestination页面移到栈顶,将处理结果传入push的onPop回调中。 + }) + + Button('popWithoutResult', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.pop(); + }) + + Button('popToNameWithoutResult', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.popToName('temp4-pageOne'); + }) + + Button('popToIndexWithoutResult', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.pathStack.popToIndex(0); + }) + }.width('100%').height('100%') + }.title('pageTwo') + .onBackPressed(() => { + this.pathStack.pop(new ResultClass(0)); // 回退到上一个页面,将处理结果传入push的onPop回调。 + return true; + }).onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack; + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template5/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b8f8a72f7e0c5700da2dc82b03d27a2671eedc2 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template5/Index.ets @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const COLOR1: string = "#80004AAF"; +const COLOR2: string = "#802787D9"; +const BLUR_STYLE_1: BlurStyle = BlurStyle.BACKGROUND_THIN; +const BLUR_STYLE_2: BlurStyle = BlurStyle.BACKGROUND_THICK; +const BLUR_STYLE_OPTION_1: BackgroundBlurStyleOptions = { + colorMode: ThemeColorMode.DARK, + adaptiveColor: AdaptiveColor.DEFAULT, + blurOptions: { grayscale: [20, 20] }, + scale: 1 +}; +const BLUR_STYLE_OPTION_2: BackgroundBlurStyleOptions = { + colorMode: ThemeColorMode.LIGHT, + adaptiveColor: AdaptiveColor.AVERAGE, + blurOptions: { grayscale: [20, 20] }, + scale: 1 +}; +const EFFECT_OPTION_1: BackgroundEffectOptions = { + radius: 20, + saturation: 10, + brightness: 0, + color: '#66FFFFFF', + adaptiveColor: AdaptiveColor.DEFAULT, + blurOptions: { grayscale: [0, 0] }, +}; +const EFFECT_OPTION_2: BackgroundEffectOptions = { + radius: 60, + saturation: 40, + brightness: 1, + color: '#661A1A1A', + adaptiveColor: AdaptiveColor.AVERAGE, + blurOptions: { grayscale: [20, 20] }, +}; + +@Component +struct BackComponent { + build() { + Row() { + Column() { + } + .height('100%') + .backgroundColor("#3D9DB4") + .layoutWeight(9) + + Column() { + } + .height('100%') + .backgroundColor("#17A98D") + .layoutWeight(9) + + Column() { + } + .height('100%') + .backgroundColor("#FFC000") + .layoutWeight(9) + } + .height('100%') + .width('100%') + } +} + +@Component +struct ColorAndBlur { + @State useColor1: boolean = true; + @State useBlur1: boolean = true; + @State useEffect1: boolean = true; + + build() { + NavDestination() { + Stack({ alignContent: Alignment.Center }) { + BackComponent() + .width('100%') + .height('100%') + Column() { + Stack({ alignContent: Alignment.Center }) { + Button("switch color") + .onClick(() => { + this.useColor1 = !this.useColor1; + }) + } + .width('100%') + .layoutWeight(1) + + Stack({ alignContent: Alignment.Center }) { + Button("switch blur") + .onClick(() => { + this.useBlur1 = !this.useBlur1; + }) + } + .width('100%') + .layoutWeight(1) + + Stack({ alignContent: Alignment.Center }) { + Button("switch effect") + .onClick(() => { + this.useEffect1 = !this.useEffect1; + }) + } + .width('100%') + .layoutWeight(1) + } + .width('100%') + .height('100%') + }.width('100%') + .height('100%') + } + .width('100%') + .height('100%') + // 开发者可以设置标题栏的背景颜色和背景模糊效果 + .title("Destination Title", { + backgroundColor: this.useColor1 ? COLOR1 : COLOR2, + backgroundBlurStyle: this.useBlur1 ? BLUR_STYLE_1 : BLUR_STYLE_2, + barStyle: BarStyle.STACK, + backgroundEffect: this.useEffect1 ? EFFECT_OPTION_1 : EFFECT_OPTION_2, + }) + // 开发者可以设置菜单的背景颜色和背景模糊效果 + .menus([ + { value: "A" }, + { value: "B" }, + { value: "C" }, + { value: "D" }, + ], { + moreButtonOptions: { + backgroundEffect: this.useEffect1 ? EFFECT_OPTION_1 : EFFECT_OPTION_2, + } + }) + // 开发者可以设置工具栏的背景颜色和背景模糊效果 + .toolbarConfiguration([ + { value: "A" }, + { value: "B" }, + { value: "C" }, + { value: "D" }, + { value: "E" }, + { value: "F" } + ], { + backgroundEffect: this.useEffect1 ? EFFECT_OPTION_1 : EFFECT_OPTION_2, + // 开发者可以设置工具栏的菜单的背景颜色和背景模糊效果 + moreButtonOptions: { + backgroundEffect: this.useEffect1 ? EFFECT_OPTION_1 : EFFECT_OPTION_2, + } + }) + } +} + +@Entry +@Component +struct Index { + @Provide('navPathStack') navPathStack: NavPathStack = new NavPathStack(); + @State useColor1: boolean = true; + @State useBlur1: boolean = true; + @State useBlurOption1: boolean = true; + + @Builder + PageBuilder(name: string, param?: Object) { + if (name === 'NavigationMenu') { + ColorAndBlur(); + } + } + + build() { + Navigation(this.navPathStack) { + Stack({ alignContent: Alignment.Center }) { + BackComponent() + .width('100%') + .height('100%') + Column() { + Stack({ alignContent: Alignment.Center }) { + Button("switch color") + .onClick(() => { + this.useColor1 = !this.useColor1; + }) + } + .width('100%') + .layoutWeight(1) + + Stack({ alignContent: Alignment.Center }) { + Button("switch blur") + .onClick(() => { + this.useBlur1 = !this.useBlur1; + }) + } + .width('100%') + .layoutWeight(1) + + Stack({ alignContent: Alignment.Center }) { + Button("switch blurOption") + .onClick(() => { + this.useBlurOption1 = !this.useBlurOption1; + }) + } + .width('100%') + .layoutWeight(1) + + Stack({ alignContent: Alignment.Center }) { + Button("push page") + .onClick(() => { + this.navPathStack.pushPathByName('NavigationMenu', null); + }) + } + .width('100%') + .layoutWeight(1) + } + .width('100%') + .height('80%') + }.width('100%') + .height('100%') + } + .width('100%') + .height('100%') + .navDestination(this.PageBuilder) + // 开发者可以设置标题栏的背景颜色和背景模糊效果 + .title("NavTitle", { + backgroundColor: this.useColor1 ? COLOR1 : COLOR2, + backgroundBlurStyle: this.useBlur1 ? BLUR_STYLE_1 : BLUR_STYLE_2, + barStyle: BarStyle.STACK, + backgroundBlurStyleOptions: this.useBlurOption1 ? BLUR_STYLE_OPTION_1 : BLUR_STYLE_OPTION_2, + }) + // 开发者可以设置菜单的背景颜色和背景模糊效果 + .menus([ + { value: "A" }, + { value: "B" }, + { value: "C" }, + { value: "D" }, + ], { + moreButtonOptions: { + backgroundBlurStyle: this.useBlur1 ? BLUR_STYLE_1 : BLUR_STYLE_2, + backgroundBlurStyleOptions: this.useBlurOption1 ? BLUR_STYLE_OPTION_1 : BLUR_STYLE_OPTION_2, + } + }) + // 开发者可以设置工具栏的背景颜色和背景模糊效果 + .toolbarConfiguration([ + { value: "A" }, + { value: "B" }, + { value: "C" }, + { value: "D" }, + { value: "E" }, + { value: "F" } + ], { + backgroundColor: this.useColor1 ? COLOR1 : COLOR2, + backgroundBlurStyle: this.useBlur1 ? BLUR_STYLE_1 : BLUR_STYLE_2, + // 开发者可以设置工具栏的菜单的背景颜色和背景模糊效果 + moreButtonOptions: { + backgroundBlurStyle: this.useBlur1 ? BLUR_STYLE_1 : BLUR_STYLE_2, + backgroundBlurStyleOptions: this.useBlurOption1 ? BLUR_STYLE_OPTION_1 : BLUR_STYLE_OPTION_2, + } + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a44e396338b8492352758a172ce687cdf79373d3 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/Index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavigationExample6 { + @State childNavStack: NavPathStack = new NavPathStack(); + + build() { + Navigation() { + Stack({ alignContent: Alignment.Center }) { + Navigation(this.childNavStack) { + Button('push Path to parent Navigation', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + // 可以获取父NavPathStack + let parentStack = this.childNavStack.getParent(); + parentStack?.pushPath({ name: "temp6-pageOne" }); + }) + } + .clip(true) + .backgroundColor(Color.Orange) + .width('80%') + .height('80%') + .title('ChildNavigation') + } + .width('100%') + .height('100%') + } + .backgroundColor(Color.Green) + .width('100%') + .height('100%') + .title('ParentNavigation') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/PageOne.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/PageOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f991155f128e5e907ebe6b973005f6e739bdb03 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template6/PageOne.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Builder +export function PageOneBuilder(name: string) { + NavDestination() { + Text('this is ' + name) + } + .title(name) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template7/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d79517dc0b0356ba43a89ffd168a6a71cea90e53 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template7/Index.ets @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class PageParam { + constructor(num_: number) { + this.num = num_; + } + + num: number = 0; +} + +@Builder +export function PageOneBuilder(name: string, param: Object) { + PageOne(); +} + +@Component +struct PageOne { + private stack: NavPathStack | null = null; + private name: string = ""; + private paramNum: number = 0; + + build() { + NavDestination() { + Column() { + Text("NavPathInfo: name: " + this.name + ", paramNum: " + this.paramNum) + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + if (this.stack) { + let p = new PageParam(this.paramNum + 1); + this.stack.pushPath({ name: "temp7-pageOne", param: p }); + } + }) + Button('pop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.stack?.pop(); + }) + } + .width('100%') + .height('100%') + } + .title('pageOne') + .onReady((ctx: NavDestinationContext) => { + // 在NavDestination中能够拿到传来的NavPathInfo和当前所处的NavPathStack + try { + this.name = ctx?.pathInfo?.name; + this.paramNum = (ctx?.pathInfo?.param as PageParam)?.num; + this.stack = ctx.pathStack; + } catch (e) { + console.log(`testTag onReady catch exception: ${JSON.stringify(e)}`); + } + }) + } +} + +@Entry +@Component +struct NavigationExample7 { + private stack: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.stack) { + Stack({ alignContent: Alignment.Center }) { + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + let p = new PageParam(1); + this.stack.pushPath({ name: "temp7-pageOne", param: p }); + }) + } + .width('100%') + .height('100%') + } + .width('100%') + .height('100%') + .title('Navigation') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template8/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template8/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a257ba6f88125db1b33b66fc77d3797ce0d7201f --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template8/Index.ets @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Builder +export function PageOneBuilder(name: string, param: Object) { + PageOneComponent(); +} + +@Component +struct PageOneComponent { + private stack: NavPathStack | null = null; + @State eventStr: string = ""; + + build() { + NavDestination() { + Column() { + Text("event: " + this.eventStr) + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + if (this.stack) { + this.stack.pushPath({ name: "temp8-pageOne" }); + } + }) + Button('pop', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.stack?.pop(); + }) + } + .width('100%') + .height('100%') + } + .title('pageOne') + .onAppear(() => { + this.eventStr += ""; + }) + .onDisAppear(() => { + this.eventStr += ""; + }) + .onShown(() => { + this.eventStr += ""; + }) + .onHidden(() => { + this.eventStr += ""; + }) + .onWillAppear(() => { + this.eventStr += ""; + }) + .onWillDisappear(() => { + this.eventStr += ""; + }) + .onWillShow(() => { + this.eventStr += ""; + }) + .onWillHide(() => { + this.eventStr += ""; + }) + // onReady会在onAppear之前调用 + .onReady((ctx: NavDestinationContext) => { + try { + this.eventStr += ""; + this.stack = ctx.pathStack; + } catch (e) { + console.log(`testTag onReady catch exception: ${JSON.stringify(e)}`); + } + }) + } +} + +@Entry +@Component +struct NavigationExample8 { + private stack: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.stack) { + Stack({ alignContent: Alignment.Center }) { + Button('pushPath', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + this.stack.pushPath({ name: "temp8-pageOne" }); + }) + } + .width('100%') + .height('100%') + } + .width('100%') + .height('100%') + .title('Navigation') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template9/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template9/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0719c1f732f68785386cb96c4f372b0d39b2d876 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template9/Index.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct NavigationExample9 { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + private scrollerForScroll: Scroller = new Scroller(); + @State barStyle: BarStyle = BarStyle.STANDARD; + + build() { + Column() { + Navigation() { + Column() { + Scroll(this.scrollerForScroll) { + Column() { + Image($r('app.media.image_1'))// 设置与标题栏高度一致,以便观察STACK效果 + .height(138) + .width('100%') + Button('BarStyle.STANDARD') + .height('50vp') + .onClick(() => { + this.barStyle = BarStyle.STANDARD; + }) + Button('BarStyle.STACK') + .height('50vp') + .margin({ top: 12 }) + .onClick(() => { + this.barStyle = BarStyle.STACK; + }) + + ForEach(this.arr, (item: number) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(Color.Orange) + .margin({ top: 12 }) + } + }, (item: string) => item) + } + } + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + } + .title( + { + main: 'NavTitle', + sub: 'subtitle' + }, + { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: this.barStyle, + } + ) + .titleMode(NavigationTitleMode.Free) + .hideTitleBar(false) + }.width('100%').height('100%').backgroundColor('#F1F3F5') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ec314b78be077705a4ec291b86bc72ee6a5300e --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template1/Index.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver } from '@kit.ArkUI'; + +@Component +struct PageOne { + build() { + NavDestination() { + Text("pageOne") + }.title("pageOne") + } +} + +@Entry +@Component +struct ObserverIndex1 { + private stack: NavPathStack = new NavPathStack(); + + @Builder + PageBuilder(name: string) { + PageOne() + } + + aboutToAppear() { + uiObserver.on('navDestinationUpdate', (info) => { + console.info('NavDestination state update', JSON.stringify(info)); + }); + } + + aboutToDisappear() { + uiObserver.off('navDestinationUpdate'); + } + + build() { + Column() { + Navigation(this.stack) { + Button("push").onClick(() => { + this.stack.pushPath({ name: "pageOne" }); + }) + } + .title("Navigation") + .navDestination(this.PageBuilder) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template2/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e1d5b6930a3a95c2e79976a8f6d8e45da83845a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template2/Index.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver } from '@kit.ArkUI'; + +@Component +struct PageOne { + build() { + NavDestination() { + Text("pageOne") + }.title("pageOne") + } +} + +@Entry +@Component +struct ObserverIndex2 { + private stack: NavPathStack = new NavPathStack(); + + @Builder + PageBuilder(name: string) { + PageOne() + } + + aboutToAppear() { + uiObserver.on('navDestinationUpdate', { navigationId: "testId" }, (info) => { + console.info('NavDestination state update', JSON.stringify(info)); + }); + } + + aboutToDisappear() { + uiObserver.off('navDestinationUpdate', { navigationId: "testId" }); + } + + build() { + Column() { + Navigation(this.stack) { + Button("push").onClick(() => { + this.stack.pushPath({ name: "pageOne" }); + }) + } + .id("testId") + .title("Navigation") + .navDestination(this.PageBuilder) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template3/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf2a26891dafeaba92df2ad316cc69369e1d99c0 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template3/Index.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver } from '@kit.ArkUI'; + +@Component +struct PageOne { + build() { + NavDestination() { + Text("pageOne") + }.title("pageOne") + } +} + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +@Entry +@Component +struct Index { + private stack: NavPathStack = new NavPathStack(); + + @Builder + PageBuilder(name: string) { + PageOne() + } + + aboutToAppear() { + uiObserver.on('navDestinationSwitch', this.getUIContext(), callBackFunc) + } + + aboutToDisappear() { + uiObserver.off('navDestinationSwitch', this.getUIContext(), callBackFunc) + } + + build() { + Column() { + Navigation(this.stack) { + Button("push").onClick(() => { + this.stack.pushPath({ name: "pageOne" }); + }) + } + .title("Navigation") + .navDestination(this.PageBuilder) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template4/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8131a1fefb0d403742347bddbc52dccdbf8dd106 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/observer/template4/Index.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiObserver } from '@kit.ArkUI'; + +@Component +struct PageOne { + build() { + NavDestination() { + Text("pageOne") + }.title("pageOne") + } +} + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +@Entry +@Component +struct Index { + private stack: NavPathStack = new NavPathStack(); + + @Builder + PageBuilder(name: string) { + PageOne() + } + + aboutToAppear() { + uiObserver.on('navDestinationSwitch', this.getUIContext(), { navigationId: 'myNavId' }, callBackFunc) + } + + aboutToDisappear() { + uiObserver.off('navDestinationSwitch', this.getUIContext(), { navigationId: 'myNavId' }, callBackFunc) + } + + build() { + Column() { + Navigation(this.stack) { + Button("push").onClick(() => { + this.stack.pushPath({ name: "pageOne" }); + }) + } + .id('myNavId') + .title("Navigation") + .navDestination(this.PageBuilder) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf88b980c5f179d25d7293f8d8640cf37b36b035 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/Index.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { router } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// 定义传递参数的类 +class innerParams { + array: number[]; + + constructor(tuple: number[]) { + this.array = tuple; + } +} + +class RouterParams { + public text: string; + public data: innerParams; + + constructor(str: string, tuple: number[]) { + this.text = str; + this.data = new innerParams(tuple); + } +} + +@Entry +@Component +struct Index { + async routePage() { + let options: router.RouterOptions = { + url: 'pages/router/template1/second', + params: new RouterParams('This is the value of the first page', [12, 45, 78]) + } + // 建议使用this.getUIContext().getRouter().pushUrl() + router.pushUrl(options) + .then(() => { + console.error(`pushUrl finish`); + }) + .catch((err: ESObject) => { + console.error(`pushUrl failed, code is ${(err as BusinessError).code}, message is ${(err as BusinessError).message}`); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text($r('app.string.RouterTemp1PageOne_text2')) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ top: 20 }) + .backgroundColor('#ccc') + .onClick(() => { + this.routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/second.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2972ec4eb871ef3d89c961a8ea5c2e0df35a3f44 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/router/template1/second.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { router } from '@kit.ArkUI'; + +class innerParams { + array: number[]; + + constructor(tuple: number[]) { + this.array = tuple; + } +} + +class RouterParams { + text: string; + data: innerParams; + + constructor(str: string, tuple: number[]) { + this.text = str; + this.data = new innerParams(tuple); + } +} + +@Entry +@Component +struct Second { + private content: string = 'This is the second page'; + // 建议使用this.getUIContext().getRouter().getParams() + @State text: string = (this.getUIContext().getRouter().getParams() as RouterParams).text; + @State data: object = (this.getUIContext().getRouter().getParams() as RouterParams).data; + @State secondData: string = ''; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text(this.text) + .fontSize(30) + .onClick(() => { + this.secondData = (this.data['array'][1]).toString(); + }) + .margin({ top: 20 }) + Text(`The value transmitted from the first page:${this.secondData}`) + .fontSize(20) + .margin({ top: 20 }) + .backgroundColor('red') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/sideBarContainer/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/sideBarContainer/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b210474fd56719675c9180a0d02eba5b48faa2d --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/sideBarContainer/template1/Index.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SideBarContainerExample { + normalIcon: Resource = $r('app.media.icon'); + selectedIcon: Resource = $r('app.media.icon'); + @State arr: number[] = [1, 2, 3]; + @State current: number = 1; + + build() { + SideBarContainer(SideBarContainerType.Embed) { + Column() { + ForEach(this.arr, (item: number) => { + Column({ space: 5 }) { + Image(this.current === item ? this.selectedIcon : this.normalIcon).width(64).height(64) + Text('Index0' + item) + .fontSize(25) + .fontColor(this.current === item ? '#0A59F7' : '#999') + .fontFamily('source-sans-pro,cursive,sans-serif') + } + .onClick(() => { + this.current = item; + }) + }, (item: string) => item) + }.width('100%') + .justifyContent(FlexAlign.SpaceEvenly) + .backgroundColor('#19000000') + + Column() { + Text('SideBarContainer content text1').fontSize(25) + Text('SideBarContainer content text2').fontSize(25) + } + .margin({ top: 50, left: 20, right: 30 }) + } + .controlButton({ + icons: { + hidden: $r('app.media.drawer'), + shown: $r('app.media.drawer'), + switching: $r('app.media.drawer') + } + }) + .sideBarWidth(150) + .minSideBarWidth(50) + .maxSideBarWidth(300) + .minContentWidth(0) + .onChange((value: boolean) => { + console.info('status:' + value); + }) + .divider({ strokeWidth: '1vp', color: Color.Gray, startMargin: '4vp', endMargin: '4vp' }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/stepper/template1/Index.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/stepper/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c982dec45c7f29dfc3f62808be8efab8cd7bb663 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/stepper/template1/Index.ets @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Styles function itemStyle () { + .width(336) + .height(621) + .margin({ top: 48, left: 12 }) + .borderRadius(24) + .backgroundColor('#FFFFFF') +} + +@Extend(Text) function itemTextStyle () { + .fontColor('#182431') + .fontSize(36) + .fontWeight(500) + .opacity(0.4) + .margin({ top: 82, bottom: 40 }) +} + +@Entry +@Component +struct StepperExample { + @State currentIndex: number = 0; + @State firstState: ItemState = ItemState.Normal; + @State secondState: ItemState = ItemState.Normal; + @State thirdState: ItemState = ItemState.Normal; + + build() { + Stepper({ + index: this.currentIndex + }) { + // 第一个步骤页 + StepperItem() { + Column() { + Text('Page One') + .itemTextStyle() + Button('change status:' + this.firstState) + .backgroundColor('#007dFF') + .onClick(() => { + this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip; + }) + }.itemStyle() + } + .nextLabel('Next') + .status(this.firstState) + // 第二个步骤页 + StepperItem() { + Column() { + Text('Page Two') + .itemTextStyle() + Button('change status:' + this.secondState) + .backgroundColor('#007dFF') + .onClick(() => { + this.secondState = this.secondState === ItemState.Disabled ? ItemState.Normal : ItemState.Disabled; + }) + }.itemStyle() + } + .nextLabel('Next') + .prevLabel('Previous') + .status(this.secondState) + // 第三个步骤页 + StepperItem() { + Column() { + Text('Page Three') + .itemTextStyle() + Button('change status:' + this.thirdState) + .backgroundColor('#007dFF') + .onClick(() => { + this.thirdState = this.thirdState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting; + }) + }.itemStyle() + } + .status(this.thirdState) + // 第四个步骤页 + StepperItem() { + Column() { + Text('Page Four') + .itemTextStyle() + }.itemStyle() + } + } + .backgroundColor('#F1F3F5') + .onFinish(() => { + // 此处可处理点击最后一页的Finish时的逻辑,例如路由跳转等 + console.info('onFinish'); + }) + .onSkip(() => { + // 此处可处理点击跳过时的逻辑,例如动态修改Stepper的index值使其跳转到某一步骤页等 + console.info('onSkip'); + }) + .onChange((prevIndex?: number, index?: number) => { + if(index){ + this.currentIndex = index; + } + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/Navigation/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..da837d9dff274a7a471ee1fbf79e711cd1286493 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "routerMap": "$profile:route_map", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "orientation": "auto_rotation", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json rename to code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/color.json diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/float.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/float.json @@ -0,0 +1,17 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, { + "name": "size_16", + "value": "16" + }, { + "name": "size_100", + "value": "100" + }, { + "name": "size_64", + "value": "64" + } + ] +} diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e6d55d0077b463017744340ce5b525aa4868214a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/element/string.json @@ -0,0 +1,130 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Navigation" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, { + "name": "please_click_button", + "value": "请点击按钮" + }, { + "name": "PageOneBuilder_text1", + "value": "返回值" + }, { + "name": "navStackTemp1PageOne_text1", + "value": "点击向内查找" + }, { + "name": "navStackTemp1PageOne_text2", + "value": "向内查找的NavDestination是" + }, { + "name": "navStackTemp1PageOne_text3", + "value": "点击向外查找" + }, { + "name": "navStackTemp1PageOne_text4", + "value": "向外查找的NavDestination是" + }, { + "name": "RouterTemp1PageOne_text1", + "value": "这是第一页的值" + }, { + "name": "RouterTemp1PageOne_text2", + "value": "这是第一页" + }, { + "name": "RouterTemp1PageOne_text3", + "value": "这是第二页" + }, { + "name": "RouterTemp1PageOne_text4", + "value": "向外查找的NavDestination是" + }, { + "name": "stepperIndex_text1", + "value": "示例1(Navigation页面布局)" + }, { + "name": "stepperIndex_text2", + "value": "示例2(使用路由栈方法)" + }, { + "name": "stepperIndex_text3", + "value": "示例3(设置可交互转场动画)" + }, { + "name": "stepperIndex_text4", + "value": "示例4(Navigation带参返回)" + }, { + "name": "stepperIndex_text5", + "value": "示例5(设置背景颜色和模糊效果)" + }, { + "name": "stepperIndex_text6", + "value": "示例6(嵌套场景下获取外层栈)" + }, { + "name": "stepperIndex_text7", + "value": "示例7(通过onReady获取栈)" + }, { + "name": "stepperIndex_text8", + "value": "示例8(NavDestination生命周期时序)" + }, { + "name": "stepperIndex_text9", + "value": "示例9(标题栏布局效果)" + }, { + "name": "stepperIndex_text10", + "value": "示例10(定义路由栈派生类)" + }, { + "name": "stepperIndex_text11", + "value": "示例11(使用Symbol组件)" + }, { + "name": "stepperIndex_text12", + "value": "示例12(设置自定义标题栏边距)" + }, { + "name": "stepperIndex_text13", + "value": "示例13(自定义转场动画)" + }, { + "name": "stepperIndex_text14", + "value": "示例1(标题栏工具栏与可滚动类组件联动)" + }, { + "name": "stepperIndex_text15", + "value": "示例2(设置NavDestination自定义转场)" + }, { + "name": "stepperIndex_text16", + "value": "示例3(设置指定的NavDestination系统转场)" + }, { + "name": "stepperIndex_text17", + "value": "示例4(NavDestination配置页面方向和对应状态栏、导航条显隐)" + }, { + "name": "stepperIndex_text18", + "value": "无感监听" + }, { + "name": "stepperIndex_text19", + "value": "uiObserver.on('navDestinationUpdate')指定监听" + }, { + "name": "stepperIndex_text20", + "value": "uiObserver.on('navDestinationSwitch')指定监听" + }, { + "name": "stepperIndex_text21", + "value": "示例1" + }, { + "name": "stepperIndex_text22", + "value": "NavPathStack派生类" + }, { + "name": "stepperIndex_text23", + "value": "基于TS扩展的声明式开发范式" + }, { + "name": "stepperIndex_text24", + "value": "返回" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/bg.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/bg.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/book.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/book.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/drawer.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/drawer.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/forest.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/forest.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/heart.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/heart.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_health_heart.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlights.svg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlights.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collect + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/ic_public_highlightsed.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collected + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon_2.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/icon_2.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image_1.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/image_1.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/img_1.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/mountain.jpg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/r.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/r.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sky.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sky.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sun.jpg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/sun.jpg differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/test.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/test.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImage.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImg.jpg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image1.jpg b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image2.png b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/tree.JPG b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/media/tree.JPG differ diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..e923d9d6d4dd7e4c5bedbc01e1231cb8fb528876 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,31 @@ +{ + "src": [ + "pages/Index", + "pages/navigation/template1/Index", + "pages/navigation/template2/Index", + "pages/navigation/template3/Index", + "pages/navigation/template4/Index", + "pages/navigation/template5/Index", + "pages/navigation/template6/Index", + "pages/navigation/template7/Index", + "pages/navigation/template8/Index", + "pages/navigation/template9/Index", + "pages/navigation/template10/Index", + "pages/navigation/template11/Index", + "pages/navigation/template12/Index", + "pages/navigation/template13/Index", + "pages/navDestination/template1/Index", + "pages/navDestination/template2/Index", + "pages/navDestination/template3/Index", + "pages/navDestination/template4/Index", + "pages/stepper/template1/Index", + "pages/sideBarContainer/template1/Index", + "pages/router/template1/Index", + "pages/router/template1/second", + "pages/observer/template1/Index", + "pages/observer/template2/Index", + "pages/observer/template3/Index", + "pages/observer/template4/Index", + "pages/navPathStackExtend/template1/Index" + ] +} diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/route_map.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/route_map.json new file mode 100644 index 0000000000000000000000000000000000000000..1f199474477f30766abe1cfe84b4d018eb56e5c2 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/base/profile/route_map.json @@ -0,0 +1,76 @@ +{ + "routerMap": [ + { + "name": "pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template2/PageOne.ets", + "buildFunction": "PageOneBuilder", + "data": { + "description": "this is pageOne" + } + }, + { + "name": "pageTwo", + "pageSourceFile": "src/main/ets/pages/navigation/template2/PageTwo.ets", + "buildFunction": "PageTwoBuilder" + }, + { + "name": "temp3-pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template3/PageOne.ets", + "buildFunction": "PageOneBuilder", + "data": { + "description": "this is pageOne" + } + }, + { + "name": "temp3-pageTwo", + "pageSourceFile": "src/main/ets/pages/navigation/template3/PageTwo.ets", + "buildFunction": "PageTwoBuilder" + }, + { + "name": "temp4-pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template4/PageOne.ets", + "buildFunction": "PageOneBuilder", + "data": { + "description": "this is pageOne" + } + }, + { + "name": "temp4-pageTwo", + "pageSourceFile": "src/main/ets/pages/navigation/template4/PageTwo.ets", + "buildFunction": "PageTwoBuilder" + }, + { + "name": "temp6-pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template6/PageOne.ets", + "buildFunction": "PageOneBuilder" + }, + { + "name": "temp7-pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template7/Index.ets", + "buildFunction": "PageOneBuilder" + }, + { + "name": "temp8-pageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template8/Index.ets", + "buildFunction": "PageOneBuilder" + }, + { + "name": "temp13-PageOne", + "pageSourceFile": "src/main/ets/pages/navigation/template13/Index.ets", + "buildFunction": "PageOneBuilder", + "data": { + "description": "this is pageOne" + } + }, + { + "name": "temp13-PageTwo", + "pageSourceFile": "src/main/ets/pages/navigation/template13/Index.ets", + "buildFunction": "PageTwoBuilder" + }, + { + "name": "navPath-pageOne", + "pageSourceFile": "src/main/ets/pages/navPathStackExtend/template1/PageOne.ets", + "buildFunction": "PageOneBuilder" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkUISample/Navigation/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd2cc64571570195f8f1c8245af16d4b4f5ffe41 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + /* + * @tc.number: Navigation_assertContain + * @tc.name: Test ability + * @tc.desc: Test ability + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + hilog.info(0x0000, 'testTag', '%{public}s', 'it end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f89fa7b508ac03ac4faefad49c3b73ce436c8d0 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { RouterTest } from './Router.test'; +import { NavigationTest } from './Navigation.test'; +import { NavDestinationTest } from './NavDestination.test'; +import { SideBarContainerTest } from './SideBarContainer.test'; +import { StepperTest } from './Stepper.test'; +import { UiObserverTest } from './UiObserver.test'; +import { QueryNavDestinationInfoTest } from './QueryNavDestinationInfo.test'; + +export default function testsuite() { + RouterTest(); + NavigationTest(); + NavDestinationTest(); + SideBarContainerTest(); + StepperTest(); + UiObserverTest(); + QueryNavDestinationInfoTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/NavDestination.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/NavDestination.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3da19c25029b4f019911a3abd740f59043792fa --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/NavDestination.test.ets @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +let aimComponent : Component + +export function NavDestinationTest() { + describe('Navigation_NavDestinationTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('NavDestination')); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_NavDestinationTest_001 + * @tc.name: example_one_NavDestination + * @tc.desc: example_one_NavDestination + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavDestinationTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text14')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push PageTwo')) + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.6356) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.459) + let startY2 = Math.floor(size.y * 0.883) + let endY2 = Math.floor(size.y * 0.353) + + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(endX, endY, startX, startY); + await driver.delayMs(1000); + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(endX, endY, startX, startY); + await driver.delayMs(1000); + + await driver.pressBack(); + + aimComponent = await driver.findComponent(ON.text('push PageOne')) + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(endX, endY, startX, startY); + await driver.delayMs(1000); + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(startX, startY2, endX, endY2); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_001_end'); + }) + + /* + * @tc.number: Navigation_NavDestinationTest_002 + * @tc.name: example_two_NavDestination + * @tc.desc: example_two_NavDestination + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavDestinationTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text15')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push next page')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.text('push next page')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_002_end'); + }) + + /* + * @tc.number: Navigation_NavDestinationTest_003 + * @tc.name: example_three_NavDestination + * @tc.desc: example_three_NavDestination + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavDestinationTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text16')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('fade')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('explode')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('slide right')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('slide bottom')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_003_end'); + }) + + /* + * @tc.number: Navigation_NavDestinationTest_004 + * @tc.name: example_four_NavDestination + * @tc.desc: example_four_NavDestination + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavDestinationTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text17')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push LANDSCAPE page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push PORTRAIT page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push LANDSCAPE page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push PORTRAIT page')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavDestinationTest_004_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Navigation.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Navigation.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..38818f411f9ebf72db1af19bcc3b0575914bd386 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Navigation.test.ets @@ -0,0 +1,548 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function NavigationTest() { + describe('Navigation_NavigationTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('Navigation')); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_NavigationTest_001 + * @tc.name: example_one_Navigation + * @tc.desc: example_one_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text1')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('TitleBar')) + expect(aimComponent) + + aimComponent = await driver.findComponent(ON.type('ToolBar')) + expect(aimComponent) + + aimComponent = await driver.findComponent(ON.type('NavBarContent')) + expect(aimComponent) + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_001_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_002 + * @tc.name: example_two_Navigation + * @tc.desc: example_two_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text2')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPathByName')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('NavIndex')) + expect(aimComponent) + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_002_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_003 + * @tc.name: example_three_Navigation + * @tc.desc: example_three_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text3')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPathByName')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPathByName')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPathByName')) + await aimComponent.click(); + await driver.delayMs(2000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(2000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_003_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_004 + * @tc.name: example_four_Navigation + * @tc.desc: example_four_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text4')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('StartTest')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pop')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.pressBack(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_004_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_005 + * @tc.name: example_five_Navigation + * @tc.desc: example_five_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text5')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch color')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch blur')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch blurOption')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch color')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch blur')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('switch effect')) + await aimComponent.click(); + await driver.delayMs(1000); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_005_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_006 + * @tc.name: example_six_Navigation + * @tc.desc: example_six_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text6')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Button')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_006_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_007 + * @tc.name: example_seven_Navigation + * @tc.desc: example_seven_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text7')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_007_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_008 + * @tc.name: example_eight_Navigation + * @tc.desc: example_eight_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_008', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_008_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text8')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPath')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_008_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_009 + * @tc.name: example_nine_Navigation + * @tc.desc: example_nine_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_009', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_009_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text9')))); + await aimComponent.click(); + await driver.delayMs(1000); + + let size = await driver.getDisplaySize() + let startX = Math.floor(size.x * 0.5) + let startY = Math.floor(size.y * 0.565) + let endX = Math.floor(size.x * 0.5) + let endY = Math.floor(size.y * 0.21186) + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(endX, endY, startX, startY); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('BarStyle.STACK')); + await aimComponent.click(); + await driver.delayMs(1000); + + await driver.swipe(startX, startY, endX, endY); + await driver.delayMs(1000); + await driver.swipe(endX, endY, startX, startY); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_009_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_010 + * @tc.name: example_ten_Navigation + * @tc.desc: example_ten_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_010', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_010_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text10')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('to Page One')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('to Page One')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('to Page One')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_010_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_011 + * @tc.name: example_eleven_Navigation + * @tc.desc: example_eleven_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_011', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_011_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text11')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('跳转')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_011_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_012 + * @tc.name: example_twelve_Navigation + * @tc.desc: example_twelve_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_012', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_012_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text12')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('apply padding 20vp')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('apply padding 32vp')); + await aimComponent.click(); + await driver.delayMs(1000); + + let Toggles = await driver.findComponents(ON.type('Toggle')); + await Toggles[0].click(); + await driver.delayMs(1000); + await Toggles[1].click(); + await driver.delayMs(1000); + await Toggles[1].click(); + await driver.delayMs(1000); + await Toggles[0].click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pushPage')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('apply padding 20vp')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('apply padding 32vp')); + await aimComponent.click(); + await driver.delayMs(1000); + + Toggles = await driver.findComponents(ON.type('Toggle')); + await Toggles[0].click(); + await driver.delayMs(1000); + await Toggles[1].click(); + await driver.delayMs(1000); + await Toggles[1].click(); + await driver.delayMs(1000); + await Toggles[0].click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_012_end'); + }) + + /* + * @tc.number: Navigation_NavigationTest_013 + * @tc.name: example_thirteen_Navigation + * @tc.desc: example_thirteen_Navigation + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'NavigationTest_013', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_013_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text13')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push next page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push next page')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('BackButton')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_NavigationTest_013_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/QueryNavDestinationInfo.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/QueryNavDestinationInfo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9adecfa45bed9f8d6559aa93e84e7eb5cb7c7f10 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/QueryNavDestinationInfo.test.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +let aimComponent : Component + +export function QueryNavDestinationInfoTest() { + describe('Navigation_QueryNavDestinationInfoTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text22')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_QueryNavDestinationInfoTest_001 + * @tc.name: example_one_QueryNavDestinationInfo + * @tc.desc: example_one_QueryNavDestinationInfo + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'QueryNavDestinationInfoTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_QueryNavDestinationInfoTest_001_begin'); + aimComponent = await driver.findComponent(ON.text('queryNavDestinationInfo18+')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('pageOne')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.navStackTemp1PageOne_text1')))) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.navStackTemp1PageOne_text3')))) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_QueryNavDestinationInfoTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Router.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Router.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7ed999d6b32dce33ba4474b1d50b9a523652864 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Router.test.ets @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function RouterTest() { + describe('Navigation_RouterTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('Router')); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_RouterTest_001 + * @tc.name: example_one_Router + * @tc.desc: example_one_Router + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'RouterTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_RouterTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text23')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('next page')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_RouterTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/SideBarContainer.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/SideBarContainer.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3eab563452fc65818ecb547e924a138ea3e987e2 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/SideBarContainer.test.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function SideBarContainerTest() { + describe('Navigation_SideBarContainerTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('SideBarContainer')); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_SideBarContainerTest_001 + * @tc.name: example_one_SideBarContainer + * @tc.desc: example_one_SideBarContainer + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'SideBarContainerTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_SideBarContainerTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text21')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Button')); + await aimComponent.click(); + await driver.delayMs(1000); + aimComponent = await driver.findComponent(ON.text('Index01')) + expect(aimComponent).assertNull(); + + aimComponent = await driver.findComponent(ON.type('Button')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Index01')) + expect(aimComponent) + + aimComponent = await driver.findComponent(ON.text('Index02')) + await aimComponent.click() + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Index03')) + await aimComponent.click() + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Index01')) + await aimComponent.click() + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_SideBarContainerTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Stepper.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Stepper.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..72e028fb342905aae1469b9cfd46e4cd74f82562 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/Stepper.test.ets @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function StepperTest() { + describe('Navigation_StepperTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('Stepper')); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_StepperTest_001 + * @tc.name: example_one_Stepper + * @tc.desc: example_one_Stepper + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'StepperTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_StepperTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text21')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Next')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change status:0')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change status:1')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('Next')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change status:0')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change status:2')); + await aimComponent.click(); + await driver.delayMs(1500); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text24')))); + await aimComponent.click(); + await driver.delayMs(1500); + + aimComponent = await driver.findComponent(ON.text('Previous')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_StepperTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/UiObserver.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/UiObserver.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d439e1cfe8813df328f155174a0f94fc279ba1f --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/ets/test/UiObserver.test.ets @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'Navigation_' +const TAG = '[Sample_Navigation_]'; +const DOMAIN = 0xF811 +let resourceManager = delegator.getAppContext().resourceManager; +const driver = Driver.create(); + +let aimComponent : Component + +export function UiObserverTest() { + describe('Navigation_UiObserverTest', () => { + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.navigation', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text18')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('Index')); + do { + await driver.pressBack(); + await driver.delayMs(1000); + aimComponent = await driver.findComponent(ON.text('Index')); + } while (aimComponent == null) + }) + + /* + * @tc.number: Navigation_UiObserverTest_001 + * @tc.name: example_one_UiObserver + * @tc.desc: example_one_UiObserver + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UiObserverTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_001_begin'); + aimComponent = await driver.findComponent(ON.text("uiObserver.on('navDestinationUpdate')")); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_001_end'); + }) + + /* + * @tc.number: Navigation_UiObserverTest_002 + * @tc.name: example_two_UiObserver + * @tc.desc: example_two_UiObserver + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UiObserverTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text19')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push')); + await aimComponent.click(); + await driver.delayMs(1000); + await driver.pressBack(); + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_002_end'); + }) + + /* + * @tc.number: Navigation_UiObserverTest_003 + * @tc.name: example_three_UiObserver + * @tc.desc: example_three_UiObserver + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UiObserverTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_003_begin'); + aimComponent = await driver.findComponent(ON.text("uiObserver.on('navDestinationSwitch')")); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_003_end'); + }) + + /* + * @tc.number: Navigation_UiObserverTest_004 + * @tc.name: example_four_UiObserver + * @tc.desc: example_four_UiObserver + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UiObserverTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.stepperIndex_text20')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('push')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'Navigation_UiObserverTest_004_end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cafc28b86d7d9f2b34f24d26a75c0dbd7299715 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/test/List.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkUISample/Navigation/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/Navigation/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2d5b53c87bb8c7e5a38072d17a6e9b9533003301 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.1.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/ArkUISample/Navigation/hvigorfile.ts b/code/DocsSample/ArkUISample/Navigation/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/Navigation/oh-package.json5 b/code/DocsSample/ArkUISample/Navigation/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b56a095f3819541cf150766a67ff7e23a23973a9 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.1.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkUISample/Navigation/ohosTest.md b/code/DocsSample/ArkUISample/Navigation/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..c42ba5654c47e8f6570d730019bda8c0b1f4f3f5 --- /dev/null +++ b/code/DocsSample/ArkUISample/Navigation/ohosTest.md @@ -0,0 +1,12 @@ +# Navigation 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| Navigation示例代码验证 | 设备正常运行 | 进入各个示例页面,push页面然后返回 | 页面跳转、动画、布局均正常 | 是 | Pass | +| NavDestination示例代码验证 | 设备正常运行 | 进入各个示例页面,push页面然后返回 | 页面跳转、动画、布局均正常 | 是 | Pass | +| NavPathStack派生类示例代码验证 | 设备正常运行 | 进入各个示例页面,push页面然后查询页面栈 | 页面栈内容和实际效果一致 | 是 | Pass | +| 无感监听示例代码验证 | 设备正常运行 | 点击页面跳转按钮 | 页面跳转正常 | 是 | Pass | +| SideBarContainer示例代码验证 | 设备正常运行 | 进入各个示例页面,点击不同的索引 | 页面切换正常 | 是 | Pass | +| Stepper派生类示例代码验证 | 设备正常运行 | 点击status,然后再点击下一页 | 页面切换正常 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/Navigation/screenshots/device/image1.png b/code/DocsSample/ArkUISample/Navigation/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..0b1381f86b58ea6484f2f70e6a03e8f979354e1b Binary files /dev/null and b/code/DocsSample/ArkUISample/Navigation/screenshots/device/image1.png differ diff --git a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/README_zh.md b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/README_zh.md index bf3bfa428ba384a2a8dcb85424d50534430a708b..d908520ba43cff70f8d3d1b7195c130702a0f184 100644 --- a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/README_zh.md +++ b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/README_zh.md @@ -47,6 +47,7 @@ entry/src/main/ets/ | | |---Index.ets | | |---UIExtension.ets | |---UniversalAttributesAccessibility // ArkUI 无障碍能力 +| | |---AccessibilityFocusDrawLevel.ets | | |---AccessibilityGroup.ets | | |---AccessibilityText.ets | | |---Index.ets @@ -71,7 +72,7 @@ entry/src/ohosTest/ 1.本示例仅支持标准系统上运行, 支持设备:RK3568。 -2.本示例为Stage模型,支持API18版本SDK,版本号:5.1.0.59,镜像版本号:OpenHarmony_5.1.0.59。 +2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.35,镜像版本号:OpenHarmony_6.0.0.35。 3.本示例需要使用DevEco Studio 5.0.3 Release (Build Version: 5.0.9.300, built on March 13, 2025)及以上版本才可编译运行。 diff --git a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/build-profile.json5 b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/build-profile.json5 index 0d4a03d0a707b773d4ef140121aa0f45bdcd67fe..fd5f8c19c18e0b5ac81bbcf11fb00b500626eb24 100644 --- a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/build-profile.json5 +++ b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/build-profile.json5 @@ -21,9 +21,9 @@ "name": "default", "signingConfig": "default", "runtimeOS": "OpenHarmony", - "compileSdkVersion": 18, - "compatibleSdkVersion": 18, - "targetSdkVersion": 18, + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "targetSdkVersion": 20, "buildOption": { "strictMode": { "caseSensitiveCheck": true diff --git a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityFocusDrawLevel.ets b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityFocusDrawLevel.ets new file mode 100644 index 0000000000000000000000000000000000000000..0fb40fb43ee987ea899c6392fe03465b851f6907 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityFocusDrawLevel.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ComponentContent } from '@kit.ArkUI'; + +class Params { +} + +@Builder +function loadingBuilder(params: Params) { + Column() { + LoadingProgress() + .color(Color.Blue) + } +} + +@Component +export struct AccessibilityFocusDrawLevel { + private contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(loadingBuilder), new Params); + + build() { + NavDestination() { + Row() { + List() { + ListItem() { + Column() { + Stack() { + Column() { + Text($r('app.string.UniversalAttributesAccessibility_text5')) + Text($r('app.string.UniversalAttributesAccessibility_text5')) + .accessibilityFocusDrawLevel(FocusDrawLevel.TOP) + } + + Column() { + Text($r('app.string.UniversalAttributesAccessibility_text6')) + .backgroundColor(Color.Gray) + Text($r('app.string.UniversalAttributesAccessibility_text6')) + .backgroundColor(Color.Gray) + } + } + + Column() { + Text($r('app.string.UniversalAttributesAccessibility_text9')) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + UIExtensionComponent({ + bundleName: 'com.example.provide', + abilityName: 'EmptyUIExtensionAbility', + parameters: { + 'ability.want.params.uiExtensionType': 'sys/commonUI' + } + }, + { + placeholder: this.contentNode, + dpiFollowStrategy: DpiFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_DPI + }) + .onReceive((err) => { + console.error('onReceive' + JSON.stringify(err)); + }) + .onError((err) => { + console.error('onError code :' + err.code + ', name: ' + err.name + ', msg: ' + err.message); + console.error('onError' + JSON.stringify(err)); + }) + .accessibilityUseSamePage(AccessibilitySamePageMode.FULL_SILENT) + .width('50%') + .height('50%') + .backgroundColor(Color.Pink) + } + } + .width('100%') + .height('100%') + .accessibilityText($r('app.string.UniversalAttributesAccessibility_text7')) + .accessibilityDescription($r('app.string.UniversalAttributesAccessibility_text8')) + + Column() { + Text($r('app.string.UniversalAttributesAccessibility_text10')) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + } + } + }.accessibilityScrollTriggerable(false) + } + .height('100%') + } + .backgroundColor('#f1f2f3') + .title($r('app.string.UniversalAttributesAccessibility_title3')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets index 6c294c94540b89811646ab92365bd59fc6d1035e..c2e1ea6f42c9006675b55426933c4b9b3ffefa61 100644 --- a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets +++ b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets @@ -17,6 +17,7 @@ import { CompletedRoutableCard } from '../../common/Card' import { Route } from '../../common/Route' import { AccessibilityText } from './AccessibilityText' import { AccessibilityGroup } from './AccessibilityGroup' +import { AccessibilityFocusDrawLevel } from './AccessibilityFocusDrawLevel' import resource from '../../common/resource' export const ACCESSIBILITY_ROUTE_PREFIX: string = 'UniversalAttributesAccessibility'; @@ -31,6 +32,11 @@ const routes: Route[] = [ name: `${ACCESSIBILITY_ROUTE_PREFIX}/AccessibilityGroup`, title: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_title2')), description: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_description2')), + }, + { + name: `${ACCESSIBILITY_ROUTE_PREFIX}/AccessibilityFocusDrawLevel`, + title: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_title3')), + description: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_description3')), } ]; @@ -42,6 +48,8 @@ export function AccessibilityDestination(name: string) { AccessibilityText(); } else if (name == routes[1].name) { AccessibilityGroup(); + } else if (name == routes[2].name) { + AccessibilityFocusDrawLevel(); } } diff --git a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/resources/base/element/string.json index 83d34a5137a2312b8855bbe7b0fe9385b7a29188..cf91256a5866dcd5dfd7a3c0a521726f20edbcec 100644 --- a/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/resources/base/element/string.json +++ b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/resources/base/element/string.json @@ -60,6 +60,10 @@ "name": "UniversalAttributesAccessibility_title2", "value": "使用无障碍属性 2" }, + { + "name": "UniversalAttributesAccessibility_title3", + "value": "使用无障碍属性 3" + }, { "name": "Embedded_Component_description", "value": "展示 EmbeddedComponent 组件的基础使用方式" @@ -84,6 +88,10 @@ "name": "UniversalAttributesAccessibility_description2", "value": "设置无障碍组" }, + { + "name": "UniversalAttributesAccessibility_description3", + "value": "设置无障碍焦点绿框绘制层级" + }, { "name": "UIExtensionComponent_button1", "value": "点击向Component发送数据" @@ -139,6 +147,14 @@ { "name": "UniversalAttributesAccessibility_text8", "value": "Column组件可以被选中,播报的内容是“分组”" + }, + { + "name": "UniversalAttributesAccessibility_text9", + "value": "文本3" + }, + { + "name": "UniversalAttributesAccessibility_text10", + "value": "文本4" } ] } \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/.gitignore b/code/DocsSample/ArkUISample/VisionEffect/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/AppScope/app.json5 b/code/DocsSample/ArkUISample/VisionEffect/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9924f317ee3a649bf56499f4ce8e35719ecab181 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.visionEffect", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..42c7546de5d951e8d23adbe2f47bd87ff07d7adf --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "VisionEffect" + } + ] +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/background.png b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/README_zh.md b/code/DocsSample/ArkUISample/VisionEffect/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6430883789b0ff341dbaba95e6dc417acac7592c --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/README_zh.md @@ -0,0 +1,185 @@ +# ArkUI使用视效组件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [图形变换](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-transformation.md)。 +2. [透明度设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-opacity.md)。 +3. [形状裁剪](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-sharp-clipping.md)。 +4. [图像效果](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-image-effect.md) +5. [背景设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-background.md) +6. [组件内容模糊](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-blur-style.md) +7. [前景色设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-color.md) +8. [点击回弹效果](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-click-effect.md) +9. [特效绘制合并](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-use-effect.md) +10. [组件内容填充方式](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-renderfit.md) +11. [外描边设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-outline.md) +12. [运动模糊](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-motionBlur.md) +13. [颜色渐变](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-gradient-color.md) +14. [前景属性设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-foreground-effect.md) +15. [视效设置](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-attributes-filter-effect.md) + + +### 效果预览 + +| 首页 | +|------------------------------------| +| ![](screenshots/device/image1.png) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---background // 背景设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| |---clickEffect // 点击回弹效果 +| | |---template1 +| | | |---Index.ets +| |---clip // 形状裁剪 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---foregroundBlurStyle // 组件内容模糊 +| | |---template1 +| | | |---Index.ets +| |---foregroundColor // 前景色设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---foregroundEffect // 前景属性设置 +| | |---template1 +| | | |---Index.ets +| |---imageEffect // 图像效果 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| | |---template4 +| | | |---Index.ets +| | |---template5 +| | | |---Index.ets +| | |---template6 +| | | |---Index.ets +| | |---template7 +| | | |---Index.ets +| | |---template8 +| | | |---Index.ets +| | |---template9 +| | | |---Index.ets +| | |---template10 +| | | |---Index.ets +| |---linearGradient // 颜色渐变 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---motionBlur // 运动模糊 +| | |---template1 +| | | |---Index.ets +| |---opacity // 透明度设置 +| | |---template1 +| | | |---Index.ets +| |---outline // 外描边设置 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| |---renderFit // 组件内容填充方式 +| | |---template1 +| | | |---Index.ets +| |---transform // 图形变换 +| | |---template1 +| | | |---Index.ets +| | |---template2 +| | | |---Index.ets +| | |---template3 +| | | |---Index.ets +| |---useEffect // 特效绘制合并 +| | |---template1 +| | | |---Index.ets +| |---visualEffect // 视效设置 +| | |---template1 +| | | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---test +| | |---Background.test.ets // 背景设置示例代码测试代码 +| | |---ClickEffect.test.ets // 点击回弹效果示例代码测试代码 +| | |---Clip.test.ets // 形状裁剪示例代码测试代码 +| | |---ForegroundBlurStyle.test.ets // 组件内容模糊示例代码测试代码 +| | |---ForegroundColor.test.ets // 前景色设置示例代码测试代码 +| | |---ForegroundEffect.test.ets // 前景属性设置示例代码测试代码 +| | |---ImageEffect.test.ets // 图像效果示例代码测试代码 +| | |---LinearGradient.test.ets // 颜色渐变示例代码测试代码 +| | |---MotionBlur.test.ets // 运动模糊示例代码测试代码 +| | |---Opacity.test.ets // 透明度设置示例代码测试代码 +| | |---OutLine.test.ets // 外描边设置示例代码测试代码 +| | |---RenderFit.test.ets // 组件内容填充方式示例代码测试代码 +| | |---Transform.test.ets // 图形变换示例代码测试代码 +| | |---UseEffect.test.ets // 特效绘制合并示例代码测试代码 +| | |---VisualEffect.test.ets // 视效设置示例代码测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API18版本SDK,版本号:5.1.0.56,镜像版本号:OpenHarmony_5.1.0.56。 + +3.本示例需要使用DevEco Studio 6.0.0 Canary1 (Build Version: 6.0.0.270, built on May 9, 2025)及以上版本才可编译运行。 + + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/VisionEffect > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +```` \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/build-profile.json5 b/code/DocsSample/ArkUISample/VisionEffect/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e1244ceecbe969910aa0eb4f5ec4543c58ee4225 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/build-profile.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "20", + "compatibleSdkVersion": "20", + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/code-linter.json5 b/code/DocsSample/ArkUISample/VisionEffect/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/code-linter.json5 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/.gitignore b/code/DocsSample/ArkUISample/VisionEffect/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/build-profile.json5 b/code/DocsSample/ArkUISample/VisionEffect/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/hvigorfile.ts b/code/DocsSample/ArkUISample/VisionEffect/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/obfuscation-rules.txt b/code/DocsSample/ArkUISample/VisionEffect/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/oh-package.json5 b/code/DocsSample/ArkUISample/VisionEffect/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..081b700cacec6def24d204fbc37ab93985f7b4ec --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { display, uiObserver, window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +function callBackFunc(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +function callBackFunc2(info: uiObserver.NavDestinationSwitchInfo) { + console.info(`testTag2 navDestinationSwitch from: ${JSON.stringify(info.from)} to: ${JSON.stringify(info.to)}`) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + uiObserver.on('navDestinationSwitch', this.context, callBackFunc); + uiObserver.on('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc2); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + uiObserver.off('navDestinationSwitch', this.context, callBackFunc); + uiObserver.off('navDestinationSwitch', this.context, { + navigationId: 'myNavId' + }, callBackFunc); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + let mainWindow: window.Window; + try { + mainWindow = windowStage.getMainWindowSync(); + let displayClass: display.Display = display.getDefaultDisplaySync(); + AppStorage.setOrCreate('orientation', displayClass.orientation); + // 监听窗口的windowsSizeChange事件,旋转屏时会触发该事件 + mainWindow.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let displayClass: display.Display | null = null; + try { + displayClass = display.getDefaultDisplaySync(); + console.info('display orientation is ' + JSON.stringify(displayClass.orientation)); + // 获取屏幕的显示方向 + AppStorage.set('orientation', displayClass.orientation); + } catch { + return; + } + }) + } catch { + hilog.info(0x0000, 'testTag', '%{public}s', 'error'); + return; + } + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0009564a340d13c6dbd9c8e4a895302929769b70 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import curves from '@ohos.curves'; +import { Route, RouteGroup } from './common/Index'; +import { KeyboardAvoidMode } from '@kit.ArkUI'; +import router from '@ohos.router'; + +@Styles +function cardPressedStyle() { + .backgroundColor('rgba(0,0,0,0.1)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardNormalStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(1) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + +@Styles +function cardDisabledStyle() { + .backgroundColor('rgba(0,0,0,0)') + .opacity(0.5) + .animation({ curve: curves.cubicBezierCurve(0.33, 0, 0.67, 1), duration: 100 }) +} + + +@Entry +@Component +struct VisionEffectIndex { + @Provide('router') router: NavPathStack = new NavPathStack(); + @State routes: RouteGroup[] = [ + { + name: "transform", + label: $r('app.string.transform'), + children: [ + { name: 'template1/Index', label: $r('app.string.example_one_transform') }, + { name: 'template2/Index', label: $r('app.string.example_two_transform') }, + { name: 'template3/Index', label: $r('app.string.example_three_transform') }, + ] + },{ + name: "opacity", + label: $r('app.string.opacity'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_opacity') }, + ] + }, { + name: "clip", + label: $r('app.string.clip'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_clip') }, + { name: 'template2/Index', label: $r('app.string.example_two_clip') }, + ] + }, { + name: "imageEffect", + label: $r('app.string.imageEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_imageEffect') }, + { name: 'template2/Index', label: $r('app.string.example_two_imageEffect') }, + { name: 'template3/Index', label: $r('app.string.example_three_imageEffect') }, + { name: 'template4/Index', label: $r('app.string.example_four_imageEffect') }, + { name: 'template5/Index', label: $r('app.string.example_five_imageEffect') }, + { name: 'template6/Index', label: $r('app.string.example_six_imageEffect') }, + { name: 'template7/Index', label: $r('app.string.example_seven_imageEffect') }, + { name: 'template8/Index', label: $r('app.string.example_eight_imageEffect') }, + { name: 'template9/Index', label: $r('app.string.example_nine_imageEffect') }, + { name: 'template10/Index', label: $r('app.string.example_ten_imageEffect') }, + ] + }, { + name: "background", + label: $r('app.string.background'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_background') }, + { name: 'template2/Index', label: $r('app.string.example_two_background') }, + { name: 'template3/Index', label: $r('app.string.example_three_background') }, + { name: 'template4/Index', label: $r('app.string.example_four_background') }, + { name: 'template5/Index', label: $r('app.string.example_five_background') }, + { name: 'template6/Index', label: $r('app.string.example_six_background') }, + { name: 'template7/Index', label: $r('app.string.example_seven_background') }, + ] + }, { + name: "foregroundBlurStyle", + label: $r('app.string.foregroundBlurStyle'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundBlurStyle') }, + ] + }, { + name: "foregroundColor", + label: $r('app.string.foregroundColor'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundColor') }, + { name: 'template2/Index', label: $r('app.string.example_two_foregroundColor') }, + { name: 'template3/Index', label: $r('app.string.example_three_foregroundColor') }, + ] + }, { + name: "clickEffect", + label: $r('app.string.clickEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_clickEffect') }, + ] + }, { + name: "useEffect", + label: $r('app.string.useEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_useEffect') }, + ] + }, { + name: "renderFit", + label: $r('app.string.renderFit'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_renderFit') }, + ] + }, { + name: "outline", + label: $r('app.string.outline'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_outline') }, + { name: 'template2/Index', label: $r('app.string.example_two_outline') }, + ] + }, { + name: "motionBlur", + label: $r('app.string.motionBlur'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_motionBlur') }, + ] + }, { + name: "linearGradient", + label: $r('app.string.linearGradient'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_linearGradient') }, + { name: 'template2/Index', label: $r('app.string.example_two_linearGradient') }, + { name: 'template3/Index', label: $r('app.string.example_three_linearGradient') }, + ] + }, { + name: "foregroundEffect", + label: $r('app.string.foregroundEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_foregroundEffect') }, + ] + }, { + name: "visualEffect", + label: $r('app.string.visualEffect'), + children:[ + { name: 'template1/Index', label: $r('app.string.example_one_visualEffect') }, + ] + } + ]; + @State selection: string | null = null; + + @Builder + ListItemGroupHeader(route: RouteGroup) { + Row() { + Text(route.label) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Medium) + + Blank() + + Text(`${route.children.length}`) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) + .opacity(this.selection === route.name ? 0 : 1) + + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + .rotate({ angle: this.selection === route.name ? 90 : 0 }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 30) }) + } + .borderRadius(20) + .width('100%') + .padding(8) + .enabled(!!route.children.length) + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .onClick(() => { + animateTo( + { curve: curves.interpolatingSpring(0, 1, 228, 25) }, + () => { + if (this.selection === route.name) { + this.selection = null; + } else { + this.selection = route.name; + } + }); + }) + } + + aboutToAppear(): void{ + this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); + } + build() { + Column() { + Text("VisionEffectIndex") + List() { + ForEach(this.routes, (routeGroup: RouteGroup) => { + ListItemGroup({ + header: this.ListItemGroupHeader(routeGroup), + style: ListItemGroupStyle.CARD, + }) { + if (routeGroup.name === this.selection) { + ForEach(routeGroup.children, (route: Route) => { + ListItem() { + Row() { + Text(route.label).fontSize(16) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .height(24) + .width(24) + } + .stateStyles({ + pressed: cardPressedStyle, + normal: cardNormalStyle, + disabled: cardDisabledStyle, + }) + .borderRadius(20) + .padding(8) + .transition( + TransitionEffect.OPACITY.animation({ + curve: curves.interpolatingSpring(0, 1, 228, 30) + }) + ) + .width('100%') + .onClick(() => { + const name = `pages/${routeGroup.name}/${route.name}`; + router.pushUrl({url: name}) + }) + } + .width('100%') + }) + } + } + .padding(2) + .divider({ strokeWidth: 0.5 }) + }) + }.padding({bottom: 10}) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4734a1586138c3f51a292c5edb306c6d06b9e362 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template1/Index.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackgroundExample { + + build() { + Column({ space: 5 }) { + Text('background color').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row().width('90%').height(50).backgroundColor(0xE5E5E5).border({ width: 1 }) + + Text('background image repeat along X').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .backgroundImage($r('app.media.bg'), ImageRepeat.X) + .backgroundImageSize({ width: '250px', height: '140px' }) + .width('90%') + .height(70) + .border({ width: 1 }) + + Text('background image repeat along Y').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .backgroundImage($r('app.media.bg'), ImageRepeat.Y) + .backgroundImageSize({ width: '500px', height: '120px' }) + .width('90%') + .height(100) + .border({ width: 1 }) + + Text('background image size').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%').height(150) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: 1000, height: 500 }) + .border({ width: 1 }) + + Text('background fill the box(Cover)').fontSize(9).width('90%').fontColor(0xCCCCCC) + // 不保证图片完整的情况下占满盒子 + Row() + .width(200) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize(ImageSize.Cover) + .border({ width: 1 }) + + Text('background fill the box(Contain)').fontSize(9).width('90%').fontColor(0xCCCCCC) + // 保证图片完整的情况下放到最大 + Row() + .width(200) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize(ImageSize.Contain) + .border({ width: 1 }) + + Text('background image position').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(50) + .backgroundImage($r('app.media.bg'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: 1000, height: 560 }) + .backgroundImagePosition({ x: -500, y: -300 }) + .border({ width: 1 }) + } + .width('100%').height('100%').padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c408a685db10436863c46c24bc36122b42f7d87c --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template2/Index.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackgroundBlurStyleDemo { + build() { + Column() { + Row() { + Text("Thin Material") + } + .width('50%') + .height('50%') + .backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 }) + .position({ x: '15%', y: '30%' }) + } + .height('100%') + .width('100%') + .backgroundImage($r('app.media.bg')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9528455392b22b511873da717b38a94e342c03b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template3/Index.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackgroundExample3 { + @Builder renderBackground() { + Column() { + Progress({value : 50}) + } + } + + build() { + Column() { + Text("content") + .width(100) + .height(40) + .fontColor("#FFF") + .position({x:50, y:80}) + .textAlign(TextAlign.Center) + .backgroundColor(Color.Green) + } + .width(200).height(200) + .background(this.renderBackground) + .backgroundColor(Color.Gray) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template4/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0468499b4d3ef24b8124146406dc017b94e4597c --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template4/Index.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackgroundBrightnessDemo { + build() { + Column() { + Row() { + Text("BackgroundBrightness") + } + .width(200) + .height(100) + .position({ x: 100, y: 100 }) + .backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT}) + .backgroundBrightness({rate:0.5,lightUpDegree:0.5}) // 背景提亮效果 + } + .width('100%') + .height('100%') + .backgroundImage($r('app.media.image')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac5c34baee8d84777b82e93e1569c7a005dd283d --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template5/Index.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BlurEffectsExample { + build() { + Column({ space: 10 }) { + // 对字体进行模糊 + Text('font blur').fontSize(15).fontColor(0xCCCCCC).width('90%') + Flex({ alignItems: ItemAlign.Center }) { + Text('original text').margin(10) + Text('blur text') + .blur(5).margin(10) + Text('blur text') + .blur(10, undefined).margin(10) // 内容模糊半径为5,禁用系统自适应优化策略。 + Text('blur text') + .blur(15).margin(10) + }.width('90%').height(40) + .backgroundColor(0xF9CF93) + + + // 对背景进行模糊 + Text('backdropBlur').fontSize(15).fontColor(0xCCCCCC).width('90%') + Text() + .width('90%') + .height(40) + .fontSize(16) + .backdropBlur(3) + .backgroundImage($r('app.media.image')) + .backgroundImageSize({ width: 1200, height: 160 }) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template6/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed5b3300890fa1ca9458d3539489c2f0ea7d461a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template6/Index.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackGround6 { + @State shColor: Color = Color.White; + @State sizeDate: number = 20; + @State rVal: number = 255; + @State gVal: number = 255; + @State bVal: number = 255; + @State aVal: number = 0.1; + @State rad: number = 40; + @State satVal: number = 0.8; + @State briVal: number = 1.5; + build() { + Stack() { + Image($r('app.media.image')) + Column() { + Column({ space: 0 }) { + Column() { + Text('11') + .fontSize(144) + .fontWeight(FontWeight.Bold) + .fontColor('rgba(255,255,255,1)') + .fontFamily('HarmonyOS-Sans-Digit') + .maxLines(1) + .lineHeight(120 * 1.25) + .height(120 * 1.25) + .letterSpacing(4 * 1.25) + Text('42') + .fontSize(144) + .fontWeight(FontWeight.Bold) + .fontColor('rgba(255,255,255,1)') + .fontFamily('HarmonyOS-Sans-Digit') + .maxLines(1) + .lineHeight(120 * 1.25) + .height(120 * 1.25) + .letterSpacing(4 * 1.25) + .shadow({ + color: 'rgba(0,0,0,0)', + radius: 20, + offsetX: 0, + offsetY: 0 + }) + Row() { + Text($r('app.string.October_16th')) + .fontSize(this.sizeDate) + .height(22) + .fontWeight('medium') + .fontColor('rgba(255,255,255,1)') + Text($r('app.string.Monday')) + .fontSize(this.sizeDate) + .height(22) + .fontWeight('medium') + .fontColor('rgba(255,255,255,1)') + } + } + .blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN) + .pixelRound({ + start: PixelRoundCalcPolicy.FORCE_FLOOR , + top: PixelRoundCalcPolicy.FORCE_FLOOR , + end: PixelRoundCalcPolicy.FORCE_CEIL, + bottom: PixelRoundCalcPolicy.FORCE_CEIL + }) + } + .blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN) + .backgroundEffect({ + radius: this.rad, + saturation: this.satVal, + brightness: this.briVal, + color: this.getVolumeDialogWindowColor() + }) + .justifyContent(FlexAlign.Center) + .pixelRound({ + start: PixelRoundCalcPolicy.FORCE_FLOOR , + top: PixelRoundCalcPolicy.FORCE_FLOOR , + end: PixelRoundCalcPolicy.FORCE_CEIL, + bottom: PixelRoundCalcPolicy.FORCE_CEIL + }) + } + } + } + getVolumeDialogWindowColor(): ResourceColor | string { + return `rgba(${this.rVal.toFixed(0)}, ${this.gVal.toFixed(0)}, ${this.bVal.toFixed(0)}, ${this.aVal.toFixed(0)})`; + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template7/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e62f9cfaaf8b9f52cd128c350cd93ab9e9571b10 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/background/template7/Index.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct BackGroundBlur { + private imageSize: number = 150; + + build() { + Column({ space: 5 }) { + // backgroundBlurStyle通过枚举值的方式设置模糊参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backgroundBlurStyle(BlurStyle.Thin) + } + + // backgroundEffect 可以自定义设置 模糊半径,亮度,饱和度等参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backgroundEffect({ radius: 20, brightness: 0.6, saturation: 15 }) + } + + // backdropBlur 只能设置模糊半径和灰阶参数 + Stack() { + Image($r('app.media.test')) + .width(this.imageSize) + .height(this.imageSize) + Column() + .width(this.imageSize) + .height(this.imageSize) + .backdropBlur(20, { grayscale: [30, 50] }) + } + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e65dd2d3b498ed34bbef705bfd406204694085bf --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clickEffect/template1/Index.ets @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ToggleExample { + build() { + Column({ space: 10 }) { + Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Switch, isOn: false }) + .clickEffect({level:ClickEffectLevel.LIGHT}) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Switch, isOn: true }) + .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5}) + .selectedColor('#007DFF') + .switchPointColor('#FFFFFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + + Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Checkbox, isOn: false }) + .clickEffect({level:ClickEffectLevel.MIDDLE}) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Checkbox, isOn: true }) + .clickEffect({level:ClickEffectLevel.MIDDLE, scale: 0.5}) + .size({ width: 20, height: 20 }) + .selectedColor('#007DFF') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + + Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Button, isOn: false }) { + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .clickEffect({level:ClickEffectLevel.HEAVY}) + .selectedColor('rgba(0,125,255,0.20)') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + + Toggle({ type: ToggleType.Button, isOn: true }) { + Text('status button').fontColor('#182431').fontSize(12) + }.width(106) + .clickEffect({level:ClickEffectLevel.HEAVY, scale: 0.5}) + .selectedColor('rgba(0,125,255,0.20)') + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn); + }) + } + }.width('100%').padding(24) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a1d54c4ca931ec1f2833f10ea18d6b49e96e2ba --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template1/Index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CircleShape, RectShape } from '@kit.ArkUI'; + +@Entry +@Component +struct ClipAndMaskExample { + build() { + Column({ space: 15 }) { + Text('clip').fontSize(12).width('75%').fontColor('#DCDCDC') + Row() { + Image($r('app.media.testImg')).width('500px').height('280px') + } + .clip(true) // 如这里不设置clip为true,则Row组件的圆角不会限制其中的Image组件,Image组件的四个角会超出Row + .borderRadius(20) + + // 用一个280px直径的圆对图片进行裁剪 + Image($r('app.media.testImg')) + .clipShape(new CircleShape({ width: '280px', height: '280px' })) + .width('500px').height('280px') + + Text('mask').fontSize(12).width('75%').fontColor('#DCDCDC') + // 给图片添加了一个500px*280px的方形遮罩 + Image($r('app.media.testImg')) + .maskShape(new RectShape({ width: '500px', height: '280px' }).fill(Color.Gray)) + .width('500px').height('280px') + + // 给图片添加了一个280px*280px的圆形遮罩 + Image($r('app.media.testImg')) + .maskShape(new CircleShape({ width: '280px', height: '280px' }).fill(Color.Gray)) + .width('500px').height('280px') + } + .width('100%') + .margin({ top: 15 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cfc4e66efb34bd8355664c3af839cfe3bf6d4f7e --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/clip/template2/Index.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ProgressMaskExample { + @State progressFlag1: boolean = true; + @State color: Color = 0x01006CDE; + @State value: number = 10.0; + @State enableBreathingAnimation: boolean = false; + @State progress: ProgressMask = new ProgressMask(10.0, 100.0, Color.Gray); + + build() { + Column({ space: 15 }) { + Text('progress mask').fontSize(12).width('75%').fontColor('#DCDCDC') + // 给图片添加了一个280px*280px的进度遮罩 + Image($r('app.media.testImg')) + .width('500px').height('280px') + .mask(this.progress) + .animation({ + duration: 2000, // 动画时长 + curve: Curve.Linear, // 动画曲线 + delay: 0, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal // 动画模式 + }) // 对Button组件的宽高属性进行动画配置 + + // 更新进度遮罩的进度值 + Button('updateProgress') + .onClick((event?: ClickEvent) => { + this.value += 10; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + + // 更新进度遮罩的颜色 + Button('updateColor') + .onClick((event?: ClickEvent) => { + if (this.progressFlag1) { + this.progress.updateColor(0x9fff0000); + } else { + this.progress.updateColor(0x9f0000ff); + } + this.progressFlag1 = !this.progressFlag1 + }).width(200).height(50).margin(20) + + // 开关呼吸光晕动画 + Button('enableBreathingAnimation:' + this.enableBreathingAnimation) + .onClick((event?: ClickEvent) => { + this.enableBreathingAnimation = !this.enableBreathingAnimation; + this.progress.enableBreathingAnimation(this.enableBreathingAnimation); + }).width(200).height(50).margin(20) + + // 恢复进度遮罩 + Button('click reset!') + .onClick((event?: ClickEvent) => { + this.value = 0; + this.progress.updateProgress(this.value); + }).width(200).height(50).margin(20) + } + .width('100%') + .margin({ top: 15 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/common/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..02c5c6b987280c6731d3e40af7c56c416176a3af --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/common/Index.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Route { + name: string; + label: ResourceStr; +} + +export interface RouteGroup extends Route { + children: Route[]; +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..df17604a668859bed453c09ceca3488b2cf01a33 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundBlurStyle/template1/Index.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ForegroundBlurStyleDemo { + build() { + Column() { + Text('Thin Material').fontSize(30).fontColor(0xCCCCCC) + Image($r('app.media.bg')) + .width(300) + .height(350) + .foregroundBlurStyle(BlurStyle.Thin, + { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..df1a63222cb31fcbefe89ae607ade7f80180086b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template1/Index.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ForegroundColorExample { + build() { + Column({ space: 100 }) { + // 绘制一个直径为150的圆,默认填充色为黑色 + Circle({ width: 150, height: 200 }) + // 绘制一个直径为150的圆, + Circle({ width: 150, height: 200 }).foregroundColor(Color.Red) + }.width('100%').backgroundColor(Color.Blue) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..14ff92a2cf34b54c180f74dc29ad57c2c8cefc19 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template2/Index.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ColoringStrategyExample { + build() { + Column({ space: 100 }) { + // 绘制一个直径为150的圆,默认填充色为黑色 + Circle({ width: 150, height: 200 }) + // 绘制一个直径为150的圆,设置前景色为组件背景色的反色 + Circle({ width: 150, height: 200 }) + .backgroundColor(Color.Black) + .foregroundColor(ColoringStrategy.INVERT) + }.width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bc2885229020008cd68e3b3086b07e3e1808a54 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundColor/template3/Index.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct foregroundColorInherit { + build() { + Column() { + Button('设置前景色为橘色').fontSize(20).foregroundColor(Color.Orange).backgroundColor(Color.Gray) + Divider() + Button('未设置前景色继承自父组件').fontSize(20).backgroundColor(Color.Gray) + }.foregroundColor(Color.Red) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2fae7b9c27a85791a763a5ba922d0b39b21c0d2 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/foregroundEffect/template1/Index.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ForegroundEffectExample { + build() { + Row() { + Image($r('app.media.icon')) + .width(100) + .height(100) + .foregroundEffect({ radius: 20 }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..543c1b789a6a6b8bb756464cc68051ad30b3b6b9 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template1/Index.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ImageEffectsExample { + build() { + Column({ space: 5 }) { + // 添加阴影效果,图片效果不变 + Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')) + .width('90%') + .height(30) + .shadow({ + radius: 10, + color: Color.Green, + offsetX: 20, + offsetY: 20 + }) + + // 添加内部阴影效果 + Text('shadow').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')) + .width('90%') + .height(30) + .shadow({ + radius: 5, + color: Color.Green, + offsetX: 20, + offsetY: 20, + fill: true + }).opacity(0.5) + + // 灰度效果0~1,越接近1,灰度越明显 + Text('grayscale').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).grayscale(0.3) + Image($r('app.media.image')).width('90%').height(30).grayscale(0.8) + + // 高光效果,1为正常图片,<1变暗,>1亮度增大 + Text('brightness').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).brightness(1.2) + + // 饱和度,原图为1 + Text('saturate').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).saturate(2.0) + Image($r('app.media.image')).width('90%').height(30).saturate(0.7) + + // 对比度,1为原图,>1值越大越清晰,<1值越小越模糊 + Text('contrast').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).contrast(2.0) + Image($r('app.media.image')).width('90%').height(30).contrast(0.8) + + // 图像反转比例 + Text('invert').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).invert(0.2) + Image($r('app.media.image')).width('90%').height(30).invert(0.8) + + // 叠色添加 + Text('colorBlend').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Green) + Image($r('app.media.image')).width('90%').height(30).colorBlend(Color.Blue) + + // 深褐色 + Text('sepia').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).sepia(0.8) + + // 色相旋转 + Text('hueRotate').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image($r('app.media.image')).width('90%').height(30).hueRotate(90) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52c5efdbc93eadbd7c16b14ba15c41ba626497c2 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template10/Index.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ImageEffectsExample10 { + build() { + Column() { + Stack() { + Image($r('app.media.testImage')).width('100%').height('100%') + Column() + .width(150) + .height(10) + .systemBarEffect() + .border({ radius: 5 }) + .margin({ bottom: 80 }) + }.alignContent(Alignment.Center) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a12fde422d88cf2c06a6beecd9d8e56e9953725d --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template2/Index.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ImageExample1 { + private_resource1: Resource = $r('app.media.testlinearGradientBlurOrigin'); + @State image_src: Resource = this.private_resource1; + + build() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Row({ space: 5 }) { + Image(this.image_src) + .linearGradientBlur(60, + { fractionStops: [[0, 0], [0, 0.33], [1, 0.66], [1, 1]], direction: GradientDirection.Bottom }) + } + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f0a70c403a3f6955bc3df7b0e98b9383b31133b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template3/Index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Component +struct Component1 { + @Prop renderGroupValue: boolean; + + build() { + Row() { + Row() { + Row() + .backgroundColor(Color.Black) + .width(100) + .height(100) + .opacity(1) + } + .backgroundColor(Color.White) + .width(150) + .height(150) + .justifyContent(FlexAlign.Center) + .opacity(0.6) + .renderGroup(this.renderGroupValue) + } + .backgroundColor(Color.Black) + .width(200) + .height(200) + .justifyContent(FlexAlign.Center) + .opacity(1) + } +} + +@Entry +@Component +struct RenderGroupExample { + build() { + Column() { + Component1({ renderGroupValue: true }) + .margin(20) + Component1({ renderGroupValue: false }) + .margin(20) + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3177a411a76b47d386478aef32659084b637593f --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template4/Index.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ImageEffectsExample4 { + build() { + Column() { + Text("blendMode") + .fontSize(20) + .fontWeight(FontWeight.Bold) + .fontColor('#ffff0101') + Row() { + Circle() + .width(200) + .height(200) + .fill(Color.Green) + .position({ x: 50, y: 50 }) + Circle() + .width(200) + .height(200) + .fill(Color.Blue) + .position({ x: 150, y: 50 }) + } + .blendMode(BlendMode.OVERLAY, BlendApplyType.OFFSCREEN) + .alignItems(VerticalAlign.Center) + .height(300) + .width('100%') + } + .height('100%') + .width('100%') + .backgroundImage($r('app.media.image')) + .backgroundImageSize(ImageSize.Cover) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a67847230b97529c878eca559526208d5d4ebcf --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template5/Index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ImageEffect5 { + build() { + Stack() { + Column() + Stack() { + Image($r('app.media.r')).width('100%') + Column() { + Column().width('100%').height(30).invert({ + low: 0, + high: 1, + threshold: 0.5, + thresholdRange: 0.2 + }) + Column().width('100%').height(30).invert({ + low: 0.2, + high: 0.5, + threshold: 0.3, + thresholdRange: 0.2 + }) + } + } + .width('100%') + .height('100%') + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1e2936d707d1b91b769a678f47a4be60f211cfc --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template6/Index.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UseShadowBatchingExample { + build() { + Column() { + Column({ space: 10 }) { + Stack() { + + } + .width('90%') + .height(50) + .margin({ top: 5 }) + .backgroundColor(0xFFE4C4) + .shadow({ + radius: 120, + color: Color.Green, + offsetX: 0, + offsetY: 0 + }) + .align(Alignment.TopStart) + .shadow({ + radius: 120, + color: Color.Green, + offsetX: 0, + offsetY: 0 + }) + + Stack() { + + } + .width('90%') + .height(50) + .margin({ top: 5 }) + .backgroundColor(0xFFE4C4) + .align(Alignment.TopStart) + .shadow({ + radius: 120, + color: Color.Red, + offsetX: 0, + offsetY: 0 + }) + .width('90%') + .backgroundColor(Color.White) + + Column() { + Text() + .fontWeight(FontWeight.Bold) + .fontSize(20) + .fontColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .width(150) + .height(150) + .borderRadius(10) + .backgroundColor(0xf56c6c) + .shadow({ + radius: 300, + color: Color.Yellow, + offsetX: 0, + offsetY: 0 + }) + + Column() { + Text() + .fontWeight(FontWeight.Bold) + .fontSize(20) + .fontColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .width(150) + .height(150) + .backgroundColor(0x67C23A) + .borderRadius(10) + .translate({ y: -50 }) + .shadow({ + radius: 220, + color: Color.Blue, + offsetX: 0, + offsetY: 0 + }) + } + .useShadowBatching(true) + } + .width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ee5f04bd6852ea779c631edfa02e9f0fadfc762 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template7/Index.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct SphericalEffectExample { + build() { + Stack() { + TextInput({ placeholder: $r('app.string.placeholder') }) + .width('50%') + .height(35) + .type(InputType.Number) + .enterKeyType(EnterKeyType.Done) + .caretColor(Color.Red) + .placeholderColor(Color.Blue) + .placeholderFont({ + size: 20, + style: FontStyle.Italic, + weight: FontWeight.Bold + }) + .sphericalEffect(0.5) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e39d9f697d4bf6bc33b649f91f1a58cc7c7e8b54 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template8/Index.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct LightUpExample { + build() { + Stack() { + Text('This is the text content with letterSpacing 0.') + .letterSpacing(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .width('50%') + .lightUpEffect(0.6) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..be953e632a2d32a8cea28cd16a2ab1153cbec3e4 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/imageEffect/template9/Index.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct PixelStretchExample { + build() { + Stack() { + Text('This is the text content with letterSpacing 0.') + .letterSpacing(0) + .fontSize(12) + .border({ width: 1 }) + .padding(10) + .clip(false) + .width('50%') + .pixelStretchEffect({ + top: 10, + left: 10, + right: 10, + bottom: 10 + }) + }.alignContent(Alignment.Center).width('100%').height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5fe2f7e82b1489d0a8cd6c6fec0d50b0a91d2d20 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template1/Index.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ColorGradientExample { + build() { + Column({ space: 5 }) { + Text('linearGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%') + .height(50) + .linearGradient({ + angle: 90, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + Text('linearGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width('90%') + .height(50) + .linearGradient({ + direction: GradientDirection.Left, // 渐变方向 + repeating: true, // 渐变颜色是否重复 + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c16b0e03fdf6c863eab0d4bc45099dc4d36d006 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template2/Index.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ColorGradientExample2 { + build() { + Column({ space: 5 }) { + Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .sweepGradient({ + center: [50, 50], + start: 0, + end: 359, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + + Text('sweepGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .sweepGradient({ + center: [50, 50], + start: 0, + end: 359, + rotation: 45, // 旋转角度 + repeating: true, // 渐变颜色是否重复 + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbe57acfdd30a6f79e915e4ad141c9d9e5d8ca68 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/linearGradient/template3/Index.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct ColorGradientExample3 { + build() { + Column({ space: 5 }) { + Text('radialGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .radialGradient({ + center: [50, 50], + radius: 60, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 1.0]] + }) + Text('radialGradient Repeat').fontSize(12).width('90%').fontColor(0xCCCCCC) + Row() + .width(100) + .height(100) + .radialGradient({ + center: [50, 50], + radius: 60, + repeating: true, + colors: [[0xff0000, 0.0], [0x0000ff, 0.3], [0xffff00, 0.5]] // 数组末尾元素占比小于1时满足重复着色效果 + }) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddf7faebcf5fe0a948d2918d6bef476c4cc35866 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/motionBlur/template1/Index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { curves } from '@kit.ArkUI'; + +@Entry +@Component +struct motionBlurTest { + @State widthSize: number = 400; + @State heightSize: number = 320; + @State flag: boolean = true; + @State radius: number = 0; + @State x: number = 0; + @State y: number = 0; + + build() { + Column() { + Column() { + Image($r('app.media.testImg')) + .width(this.widthSize) + .height(this.heightSize) + .onClick(() => { + this.radius = 5; + this.x = 0.5; + this.y = 0.5; + if (this.flag) { + this.widthSize = 100; + this.heightSize = 80; + } else { + this.widthSize = 400; + this.heightSize = 320; + } + this.flag = !this.flag; + }) + .animation({ + duration: 2000, + curve: curves.springCurve(10, 1, 228, 30), + onFinish: () => { + this.radius = 0; + } + }) + .motionBlur({ radius: this.radius, anchor: { x: this.x, y: this.y } }) + } + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..08ae8f6efa8f497135b7c08377f76c8bee309631 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/opacity/template1/Index.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct OpacityExample { + build() { + Column({ space: 5 }) { + Text('opacity(1)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(1).backgroundColor(0xAFEEEE) + Text('opacity(0.7)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.7).backgroundColor(0xAFEEEE) + Text('opacity(0.4)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.4).backgroundColor(0xAFEEEE) + Text('opacity(0.1)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0.1).backgroundColor(0xAFEEEE) + Text('opacity(0)').fontSize(9).width('90%').fontColor(0xCCCCCC) + Text().width('90%').height(50).opacity(0).backgroundColor(0xAFEEEE) + } + .width('100%') + .padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..baf0d3fa2fa36fbd3cb504a9767de7fb528c9d5b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template1/Index.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct OutlineExample { + build() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + // 线段 + Text('DASHED') + .backgroundColor(Color.Pink) + .outlineStyle(OutlineStyle.DASHED).outlineWidth(5).outlineColor(0xAFEEEE).outlineRadius(10) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + // 点线 + Text('DOTTED') + .backgroundColor(Color.Pink) + .outline({ width: 5, color: 0x317AF7, radius: 10, style: OutlineStyle.DOTTED }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + }.width('100%').height(150) + + Text('.outline') + .backgroundColor(Color.Pink) + .fontSize(50) + .width(300) + .height(300) + .outline({ + width: { left: 3, right: 6, top: 10, bottom: 15 }, + color: { left: '#e3bbbb', right: Color.Blue, top: Color.Red, bottom: Color.Green }, + radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 }, + style: { + left: OutlineStyle.DOTTED, + right: OutlineStyle.DOTTED, + top: OutlineStyle.SOLID, + bottom: OutlineStyle.DASHED + } + }).textAlign(TextAlign.Center) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d66ffe5be2e8926b17495a36b8450faf6845bebd --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/outline/template2/Index.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct OutlineExample2 { + build() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + // 线段 + Text('DASHED') + .backgroundColor(Color.Pink) + .outlineStyle(OutlineStyle.DASHED).outlineWidth(5).outlineColor(0xAFEEEE).outlineRadius(10) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + // 点线 + Text('DOTTED') + .backgroundColor(Color.Pink) + .outline({ width: 5, color: 0x317AF7, radius: 10, style: OutlineStyle.DOTTED }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + }.width('100%').height(150) + + Text('.outline') + .backgroundColor(Color.Pink) + .fontSize(50) + .width(300) + .height(300) + .outline({ + width: { left: 3, right: 6, top: 10, bottom: 15 }, + color: { start: '#e3bbbb', end: Color.Blue, top: Color.Red, bottom: Color.Green }, + radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 }, + style: { + left: OutlineStyle.DOTTED, + right: OutlineStyle.DOTTED, + top: OutlineStyle.SOLID, + bottom: OutlineStyle.DASHED + } + }).textAlign(TextAlign.Center) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..462ea9c2154a546a6de1aa40dc194223c426ea2e --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/renderFit/template1/Index.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct RenderFitExample { + @State width1: number = 100; + @State height1: number = 30; + flag: boolean = true; + + build() { + Column() { + Text("Hello") + .width(this.width1) + .height(this.height1) + .borderWidth(1) + .textAlign(TextAlign.Start) + .renderFit(RenderFit.LEFT)// 设置LEFT的renderFit,动画过程中,动画的终态内容与组件保持左对齐 + .margin(20) + + Text("Hello") + .width(this.width1) + .height(this.height1) + .textAlign(TextAlign.Center) + .borderWidth(1) + .renderFit(RenderFit.CENTER)// 设置CENTER的renderFit,动画过程中,动画的终态内容与组件保持中心对齐 + .margin(20) + + Button("animate") + .onClick(() => { + this.getUIContext()?.animateTo({ curve: Curve.Ease }, () => { + if (this.flag) { + this.width1 = 150; + this.height1 = 50; + } else { + this.width1 = 100; + this.height1 = 30; + } + this.flag = !this.flag; + }) + }) + }.width('100%').height('100%').alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce0425413b306dcb3f223d4a21af27bdb5a25a34 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template1/Index.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { matrix4 } from '@kit.ArkUI'; + +@Entry +@Component +struct TransformExample { + build() { + Column() { + Text('rotate').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .rotate({ + x: 0, + y: 0, + z: 1, + centerX: '50%', + centerY: '50%', + angle: 300 + })// 组件以矢量(0,0,1)为旋转轴,绕中心点顺时针旋转300度 + .width(100).height(100).backgroundColor(0xAFEEEE) + + Text('translate').width('90%').fontColor(0xCCCCCC).padding(10).fontSize(14) + Row() + .translate({ x: 100, y: 10 })// x轴方向平移100,y轴方向平移10 + .width(100) + .height(100) + .backgroundColor(0xAFEEEE) + .margin({ bottom: 10 }) + + Text('scale').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .scale({ x: 2, y: 0.5 })// 高度缩小一倍,宽度放大一倍,z轴在2D下无效果 + .width(100).height(100).backgroundColor(0xAFEEEE) + + Text('Matrix4').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14) + Row() + .width(100).height(100).backgroundColor(0xAFEEEE) + .transform(matrix4.identity().translate({ x: 50, y: 50 }).scale({ x: 1.5, y: 1 }).rotate({ + x: 0, + y: 0, + z: 1, + angle: 60 + })) + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c95c3279180516809bae9f60848140b128770cd --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template2/Index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct TransFormExample2 { + @State prep: number = 10; + + build() { + Row() { + Column() { + Stack() + .width(100) + .height(100) + .backgroundColor(Color.Red) + .rotate({ y: 1, angle: 45, perspective: this.prep }) + Button('change prep') + .margin({ top: 100 }) + .onClick(() => { + this.getUIContext()?.animateTo({ + duration: 2000, + curve: Curve.EaseIn, + iterations: 1, + playMode: PlayMode.Normal, + onFinish: () => { + console.info('play end'); + } + }, () => { + this.prep = 500 // 组件视距从10变换到500 + }) + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd3ebbfa6ff98dbd8442001282171e42b60b3c59 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/transform/template3/Index.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { matrix4 } from '@kit.ArkUI'; + +@Entry +@Component +struct MatrixExample { + build() { + Column({ space: 100 }) { + Text('Hello1') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + + Text('Hello2') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .rotate({ + // 绕(100vp,60vp)的锚点旋转90度,rotate或scale的centerX、centerY为组件锚点 + z: 1, + angle: 90, + centerX: 100, + centerY: 60 + }) + + Text('Hello3') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .transform(matrix4.identity() + .rotate({ + // 组件锚点(centerX,centerY)默认为(50%,50%),即锚点在(50vp,30vp) + // transform的rotate指定(centerX,centerY)为(50vp,30vp),相对于在组件本身锚点基础上再额外偏移(50vp,30vp) + // 此次变换相当于绕(100vp,60vp)旋转,和"Hello2"实现同样的旋转效果 + z: 1, + angle: 90, + centerX: this.getUIContext().vp2px(50), + centerY: this.getUIContext().vp2px(30) + })) + + Text('Hello4') + .textAlign(TextAlign.Center) + .width(100) + .height(60) + .borderWidth(1) + .scale({ + // 当设置x或y时,centerX和centerY才能生效 + // 设置组件锚点为(100vp,60vp) + x: 1, + y: 1, + centerX: 100, + centerY: 60 + })// transform的rotate不指定centerX、centerY,此次旋转的中心相对于组件本身锚点没有额外偏移 + // 该组件通过scale设置的锚点,绕(100vp,60vp)进行旋转,和"Hello2"实现同样的旋转效果 + .transform(matrix4.identity().rotate({ z: 1, angle: 90 })) + }.width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..89b75f28bc2c860e257783b50ddd253c7efd021a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/useEffect/template1/Index.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct UseEffectExample { + @State isUse: boolean = true; + + build() { + Stack() { + Image($r("app.media.mountain")) + .autoResize(true) + EffectComponent() { + Column({ space: 20 }) { + Column() { + } + .position({ x: 0, y: 0 }) + .width(150) + .height(800) + .useEffect(this.isUse, EffectType.WINDOW_EFFECT) + + Column() { + } + .position({ x: 200, y: 20 }) + .width(150) + .height(300) + .useEffect(this.isUse, EffectType.DEFAULT) + + Column() { + } + .position({ x: 400, y: 20 }) + .width(150) + .height(300) + .useEffect(this.isUse) + } + .width('100%') + .height('100%') + } + .backgroundBlurStyle(BlurStyle.Thin) + + Column() { + } + .position({ x: 600, y: 0 }) + .width(150) + .height(800) + .useEffect(this.isUse, EffectType.WINDOW_EFFECT) + + Row() { + Button('useEffect') + .margin(30) + .onClick(() => { + this.isUse = !this.isUse; + }) + } + .position({ x: 300, y: 450 }) + } + .backgroundColor(Color.Black) + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..50e5ab0251c8a331da9f25e46c5fedd42a0edce6 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/ets/pages/visualEffect/template1/Index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { uiEffect } from '@kit.ArkGraphics2D'; + +@Entry +@Component +struct FilterEffectExample { + @State filterTest1: uiEffect.Filter = uiEffect.createFilter().blur(10); + @State filterTest2: uiEffect.Filter = uiEffect.createFilter().blur(10); + @State filterTest3: uiEffect.Filter = uiEffect.createFilter().blur(10); + + build() { + Column({ space: 15 }) { + + Text('foregroundFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('前景滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .foregroundFilter(this.filterTest1) // 通过 foregroundFilter 设置模糊效果 + + Text('backgroundFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('背景滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .backgroundFilter(this.filterTest2) // 通过 backgroundFilter 设置模糊效果 + + Text('compositingFilter').fontSize(20).width('75%').fontColor('#DCDCDC') + Text('合成滤镜') + .width(100) + .height(100) + .backgroundColor('#ADD8E6') + .backgroundImage($r("app.media.app_icon")) + .backgroundImageSize({ width: 80, height: 80 }) + .compositingFilter(this.filterTest3) // 通过 compositingFilter 设置模糊效果 + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..196e6b3978857f196aa334edffc3c5b431c6bc83 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "orientation": "auto_rotation", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/color.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/color.json rename to code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/color.json diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/float.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..153478e3f449f86a897686bc35316bd4fc96fb99 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/float.json @@ -0,0 +1,17 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, { + "name": "size_16", + "value": "16" + }, { + "name": "size_100", + "value": "100" + }, { + "name": "size_64", + "value": "64" + } + ] +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..47f4e9fdb22b0b93b85595f69e294438c6d8952b --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/element/string.json @@ -0,0 +1,256 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "VisionEffect" + }, + { + "name": "navigation_toolbar_add", + "value": "add" + }, + { + "name": "navigation_toolbar_app", + "value": "app" + }, + { + "name": "navigation_toolbar_collect", + "value": "collect" + }, + { + "name": "please_click_button", + "value": "请点击按钮" + }, + { + "name": "transform", + "value": "图形变换" + }, + { + "name": "example_one_transform", + "value": "示例1(为组件添加图形变换效果)" + }, + { + "name": "example_two_transform", + "value": "示例2(设置旋转视距)" + }, + { + "name": "example_three_transform", + "value": "示例3(按中心点旋转)" + }, + { + "name": "opacity", + "value": "透明度设置" + }, + { + "name": "example_one_opacity", + "value": "示例1" + }, + { + "name": "example_one_clip", + "value": "示例1(使用不同裁剪属性)" + }, + { + "name": "example_two_clip", + "value": "示例2(裁剪属性动画)" + }, + { + "name": "clip", + "value": "形状裁剪" + }, + { + "name": "imageEffect", + "value": "图像效果" + }, + { + "name": "background", + "value": "背景设置" + }, + { + "name": "foregroundBlurStyle", + "value": "组件内容模糊" + }, + { + "name": "foregroundColor", + "value": "前景色设置" + }, + { + "name": "clickEffect", + "value": "点击回弹效果" + }, + { + "name": "useEffect", + "value": "特效绘制合并" + }, + { + "name": "renderFit", + "value": "组件内容填充方式" + }, + { + "name": "outline", + "value": "外描边设置" + }, + { + "name": "motionBlur", + "value": "运动模糊" + }, + { + "name": "linearGradient", + "value": "颜色渐变" + }, + { + "name": "foregroundEffect", + "value": "前景属性设置" + }, + { + "name": "visualEffect", + "value": "视效设置" + }, + { + "name": "example_one_imageEffect", + "value": "示例1(设置图片不同属性效果)'" + }, + { + "name": "example_two_imageEffect", + "value": "示例2(设置组件线性渐变模糊效果)" + }, + { + "name": "example_three_imageEffect", + "value": "示例3(设置离屏渲染效果)" + }, + { + "name": "example_four_imageEffect", + "value": "示例4(当前组件内容与下方画布内容混合)" + }, + { + "name": "example_five_imageEffect", + "value": "示例5(前景智能取反色)" + }, + { + "name": "example_six_imageEffect", + "value": "示例6(设置同层阴影不重叠效果)" + }, + { + "name": "example_seven_imageEffect", + "value": "示例7(设置组件图像球面效果)" + }, + { + "name": "example_eight_imageEffect", + "value": "示例8(设置组件图像渐亮效果)" + }, + { + "name": "example_nine_imageEffect", + "value": "示例9(设置组件图像边缘像素扩展效果)" + }, + { + "name": "example_ten_imageEffect", + "value": "示例10(系统导航条智能反色)" + }, + { + "name": "example_one_background", + "value": "示例1(设置背景基础样式)'" + }, + { + "name": "example_two_background", + "value": "示例2(设置背景模糊样式)" + }, + { + "name": "example_three_background", + "value": "示例3(设置组件背景)" + }, + { + "name": "example_four_background", + "value": "示例4(设置组件背景提亮效果)" + }, + { + "name": "example_five_background", + "value": "示例5(设置模糊属性)" + }, + { + "name": "example_six_background", + "value": "示例6(设置文字异形模糊效果)" + }, + { + "name": "example_seven_background", + "value": "示例7(模糊效果对比)" + }, + { + "name": "example_one_foregroundBlurStyle", + "value": "示例1" + }, + { + "name": "example_one_foregroundColor", + "value": "示例1(使用前景色设置)'" + }, + { + "name": "example_two_foregroundColor", + "value": "示例2(设置前景色为组件背景色反色)" + }, + { + "name": "example_three_foregroundColor", + "value": "示例3(前置景色未继承父组件)" + }, + { + "name": "example_one_clickEffect", + "value": "示例1'" + }, + { + "name": "example_one_useEffect", + "value": "示例1'" + }, + { + "name": "example_one_renderFit", + "value": "示例1'" + }, + { + "name": "example_one_outline", + "value": "示例1(使用外描边属性)'" + }, + { + "name": "example_two_outline", + "value": "示例2(使用LocalizedEdgeColors类型)" + }, + { + "name": "example_one_motionBlur", + "value": "示例1'" + }, + { + "name": "example_one_linearGradient", + "value": "示例1(颜色从右向左线性渐变)" + }, + { + "name": "example_two_linearGradient", + "value": "示例2(颜色按旋转角度渐变)'" + }, + { + "name": "example_three_linearGradient", + "value": "示例3(颜色按径向渐变)" + }, + { + "name": "example_one_foregroundEffect", + "value": "示例1'" + }, + { + "name": "example_one_visualEffect", + "value": "示例1'" + }, + { + "name": "October_16th", + "value": "10月16日'" + }, + { + "name": "Monday", + "value": "星期一'" + }, + { + "name": "placeholder", + "value": "请输入变化范围百分比([0%,100%])'" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/app_icon.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/bg.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/bg.JPG new file mode 100644 index 0000000000000000000000000000000000000000..77d1db9c5ae70097ed69f7c9d2fcae8a751e8fff Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/bg.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/book.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/book.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/book.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/drawer.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/drawer.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/drawer.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/forest.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/forest.png new file mode 100644 index 0000000000000000000000000000000000000000..25165d3dac9606d9078b49a9853c66c9cb77320a Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/forest.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/heart.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/heart.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c0843441f0fa499317d594a0f81a0f169ac4cad9 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_health_heart.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlights.svg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlights.svg new file mode 100644 index 0000000000000000000000000000000000000000..7f0c77423290d138e1c06b9de163af52d0ba0195 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlights.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collect + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlightsed.svg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlightsed.svg new file mode 100644 index 0000000000000000000000000000000000000000..bda82973349ceba0d7de8e9f85d704844cb31318 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/ic_public_highlightsed.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_collected + + + + + + + + + + \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon_2.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon_2.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/icon_2.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image.JPG new file mode 100644 index 0000000000000000000000000000000000000000..29bd746fee2f280b5a97640c3c91125bb0934ca1 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image_1.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8b474587838c8cc696fc7747dfe9b1c70f80dc2d Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/image_1.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/img_1.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/img_1.JPG new file mode 100644 index 0000000000000000000000000000000000000000..461eda6a6847cb09d9d6569a4258009d414610e8 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/img_1.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/mountain.jpg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/mountain.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3c244ab4218031e18dd0069e240e558622924668 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/mountain.jpg differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/r.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/r.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cd3fef02a58cabe165cb12fde35cb4c249afa5a4 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/r.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sky.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sky.JPG new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sky.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sun.jpg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sun.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2ad0955113af2e2ad0228837c86427b3022bd86 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/sun.jpg differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/test.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/test.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/test.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImage.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImage.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cc6a0782c6ff9609f0f790c6562b7ab9c549830e Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImage.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImg.jpg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testImg.jpg differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG new file mode 100644 index 0000000000000000000000000000000000000000..e2e542fcde54adf541a680c384bf8477b41548eb Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/testlinearGradientBlurOrigin.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fb37bd1079db72818f5e375973c80fb670c7a70 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image1.jpg differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image2.png b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image2.png new file mode 100644 index 0000000000000000000000000000000000000000..af8d4c98a86f23a41841d07b74636926a17d1c89 Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/transition_image2.png differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/tree.JPG b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/tree.JPG new file mode 100644 index 0000000000000000000000000000000000000000..bdad6db5558c4190bccb951489e8bc67fc0ababe Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/media/tree.JPG differ diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..848733fbd37aa508501d724aaec6f794e418ffd5 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,43 @@ +{ + "src": [ + "pages/Index", + "pages/transform/template1/Index", + "pages/transform/template2/Index", + "pages/transform/template3/Index", + "pages/opacity/template1/Index", + "pages/clip/template1/Index", + "pages/clip/template2/Index", + "pages/imageEffect/template1/Index", + "pages/imageEffect/template2/Index", + "pages/imageEffect/template3/Index", + "pages/imageEffect/template4/Index", + "pages/imageEffect/template5/Index", + "pages/imageEffect/template6/Index", + "pages/imageEffect/template7/Index", + "pages/imageEffect/template8/Index", + "pages/imageEffect/template9/Index", + "pages/imageEffect/template10/Index", + "pages/background/template1/Index", + "pages/background/template2/Index", + "pages/background/template3/Index", + "pages/background/template4/Index", + "pages/background/template5/Index", + "pages/background/template6/Index", + "pages/background/template7/Index", + "pages/foregroundBlurStyle/template1/Index", + "pages/foregroundColor/template1/Index", + "pages/foregroundColor/template2/Index", + "pages/foregroundColor/template3/Index", + "pages/clickEffect/template1/Index", + "pages/useEffect/template1/Index", + "pages/renderFit/template1/Index", + "pages/outline/template1/Index", + "pages/outline/template2/Index", + "pages/motionBlur/template1/Index", + "pages/linearGradient/template1/Index", + "pages/linearGradient/template2/Index", + "pages/linearGradient/template3/Index", + "pages/foregroundEffect/template1/Index", + "pages/visualEffect/template1/Index" + ] +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkUISample/VisionEffect/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f7cdedbde009a69923d11e79b251d52ee3eaa92 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + /* + * @tc.number: VisionEffect_assertContain + * @tc.name: Test ability + * @tc.desc: Test ability + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + hilog.info(0x0000, 'testTag', '%{public}s', 'it end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b94e5e1c60390087c2e5f8746643f9c63a12df7c --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Background.test.ets @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function BackgroundTest() { + describe('VisionEffect_BackgroundTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.background')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_001 + * @tc.name: example_one_background + * @tc.desc: example_one_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_002 + * @tc.name: example_two_background + * @tc.desc: example_two_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_003 + * @tc.name: example_three_background + * @tc.desc: example_three_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_003_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_004 + * @tc.name: example_four_background + * @tc.desc: example_four_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_four_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_004_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_005 + * @tc.name: example_five_background + * @tc.desc: example_five_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_five_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_005_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_006 + * @tc.name: example_six_background + * @tc.desc: example_six_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_six_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_006_end'); + }) + + /* + * @tc.number: VisionEffect_BackgroundTest_007 + * @tc.name: example_seven_background + * @tc.desc: example_seven_background + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'BackgroundTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_seven_background')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_007_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b2b43c5bc710e5628e028583cf31d9297f119a77 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ClickEffect.test.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + +const driver = Driver.create(); +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ClickEffectTest() { + describe('VisionEffect_ClickEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.clickEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ClickEffectTest_001 + * @tc.name: example_one_clickEffect + * @tc.desc: example_one_clickEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClickEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClickEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_clickEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + + let Toggles = await driver.findComponents(ON.type('Toggle')); + await Toggles[0].click(); + await driver.delayMs(1000); + + await Toggles[1].click(); + await driver.delayMs(1000); + + await Toggles[2].click(); + await driver.delayMs(1000); + + await Toggles[3].click(); + await driver.delayMs(1000); + + let aimComponents = await driver.findComponents(ON.text('status button')); + await aimComponents[0].click(); + await driver.delayMs(1000); + + await aimComponents[1].click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ClickEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..544677206c2d1ca3091a2d47952dc9134dd121f7 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Clip.test.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ClipTest() { + describe('VisionEffect_ClipTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ClipTest_001 + * @tc.name: example_one_clip + * @tc.desc: example_one_clip + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClipTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ClipTest_002 + * @tc.name: example_two_clip + * @tc.desc: example_two_clip + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ClipTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_clip')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('updateProgress')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + + aimComponent = await driver.findComponent(ON.text('click reset!')); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('updateColor')); + await aimComponent.click(); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text('updateProgress')); + for (let index = 0; index < 10; index++) { + await aimComponent.click(); + await driver.delayMs(100); + } + hilog.info(DOMAIN, TAG, 'VisionEffect_ClipTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..150f45e25607f683e9c530d25e5d1f561409e4a1 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundBlurStyle.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundBlurStyleTest() { + describe('VisionEffect_ForegroundBlurStyleTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundBlurStyle')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundBlurStyleTest_001 + * @tc.name: example_one_foregroundBlurStyle + * @tc.desc: example_one_foregroundBlurStyle + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundBlurStyleTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundBlurStyleTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundBlurStyle')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundBlurStyleTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bf224c4bd6b64b1bf73ac5d7055fd6335f23f42 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundColor.test.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundColorTest() { + describe('VisionEffect_ForegroundColorTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_001 + * @tc.name: example_one_foregroundColor + * @tc.desc: example_one_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_002 + * @tc.name: example_two_foregroundColor + * @tc.desc: example_two_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_ForegroundColorTest_003 + * @tc.name: example_three_foregroundColor + * @tc.desc: example_three_foregroundColor + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundColorTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_foregroundColor')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundColorTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb5ea0bd469c7beb236cdcdcce9b34123c8277eb --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ForegroundEffect.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ForegroundEffectTest() { + describe('VisionEffect_ForegroundEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.foregroundEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ForegroundEffectTest_001 + * @tc.name: example_one_foregroundEffect + * @tc.desc: example_one_foregroundEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ForegroundEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_foregroundEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ForegroundEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f96dad946ca9e0e7a73dfad6847aa02dc6d61ae8 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/ImageEffect.test.ets @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function ImageEffectTest() { + describe('VisionEffect_ImageEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_001 + * @tc.name: example_one_imageEffect + * @tc.desc: example_one_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_BackgroundTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_002 + * @tc.name: example_two_imageEffect + * @tc.desc: example_two_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_003 + * @tc.name: example_three_imageEffect + * @tc.desc: example_three_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_003_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_004 + * @tc.name: example_four_imageEffect + * @tc.desc: example_four_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_004', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_004_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_four_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_004_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_005 + * @tc.name: example_five_imageEffect + * @tc.desc: example_five_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_005', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_005_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_five_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_005_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_006 + * @tc.name: example_six_imageEffect + * @tc.desc: example_six_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_006', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_006_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_six_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_006_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_007 + * @tc.name: example_seven_imageEffect + * @tc.desc: example_seven_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_007', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_007_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_seven_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_007_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_008 + * @tc.name: example_eight_imageEffect + * @tc.desc: example_eight_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_008', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_008_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_eight_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_008_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_009 + * @tc.name: example_nine_imageEffect + * @tc.desc: example_nine_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_009', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_009_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_nine_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_009_end'); + }) + + /* + * @tc.number: VisionEffect_ImageEffectTest_010 + * @tc.name: example_ten_imageEffect + * @tc.desc: example_ten_imageEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'ImageEffectTest_010', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_010_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_ten_imageEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_ImageEffectTest_010_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9167606aace450a1cdbf4e59c7cb1c6f20f18cdd --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/LinearGradient.test.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function LinearGradientTest() { + describe('VisionEffect_LinearGradientTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_001 + * @tc.name: example_one_linearGradient + * @tc.desc: example_one_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_002 + * @tc.name: example_two_linearGradient + * @tc.desc: example_two_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_LinearGradientTest_003 + * @tc.name: example_three_linearGradient + * @tc.desc: example_three_linearGradient + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'LinearGradientTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_linearGradient')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_LinearGradientTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..318bbc28c73fb4d174eb1720cc76c84e11882532 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { TransformTest } from './Transform.test'; +import { OpacityTest } from './Opacity.test'; +import { ClipTest } from './Clip.test'; +import { ImageEffectTest } from './ImageEffect.test'; +import { BackgroundTest } from './Background.test'; +import { ForegroundBlurStyleTest } from './ForegroundBlurStyle.test'; +import { ForegroundColorTest } from './ForegroundColor.test'; +import { ClickEffectTest } from './ClickEffect.test'; +import { UseEffectTest } from './UseEffect.test'; +import { OutLineTest } from './OutLine.test'; +import { RenderFitTest } from './RenderFit.test'; +import { MotionBlurTest } from './MotionBlur.test'; +import { LinearGradientTest } from './LinearGradient.test'; +import { ForegroundEffectTest } from './ForegroundEffect.test'; +import { VisualEffectTest } from './VisualEffect.test' + + +export default function testsuite() { + TransformTest(); + OpacityTest(); + ClipTest(); + ImageEffectTest(); + BackgroundTest(); + ForegroundBlurStyleTest(); + ForegroundColorTest(); + ClickEffectTest(); + UseEffectTest(); + RenderFitTest(); + OutLineTest(); + MotionBlurTest(); + LinearGradientTest(); + ForegroundEffectTest(); + VisualEffectTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..19e739f5794bbb785e63e030e26ed6c12aee20fe --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/MotionBlur.test.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function MotionBlurTest() { + describe('VisionEffect_MotionBlurTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.motionBlur')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_MotionBlurTest_001 + * @tc.name: example_one_motionBlur + * @tc.desc: example_one_motionBlur + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'MotionBlurTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_MotionBlurTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_motionBlur')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Image')) + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.type('Image')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_MotionBlurTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..897bf55df22e64fe4d39fb2357d5607eaf753c2f --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Opacity.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function OpacityTest() { + describe('VisionEffect_OpacityTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.opacity')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_OpacityTest_001 + * @tc.name: example_one_opacity + * @tc.desc: example_one_opacity + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OpacityTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OpacityTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_opacity')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OpacityTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c18d7e3f8cd9c4796900bdba5644fbaaab99539 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/OutLine.test.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function OutLineTest() { + describe('VisionEffect_OutLineTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_OutLineTest_001 + * @tc.name: example_one_outline + * @tc.desc: example_one_outline + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OutLineTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_OutLineTest_002 + * @tc.name: example_two_outline + * @tc.desc: example_two_outline + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'OutLineTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_outline')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_OutLineTest_002_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..50bdc69d39dad7a9944c58d41529403f0e9ada35 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/RenderFit.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function RenderFitTest() { + describe('VisionEffect_RenderFitTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.renderFit')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_RenderFitTest_001 + * @tc.name: example_one_renderFit + * @tc.desc: example_one_renderFit + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'RenderFitTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_RenderFitTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_renderFit')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('animate')); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_RenderFitTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f12681f8738e7effb2afea3494e8eec3b8fa280 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/Transform.test.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function TransformTest() { + describe('VisionEffect_TransformTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_TransformTest_001 + * @tc.name: example_one_transform + * @tc.desc: example_one_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_001_end'); + }) + + /* + * @tc.number: VisionEffect_TransformTest_002 + * @tc.name: example_two_transform + * @tc.desc: example_two_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_002', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_002_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_two_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('change prep')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_002_end'); + }) + + /* + * @tc.number: VisionEffect_TransformTest_003 + * @tc.name: example_three_transform + * @tc.desc: example_three_transform + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'TransformTest_003', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_003_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_three_transform')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_TransformTest_003_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b835508bd4b75f9437da79ce863bfa9773e8bb57 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/UseEffect.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function UseEffectTest() { + describe('VisionEffect_UseEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.useEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_UseEffectTest_001 + * @tc.name: example_one_useEffect + * @tc.desc: example_one_useEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'UseEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_UseEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_useEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + + aimComponent = await driver.findComponent(ON.text('useEffect')) + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_UseEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..beed8c5f11bd0afb5621048fd3b5a99175c37ea7 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/ets/test/VisualEffect.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { abilityDelegatorRegistry, Component, Driver } from '@kit.TestKit'; +import { afterEach, beforeAll, describe, expect, it } from '@ohos/hypium'; +import { ON } from '@ohos.UiTest'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() +const BUNDLE = 'VisionEffect_' +const TAG = '[Sample_VisionEffect_]'; +const DOMAIN = 0xF811 + +const driver = Driver.create(); + +let aimComponent : Component +let resourceManager = delegator.getAppContext().resourceManager; + +export function VisualEffectTest() { + describe('VisionEffect_VisualEffectTest', () => { + + beforeAll(async () => { + await delegator.startAbility({ + bundleName: 'com.samples.visionEffect', + abilityName: 'EntryAbility' + }); + await driver.delayMs(3000); + + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.visualEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + }) + + afterEach(async () => { + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + do { + await driver.pressBack(); + aimComponent = await driver.findComponent(ON.text('VisionEffectIndex')); + } while (aimComponent == null) + }) + + /* + * @tc.number: VisionEffect_VisualEffectTest_001 + * @tc.name: example_one_visualEffect + * @tc.desc: example_one_visualEffect + * @tc.size: MediumTest + * @tc.type: Function + * @tc.level Level 1 + */ + it(BUNDLE + 'VisualEffectTest_001', 0, async () => { + hilog.info(DOMAIN, TAG, 'VisionEffect_VisualEffectTest_001_begin'); + aimComponent = await driver.findComponent(ON.text(resourceManager.getStringSync($r('app.string.example_one_visualEffect')))); + await aimComponent.click(); + await driver.delayMs(1000); + hilog.info(DOMAIN, TAG, 'VisionEffect_VisualEffectTest_001_end'); + }) + + }) +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1cafc28b86d7d9f2b34f24d26a75c0dbd7299715 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/ohosTest/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/List.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/VisionEffect/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/VisionEffect/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2d5b53c87bb8c7e5a38072d17a6e9b9533003301 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.1.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/hvigorfile.ts b/code/DocsSample/ArkUISample/VisionEffect/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/oh-package.json5 b/code/DocsSample/ArkUISample/VisionEffect/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b56a095f3819541cf150766a67ff7e23a23973a9 --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.1.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkUISample/VisionEffect/ohosTest.md b/code/DocsSample/ArkUISample/VisionEffect/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..9c090d5c0dca5f9949c78f5a2da22450c84a955e --- /dev/null +++ b/code/DocsSample/ArkUISample/VisionEffect/ohosTest.md @@ -0,0 +1,21 @@ +# VisualEffect 测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ------------------- | -------------- | ----------------------- | ------------------------------------------------------------ | :------- | -------- | +| 背景设置示例代码验证 | 设备正常运行 | 切换背景颜色 | 背景颜色效果符合预期 | 是 | Pass | +| 点击回弹效果示例代码验证 | 设备正常运行 | 切换回弹效果 | 回弹效果符合预期 | 是 | Pass | +| 形状裁剪示例代码验证 | 设备正常运行 | 查看各个组件的裁剪效果 | 各个组件的裁剪效果正常 | 是 | Pass | +| 组件内容模糊示例代码验证 | 设备正常运行 | 查看各个组件的模糊效果 | 模糊效果正常,页面布局正常 | 是 | Pass | +| 前景色设置示例代码验证 | 设备正常运行 | 切换前景色 | 前景色正常,页面布局正常 | 是 | Pass | +| 前景属性设置示例代码验证 | 设备正常运行 | 切换前景属性 | 视效效果符合预期 | 是 | Pass | +| 图像效果示例代码验证 | 设备正常运行 | 切换页面,查看各种图像效果 | 图像效果符合预期 | 是 | Pass | +| 颜色渐变示例代码验证 | 设备正常运行 | 查看各个组件的渐变效果 | 渐变效果符合预期 | 是 | Pass | +| 运动模糊示例代码验证 | 设备正常运行 | 点击控件触发视效 | 运动模糊效果符合预期 | 是 | Pass | +| 透明度设置示例代码验证 | 设备正常运行 | 查看各个控件的透明度效果 | 透明度效果从上至下由深到浅 | 是 | Pass | +| 外描边设置示例代码验证 | 设备正常运行 | 查看各个控件的外描边效果 | 外描边效果符合预期 | 是 | Pass | +| 组件内容填充方式示例代码验证 | 设备正常运行 | 点击animate按钮 | 动画效果正常,视效效果正常,页面布局正常 | 是 | Pass | +| 图形变换示例代码验证 | 设备正常运行 | 查看各个示例页面中的组件 | 图形变换效果正常,页面布局正常 | 是 | Pass | +| 特效绘制合并示例代码验证 | 设备正常运行 | 点击useEffect按钮 | 特效绘制合并效果正常,页面布局正常 | 是 | Pass | +| 视效设置示例代码验证 | 设备正常运行 | 点击各种视觉效果 | 视效效果正常,页面布局正常 | 是 | Pass | diff --git a/code/DocsSample/ArkUISample/VisionEffect/screenshots/device/image1.png b/code/DocsSample/ArkUISample/VisionEffect/screenshots/device/image1.png new file mode 100644 index 0000000000000000000000000000000000000000..c169671c94477334f99ca19063dd351cde63861f Binary files /dev/null and b/code/DocsSample/ArkUISample/VisionEffect/screenshots/device/image1.png differ diff --git a/code/DocsSample/International/Internationalization/entry/src/main/ets/i18napplication/DateTimeFormatting.ets b/code/DocsSample/International/Internationalization/entry/src/main/ets/i18napplication/DateTimeFormatting.ets index 768bf6e974ffe5b299b645c3eed11a7547d07d36..dfbb6e46c598d99943737ca5abed09d1bf96ddcc 100644 --- a/code/DocsSample/International/Internationalization/entry/src/main/ets/i18napplication/DateTimeFormatting.ets +++ b/code/DocsSample/International/Internationalization/entry/src/main/ets/i18napplication/DateTimeFormatting.ets @@ -32,7 +32,7 @@ import { intl } from '@kit.LocalizationKit'; * - 时间日期格式化 * let formattedDate: string = dateFormat.format(date: Date); * - 相对时间格式化 - * let formattedDate: string = dateFormat.format(date: Date); + * let formattedDateRange: string = dateFormat.formatRange(startDate: Date, endDate: Date); * 4. 获取格式化选项,查看对象的设置信息 * let options: intl.DateTimeOptions = dateFormat.resolvedOptions(); *********************************************************************************************************************/ @@ -137,10 +137,6 @@ const expectedFormattedRelativeTime1 = '1 day ago'; const expectedFormattedRelativeTime2 = 'yesterday'; const expectedFormattedRelativeTime3 = 'il y a 1 jour'; const expectedFormattedRelativeTime4 = '-1 j'; -const expectedCustomFormat = - '[{\"value\":\"in \",\"type\":\"literal\"},' + - '{\"value\":\"1\",\"unit\":\"day\",\"type\":\"integer\"},' + - '{\"value\":\" day\",\"type\":\"literal\"}]'; const expectedNumeric = 'auto'; @Extend(Text) @@ -190,7 +186,9 @@ struct DateTimeFormatting { Text(assertEqual(formattedRelativeTime4, expectedFormattedRelativeTime4, $r('app.string.NarrowFormatRelativeTime'))) .textStyle() - Text(assertEqual(JSON.stringify(parts), expectedCustomFormat, $r('app.string.CustomFormatRelativeTime'))) + Text($r('app.string.CustomFormatRelativeTime')) + .textStyle() + Text(JSON.stringify(parts)) .textStyle() Text(assertEqual(numeric, expectedNumeric, $r('app.string.GetRelativeTimeFormatOptions'))) .textStyle() diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/.gitignore b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/app.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..530edd98abd603959b51947f534038b2032e1589 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.AVImageGeneratorArkTS", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9ea1b19fe6f249adc9c4d784529afe2314f283d7 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AVImageGeneratorArkTS" + } + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/README.md b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8cb9b191b8be197403fe931b965a76a52b34007c --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/README.md @@ -0,0 +1,69 @@ +# AVImageGeneratorArkTS + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用AVImageGenerator提取视频指定时间图像(ArkTS)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/avimagegenerator.md)的配套示例工程。 + +本示例展示了如何获取视频资源的缩略图。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击获取缩略图按钮,获取视频缩略图; + + +## 工程目录 + +``` +AVImageGeneratorArkTS +entry/src/main/ets/ +└── pages + └── Index.ets (获取缩略图界面) +entry/src/main/resources/ +├── base +│ ├── element +│ │ ├── color.json +│ │ ├── float.json +│ │ └── string.json +│ └── media +│ +└── rawfile + └── H264_AAC.mp4 (视频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/build-profile.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a2b572d947cd6f7dfba85072fb0313ca83f317c --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/.gitignore b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/build-profile.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/hvigorfile.ts b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/oh-package.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..9833de65487c05e70797a05302f99f1e06b4c879 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { media } from '@kit.MediaKit'; +import { image } from '@kit.ImageKit'; +import { common } from '@kit.AbilityKit'; + +const TAG = 'MetadataDemo'; +@Entry +@Component +struct Index { + // pixelMap对象声明,用于图片显示。 + @State pixelMap: image.PixelMap | undefined = undefined; + + build() { + Row() { + Column() { + Button() { + Text($r('app.string.FetchFrame')) + .fontSize(26) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + .onClick(async () => { + // 设置fdSrc, 获取视频的缩略图。 + await this.testFetchFrameByTime(); + }) + .id('FetchFrameButton') + Image(this.pixelMap).width(300).height(300) + .margin({ + top: 20 + }) + } + .width('100%') + } + .height('100%') + } + + // 在以下demo中,使用资源管理接口获取打包在HAP内的视频文件,通过设置fdSrc属性。 + // 获取视频指定时间的缩略图,并通过Image控件显示在屏幕上。 + async testFetchFrameByTime() { + try { + // 创建AVImageGenerator对象。 + let avImageGenerator: media.AVImageGenerator = await media.createAVImageGenerator(); + // 设置fdSrc。 + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + avImageGenerator.fdSrc = await context.resourceManager.getRawFd('H264_AAC.mp4'); + + // 初始化入参。 + let timeUs = 0; + let queryOption = media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC; + let param: media.PixelMapParams = { + width : 300, + height : 300 + }; + + // 获取缩略图(promise模式)。 + this.pixelMap = await avImageGenerator.fetchFrameByTime(timeUs, queryOption, param); + + // 释放资源(promise模式)。 + avImageGenerator.release(); + console.info(TAG, `release success.`); + } catch (err) { + console.error(`FetchFrameByTime errCode is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/module.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9847f338dc03ee5236a5b2ea61939973588f0129 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "获取缩略图ArkTS" + }, + { + "name": "FetchFrame", + "value": "获取缩略图" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7277b0e4910c52a8614d4f2162af3c03ad8589100f32e80dc36a9c96ba797ecd +size 1894335 diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..851e98caf1cfb63a8432dd7a130d383e3b4a4f6a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AVImageGenerator]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AVImageGeneratorArkTS_001', 0, async (done: Function) => { + console.info(TAG, 'AVImageGeneratorArkTS_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('FetchFrameButton')); + await button.click(); + await driver.delayMs(3000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AVImageGeneratorArkTS_001 end'); + }) + }) +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/List.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigorfile.ts b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/oh-package.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/ohosTest.md b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..5c23aeab43003897f35a63c73025c8178951d9ea --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/ohosTest.md @@ -0,0 +1,7 @@ +# AVImageGeneratorArkTS测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并获取缩略图 | 设备正常运行 | | 获取成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/screenshots/AVImageGeneratorArkTS.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/screenshots/AVImageGeneratorArkTS.png new file mode 100644 index 0000000000000000000000000000000000000000..6f4c3fcdff0972d309958d35729879e7004feec1 Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorArkTS/screenshots/AVImageGeneratorArkTS.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/.gitignore b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/app.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d5e0efedb9131cab56bf825c087dc617b3a065ca --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.samples.AVImageGeneratorNDK", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f5f0ec704bbb8ec48f3d70bda3ccf06045164d06 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AVImageGeneratorNDK" + } + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/README.md b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/README.md new file mode 100644 index 0000000000000000000000000000000000000000..cd742b2e892d493272d26af9ac8f659838331936 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/README.md @@ -0,0 +1,77 @@ +# AVImageGeneratorNDK + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用AVImageGenerator获取视频帧(C/C++)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/using-ndk-avimagegenerator-for-video.md)的配套示例工程。 + +本示例展示了如何获取视频资源的缩略图。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 选择传入时间点与关键帧的关系,点击开始抽帧按钮,获取指定时间的视频缩略图; +3. 点击清楚图片按钮,清除生成的缩略图; + + +## 工程目录 + +``` +AVImageGeneratorNDK +entry/src/main/ets/ +└── pages + └── Index.ets (获取缩略图界面) +entry/src/main/ +├── cpp +│ ├── types +│ │ └── libentry +│ │ └── Index.d.ts (NDK函数对应的js映射) +│ ├── CMakeLists.txt (CMake脚本) +│ └── napi_init.cpp (NDK函数) +└── resources + ├── base + │ ├── element + │ │ ├── color.json + │ │ ├── float.json + │ │ └── string.json + │ └── media + │ + └── rawfile + └── H264_AAC.mp4 (视频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/build-profile.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a2b572d947cd6f7dfba85072fb0313ca83f317c --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/.gitignore b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/build-profile.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9bf154bd51072d27832bec1764cd98af35290ca3 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["armeabi-v7a", "arm64-v8a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/hvigorfile.ts b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/oh-package.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3c03cc6d380389d57e0120a980bda3b75099adee --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6efb82a01d9af8615909533224144b522ab5cf11 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,23 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(AVMetadataExtractorNDK) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC + libace_napi.z.so + libavimage_generator.so + libhilog_ndk.z.so + libpixelmap.so + libpixelmap_ndk.z.so + libavmetadata_extractor.so + libnative_media_core.so +) diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c39ff8f9bfefa85ec9806cf75edbd3a448f0302 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +#include +#include +#include +#include +#include "multimedia/player_framework/avmetadata_extractor.h" +#include "multimedia/player_framework/avmetadata_extractor_base.h" + +#include + +#define LOG_PRINT_DOMAIN 0xFF00 +#define APP_LOG_DOMAIN 0x0001 +constexpr const char *APP_LOG_TAG = "AVImageGenerator"; +const int FETCH_FRAME_ARG_NUM = 5; +const int GET_DURATION_ARG_NUM = 3; +const int FIRST_PARAM = 0; +const int SECOND_PARAM = 1; +const int THIRD_PARAM = 2; +const int FOUTRH_PARAM = 3; +const int FIFTH_PARAM = 4; +#define H_LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) + +// 辅助函数:检查参数数量和类型。 +bool CheckArgs(napi_env env, napi_callback_info info, size_t expectedArgc) +{ + size_t argc; + napi_value thisArg; + void* data; + napi_get_cb_info(env, info, &argc, nullptr, &thisArg, &data); + if (argc < expectedArgc) { + napi_throw_error(env, "EINVAL", "Insufficient arguments"); + return false; + } + napi_value argv[expectedArgc]; + napi_get_cb_info(env, info, &argc, argv, &thisArg, &data); + for (size_t i = 0; i < expectedArgc; ++i) { + napi_valuetype type; + napi_typeof(env, argv[i], &type); + if (type != napi_number) { + napi_throw_type_error(env, "EINVAL", "All arguments must be numbers"); + return false; + } + } + return true; +} + +// 辅助函数:获取 int32 类型值并进行错误处理。 +bool GetInt32Value(napi_env env, napi_value value, int32_t* result) +{ + napi_status status = napi_get_value_int32(env, value, result); + if (status != napi_ok) { + napi_throw_error(env, "EINVAL", "Failed to get int32 value"); + return false; + } + return true; +} + +// 辅助函数:获取 int64 类型值并进行错误处理。 +bool GetInt64Value(napi_env env, napi_value value, int64_t* result) +{ + napi_status status = napi_get_value_int64(env, value, result); + if (status != napi_ok) { + napi_throw_error(env, "EINVAL", "Failed to get int64 value"); + return false; + } + return true; +} + +// FetchFrameByTime的输入参数 +struct FetchFrameParams { + int64_t timeUs = 0; + int64_t offset = 0; + int32_t fileDescribe = -1; + int32_t fileSize = 0; + int32_t options = OH_AVIMAGE_GENERATOR_QUERY_CLOSEST; +}; + +// 辅助函数:获取FetchFrameByTime的输入参数 +bool GetFetchFrameByTimeParams(napi_env env, napi_callback_info info, FetchFrameParams &fetchFrameParams) +{ + if (!CheckArgs(env, info, FETCH_FRAME_ARG_NUM)) { + return false; + } + size_t argc = FETCH_FRAME_ARG_NUM; + napi_value argv[FETCH_FRAME_ARG_NUM]; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (!GetInt32Value(env, argv[FIRST_PARAM], &fetchFrameParams.fileDescribe)) { + return false; + } + if (!GetInt32Value(env, argv[SECOND_PARAM], &fetchFrameParams.fileSize)) { + return false; + } + if (!GetInt64Value(env, argv[THIRD_PARAM], &fetchFrameParams.timeUs)) { + return false; + } + if (!GetInt32Value(env, argv[FOUTRH_PARAM], &fetchFrameParams.options)) { + return false; + } + if (!GetInt64Value(env, argv[FIFTH_PARAM], &fetchFrameParams.offset)) { + return false; + } + if (fetchFrameParams.options < OH_AVIMAGE_GENERATOR_QUERY_NEXT_SYNC || + fetchFrameParams.options > OH_AVIMAGE_GENERATOR_QUERY_CLOSEST) { + napi_throw_range_error(env, "EINVAL", "Invalid options value"); + return false; + } + return true; +} + +/** + * 需要在index.d.ts文件内描述映射的OhAvImageGeneratorFetchFrameByTime方法。 + * export const OhAvImageGeneratorFetchFrameByTime: (fdsrc : number, size : number, timeus : number, + * options : number, offset : number) => image.PixelMap; + * 需要传入媒体文件描述符fdsrc、媒体文件大小size、指定的时间timeus(单位us)、 + * 指定时间点与视频帧的对应关系options、媒体源在文件描述符中的偏移量offset。 + * 返回PixelMap对象。 + */ +static napi_value OhAvImageGeneratorFetchFrameByTime(napi_env env, napi_callback_info info) +{ + FetchFrameParams fetchFrameParams; + if (!GetFetchFrameByTimeParams(env, info, fetchFrameParams)) { + return nullptr; + } + int64_t timeUs = fetchFrameParams.timeUs; + int64_t offset = fetchFrameParams.offset; + int32_t fileDescribe = fetchFrameParams.fileDescribe; + int32_t fileSize = fetchFrameParams.fileSize; + int32_t options = fetchFrameParams.options; + // 创建OH_AVImageGenerator实例。 + OH_AVImageGenerator* generator = OH_AVImageGenerator_Create(); + // 异常处理。 + if (!generator) { + napi_throw_error(env, "EFAILED", "Create generator failed"); + return nullptr; + } + // 设置视频资源的文件描述符。 + OH_AVErrCode avErrCode = OH_AVImageGenerator_SetFDSource(generator, fileDescribe, offset, fileSize); + // 异常处理。 + if (avErrCode != AV_ERR_OK) { + OH_AVImageGenerator_Release(generator); + napi_throw_error(env, "EFAILED", "SetFDSource failed"); + return nullptr; + } + // 取指定时间的视频帧。 + OH_PixelmapNative* pixelMap = nullptr; + avErrCode = OH_AVImageGenerator_FetchFrameByTime(generator, timeUs, + (OH_AVImageGenerator_QueryOptions)options, &pixelMap); + // 异常处理。 + if (avErrCode != AV_ERR_OK || !pixelMap) { + OH_AVImageGenerator_Release(generator); + napi_throw_error(env, "EFAILED", "FetchFrameByTime failed"); + return nullptr; + } + // 将nativePixelMap对象转换为PixelMapnapi对象。 + napi_value pixelmapNapi = nullptr; + Image_ErrorCode errCode = OH_PixelmapNative_ConvertPixelmapNativeToNapi(env, pixelMap, &pixelmapNapi); + // 释放OH_PixelmapNative资源。 + OH_PixelmapNative_Release(pixelMap); + // 释放OH_AVImageGenerator资源。 + OH_AVImageGenerator_Release(generator); + // 异常处理。 + if (errCode != IMAGE_SUCCESS) { + napi_throw_error(env, "EFAILED", "Convert PixelMap failed"); + return nullptr; + } + return pixelmapNapi; +} + +// 辅助函数:获取GetDuration的输入参数 +bool GetGetDurationParams(napi_env env, napi_callback_info info, int64_t &offset, int32_t &fileDescribe, + int64_t &fileSize) +{ + if (!CheckArgs(env, info, GET_DURATION_ARG_NUM)) { + return false; + } + size_t argc = GET_DURATION_ARG_NUM; + napi_value argv[GET_DURATION_ARG_NUM]; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (!GetInt32Value(env, argv[FIRST_PARAM], &fileDescribe)) { + return false; + } + if (!GetInt64Value(env, argv[SECOND_PARAM], &fileSize)) { + return false; + } + if (!GetInt64Value(env, argv[THIRD_PARAM], &offset)) { + return false; + } + return true; +} + +static napi_value OhAVMetadataExtractorGetDuration(napi_env env, napi_callback_info info) +{ + int64_t offset = 0; + int32_t fileDescribe = -1; + int64_t fileSize = 0; + if (!GetGetDurationParams(env, info, offset, fileDescribe, fileSize)) { + return nullptr; + } + OH_AVMetadataExtractor* mainExtractor = OH_AVMetadataExtractor_Create(); + if (!mainExtractor) { + napi_throw_error(env, "EFAILED", "Create metadata extractor failed"); + return nullptr; + } + OH_AVErrCode avErrCode = OH_AVMetadataExtractor_SetFDSource(mainExtractor, fileDescribe, offset, fileSize); + if (avErrCode != AV_ERR_OK) { + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "SetFDSource for metadata extractor failed"); + return nullptr; + } + OH_AVFormat* avMetadata = OH_AVFormat_Create(); + avErrCode = OH_AVMetadataExtractor_FetchMetadata(mainExtractor, avMetadata); + if (avErrCode != AV_ERR_OK) { + OH_AVFormat_Destroy(avMetadata); + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Fetch metadata failed"); + return nullptr; + } + int64_t out; + if (!OH_AVFormat_GetLongValue(avMetadata, OH_AVMETADATA_EXTRACTOR_DURATION, &out)) { + OH_AVFormat_Destroy(avMetadata); + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Get duration failed"); + return nullptr; + } + napi_value duration; + napi_create_int64(env, out, &duration); + OH_AVFormat_Destroy(avMetadata); + OH_AVMetadataExtractor_Release(mainExtractor); + return duration; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "OhAvImageGeneratorFetchFrameByTime", nullptr, OhAvImageGeneratorFetchFrameByTime, nullptr, nullptr, nullptr, + napi_default, nullptr }, + { "OhAVMetadataExtractorGetDuration", nullptr, OhAVMetadataExtractorGetDuration, nullptr, nullptr, nullptr, + napi_default, nullptr }, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..430afce44bac24a571b4ed11f9114d904c681eaa --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { image } from "@kit.ImageKit"; + +export const OhAvImageGeneratorFetchFrameByTime: (fdsrc : number, size : number, timeus : number, options : number, offset : number) => image.PixelMap; +export const OhAVMetadataExtractorGetDuration: (fdsrc : number, fileSize : number, offset : number) => number; diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f46aeb4a4fa2fa8023596a85e291a48b0dd2deeb --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..28a8e6c49ceedb17310f0d0e805c8cb81a09d20b --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { image } from '@kit.ImageKit'; +import avimagegenerator from 'libentry.so'; +import {promptAction} from '@kit.ArkUI'; +import { common } from '@kit.AbilityKit'; + +@Entry +@Component +struct Index { + @State totalDuration: number = 0; + @State queryOption: string = 'next sync' + @State arrowPosition: ArrowPosition = ArrowPosition.END + @State space: number = 8 + // pixelMap对象声明,用于图片显示。 + @State pixelMap: image.PixelMap | undefined = undefined; + @State queryOptionIndex: number = 0 + private videoName: string = 'H264_AAC.mp4'; + + build() { + Column() { + + Text(this.videoName).fontSize(20).fontWeight(FontWeight.Bold) + + Select([{ value: $r('app.string.nextSync') }, + { value: $r('app.string.previousSync') }, + { value: $r('app.string.closestSync') }, + { value: $r('app.string.closest') }]) + .selected(this.queryOptionIndex) + .value(this.queryOption) + .font({ size: 16, weight: 500 }) + .fontColor('#182431') + .selectedOptionFont({ size: 16, weight: 400 }) + .optionFont({ size: 16, weight: 400 }) + .space(this.space) + .arrowPosition(this.arrowPosition) + .menuAlign(MenuAlignType.START, {dx:0, dy:0}) + .margin({ + top: 20 + }) + .width('60%') + .onSelect((index:number, text?: string | undefined)=>{ + console.info('Select:' + index) + this.queryOptionIndex = index; + if(text){ + this.queryOption = text; + } + }) + + Button() { + Text($r('app.string.FetchFrame')) + .fontSize(30) + .fontWeight(FontWeight.Bold); + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + .onClick(() => { + this.testFetchFrameByTime(); + }) + .id('FetchFrameButton'); + + Row () { + if (this.pixelMap) { + Image(this.pixelMap) + .width(300) + .height(300) + .margin({ + top: 20 + }) + .borderWidth(2) + .borderColor('#0D9FFB').objectFit(ImageFit.Fill) + } else { + Image(null) + .width('16.67%') + .margin({ + top: 20 + }) + .borderWidth(0) + .borderColor('#0D9FFB') + } + } + + Button($r('app.string.ClearPictures'), { type: ButtonType.Normal }) + .onClick(() => { + this.pixelMap = undefined; + promptAction.showToast({ + message:$r('app.string.ClearPicturesFinish'), + duration:2000, + showMode: promptAction.ToastShowMode.DEFAULT, + bottom:80 + }) + }) + .id('ClearPicturesButton'); + }.width('100%').height('100%') + } + + async testFetchFrameByTime() { + try { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let avFileDescriptor = await context.resourceManager.getRawFd(this.videoName); + let fdsrc : number = avFileDescriptor.fd; + let size : number = avFileDescriptor.length; + let offset : number = avFileDescriptor.offset; + let timeMs : number = 0; + timeMs = avimagegenerator.OhAVMetadataExtractorGetDuration(fdsrc, size, offset); + this.totalDuration = timeMs / 1_000; + this.pixelMap = avimagegenerator.OhAvImageGeneratorFetchFrameByTime(fdsrc, size, timeMs * 1000 / 5, + this.queryOptionIndex, offset); + } catch (err) { + console.error(`OhAVMetadataExtractorGetDuration errCode is ${err.code}, message is ${err.message}`); + } + } + +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/module.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d28ff26be237141285e247119e05c7bc983f0248 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/element/string.json @@ -0,0 +1,44 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "获取缩略图NDK" + }, + { + "name": "nextSync", + "value": "next sync" + }, + { + "name": "previousSync", + "value": "previous sync" + }, + { + "name": "closestSync", + "value": "closest sync" + }, + { + "name": "closest", + "value": "closest" + }, + { + "name": "FetchFrame", + "value": "开始抽帧" + }, + { + "name": "ClearPictures", + "value": "清除图片" + }, + { + "name": "ClearPicturesFinish", + "value": "已清除图片" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/rawfile/H264_AAC.mp4 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/main/resources/rawfile/H264_AAC.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7277b0e4910c52a8614d4f2162af3c03ad8589100f32e80dc36a9c96ba797ecd +size 1894335 diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a2f76ebd321544ce1936d4dbe4ccf9cd96e4eb6 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AVImageGeneratorNDK]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AVImageGeneratorNDK_001', 0, async (done: Function) => { + console.info(TAG, 'AVImageGeneratorNDK_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('FetchFrameButton')); + await button.click(); + await driver.delayMs(2000); + const button2 = await driver.findComponent(ON.id('ClearPicturesButton')); + await button2.click(); + await driver.delayMs(2000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AVImageGeneratorNDK_001 end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/List.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigorfile.ts b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/oh-package.json5 b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/ohosTest.md b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..fb61c4f98416b04581899e543b2c17809f57c688 --- /dev/null +++ b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/ohosTest.md @@ -0,0 +1,7 @@ +# AVImageGeneratorNDK测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并获取缩略图 | 设备正常运行 | | 获取成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/screenshots/AVImageGeneratorNDK.png b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/screenshots/AVImageGeneratorNDK.png new file mode 100644 index 0000000000000000000000000000000000000000..5ec62a9da7cda7a0d89dfd04fbda55d03bcb60b3 Binary files /dev/null and b/code/DocsSample/Media/AVImageGenerator/AVImageGeneratorNDK/screenshots/AVImageGeneratorNDK.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/.gitignore b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/app.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8fd03c7e22d0faf9268bd7c6ab322c70e7de682c --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.AVMetadataExtractorArkTS", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c667fafdd6b692262f3f0f2d04c0cf45f012819c --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AVMetadataExtractorArkTS" + } + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/README.md b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c0b09366cef5e9518523cbe322bd6c188108c518 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/README.md @@ -0,0 +1,68 @@ +# AVMetadataExtractorArkTS + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用AVMetadataExtractor提取音视频元数据信息(ArkTS)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/avmetadataextractor.md)的配套示例工程。 + +本示例展示了如何获取一个音频资源的元数据。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击获取元数据信息按钮,日志打印资源文件的元数据信息,获取专辑封面; + +## 工程目录 + +``` +AVMetadataExtractorArkTS +entry/src/main/ets/ +└── pages + └── Index.ets (获取元数据界面) +entry/src/main/resources/ +├── base +│ ├── element +│ │ ├── color.json +│ │ ├── float.json +│ │ └── string.json +│ └── media +│ +└── rawfile + └── test.mp3 (音频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/build-profile.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a705bc1cb2b918d64bdda76a08b4f000129647e7 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/.gitignore b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/build-profile.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/hvigorfile.ts b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/oh-package.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60294cd76caa83804a07c004ac092f7d4a3ec4d --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { media } from '@kit.MediaKit'; +import { image } from '@kit.ImageKit'; +import { common } from '@kit.AbilityKit'; +import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit'; + +const TAG = 'MetadataDemo'; + +@Entry +@Component +struct Index { + // pixelMap对象声明,用于图片显示。 + @State pixelMap: image.PixelMap | undefined = undefined; + context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; + rootPath: string = this.context.filesDir; + testFilename: string = '/test.mp3'; + + build() { + Row() { + Column() { + Button() { + Text($r('app.string.FetchMetadata')) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('60%') + .height('5%') + .onClick(async () => { + // 设置fdSrc, 获取音频元数据和专辑封面(异步接口以Callback形式调用)。 + await this.testFetchMetadataFromFdSrcByCallback(); + // 设置fdSrc, 获取音频元数据和专辑封面(异步接口以Promise形式调用)。 + await this.testFetchMetadataFromFdSrcByPromise(); + // 通过fdSrc获取沙箱路径下音频元数据和专辑封面(文件必须在沙箱路径里存在)。 + await this.testFetchMetadataFromFdSrc(); + // 设置dataSrc, 获取沙箱路径下音频元数据和专辑封面(文件必须在沙箱路径里存在)。 + await this.testFetchMetadataFromDataSrc(); + }) + .id('FetchMetadataButton') + + Image(this.pixelMap).width(300).height(300) + .margin({ + top: 20 + }) + } + .width('100%') + } + .height('100%') + } + + // 在以下demo中,使用资源管理接口获取打包在HAP内的媒体资源文件,通过设置fdSrc属性,获取音频元数据并打印。 + // 获取音频专辑封面并通过Image控件显示在屏幕上。该demo以Callback形式进行异步接口调用。 + async testFetchMetadataFromFdSrcByCallback() { + if (canIUse('SystemCapability.Multimedia.Media.AVMetadataExtractor')) { + try { + // 创建AVMetadataExtractor对象。 + let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor(); + // 设置fdSrc。 + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + avMetadataExtractor.fdSrc = await context.resourceManager.getRawFd('test.mp3'); + + // 获取元数据(callback模式)。 + avMetadataExtractor.fetchMetadata((error, metadata) => { + if (error) { + console.error(TAG, `fetchMetadata callback failed, err = ${JSON.stringify(error)}`); + return; + } + console.info(TAG, `fetchMetadata callback success, genre: ${metadata.genre}`); + }) + + //获取专辑封面(callback模式)。 + avMetadataExtractor.fetchAlbumCover((err, pixelMap) => { + if (err) { + console.error(TAG, `fetchAlbumCover callback failed, err = ${JSON.stringify(err)}`); + return; + } + this.pixelMap = pixelMap; + + // 释放资源(callback模式)。 + avMetadataExtractor.release((error) => { + if (error) { + console.error(TAG, `release failed, err = ${JSON.stringify(error)}`); + return; + } + console.info(TAG, `release success.`); + }) + }) + } catch (e) { + console.error(TAG + `FetchMetadataFromFdSrcByCallback, code is ${e.code}, message is ${e.message}`); + } + } + } + + // 在以下demo中,使用资源管理接口获取打包在HAP内的媒体资源文件,通过设置fdSrc属性,获取音频元数据并打印。 + // 获取音频专辑封面并通过Image控件显示在屏幕上。该demo以Promise形式进行异步接口调用。 + async testFetchMetadataFromFdSrcByPromise() { + if (canIUse('SystemCapability.Multimedia.Media.AVMetadataExtractor')) { + try { + // 创建AVMetadataExtractor对象。 + let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor(); + + // 设置fdSrc。 + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + avMetadataExtractor.fdSrc = await context.resourceManager.getRawFd('test.mp3'); + + // 获取元数据(promise模式)。 + let metadata = await avMetadataExtractor.fetchMetadata(); + console.info(TAG, `get meta data, hasAudio: ${metadata.hasAudio}`); + + // 获取专辑封面(promise模式)。 + this.pixelMap = await avMetadataExtractor.fetchAlbumCover(); + + // 释放资源(promise模式)。 + avMetadataExtractor.release(); + console.info(TAG, `release success.`); + } catch (e) { + console.error(TAG + `FetchMetadataFromFdSrcByPromise, code is ${e.code}, message is ${e.message}`); + } + } + } + + // 在以下demo中,使用fs文件系统打开沙箱地址获取媒体文件地址,设置fdSrc属性,获取音频元数据并打印。 + // 获取音频专辑封面并通过Image控件显示在屏幕上。 + async testFetchMetadataFromFdSrc() { + if (canIUse('SystemCapability.Multimedia.Media.AVMetadataExtractor')) { + try { + // 创建AVMetadataExtractor对象。 + let avMetadataExtractor = await media.createAVMetadataExtractor(); + + // 设置fdSrc。 + console.info(TAG, `path: ${this.rootPath + this.testFilename}`); + avMetadataExtractor.fdSrc = fs.openSync(this.rootPath + this.testFilename); + + // 获取元数据(promise模式)。 + let metadata = await avMetadataExtractor.fetchMetadata(); + console.info(TAG, `get meta data, mimeType: ${metadata.mimeType}`); + + // 获取专辑封面(promise模式)。 + this.pixelMap = await avMetadataExtractor.fetchAlbumCover(); + + // 释放资源(promise模式)。 + avMetadataExtractor.release(); + console.info(TAG, `release data source success.`); + } catch (e) { + console.error(TAG + `FetchMetadataFromFdSrc, code is ${e.code}, message is ${e.message}`); + } + } + } + + // 在以下demo中,使用fs文件系统打开沙箱地址获取媒体文件地址,设置dataSrc属性,获取音频元数据并打印。 + // 获取音频专辑封面并通过Image控件显示在屏幕上。 + async testFetchMetadataFromDataSrc() { + if (canIUse('SystemCapability.Multimedia.Media.AVMetadataExtractor')) { + try { + // 通过UIAbilityContext获取沙箱地址filesDir(以Stage模型为例)。 + let fd: number = fs.openSync(this.rootPath + this.testFilename).fd; + let fileSize: number = fs.statSync(this.rootPath + this.testFilename).size; + // 设置dataSrc描述符,通过callback从文件中获取资源,写入buffer中。 + let dataSrc: media.AVDataSrcDescriptor = { + fileSize: fileSize, + callback: (buffer, len, pos) => { + if (buffer == undefined || len == undefined || pos == undefined) { + console.error(TAG, `dataSrc callback param invalid`); + return -1; + } + let options: ReadOptions = { + offset: pos, + length: len + }; + let num = fs.readSync(fd, buffer, options); + console.info(TAG, 'readAt end, num: ' + num); + if (num > 0 && fileSize >= pos) { + return num; + } + return -1; + } + }; + + // 创建AVMetadataExtractor对象。 + let avMetadataExtractor = await media.createAVMetadataExtractor(); + // 设置dataSrc。 + avMetadataExtractor.dataSrc = dataSrc; + + // 获取元数据(promise模式)。 + let metadata = await avMetadataExtractor.fetchMetadata(); + console.info(TAG, `get meta data, mimeType: ${metadata.mimeType}`); + + // 获取专辑封面(promise模式)。 + this.pixelMap = await avMetadataExtractor.fetchAlbumCover(); + + // 释放资源(promise模式)。 + avMetadataExtractor.release(); + console.info(TAG, `release data source success.`); + } catch (e) { + console.error(TAG + `FetchMetadataFromDataSrc, code is ${e.code}, message is ${e.message}`); + } + } + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/module.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..09cd726f273c7c90004a43ccab0dc87f5ccb8563 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "获取元数据ArkTS" + }, + { + "name": "FetchMetadata", + "value": "获取元数据信息" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/rawfile/test.mp3 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/rawfile/test.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..d282626586e8d699e9d8c809b9d1dbe26970270c Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/main/resources/rawfile/test.mp3 differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..deab52e2bf6d092b73e6f1360ae1b149e4761d64 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AVMetadataExtractor]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AVMetadataExtractorArkTS_001', 0, async (done: Function) => { + console.info(TAG, 'AVMetadataExtractorArkTS_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('FetchMetadataButton')); + await button.click(); + await driver.delayMs(5000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AVMetadataExtractorArkTS_001 end'); + }) + }) +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/List.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigorfile.ts b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/oh-package.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/ohosTest.md b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..24e60ec28ba579c5525172febf05d121610e397a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/ohosTest.md @@ -0,0 +1,7 @@ +# AVMetadataExtractorArkTS测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并获取元信息 | 设备正常运行 | | 获取成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/screenshots/AVMetadataExtractorArkTS.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/screenshots/AVMetadataExtractorArkTS.png new file mode 100644 index 0000000000000000000000000000000000000000..d1643f76ba0443b8522a270b84cd58ef77766902 Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorArkTS/screenshots/AVMetadataExtractorArkTS.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/.gitignore b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/app.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c67ebdf8650f278ac2bb20690fa2eec4dc980c10 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.AVMetadataExtractorNDK", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2a4fc3662e1ddee38a714c4f21accbafa884ffd9 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AVMetadataExtractorNDK" + } + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/README.md b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/README.md new file mode 100644 index 0000000000000000000000000000000000000000..de7fd9f58df2a8afc24724e324bb1665850e4e4f --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/README.md @@ -0,0 +1,77 @@ +# AVMetadataExtractorNDK + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用AVMetadataExtractor获取元数据(C/C++)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/using-ndk-avmetadataextractor-for-media.md)的配套示例工程。 + +本示例展示了如何获取一个音频资源的元数据。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击获取视频的封面按钮,获取专辑封面; +3. 点击获取视频的元数据按钮,获取资源文件元数据信息; + +## 工程目录 + +``` +AVMetadataExtractorNDK +entry/src/main/ets/ +└── pages + └── Index.ets (获取元数据界面) +entry/src/main/ +├── cpp +│ ├── types +│ │ └── libentry +│ │ └── Index.d.ts (NDK函数对应的js映射) +│ ├── CMakeLists.txt (CMake脚本) +│ └── napi_init.cpp (NDK函数) +└── resources + ├── base + │ ├── element + │ │ ├── color.json + │ │ ├── float.json + │ │ └── string.json + │ └── media + │ + └── rawfile + └── test.mp3 (音频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/build-profile.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a705bc1cb2b918d64bdda76a08b4f000129647e7 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/.gitignore b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/build-profile.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9bf154bd51072d27832bec1764cd98af35290ca3 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["armeabi-v7a", "arm64-v8a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/hvigorfile.ts b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/oh-package.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5b21e253af246edab8b6ef4f10938f4417e8bc25 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..102fb0f38ef1402aa2955640539143a363e3a0f7 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,22 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(AVImageGeneratorNDK) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) +target_link_libraries(entry PUBLIC + libace_napi.z.so + libhilog_ndk.z.so + libpixelmap.so + libavmetadata_extractor.so + libpixelmap_ndk.z.so + libnative_media_core.so +) diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3030c509bc752489adbe9de0d28d959036ae164 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "napi/native_api.h" + +#include +#include +#include +#include +#include +#include + +#include + +#define LOG_PRINT_DOMAIN 0xFF00 +#define APP_LOG_DOMAIN 0x0001 +constexpr const char *APP_LOG_TAG = "AVMetadataExtractor"; +const int ARG_NUM = 3; +const int FIRST_PARAM = 0; +const int SECOND_PARAM = 1; +const int THIRD_PARAM = 2; +const int STRING_VALUE = 0; +const int INT_VALUE = 1; +#define H_LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) + +// 辅助函数:检查参数数量和类型。 +bool CheckArgs(napi_env env, napi_callback_info info, size_t expectedArgc) +{ + size_t argc; + napi_value thisArg; + void* data; + napi_get_cb_info(env, info, &argc, nullptr, &thisArg, &data); + if (argc < expectedArgc) { + napi_throw_error(env, "EINVAL", "Insufficient arguments"); + return false; + } + napi_value argv[expectedArgc]; + napi_get_cb_info(env, info, &argc, argv, &thisArg, &data); + for (size_t i = 0; i < expectedArgc; ++i) { + napi_valuetype type; + napi_typeof(env, argv[i], &type); + if (type != napi_number) { + napi_throw_type_error(env, "EINVAL", "All arguments must be numbers"); + return false; + } + } + return true; +} + +// 辅助函数:获取 int32 类型值并进行错误处理。 +bool GetInt32Value(napi_env env, napi_value value, int32_t* result) +{ + napi_status status = napi_get_value_int32(env, value, result); + if (status != napi_ok) { + napi_throw_error(env, "EINVAL", "Failed to get int32 value"); + return false; + } + return true; +} + +// 辅助函数:获取 int64 类型值并进行错误处理。 +bool GetInt64Value(napi_env env, napi_value value, int64_t* result) +{ + napi_status status = napi_get_value_int64(env, value, result); + if (status != napi_ok) { + napi_throw_error(env, "EINVAL", "Failed to get int64 value"); + return false; + } + return true; +} + +// 辅助函数:将 string 类型值转为napi对象并进行错误处理。 +bool SetPropertyString(napi_env env, napi_value &obj, const std::string &key, const std::string &value) +{ + napi_value keyNapi = nullptr; + napi_status status = napi_create_string_utf8(env, key.c_str(), NAPI_AUTO_LENGTH, &keyNapi); + if (status != napi_ok) { + return false; + } + napi_value valueNapi = nullptr; + status = napi_create_string_utf8(env, value.c_str(), NAPI_AUTO_LENGTH, &valueNapi); + if (status != napi_ok) { + return false; + } + status = napi_set_property(env, obj, keyNapi, valueNapi); + if (status != napi_ok) { + return false; + } + return true; +} + +// 辅助函数:将 double 类型值转为napi对象并进行错误处理。 +bool SetPropertyDouble(napi_env env, napi_value &obj, const std::string &key, double value) +{ + napi_value keyNapi = nullptr; + napi_status status = napi_create_string_utf8(env, key.c_str(), NAPI_AUTO_LENGTH, &keyNapi); + if (status != napi_ok) { + return false; + } + napi_value valueNapi = nullptr; + status = napi_create_double(env, value, &valueNapi); + if (status != napi_ok) { + return false; + } + status = napi_set_property(env, obj, keyNapi, valueNapi); + if (status != napi_ok) { + return false; + } + return true; +} + +// 辅助函数:将 int 类型值转为napi对象并进行错误处理。 +bool SetPropertyInt(napi_env env, napi_value &obj, const std::string &key, int value) +{ + napi_value keyNapi = nullptr; + napi_status status = napi_create_string_utf8(env, key.c_str(), NAPI_AUTO_LENGTH, &keyNapi); + if (status != napi_ok) { + return false; + } + napi_value valueNapi = nullptr; + status = napi_create_int32(env, value, &valueNapi); + if (status != napi_ok) { + return false; + } + status = napi_set_property(env, obj, keyNapi, valueNapi); + if (status != napi_ok) { + return false; + } + return true; +} + +// 辅助函数:获取FetchAlbumCover、FetchMetadata的输入参数 +bool GetInputParams(napi_env env, napi_callback_info info, int64_t &offset, int32_t &fileDescribe, + int64_t &fileSize) +{ + if (!CheckArgs(env, info, ARG_NUM)) { + return false; + } + size_t argc = ARG_NUM; + napi_value argv[ARG_NUM]; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (!GetInt32Value(env, argv[FIRST_PARAM], &fileDescribe)) { + return false; + } + if (!GetInt64Value(env, argv[SECOND_PARAM], &fileSize)) { + return false; + } + if (!GetInt64Value(env, argv[THIRD_PARAM], &offset)) { + return false; + } + return true; +} + +/** + * 获取专辑封面。 + * 需要在index.d.ts文件内描述映射的OhAVMetadataExtractorFetchAlbumCover方法。 + * export const OhAVMetadataExtractorFetchAlbumCover: (fdsrc : number, size : number, + * offset : number) => image.PixelMap; + * 需要传入媒体文件描述符fdsrc、媒体文件大小size、媒体源在文件描述符中的偏移量offset。 + * 返回PixelMap对象。 + */ +static napi_value OhAVMetadataExtractorFetchAlbumCover(napi_env env, napi_callback_info info) +{ + int64_t offset = 0; + int32_t fileDescribe = -1; + int64_t fileSize = 0; + if (!GetInputParams(env, info, offset, fileDescribe, fileSize)) { + return nullptr; + } + // 创建OH_AVMetadataExtractor实例。 + OH_AVMetadataExtractor* mainExtractor = OH_AVMetadataExtractor_Create(); + // 处理异常。 + if (!mainExtractor) { + napi_throw_error(env, "EFAILED", "Create metadata extractor failed"); + return nullptr; + } + // 设置视频资源的文件描述符。 + OH_AVErrCode avErrCode = OH_AVMetadataExtractor_SetFDSource(mainExtractor, fileDescribe, offset, fileSize); + // 处理异常。 + if (avErrCode != AV_ERR_OK) { + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "SetFDSource for metadata extractor failed"); + return nullptr; + } + // 获取专辑封面。 + OH_PixelmapNative* pixelMap = nullptr; + avErrCode = OH_AVMetadataExtractor_FetchAlbumCover(mainExtractor, &pixelMap); + // 处理异常。 + if (avErrCode != AV_ERR_OK || !pixelMap) { + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Fetch album cover failed"); + return nullptr; + } + // 将nativePixelMap对象转换为PixelMapnapi对象。 + napi_value pixelmapNapi = nullptr; + Image_ErrorCode errCode = OH_PixelmapNative_ConvertPixelmapNativeToNapi(env, pixelMap, &pixelmapNapi); + // 释放OH_PixelmapNative资源。 + OH_PixelmapNative_Release(pixelMap); + // 释放OH_AVMetadataExtractor资源。 + OH_AVMetadataExtractor_Release(mainExtractor); + // 处理异常。 + if (errCode != IMAGE_SUCCESS) { + napi_throw_error(env, "EFAILED", "Convert PixelMap failed"); + return nullptr; + } + return pixelmapNapi; +} + +// 辅助函数:从OH_AVFormat对象中解析出string类型的元数据值,再保存到JS所需的AVMetadata中。 +void GetStringMetaData(struct OH_AVFormat *avMetadata, napi_env env, napi_value &JsMetadata, const char* &key) +{ + const char* out = nullptr; + bool ret = false; + ret = OH_AVFormat_GetStringValue(avMetadata, key, &out); + std::string result = std::string(key) + " : %{public}s"; + H_LOGI(result.c_str(), out); + if (ret && out) { + SetPropertyString(env, JsMetadata, key, out); + } +} + +// 辅助函数:从OH_AVFormat对象中解析出string类型的元数据值,再保存到JS所需的AVMetadata中。 +void GetStringValueFromAVFormat(struct OH_AVFormat *avMetadata, napi_env env, napi_value &JsMetadata) +{ + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_ALBUM); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_ALBUM_ARTIST); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_ARTIST); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_AUTHOR); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_DATE_TIME); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_DATE_TIME_FORMAT); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_COMPOSER); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_GENRE); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_MIME_TYPE); + GetStringMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_TITLE); +} + +// 辅助函数:从OH_AVFormat对象中解析出int类型的元数据值,再保存到JS所需的AVMetadata中。 +void GetIntMetaData(struct OH_AVFormat *avMetadata, napi_env env, napi_value &JsMetadata, const char* &key) +{ + const char* out = nullptr; + bool ret = false; + int32_t value = 0; + ret = OH_AVFormat_GetIntValue(avMetadata, key, &value); + std::string result = std::string(key) + " : %{public}d"; + H_LOGI(result.c_str(), value); + if (ret) { + out = std::to_string(value).c_str(); + SetPropertyString(env, JsMetadata, key, out); + } +} + +// 辅助函数:从OH_AVFormat对象中解析出int类型的元数据值,再保存到JS所需的AVMetadata中。 +void GetIntValueFromAVFormat(struct OH_AVFormat *avMetadata, napi_env env, napi_value &JsMetadata) +{ + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_HAS_AUDIO); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_HAS_VIDEO); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_TRACK_COUNT); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_SAMPLE_RATE); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_VIDEO_HEIGHT); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_VIDEO_WIDTH); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_VIDEO_ORIENTATION); + GetIntMetaData(avMetadata, env, JsMetadata, OH_AVMETADATA_EXTRACTOR_HAS_AUDIO); + + bool ret = false; + int32_t hdrType; + ret = OH_AVFormat_GetIntValue(avMetadata, OH_AVMETADATA_EXTRACTOR_VIDEO_IS_HDR_VIVID, &hdrType); + H_LOGI("OH_AVMETADATA_EXTRACTOR_VIDEO_IS_HDR_VIVID : %{public}d ret %{public}d", hdrType, ret); + if (ret) { + bool hh = SetPropertyInt(env, JsMetadata, OH_AVMETADATA_EXTRACTOR_VIDEO_IS_HDR_VIVID, hdrType); + H_LOGI("OH_AVMETADATA_EXTRACTOR_VIDEO_IS_HDR_VIVID : %{public}d hh %{public}d", hdrType, hh); + } +} + +// 辅助函数:从OH_AVFormat对象中解析出float、long类型的元数据值,再保存到JS所需的AVMetadata中。 +void GetOtherValueFromAVFormat(struct OH_AVFormat *avMetadata, napi_env env, napi_value &JsMetadata) +{ + const char* out = nullptr; + bool ret = false; + + int64_t duration = 0; + ret = OH_AVFormat_GetLongValue(avMetadata, OH_AVMETADATA_EXTRACTOR_DURATION, &duration); + H_LOGI("OH_AVMETADATA_EXTRACTOR_DURATION : %{public}lld", duration); + if (ret) { + out = std::to_string(duration).c_str(); + SetPropertyString(env, JsMetadata, OH_AVMETADATA_EXTRACTOR_DURATION, out); + } + + napi_value location = nullptr; + napi_create_object(env, &location); + float latitude; + bool retLatitude = OH_AVFormat_GetFloatValue(avMetadata, OH_AVMETADATA_EXTRACTOR_LOCATION_LATITUDE, &latitude); + H_LOGI("OH_AVMETADATA_EXTRACTOR_LOCATION_LATITUDE : %{public}f", latitude); + if (retLatitude) { + SetPropertyDouble(env, location, OH_AVMETADATA_EXTRACTOR_LOCATION_LATITUDE, latitude); + } + + float longitude; + bool retLongitude = OH_AVFormat_GetFloatValue(avMetadata, OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE, &longitude); + H_LOGI("OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE : %{public}f", longitude); + if (retLongitude) { + SetPropertyDouble(env, location, OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE, longitude); + } + + if (retLatitude || retLongitude) { + napi_value keyNapi = nullptr; + std::string key = "location"; + napi_create_string_utf8(env, key.c_str(), NAPI_AUTO_LENGTH, &keyNapi); + napi_set_property(env, JsMetadata, keyNapi, location); + } +} + +/** + * 获取元数据。 + * 需要在index.d.ts文件内描述映射的OhAVMetadataExtractorFetchMetadata方法。 + * export const OhAVMetadataExtractorFetchMetadata: (fdsrc : number, size : number, + * offset : number) => media.AVMetadata; + * 需要传入媒体文件描述符fdsrc、媒体文件大小size、媒体源在文件描述符中的偏移量offset。 + * 返回AVMetadata对象。 + */ +static napi_value OhAVMetadataExtractorFetchMetadata(napi_env env, napi_callback_info info) +{ + int64_t offset = 0; + int32_t fileDescribe = -1; + int64_t fileSize = 0; + if (!GetInputParams(env, info, offset, fileDescribe, fileSize)) { + return nullptr; + } + // 创建OH_AVMetadataExtractor实例。 + OH_AVMetadataExtractor* mainExtractor = OH_AVMetadataExtractor_Create(); + // 异常处理。 + if (!mainExtractor) { + napi_throw_error(env, "EFAILED", "Create metadata extractor failed"); + return nullptr; + } + // 设置视频资源的文件描述符。 + OH_AVErrCode avErrCode = OH_AVMetadataExtractor_SetFDSource(mainExtractor, fileDescribe, offset, fileSize); + // 异常处理。 + if (avErrCode != AV_ERR_OK) { + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "SetFDSource for metadata extractor failed"); + return nullptr; + } + // 创建OH_AVFormat对象。 + OH_AVFormat* avMetadata = OH_AVFormat_Create(); + // 异常处理。 + if (!avMetadata) { + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Create AVFormat failed"); + return nullptr; + } + // 获取元数据。 + avErrCode = OH_AVMetadataExtractor_FetchMetadata(mainExtractor, avMetadata); + // 异常处理。 + if (avErrCode != AV_ERR_OK) { + OH_AVFormat_Destroy(avMetadata); + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Fetch metadata failed"); + return nullptr; + } + napi_value JsMetadata = nullptr; + napi_status status = napi_create_object(env, &JsMetadata); + // 异常处理。 + if (status != napi_ok) { + OH_AVFormat_Destroy(avMetadata); + OH_AVMetadataExtractor_Release(mainExtractor); + napi_throw_error(env, "EFAILED", "Create JavaScript object failed"); + return nullptr; + } + // 从OH_AVFormat对象中解析出各个元数据值,再保存到JS所需的AVMetadata中。 + GetStringValueFromAVFormat(avMetadata, env, JsMetadata); + GetIntValueFromAVFormat(avMetadata, env, JsMetadata); + GetOtherValueFromAVFormat(avMetadata, env, JsMetadata); + // 释放OH_AVFormat资源。 + OH_AVFormat_Destroy(avMetadata); + // 释放OH_AVMetadataExtractor资源。 + OH_AVMetadataExtractor_Release(mainExtractor); + return JsMetadata; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "OhAVMetadataExtractorFetchAlbumCover", nullptr, OhAVMetadataExtractorFetchAlbumCover, nullptr, nullptr, + nullptr, napi_default, nullptr }, + { "OhAVMetadataExtractorFetchMetadata", nullptr, OhAVMetadataExtractorFetchMetadata, nullptr, nullptr, + nullptr, napi_default, nullptr }, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f28cce8c42992025927dfb9c83d986497365354 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { image } from "@kit.ImageKit"; +import { media } from '@kit.MediaKit'; + +export const OhAVMetadataExtractorFetchAlbumCover: (a:number,b:number,c:number) => image.PixelMap; +export const OhAVMetadataExtractorFetchMetadata: (a:number,b:number,c:number) => media.AVMetadata; \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f46aeb4a4fa2fa8023596a85e291a48b0dd2deeb --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e470c89821cef8bcdc515f12c0b5b564f81c12a9 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { image } from '@kit.ImageKit'; +import { media } from '@kit.MediaKit'; +import avmetadataextractor from 'libentry.so'; +import { promptAction } from '@kit.ArkUI'; +import { common } from '@kit.AbilityKit'; + +const TAG: string = 'AvImageGenerator Demo:' + +@Entry +@Component +struct Index { + private videoName: string = 'test.mp3'; + @State coverPixelMap: image.PixelMap | undefined = undefined; + @State metadata: media.AVMetadata | undefined = undefined; + @State show: boolean = true; + + build() { + Column() { + Text(this.videoName).fontSize(20).fontWeight(FontWeight.Bold) + Row () { + Column() { + Button($r('app.string.FetchCover'), { type: ButtonType.Capsule }) + .margin({ top: 30 }) + .onClick(async() => { + await this.getSelectedVideoCover(); + this.show = true; + promptAction.showToast({ + message:$r('app.string.FetchCoverStart'), + duration:2000, + showMode: promptAction.ToastShowMode.DEFAULT, + bottom:80 + }) + }) + .id('FetchCover') + } + Column() { + Button($r('app.string.FetchMetaData'), { type: ButtonType.Capsule }) + .margin({ top: 30 }) + .onClick(async() => { + this.coverPixelMap = undefined; + await this.getMetadata(); + this.show = false; + promptAction.showToast({ + message:$r('app.string.FetchMetaDataStart'), + duration:2000, + showMode: promptAction.ToastShowMode.DEFAULT, + bottom:80 + }) + }) + .id('FetchMetaData') + } + } + + Row () { + if (this.show) { + Image(this.coverPixelMap) + .width('70%') + .height(300) + .margin({ + top: 50 + }) + .borderWidth(2) + .borderColor('#0D9FFB') + } else { + Column() { + Text($r('app.string.album')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.albumArtist')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.artist')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.author')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.dateTime')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.dateTimeFormat')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.composer')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.duration')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.genre')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.hasAudio')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.hasVideo')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.mimeType')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.trackCount')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.sampleRate')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.title')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.videoHeight')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.videoWidth')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.videoOrientation')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.hdrType')).fontSize(15).fontWeight(FontWeight.Bold) + Text($r('app.string.location')).fontSize(15).fontWeight(FontWeight.Bold) + } + .width('50%') + .margin({ + top: 50 + }) + + Column() { + Text(this.metadata ? this.metadata.album + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.albumArtist + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.artist + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.author + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.dateTime + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.dateTimeFormat + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.composer + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.duration + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.genre + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.hasAudio + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.hasVideo + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.mimeType + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.trackCount + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.sampleRate + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.title + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.videoHeight + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.videoWidth + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.videoOrientation + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? this.metadata.hdrType + ' ' : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + + Text(this.metadata ? `${JSON.stringify(this.metadata.location)} ` : $r('app.string.noValue')) + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + .width('50%') + .margin({ + top: 50 + }) + } + + } + }.width('100%').height('100%') + } + + async getSelectedVideoCover() { + this.coverPixelMap = undefined; + console.info(TAG + 'getSelectedVideoCover: start') + try { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let avFileDescriptor = await context.resourceManager.getRawFd(this.videoName); + let fdsrc : number = avFileDescriptor.fd; + let size : number = avFileDescriptor.length; + let offset : number = avFileDescriptor.offset; + this.coverPixelMap = avmetadataextractor.OhAVMetadataExtractorFetchAlbumCover(fdsrc, size, offset); + } catch (e) { + console.error(TAG + `getSelectedVideoCover, code is ${e.code}, message is ${e.message}`); + } + console.info(TAG + 'getSelectedVideoCover: start') + } + + async getMetadata() { + console.debug(TAG + 'getMeter START') + try { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let avFileDescriptor = await context.resourceManager.getRawFd(this.videoName); + let fdsrc : number = avFileDescriptor.fd; + let size : number = avFileDescriptor.length; + let offset : number = avFileDescriptor.offset; + this.metadata = avmetadataextractor.OhAVMetadataExtractorFetchMetadata(fdsrc, size, offset) + } catch (e) { + console.error(TAG + 'getMetadata' + JSON.stringify(e)); + } + console.debug(TAG + 'getMeter END') + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/module.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5002b04f5deacf23f88dbd49534ff93b8750db15 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/element/string.json @@ -0,0 +1,116 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "获取元数据NDK" + }, + { + "name": "FetchCover", + "value": "获取视频的封面" + }, + { + "name": "FetchCoverStart", + "value": "开始获取视频的封面" + }, + { + "name": "FetchMetaData", + "value": "获取视频的元数据" + }, + { + "name": "FetchMetaDataStart", + "value": "开始获取视频的元数据" + }, + { + "name": "album", + "value": "album" + }, + { + "name": "albumArtist", + "value": "albumArtist" + }, + { + "name": "artist", + "value": "artist" + }, + { + "name": "author", + "value": "author" + }, + { + "name": "dateTime", + "value": "dateTime" + }, + { + "name": "dateTimeFormat", + "value": "dateTimeFormat" + }, + { + "name": "composer", + "value": "composer" + }, + { + "name": "duration", + "value": "duration" + }, + { + "name": "genre", + "value": "genre" + }, + { + "name": "hasAudio", + "value": "hasAudio" + }, + { + "name": "hasVideo", + "value": "hasVideo" + }, + { + "name": "mimeType", + "value": "mimeType" + }, + { + "name": "trackCount", + "value": "trackCount" + }, + { + "name": "sampleRate", + "value": "sampleRate" + }, + { + "name": "title", + "value": "title" + }, + { + "name": "videoHeight", + "value": "videoHeight" + }, + { + "name": "videoWidth", + "value": "videoWidth" + }, + { + "name": "videoOrientation", + "value": "videoOrientation" + }, + { + "name": "hdrType", + "value": "hdrType" + }, + { + "name": "location", + "value": "location" + }, + { + "name": "noValue", + "value": "无" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/rawfile/test.mp3 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/rawfile/test.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..d282626586e8d699e9d8c809b9d1dbe26970270c Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/main/resources/rawfile/test.mp3 differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad8cf4ba61ff3d3791005887ffb13cca6d3b66ec --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AVMetadataExtractorNDK]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AVMetadataExtractorNDK_001', 0, async (done: Function) => { + console.info(TAG, 'AVMetadataExtractorNDK_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('FetchCover')); + await button.click(); + await driver.delayMs(2000); + const button2 = await driver.findComponent(ON.id('FetchMetaData')); + await button2.click(); + await driver.delayMs(2000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AVMetadataExtractorNDK_001 end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/List.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigorfile.ts b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/oh-package.json5 b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/ohosTest.md b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..baed9b17f7f718d4e75205c94cc2fb0fad5b4dfa --- /dev/null +++ b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/ohosTest.md @@ -0,0 +1,7 @@ +# AVMetadataExtractorNDK测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并获取元信息 | 设备正常运行 | | 获取成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchCover.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchCover.png new file mode 100644 index 0000000000000000000000000000000000000000..f614b270bb1c069601e8d872d4e72e553025257e Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchCover.png differ diff --git a/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchMetaData.png b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchMetaData.png new file mode 100644 index 0000000000000000000000000000000000000000..99435ff6588d3b70fd8d71d8f0f1217c0c550e04 Binary files /dev/null and b/code/DocsSample/Media/AVMetadataExtractor/AVMetadataExtractorNDK/screenshots/FetchMetaData.png differ diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSAudio/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSAudio/README.md index 1c5e051e9ce80b7e049a9af8d08fb1aa7617da1f..3a670022bda3be394b3d6c8441055b2c6bc2b0ce 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSAudio/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSAudio/README.md @@ -61,6 +61,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerArkTSAudio/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/README.md index 01ebff0b997a8203d689f0e2a8c0f8c005eac5cb..245beb76275a99964c96005115422943fd9a82b3 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/README.md @@ -61,6 +61,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSSubtitle/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSSubtitle/README.md index db1b864c0c79da63b5ae2d1672d0a799569013d3..4a4b59a652e3048b7788a93a2a61fc1898c9dbae 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSSubtitle/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSSubtitle/README.md @@ -62,6 +62,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerArkTSSubtitle/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/README.md index 26cc9856164dc88aea0489b637b3b7400605c564..115d7b5ee0b7af63485fe2745728ce121065ba29 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/README.md @@ -63,6 +63,6 @@ ohos.permission.GET_WIFI_INFO git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/entry/src/main/ets/pages/Index.ets index 5f31d4bea56f27f4904f761238f6d2db48fc9f16..be70853ccbc5647adff71bb0b5ac48366f391811 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSURL/entry/src/main/ets/pages/Index.ets @@ -56,7 +56,7 @@ struct Index { @State title: Resource = $r('app.string.EntryAbility_label'); @State fileName: string = 'test_01.mp3'; - @State m3u8fileName: string = 'test.m3u8'; + @State m3u8FileName: string = 'test.m3u8'; @State isSwiping: boolean = false; // 用户滑动过程中 @State isPaused: boolean = true; // 暂停播放 @State XComponentFlag: boolean = false; @@ -148,7 +148,7 @@ struct Index { // 情况四:通过本地Raw文件中的m3u8文件播放在线流媒体资源 /* // 通过本地m3u8文件名,获取文件描述符 - let fileDescriptor = await this.context.resourceManager.getRawFd(this.m3u8fileName); + let fileDescriptor = await this.context.resourceManager.getRawFd(this.m3u8FileName); // 用文件描述符构造本地m3u8的URL let fdUrl : string = "fd://" + fileDescriptor.fd + "?offset=" + fileDescriptor.offset + "&size=" + fileDescriptor.length; @@ -169,7 +169,7 @@ struct Index { // 情况五:通过应用沙箱中的m3u8文件播放在线流媒体资源 /* - let filePath = `/data/storage/el1/bundle/${this.m3u8fileName}`; + let filePath = `${this.context.filesDir}/${this.m3u8FileName}`; // 通过fs.openSync获取文件句柄 let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); let fd : string = file.fd.toString(); @@ -196,8 +196,7 @@ struct Index { // 情况一:应用沙箱文件播放 let fdPath = 'fd://'; // 通过UIAbilityContext获取沙箱地址filesDir,以Stage模型为例 - let pathDir = this.context.filesDir; - let path = `/data/storage/el1/bundle/${this.fileName}`; + let path = `${this.context.filesDir}/${this.fileName}`; // 打开相应的资源文件地址获取fd,并为url赋值触发initialized状态机上报 let file = await fs.open(path); fdPath = fdPath + '' + file.fd; diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSVideo/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSVideo/README.md index 104c91137e1bf352c094419655734309cb685898..0c1b575c85e4986002e352eb6384ff77b0815c48 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerArkTSVideo/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSVideo/README.md @@ -61,6 +61,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerArkTSVideo/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerNDK/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerNDK/README.md index e758cfccbe2cb3f9a6b197eece21956c262b64fb..0449608a7ee99f029b21a8e62415ab608c981f46 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerNDK/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerNDK/README.md @@ -74,7 +74,7 @@ entry/src/ohosTest/ets/ ``` git init git config core.sparsecheckout true -echo code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +echo code/DocsSample/Media/AVPlayer/AVPlayerNDK/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openHarmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerNDKAudio/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerNDKAudio/README.md index 84f73ba8a86c7c2e0e828c6d98e86c1e08d585f7..6bb140a4489e53df032cdda961513e07fd9d706d 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerNDKAudio/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerNDKAudio/README.md @@ -68,6 +68,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerNDKAudio/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/README.md b/code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/README.md index e642a1aad7f5e3bcdba72d557a33b3e9178d51a5..4fdf17d417ca4e2cec4310d1035f321cfd531472 100644 --- a/code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/README.md +++ b/code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/README.md @@ -68,6 +68,6 @@ entry/src/ohosTest/ets/ git init git config core.sparsecheckout true echo code/DocsSample/Media/AVPlayer/AVPlayerNDKVideo/ > .git/info/sparse-checkout -git remote add origin OpenHarmony/applications_app_samples +git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/.gitignore b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/app.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..67eb7477adfd59da092a4937dc171e544496f3d6 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.samples.AVTranscoderArkTS", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d3bb8ff4256854629adf939e6949747596513b8c --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AVTranscoderArkTS" + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/README.md b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/README.md new file mode 100644 index 0000000000000000000000000000000000000000..083a96301d8e8c98cf494d6688702c3eb0cffcef --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/README.md @@ -0,0 +1,72 @@ +# AVTranscoderArkTS + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用AVTranscoder实现视频转码(ArkTS)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/using-avtranscoder-for-transcodering.md)的配套示例工程。 + +本示例以“开始转码-暂停转码-恢复转码-转码完成”的一次流程为示例,展示AVTranscoder视频转码相关功能。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击启动转码按钮,当进度条达到100%时完成转码,可从设置的沙箱路径导出生成的转码视频; + +## 工程目录 + +``` +AVTranscoderArkTS +entry/src/main/ets/ +└── pages +│ └── Index.ets (转码界面) +│ +└── transcoder + └── AVTranscoderManager.ets (转码功能) + +entry/src/main/resources/ +├── base +│ ├── element +│ │ ├── color.json +│ │ ├── float.json +│ │ └── string.json +│ └── media +│ +└── rawfile + └── H264_AAC.mp4 (视频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/build-profile.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a2b572d947cd6f7dfba85072fb0313ca83f317c --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/.gitignore b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/build-profile.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..982dbb524bd63408e05cfbed7204dd87a31dd681 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/build-profile.json5 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/hvigorfile.ts b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/oh-package.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3888cdb09d38032e0e3fb9467ec654de50a9cc3 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {AVTranscoderDemo} from '../transcoder/AVTranscoderManager' + +@Entry +@Component +struct Index { + private context:Context | undefined = this.getUIContext().getHostContext(); + @State avTranscoder: AVTranscoderDemo = new AVTranscoderDemo(this.context); + + build() { + RelativeContainer() { + Column() { + Button($r('app.string.StartTranscoder')) + .onClick(async () => { + console.info(`Button put`); + await this.avTranscoder.avTranscoderDemo(); + }) + .id('AVTranscoderButton') + Progress({ value: 0, total: 100, type: ProgressType.Linear }).value(this.avTranscoder.getCurrentProgress()) + .height(50) + .width('80%') + } + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/transcoder/AVTranscoderManager.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/transcoder/AVTranscoderManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..78ed11206cd124de91125c3ebdf4b1483fa7cc3e --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/transcoder/AVTranscoderManager.ets @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { media } from '@kit.MediaKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import fs from '@ohos.file.fs'; + +export class AVTranscoderDemo { + private avTranscoder: media.AVTranscoder | undefined = undefined; + private context: Context | undefined; + private currentProgress: number = 0; + constructor(context: Context | undefined) { + if (context != undefined) { + this.context = context; + } + } + private avConfig: media.AVTranscoderConfig = { + audioBitrate: 100000, // 音频比特率。 + audioCodec: media.CodecMimeType.AUDIO_AAC, // 音频编码格式。 + fileFormat: media.ContainerFormatType.CFT_MPEG_4, // 封装格式。 + videoBitrate: 200000, // 视频比特率。 + videoCodec: media.CodecMimeType.VIDEO_AVC, // 视频编码格式。 + }; + + // 注册avTranscoder回调函数。 + setAVTranscoderCallback() { + if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { + if (this.avTranscoder != undefined) { + // 转码完成回调函数。 + this.avTranscoder.on('complete', async () => { + console.log(`AVTranscoder is completed`); + await this.releaseTranscoderingProcess(); + }); + // 错误上报回调函数。 + this.avTranscoder.on('error', (err: BusinessError) => { + console.error(`AVTranscoder failed, code is ${err.code}, message is ${err.message}`); + }); + // 进度上报回调函数 + this.avTranscoder.on('progressUpdate', (progress: number) => { + console.info(`AVTranscoder progressUpdate = ${progress}`); + this.currentProgress = progress; + }) + } + } + } + + // 开始转码对应的流程。 + async startTranscoderingProcess() { + if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { + if (this.avTranscoder != undefined) { + await this.avTranscoder.release(); + this.avTranscoder = undefined; + } + // 1.创建转码实例。 + this.avTranscoder = await media.createAVTranscoder(); + this.setAVTranscoderCallback(); + // 2.获取转码源文件fd和目标文件fd赋予avTranscoder;参考FilePicker文档。 + if (this.context != undefined) { + try { + // 获取输入文件fd,H264_AAC.mp4为rawfile目录下的预置资源,需要开发者根据实际情况进行替换。 + let fileDescriptor = await this.context.resourceManager.getRawFd('H264_AAC.mp4'); + this.avTranscoder.fdSrc = fileDescriptor; + } catch (error) { + console.error('Failed to get the file descriptor, please check the resource and path.'); + } + let outputFilePath = this.context.filesDir + '/output.mp4'; + let file = fs.openSync(outputFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + this.avTranscoder.fdDst = file.fd; + this.currentProgress = 0; + } + // 3.配置转码参数完成准备工作。 + await this.avTranscoder.prepare(this.avConfig); + // 4.开始转码。 + await this.avTranscoder.start(); + } + } + + // 暂停转码对应的流程。 + async pauseTranscoderingProcess() { + if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { + if (this.avTranscoder != undefined) { // 仅在调用start返回后调用pause为合理调用。 + await this.avTranscoder.pause(); + } + } + } + + // 恢复对应的转码流程。 + async resumeTranscoderingProcess() { + if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { + if (this.avTranscoder != undefined) { // 仅在调用pause返回后调用resume为合理调用。 + await this.avTranscoder.resume(); + } + } + } + + // 释放转码流程。 + async releaseTranscoderingProcess() { + if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { + if (this.avTranscoder != undefined) { + // 1.释放转码实例。 + await this.avTranscoder.release(); + this.avTranscoder = undefined; + // 2.关闭转码目标文件fd。 + fs.closeSync(this.avTranscoder!.fdDst); + } + } + } + + // 获取当前进度 + getCurrentProgress(): number { + console.info(`getCurrentProgress = ${this.currentProgress}`); + return this.currentProgress; + } + + // 一个完整的【开始转码-暂停转码-恢复转码-转码完成】示例。 + async avTranscoderDemo() { + await this.startTranscoderingProcess(); // 开始转码。 + await this.pauseTranscoderingProcess(); //暂停转码。 + await this.resumeTranscoderingProcess(); // 恢复转码。 + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/module.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e9f202514f24c3004040ac92771599168fb22878 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "视频转码ArkTS" + }, + { + "name": "StartTranscoder", + "value": "启动转码" + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/resources/rawfile/H264_AAC.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7277b0e4910c52a8614d4f2162af3c03ad8589100f32e80dc36a9c96ba797ecd +size 1894335 diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3756ab985fbd257019c04836c98509e95f53f07 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AVTranscoder]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AVTranscoderTest_001', 0, async (done: Function) => { + console.info(TAG, 'AVTranscoderTest_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('AVTranscoderButton')); + await button.click(); + await driver.delayMs(9000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AVTranscoderTest_001 end'); + }) + }) +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/List.test.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigorfile.ts b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/oh-package.json5 b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/ohosTest.md b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..c8595a3cb22b2a239eeecd4b0ba03a4c0c4b5ef4 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/ohosTest.md @@ -0,0 +1,7 @@ +# AVTranscoderArkTS测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并转码 | 设备正常运行 | | 转码成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/screenshots/AVTranscoderArkTS.png b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/screenshots/AVTranscoderArkTS.png new file mode 100644 index 0000000000000000000000000000000000000000..1de1bcda3d5cb5686d4b07c023cff08ee74047d5 Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/screenshots/AVTranscoderArkTS.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/.gitignore b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/app.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..551bc577f6a39a2127ef39ce2981ee79ad4e0c28 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.AsyncTranscoder", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/element/string.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d4d767f0f73795c784cfedac4124d3f6ec28deea --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AsyncTranscoder" + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/background.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/README.md b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1e06fc292c36b8b25a6ca0ccd4f9442704184c75 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/README.md @@ -0,0 +1,75 @@ +# AsyncTranscoder + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[创建异步线程执行AVTranscoder视频转码(ArkTS)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/avtranscoder-practice.md)的配套示例工程。 + +本示展示了使用worker线程的方式来实现异步线程进行转码。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击启动转码按钮,当进度条达到100%时完成转码,可从设置的沙箱路径导出生成的转码视频; + +## 工程目录 + +``` +AsyncTranscoder +entry/build-profile.json5 (配置字段信息将Worker线程文件打包到应用) +entry/src/main/ets/ +├── pages +│ └── Index.ets (转码界面) +├── util +│ └── SendableObject.ets (Sendable对象) +│ +└── workers + └── task.ets (转码任务) + +entry/src/main/resources/ +├── base +│ ├── element +│ │ ├── color.json +│ │ ├── float.json +│ │ └── string.json +│ └── media +│ +└── rawfile + └── H264_AAC.mp4 (视频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/AVTranscoder/AsyncTranscoder/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/build-profile.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a2b572d947cd6f7dfba85072fb0313ca83f317c --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/.gitignore b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/build-profile.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..79369869089572f3970c5649d6135c5def8ca926 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/build-profile.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + "sourceOption": { + "workers": [ + "./src/main/ets/workers/task.ets", + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/hvigorfile.ts b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8774588471ede4c1563f09d9a1d22f764bb1fd9e --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/obfuscation-rules.txt b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/oh-package.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c21e1a1e208ff3b068c9018d19e3ecb4d51f9fa --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ErrorEvent, MessageEvents, worker } from '@kit.ArkTS' +import { SendableObject } from '../util/SendableObject'; +import { common, sendableContextManager } from '@kit.AbilityKit'; + + +@Entry +@Component +struct Index { + private workerInstance?: worker.ThreadWorker; + private context: Context | undefined; + @State currentProgress: number = 0; + + build() { + RelativeContainer() { + Column() { + Button($r('app.string.StartTranscoder')) + .onClick(async () => { + console.info(`Button put`); + await this.startWorker(); + }) + .id('AsyncAVTranscoderButton') + Progress({ value: 0, total: 100, type: ProgressType.Linear }).value(this.currentProgress) + .height(50) + .width('80%') + } + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } + + + async startWorker() { + // 创建Worker对象 + this.workerInstance = new worker.ThreadWorker('entry/ets/workers/task.ets'); + + + // 注册onmessage回调,当宿主线程接收到来自其创建的Worker通过workerPort.postMessage接口发送的消息时被调用, + // 在宿主线程执行 + this.workerInstance.onmessage = (e: MessageEvents) => { + let data: string | number = e.data; + if (typeof data === 'string') { + console.info('workerInstance onmessage is: ', data); + if (data === 'complete') { + console.info('complete: ', data); + this.workerInstance?.terminate(); + } + } else if (typeof data === 'number') { + this.currentProgress = data; + } + } + + + // 注册onErrors回调,可以捕获Worker线程的onmessage回调、timer回调以及文件执行等流程产生的全局异常, + // 在宿主线程执行 + this.workerInstance.onerror = (err: ErrorEvent) => { + console.error('workerInstance onerror message is: ' + err.message); + } + + + // 注册onmessageerror回调,当Worker对象接收到一条无法被序列化的消息时被调用,在宿主线程执行 + this.workerInstance.onmessageerror = () => { + console.error('workerInstance onmessageerror'); + } + + + // 注册onexit回调,当Worker销毁时被调用,在宿主线程执行 + this.workerInstance.onexit = (e: number) => { + // 当Worker正常退出时code为0,异常退出时code为1 + console.info('workerInstance onexit code is: ', e); + } + + + // 向Worker线程发送消息 + this.context = this.getUIContext().getHostContext(); + if (this.context != undefined) { + const sendableContext: sendableContextManager.SendableContext =sendableContextManager.convertFromContext( + this.context); + const sendableObject: SendableObject = new SendableObject(sendableContext, 'some information'); + this.workerInstance.postMessageWithSharedSendable(sendableObject); + } + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/util/SendableObject.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/util/SendableObject.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cfbfa8ff91de4e9c2188635b0c68b26417e7cf3 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/util/SendableObject.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { sendableContextManager } from '@kit.AbilityKit'; + + +//发送的参数必须加上@Sendable标注 +@Sendable +export class SendableObject { + constructor(sendableContext: sendableContextManager.SendableContext, data: string = '') { + this.sendableContext = sendableContext; + this.data = data; + } + + + private sendableContext: sendableContextManager.SendableContext; + private data: string; + + + public getSendableContext() { + return this.sendableContext; + } + + + public getData() { + return this.data; + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/workers/task.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/workers/task.ets new file mode 100644 index 0000000000000000000000000000000000000000..1246259fd084a1523cad523285c92d4bcc544c11 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/ets/workers/task.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; +import { media } from '@kit.MediaKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import fs from '@ohos.file.fs'; +import { SendableObject } from '../util/SendableObject'; +import { common, sendableContextManager } from '@kit.AbilityKit'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +workerPort.onmessage = async (event: MessageEvents) => { + console.info(`onmessage in`); + //worker线程接收参数 + const sendableObject: SendableObject = event.data; + const sendableContext: sendableContextManager.SendableContext = + sendableObject.getSendableContext() as sendableContextManager.SendableContext; + const context: common.Context = + sendableContextManager.convertToContext(sendableContext) as common.Context; + //执行转码逻辑 + await doSome(context); + // 向主线程发送消息 + workerPort.postMessage('start end'); +}; + +workerPort.onmessageerror = (event: MessageEvents) => { + console.info('workerPort onmessageerror'); +}; + +workerPort.onerror = (event: ErrorEvent) => { + console.info('workerPort onerror err is: ', event.message); +}; + +async function doSome(context: common.Context) { + console.info(`doSome in`); + try { + let transcoder = await media.createAVTranscoder(); + // 转码完成回调函数 + transcoder.on('complete', async () => { + console.info(`transcode complete`); + fs.closeSync(transcoder.fdDst); + await transcoder?.release() + // 向主线程发送转码结束的消息 + workerPort.postMessage('complete'); + }) + // 转码错误回调函数 + transcoder.on('error', async (err: BusinessError) => { + fs.closeSync(transcoder.fdDst); + await transcoder?.release(); + }) + // 转码进度更新 + transcoder.on('progressUpdate', (progress: number) => { + console.info(`AVTranscoder progressUpdate = ${progress}`); + workerPort.postMessage(progress); + }) + try { + // 获取输入文件fd,3.mkv为rawfile目录下的预置资源,需要开发者根据实际情况进行替换。 + let fileDescriptor = await context.resourceManager.getRawFd('H264_AAC.mp4'); + transcoder.fdSrc = fileDescriptor; + } catch (error) { + console.error('Failed to get the file descriptor, please check the resource and path.'); + } + let fdPath = context.filesDir + '/' + 'VID_' + Date.parse(new Date().toString()) + '.mp4'; + let file = fs.openSync(fdPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let fd = file.fd; + console.info(`file fd ${fd}`); + transcoder.fdDst = file.fd; + + let config: media.AVTranscoderConfig = { + fileFormat: media.ContainerFormatType.CFT_MPEG_4, + audioCodec: media.CodecMimeType.AUDIO_AAC, + videoCodec: media.CodecMimeType.VIDEO_AVC, + videoBitrate: 200000, + } + await transcoder?.prepare(config); + await transcoder?.start(); + } catch (e) { + console.error(`transcode error: code = ` + e.code.toString() + `, message = ${JSON.stringify(e.message)}`); + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/module.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce393bdb985dc14dc42b0e8eadc5f889bc1373d3 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/module.json5 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..41ec77a69a6d148d7084866004ff216a4202e916 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "异步线程执行转码" + }, + { + "name": "StartTranscoder", + "value": "启动转码" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/rawfile/H264_AAC.mp4 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/rawfile/H264_AAC.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..4b1e20e73501523f801a942f84f91ed6334161fa --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/main/resources/rawfile/H264_AAC.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7277b0e4910c52a8614d4f2162af3c03ad8589100f32e80dc36a9c96ba797ecd +size 1894335 diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..323d1d611fecf4ecb751976e3a71500b3712a445 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/mock/mock-config.json5 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..850c3c6997b41532e0d7e686da3287b2ea9dd040 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_AsyncAVTranscoder]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('AsyncAVTranscoderTest_001', 0, async (done: Function) => { + console.info(TAG, 'AsyncAVTranscoderTest_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + try { + const button = await driver.findComponent(ON.id('AsyncAVTranscoderButton')); + await button.click(); + await driver.delayMs(9000); + done(); + } catch (exception) { + expect().assertFail(); + } + console.info(TAG, 'AsyncAVTranscoderTest_001 end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d3069fb7f9163da9f7e6ffe7366140c3368edc34 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/List.test.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a60c87c5cbb0badf7c3fd8975034590e6fafa992 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..841bfd77e56060e50ec0924302a5ae624e76e3aa --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigor/hvigor-config.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigorfile.ts b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/oh-package.json5 b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/ohosTest.md b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..c1bd1b343c9338ade096d5fecdc48787fc58edbe --- /dev/null +++ b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/ohosTest.md @@ -0,0 +1,7 @@ +# AsyncTranscoder测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并转码 | 设备正常运行 | | 转码成功 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/screenshots/AsyncTranscoder.png b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/screenshots/AsyncTranscoder.png new file mode 100644 index 0000000000000000000000000000000000000000..1de1bcda3d5cb5686d4b07c023cff08ee74047d5 Binary files /dev/null and b/code/DocsSample/Media/AVTranscoder/AsyncTranscoder/screenshots/AsyncTranscoder.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/.gitignore b/code/DocsSample/Media/Image/NdkPicture/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/AppScope/app.json5 b/code/DocsSample/Media/Image/NdkPicture/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2da0cb584c179b8c7619d1b1aa840eab7ee646eb --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/AppScope/app.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "bundleName": "com.samples.ndkpicture", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/element/string.json b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..86426c28cf3b0aa0617d9dded26fdae7a7359ced --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NdkPicture" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/background.png b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..4f9ad6307a2bc56beb6d0fce0a49cbf213b20a74 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,6 @@ +{ + "layered-image": { + "background": "$media:background", + "foreground": "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/README.md b/code/DocsSample/Media/Image/NdkPicture/README.md new file mode 100644 index 0000000000000000000000000000000000000000..15bb7fc68d6cf8f9c85344438a4b948e41d3c68c --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/README.md @@ -0,0 +1,74 @@ +# NdkPicture + +## 介绍 +本示例主要实现了基于Picture的图片解码、主图获取、图片编码等功能。 + +## 效果预览 + +| 主界面 | +| ---------------------------------------------- | +| ![NdkPixelMap](./screenshots/NdkPictureUI.png) | + +使用说明: + +1. 点击'Create Picture'按钮,解码图片,并以弹窗的形式通知结果(是否解码成功)。 +2. 点击'Get MainPixelMap'按钮,从解码的Picture中获取主图,并以弹窗的形式通知结果。 +3. 点击'Pack To Data'按钮或'Pack To File'按钮,将Picture编码到缓冲区或图片文件,并以弹窗的形式通知结果。 +4. 点击'Realease Picture'按钮,释放Picture对象。 + +## 工程目录 + +``` +NdkPicture +entry/src/main/cpp/ +├── types +│ └── libentry +│ └── Index.d.ts (声明Napi接口,供ts调用) +├── CMakeLists.txt (CMake编译配置文件) +└── napi_init.cpp (初始化Napi接口) +entry/src/main/ets/ +├── utils +│ └── Logger.ets (logger日志类) +│ └── MyButton.ets (自定义Button按钮类) +│ └── PictureFunctions.ets (Picture函数类) +└── pages + └── Index.ets (UI界面) +entry/src/main/resources/ +└── rawfile + └── test.jpg(图片资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 具体实现 ++ 图片解码、获取主图、图片编码等功能的CPAI封装均在napi_init中实现,源码参考[napi_init.cpp](./entry/src/main/cpp/napi_init.cpp)。 + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API15版本SDK,版本号:5.0.3.135; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.8.300,构建 2025年3月19日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/Image/NdkPicture/ > .git/info/sparse-checkout +git remote add origin OpenHarmony/applications_app_samples +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/build-profile.json5 b/code/DocsSample/Media/Image/NdkPicture/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1be9d2a570766548232f7292e26e5d2d323d9ab9 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 15, + "targetSdkVersion": 15, + "compatibleSdkVersion": 15, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/code-linter.json5 b/code/DocsSample/Media/Image/NdkPicture/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/.gitignore b/code/DocsSample/Media/Image/NdkPicture/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/build-profile.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7ddb49d18026714e9bbca59e42790065cdb434e9 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "arm64-v8a", + "x86_64", + "armeabi-v7a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/hvigorfile.ts b/code/DocsSample/Media/Image/NdkPicture/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/obfuscation-rules.txt b/code/DocsSample/Media/Image/NdkPicture/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/oh-package.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5b21e253af246edab8b6ef4f10938f4417e8bc25 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce4f206e4a3c8bf11ef23bbac4686ec93bd7e153 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,24 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(NdkPictur) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_library(entry SHARED napi_init.cpp) + +target_link_libraries(entry PUBLIC + libace_napi.z.so + libhilog_ndk.z.so + libohimage.so + libimage_source.so + libpicture.so + libimage_common.so + libimage_packer.so +) \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fcf5641296215207c2b0a4249df102801f6cd0c1 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,540 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" +#include +#include +#include +#include +#include +#include +#include + +#define IMG_IS_OK(x) ((x) == napi_ok) + +#define IMG_NAPI_CHECK_RET_D(x, res, msg) \ + do { \ + if (!(x)) { \ + msg; \ + return (res); \ + } \ + } while (0) + +#define IMG_JS_ARGS(env, info, status, argc, argv, thisVar) \ + do { \ + status = napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); \ + } while (0) + +#define H_LOGI(...) ((void)OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define H_LOGD(...) ((void)OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define H_LOGW(...) ((void)OH_LOG_Print(LOG_APP, LOG_WARNING, LOG_DOMAIN, APP_LOG_TAG, __VA_ARGS__)) +#define H_LOGE(format, ...) \ + OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_DOMAIN, APP_LOG_TAG, "%{public}s:%{public}s:%{public}d: " format, \ + __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) + +const char *APP_LOG_TAG = "MultiMediaImage"; +const char *PROJECT_TAG = "[NdkPicture]"; + +class ImagePictureNative { +public: + Image_ErrorCode errCode_ = IMAGE_SUCCESS; + OH_DecodingOptionsForPicture *options_ = nullptr; + OH_ImagePackerNative *imagePacker_ = nullptr; + OH_PackingOptions *packerOptions_ = nullptr; + OH_AuxiliaryPictureNative *auxiliaryPicture_ = nullptr; + OH_AuxiliaryPictureNative *gainMapAuxiliaryPicture_ = nullptr; + OH_PictureNative *picture_ = nullptr; + OH_PictureNative *pictureByImageSource = nullptr; + OH_AuxiliaryPictureInfo *info_ = nullptr; + OH_PictureMetadata *Metadata_ = nullptr; + OH_PictureMetadata *newMetadata_ = nullptr; + OH_ImageSourceNative *source_ = nullptr; + OH_PixelmapNative *resPixMap_ = nullptr; + ImagePictureNative() {} + ~ImagePictureNative() {} +}; +static ImagePictureNative *ndkPicture_ = new ImagePictureNative(); + +// 将int类型的返回值转换为napi_value类型 +napi_value getJsResult(napi_env env, int result) { + napi_value resultNapi = nullptr; + napi_create_int32(env, result, &resultNapi); + return resultNapi; +} + +// 传入图片文件路径,解码得到PixelMap +Image_ErrorCode CreatePixelmap(char filePath[1024], size_t filePathSize) { + if (ndkPicture_->source_ != nullptr) { + OH_ImageSourceNative_Release(ndkPicture_->source_); + ndkPicture_->source_ = nullptr; + } + + ndkPicture_->errCode_ = OH_ImageSourceNative_CreateFromUri(filePath, filePathSize, &ndkPicture_->source_); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_ImageSourceNative_CreateFromUri failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return ndkPicture_->errCode_; + } else { + H_LOGI("%{public}s OH_ImageSourceNative_CreateFromUri success !", PROJECT_TAG); + } + + OH_DecodingOptions *ops = nullptr; + OH_DecodingOptions_Create(&ops); + ndkPicture_->errCode_ = OH_ImageSourceNative_CreatePixelmap(ndkPicture_->source_, ops, &ndkPicture_->resPixMap_); + OH_DecodingOptions_Release(ops); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_ImageSourceNative_CreatePixelmap failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return ndkPicture_->errCode_; + } else { + H_LOGI("%{public}s OH_ImageSourceNative_CreatePixelmap success !", PROJECT_TAG); + } + return ndkPicture_->errCode_; +} + +// 使用PixelMap创建Picture,通过这种方式创建的Picture仅包含主图 +static napi_value CreatePicture(napi_env env, napi_callback_info info) { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value result = nullptr; + + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok || argc < 1 || args[0] == nullptr) { + H_LOGE("%{public}s CreatePicture_ napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + + char filePath[1024]; + size_t filePathSize; + napi_get_value_string_utf8(env, args[0], filePath, 1024, &filePathSize); + + ndkPicture_->errCode_ = CreatePixelmap(filePath, filePathSize); + if (ndkPicture_->picture_ != nullptr) { + ndkPicture_->errCode_ = OH_PictureNative_Release(ndkPicture_->picture_); + ndkPicture_->picture_ = nullptr; + } + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s CreatePicture_ OH_PictureNative_Release failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } + + ndkPicture_->errCode_ = OH_PictureNative_CreatePicture(ndkPicture_->resPixMap_, &ndkPicture_->picture_); + + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_PictureNative_CreatePicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + ; + } else { + napi_status status = + napi_create_external(env, reinterpret_cast(ndkPicture_->picture_), nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_PictureNative_CreatePicture success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +// 使用ImageSource创建Picture,通过这种方式创建的Picture会包含主图、辅助图、元数据(如果原图有辅助图和元数据) +static napi_value CreatePictureByImageSource(napi_env env, napi_callback_info info) { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_value result = nullptr; + + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok || argc < 1 || args[0] == nullptr) { + H_LOGE("%{public}s CreatePicture_ napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + char filePath[1024]; + size_t filePathSize; + napi_get_value_string_utf8(env, args[0], filePath, 1024, &filePathSize); + + if (ndkPicture_->source_ != nullptr) { + OH_ImageSourceNative_Release(ndkPicture_->source_); + ndkPicture_->source_ = nullptr; + } + + ndkPicture_->errCode_ = OH_ImageSourceNative_CreateFromUri(filePath, filePathSize, &ndkPicture_->source_); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_ImageSourceNative_CreateFromUri failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + H_LOGI("%{public}s OH_ImageSourceNative_CreateFromUri success !", PROJECT_TAG); + } + OH_DecodingOptions *ops = nullptr; + OH_DecodingOptions_Create(&ops); + ndkPicture_->errCode_ = OH_ImageSourceNative_CreatePicture(ndkPicture_->source_, ndkPicture_->options_, + &ndkPicture_->pictureByImageSource); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s ImageSourceNative_CreatePicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = napi_create_external(env, reinterpret_cast(ndkPicture_->pictureByImageSource), + nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s ImageSourceNative_CreatePicture success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +// 获取主图 +static napi_value GetMainPixelMap(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + OH_PixelmapNative *mainPixelMap = nullptr; + napi_get_undefined(env, &result); + + ndkPicture_->errCode_ = OH_PictureNative_GetMainPixelmap(ndkPicture_->picture_, &mainPixelMap); + + if (ndkPicture_->errCode_ != IMAGE_SUCCESS || mainPixelMap == nullptr) { + H_LOGE("%{public}s OH_PictureNative_GetMainPixelmap failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = + napi_create_external(env, reinterpret_cast(mainPixelMap), nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_PictureNative_GetMainPixelmap success !", PROJECT_TAG); + return getJsResult(env, ndkPicture_->errCode_); + } +} + +// 获取GainMap辅助图,需要这张Picture包含GainMap辅助图才能成功获取。 +static napi_value GetGainMapPixelMap(napi_env env, napi_callback_info info) { + napi_value result; + OH_PixelmapNative *gainMapPixelMap = nullptr; + ndkPicture_->errCode_ = OH_PictureNative_GetGainmapPixelmap(ndkPicture_->picture_, &gainMapPixelMap); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("GetGainMapPixelMap failed, errCode: %{public}d.", ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = + napi_create_external(env, reinterpret_cast(gainMapPixelMap), nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + } + H_LOGI("GetGainMapPixelMap success !"); + return getJsResult(env, ndkPicture_->errCode_); +} + +// 合成hdr图并获取hdr图的pixelmap +static napi_value GetHdrComposedPixelMap(napi_env env, napi_callback_info info) { + + napi_value result; + OH_PixelmapNative *hdrComposedPixelMap = nullptr; + + ndkPicture_->errCode_ = OH_PictureNative_GetHdrComposedPixelmap(ndkPicture_->picture_, &hdrComposedPixelMap); + + if (ndkPicture_->errCode_ != IMAGE_SUCCESS || !hdrComposedPixelMap) { + H_LOGE("%{public}s OH_PictureNative_GetHdrComposedPixelmap failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = + napi_create_external(env, reinterpret_cast(hdrComposedPixelMap), nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_PictureNative_GetHdrComposedPixelmap success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +static napi_value CreateAuxiliaryPicture(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_status status; + + size_t argc = 3; + napi_value args[3] = {nullptr}; + + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok || argc < 3 || args[0] == nullptr || + args[1] == nullptr || args[2] == nullptr) { + H_LOGE("%{public}s OH_AuxiliaryPictureNative_Create napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + + void *data0; + size_t dataLength = 10; + status = napi_get_arraybuffer_info(env, args[0], &data0, &dataLength); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, H_LOGE("Fail to get auxiliary picture buffer")); + uint8_t *data = reinterpret_cast(data0); + + Image_Size *size; + napi_value tempValue = nullptr; + napi_value tempValue2 = nullptr; + IMG_IS_OK(napi_get_named_property(env, args[1], "width", &tempValue)); + IMG_IS_OK(napi_get_value_uint32(env, tempValue, &size->width)); + IMG_IS_OK(napi_get_named_property(env, args[1], "height", &tempValue2)); + IMG_IS_OK(napi_get_value_uint32(env, tempValue2, &size->height)); + + int32_t value = 0; // auxType是指向了这个变量的指针 + int32_t *auxType = &value; + status = napi_get_value_int32(env, args[2], auxType); + if (*auxType >= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP) && + *auxType <= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP)) { + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type: %{public}d.", PROJECT_TAG, *auxType); + } else { + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type is set GAINMAP: %{public}d.", PROJECT_TAG, *auxType); + *auxType = static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP); + } + Image_AuxiliaryPictureType *type = reinterpret_cast(auxType); + + ndkPicture_->errCode_ = + OH_AuxiliaryPictureNative_Create(data, dataLength, size, *type, &ndkPicture_->auxiliaryPicture_); + + if (ndkPicture_->errCode_ != IMAGE_SUCCESS || !ndkPicture_->auxiliaryPicture_) { + H_LOGE("%{public}s OH_AuxiliaryPictureNative_Create failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = napi_create_external(env, reinterpret_cast(ndkPicture_->auxiliaryPicture_), + nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +static napi_value GetAuxType(napi_env env, napi_callback_info info) { + Image_AuxiliaryPictureType type; + ndkPicture_->errCode_ = OH_AuxiliaryPictureNative_GetType(ndkPicture_->auxiliaryPicture_, &type); + + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_AuxiliaryPictureNative_GetType failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + H_LOGI("%{public}s OH_AuxiliaryPictureNative_GetType success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +static napi_value SetAuxiliaryPicture(napi_env env, napi_callback_info info) { + napi_status status; + size_t argc = 1; + napi_value args[1] = {nullptr}; + + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok || argc < 1 || args[0] == nullptr) { + H_LOGE("%{public}s CreatePicture_ napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + + int32_t value = 0; // 假设 auxType 指向了这个变量的地址 + int32_t *auxType = &value; + status = napi_get_value_int32(env, args[0], auxType); + if (*auxType >= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP) && + *auxType <= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP)) { + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type: %{public}d.", PROJECT_TAG, *auxType); + } else { + *auxType = static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP); + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type is set GAINMAP: %{public}d.", PROJECT_TAG, *auxType); + } + Image_AuxiliaryPictureType *type = reinterpret_cast(auxType); + + if (ndkPicture_->auxiliaryPicture_ == nullptr) { + H_LOGE("%{public}s OH_PictureNative_SetAuxiliaryPicture is nullptr", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + + ndkPicture_->errCode_ = + OH_PictureNative_SetAuxiliaryPicture(ndkPicture_->picture_, *type, ndkPicture_->auxiliaryPicture_); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_PictureNative_SetAuxiliaryPicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + H_LOGI("%{public}s OH_PictureNative_SetAuxiliaryPicture success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +static napi_value GetAuxiliaryPicture(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_status status; + size_t argc = 1; + napi_value args[1] = {nullptr}; + + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok || argc < 1 || args[0] == nullptr) { + H_LOGE("%{public}s CreatePicture_ napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, IMAGE_BAD_PARAMETER); + } + + int32_t value = 0; // 假设 auxType 指向了这个变量的地址 + int32_t *auxType = &value; + status = napi_get_value_int32(env, args[0], auxType); + if (*auxType >= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP) && + *auxType <= static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP)) { + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type: %{public}d.", PROJECT_TAG, *auxType); + } else { + *auxType = static_cast(Image_AuxiliaryPictureType::AUXILIARY_PICTURE_TYPE_GAINMAP); + H_LOGI("%{public}s OH_AuxiliaryPictureNative_Create type is set GAINMAP: %{public}d.", PROJECT_TAG, *auxType); + } + Image_AuxiliaryPictureType *type = reinterpret_cast(auxType); + + ndkPicture_->errCode_ = + OH_PictureNative_GetAuxiliaryPicture(ndkPicture_->picture_, *type, &ndkPicture_->auxiliaryPicture_); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_PictureNative_GetAuxiliaryPicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = napi_create_external(env, reinterpret_cast(ndkPicture_->auxiliaryPicture_), + nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_PictureNative_GetAuxiliaryPicture success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +// 将Picture编码到缓冲区 +static napi_value PackToData(napi_env env, napi_callback_info info) { + napi_value result = nullptr; + size_t outDataSize = 10000 * 10000; + uint8_t *outData = new uint8_t[outDataSize]; + + if (ndkPicture_->packerOptions_ == nullptr) { + ndkPicture_->errCode_ = OH_PackingOptions_Create(&ndkPicture_->packerOptions_); + } + if (ndkPicture_->imagePacker_ == nullptr) { + ndkPicture_->errCode_ = OH_ImagePackerNative_Create(&ndkPicture_->imagePacker_); + } + Image_MimeType format; + format.size = 10; + format.data = const_cast("image/jpeg"); + OH_PackingOptions_SetMimeType(ndkPicture_->packerOptions_, &format); + ndkPicture_->errCode_ = OH_ImagePackerNative_PackToDataFromPicture( + ndkPicture_->imagePacker_, ndkPicture_->packerOptions_, ndkPicture_->picture_, outData, &outDataSize); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_ImagePackerNative_PackToDataFromPicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + delete [] outData; + return getJsResult(env, ndkPicture_->errCode_); + } else { + napi_status status = napi_create_external(env, reinterpret_cast(outData), nullptr, nullptr, &result); + if (status != napi_ok) { + napi_throw_error(env, nullptr, "Failed to create external object"); + delete [] outData; + return getJsResult(env, ndkPicture_->errCode_); + } + H_LOGI("%{public}s OH_ImagePackerNative_PackToDataFromPicture success !", PROJECT_TAG); + } + delete [] outData; + return getJsResult(env, ndkPicture_->errCode_); +}; + +// 将Picture编码到图片文件 +static napi_value PackToFile(napi_env env, napi_callback_info info) { + napi_value result; + size_t argc = 1; + napi_value args[1] = {nullptr}; + if (napi_get_cb_info(env, info, &argc, args, nullptr, nullptr) != napi_ok) { + napi_create_int32(env, -1, &result); + H_LOGE("%{public}s napi_get_cb_info failed !", PROJECT_TAG); + return getJsResult(env, ndkPicture_->errCode_); + } + uint32_t fd = 0; + napi_get_value_uint32(env, args[0], &fd); + + if (ndkPicture_->packerOptions_ == nullptr) { + ndkPicture_->errCode_ = OH_PackingOptions_Create(&ndkPicture_->packerOptions_); + } + if (ndkPicture_->imagePacker_ == nullptr) { + ndkPicture_->errCode_ = OH_ImagePackerNative_Create(&ndkPicture_->imagePacker_); + } + Image_MimeType format; + format.size = 10; + format.data = const_cast("image/jpeg"); + OH_PackingOptions_SetMimeType(ndkPicture_->packerOptions_, &format); + ndkPicture_->errCode_ = OH_ImagePackerNative_PackToFileFromPicture( + ndkPicture_->imagePacker_, ndkPicture_->packerOptions_, ndkPicture_->picture_, fd); + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_ImagePackerNative_PackToFileFromPicture failed, errCode: %{public}d.", PROJECT_TAG, + ndkPicture_->errCode_); + + return getJsResult(env, ndkPicture_->errCode_); + } else { + H_LOGI("%{public}s OH_ImagePackerNative_PackToFileFromPicture success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +static napi_value ReleasePicture(napi_env env, napi_callback_info info) { + ndkPicture_->errCode_ = OH_PictureNative_Release(ndkPicture_->picture_); + ndkPicture_->picture_ = nullptr; + if (ndkPicture_->errCode_ != IMAGE_SUCCESS) { + H_LOGE("%{public}s OH_PictureNative_Release failed, errCode: %{public}d.", PROJECT_TAG, ndkPicture_->errCode_); + return getJsResult(env, ndkPicture_->errCode_); + } else { + H_LOGI("%{public}s OH_PictureNative_Release success !", PROJECT_TAG); + } + + return getJsResult(env, ndkPicture_->errCode_); +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"CreatePicture", nullptr, CreatePicture, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"GetMainPixelMap", nullptr, GetMainPixelMap, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"CreatePictureByImageSource", nullptr, CreatePictureByImageSource, nullptr, nullptr, nullptr, napi_default, + nullptr}, + {"PackToData", nullptr, PackToData, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"PackToFile", nullptr, PackToFile, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"ReleasePicture", nullptr, ReleasePicture, nullptr, nullptr, nullptr, napi_default, nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6554ceac274a0f9426ae83ae0b54d2745b91f3a --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { image } from "@kit.ImageKit"; + +declare namespace ndk_picture { + export const CreatePicture: (path: string) => number; + + export const CreatePictureByImageSource: (path: string) => number; + + export const GetMainPixelMap: () => number; + + export const PackToData: () => number; + + export const PackToFile: (fd: number) => number; + + export const ReleasePicture: () => number; +} + +export default ndk_picture; \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..77052c679533e45a066030a9fc21cdbf9cbcf995 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..843c7f0c1f7b9a460e3dbbd2689e5b34016027d1 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..06fc61fa7bb153b8a8cceeedc13a7e9cb1644b6d --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import image from '@ohos.multimedia.image'; +import { myButton } from '../utils/MyButton' +import { PictureFunctions } from '../utils/PicutreFunctions' + +@Entry +@Component +struct Index { + @State message: number = 0; + @State picture: image.Picture | null = null; + @State returnMessage: string = "No"; + private test = new PictureFunctions(); + + build() { + Row() { + Column() { + List() { + ListItem() { + myButton({ text: "Create Picture", fun: this.test.createPicture }) + } + + ListItem() { + myButton({ text: "Get MainPixelMap", fun: this.test.getMainPixelMap }) + } + + ListItem() { + myButton({ text: "Pack to Data", fun: this.test.packToData }) + } + + ListItem() { + myButton({ text: "Pack to File", fun: this.test.packToFile }) + } + + ListItem() { + myButton({ text: "Release Picture", fun: this.test.pictureRelease }) + } + } + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/Logger.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c739c2a2b0bb94b9e444ab564ce665d4de8f6e0 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class AppLog { + constructor(tag: string) { + this.tagName = tag + } + prefix : string = '[Sample_NdkPicture]' + tagName: string + log = (msg: string) => { + console.info(this.prefix + this.tagName + ' ' + msg) + } + check_result = (msg: string, res: object | number) => { + if (typeof res === "object") { + this.log(msg + `object result success :${res}`) + } else if (typeof res === "number") { + if (res == 0) { + this.log(msg + `: errorcode result succ: ${res}`) + } else { + this.log(msg + `: errorcode result failed: ${res}`) + } + } else { + this.log(msg + `unknown result type: ${res}`) + } + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/MyButton.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/MyButton.ets new file mode 100644 index 0000000000000000000000000000000000000000..b99101268f4fe944c59eb4f90081a644de6ecfaf --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/MyButton.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AppLog } from '../utils/Logger' + +const TAG: string = "DEBUG TEST"; + +@Component +export struct myButton { + //自定义button 回调函数目前只支持void和无参 + public logger = new AppLog(TAG); + public fun: () => void = () => { + }; + public text = "This is a button"; + @State returnMessage: string = "No"; + + build() { + Row() { + Column() { + Blank().height(40); + Button(`${this.text}`) + .labelStyle({ + overflow: TextOverflow.Clip, + maxLines: 2, + minFontSize: 20, + maxFontSize: 20, + font: { + size: 20, + weight: FontWeight.Bolder, + family: 'cursive', + style: FontStyle.Italic + } + }) + .onClick(() => { + this.logger.log("\n start->>>>>>>>>>>>>>>>>>>>>>"); + this.fun(); + this.logger.log((this.fun.toString()) + "\n end:->>>>>>>>>>>>>>>>>>>>>>"); + this.returnMessage = "Yes"; + }) + Blank().height(40); + Divider(); + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/PicutreFunctions.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/PicutreFunctions.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7f0f97f0c50fef646d33ba2cc68c8d642bbe219 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/ets/utils/PicutreFunctions.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import testNapi from 'libentry.so'; +import fs from '@ohos.file.fs' +import {AppLog } from '../utils/Logger' +import image from '@ohos.multimedia.image'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { promptAction } from '@kit.ArkUI'; + +const TAG: string = 'PictureFunctions: ' +export class PictureFunctions { + constructor() { + } + + private logger = new AppLog(TAG) + + createPicture() { + this.logger.log("start createPicture"); + let context = getContext(); + let filePath = context.filesDir + "/test.jpg"; + let ec = testNapi.CreatePicture(filePath); + if(ec === 0) { + promptAction.showToast({ message: 'Create Picture Success.'}); + } else { + this.logger.log("CreatePicture error is: " + ec); + } + } + + createPictureByImageSource() { + this.logger.log("start createPicture"); + let context = getContext(); + let filePath = context.filesDir + "/test.jpg"; + let ec = testNapi.CreatePictureByImageSource(filePath); + if(ec === 0) { + promptAction.showToast({ message: 'Create Picture Success.'}); + } else { + this.logger.log("CreatePicture error is: " + ec); + } + } + + getMainPixelMap() { + let ec = testNapi.GetMainPixelMap(); + this.logger.check_result("GetMainPixelMap", ec); + if(ec === 0) { + promptAction.showToast({ message: 'getMainPixelMap Success.'}); + } else { + promptAction.showToast({ message: 'getMainPixelMap failed. Please create picture first.'}); + this.logger.log("getMainPixelMap error is: " + ec); + } + } + + packToData(): void { + let ec = testNapi.PackToData(); + this.logger.check_result("packToDataFromPicture result is:" , ec); + if(ec === 0) { + promptAction.showToast({ message: 'packToData Success.'}); + } else { + promptAction.showToast({ message: 'packToData failed. Please create picture first.'}); + this.logger.log("packToData error is: " + ec); + } + } + + packToFile(): void { + let context = getContext(); + let filePath = context.filesDir + "/packTest.jpg"; + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let ec = testNapi.PackToFile(file.fd); + this.logger.check_result("packToDataFromPicture result is:" , ec); + if(ec === 0) { + promptAction.showToast({ message: 'packToFile Success.'}); + } else { + promptAction.showToast({ message: 'packToFile failed. Please create picture first.'}); + this.logger.log("packToFile error is: " + ec); + } + } + + pictureRelease() { + let ec = testNapi.ReleasePicture(); + this.logger.check_result("pictureNative_Release done, return is:" , ec); + if(ec === 0) { + promptAction.showToast({ message: 'pictureRelease Success.'}); + } else { + promptAction.showToast({ message: 'pictureRelease failed. Please create picture first.'}); + this.logger.log("pictureRelease error is: " + ec); + } + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/module.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c75d702e2d350523978ecaf801c22762ce7d40c0 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6b14e1dbad3297c648c76f395769012a3f41c8af --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "NdkPicture" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..55c3f007f87b7ce5206d325f968cc56f2f79441f --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/rawfile/test.jpg b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/rawfile/test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..28eea137afa5584f35736d3b13423a8a9816df2a Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/entry/src/main/resources/rawfile/test.jpg differ diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/Libentry.mock.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..82fa70b5693ddab96d237d2d17d943d866b61465 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..98b0ae79f0090e1fc381d54c959fb32c9f7563f4 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/mock/mock-config.json5 @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..987b1a582262f0c046c8296bed24b9947579caac --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG: string = '[Sample_NdkPicture]'; + const DOMAIN = 0xF811; + const BUNDLE = 'NdkPicture_'; + const DELAY_TIME = 1000; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + describe('ActsAbilityTest', () => { + + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + /** + * 打开应用 + */ + it('StartAbility_001', 0, async (done: Function) => { + console.info(TAG, 'StartAbility_001 begin'); + + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + hilog.error(DOMAIN, TAG, `StartAbility_001 exception = ${JSON.stringify(exception)}`); + expect().assertFail(); + } + await driver.delayMs(3000); + done(); + console.info(TAG, 'StartAbility_001 end'); + }) + /** + * 解码得到Picture + */ + it(BUNDLE + 'CreatePicture_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'CreatePicture_001 begin'); + await driver.delayMs(DELAY_TIME); + // 点击 Create Picture 按钮 + await driver.assertComponentExist(ON.text("Create Picture")); + let btn = await driver.findComponent(ON.text("Create Picture")); + await btn.click(); + await driver.delayMs(DELAY_TIME); + hilog.info(DOMAIN, TAG, BUNDLE + 'CreatePicture_001 end'); + done(); + }) + /** + * 获取主图 + */ + it(BUNDLE + 'GetMainPixelMap_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'GetMainPixelMap_001 begin'); + await driver.delayMs(DELAY_TIME); + // 点击 Get MainPixelMap 按钮 + await driver.assertComponentExist(ON.text("Get MainPixelMap")); + let btn = await driver.findComponent(ON.text("Get MainPixelMap")); + await btn.click(); + await driver.delayMs(DELAY_TIME); + hilog.info(DOMAIN, TAG, BUNDLE + 'GetMainPixelMap_001 end'); + done(); + }) + /** + * 将Picture编码到缓冲区 + */ + it(BUNDLE + 'PackToData_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'PackToData_001 begin'); + await driver.delayMs(DELAY_TIME); + // 点击 Pack to Data 按钮 + await driver.assertComponentExist(ON.text("Pack to Data")); + let btn = await driver.findComponent(ON.text("Pack to Data")); + await btn.click(); + await driver.delayMs(DELAY_TIME); + hilog.info(DOMAIN, TAG, BUNDLE + 'PackToData_001 end'); + done(); + }) + /** + * 将Picture编码到图片文件 + */ + it(BUNDLE + 'PackToFile_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'PackToFile_001 begin'); + await driver.delayMs(DELAY_TIME); + // 点击 Pack to File 按钮 + await driver.assertComponentExist(ON.text("Pack to File")); + let btn = await driver.findComponent(ON.text("Pack to File")); + await btn.click(); + await driver.delayMs(DELAY_TIME); + hilog.info(DOMAIN, TAG, BUNDLE + 'PackToFile_001 end'); + done(); + }) + /** + * 释放Picture + */ + it(BUNDLE + 'ReleasePicture_001', 0, async (done: Function) => { + hilog.info(DOMAIN, TAG, BUNDLE + 'ReleasePicture_001 begin'); + await driver.delayMs(DELAY_TIME); + // 点击 Release Picture 按钮 + await driver.assertComponentExist(ON.text("Release Picture")); + let btn = await driver.findComponent(ON.text("Release Picture")); + await btn.click(); + await driver.delayMs(DELAY_TIME); + hilog.info(DOMAIN, TAG, BUNDLE + 'ReleasePicture_001 end'); + done(); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c64e0b06938d246ce044186d4b2d02b500a89e14 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..69026872775eebd0844900b225c411959ae5608b --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/ohosTest/module.json5 @@ -0,0 +1,12 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/test/List.test.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/Image/NdkPicture/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/hvigor/hvigor-config.json5 b/code/DocsSample/Media/Image/NdkPicture/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..15688394471007faea3f8215ad9e367b25f428b6 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/Image/NdkPicture/hvigorfile.ts b/code/DocsSample/Media/Image/NdkPicture/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/Image/NdkPicture/oh-package.json5 b/code/DocsSample/Media/Image/NdkPicture/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c44d132b0b0fc4c38d7050a308f0d7f4aeb0653c --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/Image/NdkPicture/ohosTest.md b/code/DocsSample/Media/Image/NdkPicture/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..c3b2dc3594da5dc6d15a3fc73a32db7d7a4e7d73 --- /dev/null +++ b/code/DocsSample/Media/Image/NdkPicture/ohosTest.md @@ -0,0 +1,12 @@ +# NdkPicture测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|------------------------|--------------|-----------------------------|-----------------------------------|----------|----------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | +| 图片解码功能 | 进入主界面 | 点击 Create Picture 按钮 | 弹窗通知 createPicture Success. | 是 | Pass | +| 获取主图功能 | 进入主界面 | 点击位图操作按钮 | 弹窗通知 getMainPixelMap Success.| 是 | Pass | +| 图片编码到缓冲区功能 | 进入主界面 | 点击 Pack To Data 按钮 | 弹窗通知 packToData Success. | 是 | Pass | +| 图片编码到文件功能 | 进入主界面 | 点击 Pack To File 按钮 | 弹窗通知 packToFile Success. | 是 | Pass | +| 释放 Picture 功能 | 进入主界面 | 点击 Realease Picture 按钮 | 弹窗通知 pictureRelease Success | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/Image/NdkPicture/screenshots/NdkPictureUI.png b/code/DocsSample/Media/Image/NdkPicture/screenshots/NdkPictureUI.png new file mode 100644 index 0000000000000000000000000000000000000000..dd36e2e22067ad41f824305075d737f5900c0bc3 Binary files /dev/null and b/code/DocsSample/Media/Image/NdkPicture/screenshots/NdkPictureUI.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/.gitignore b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/app.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b409266e20a53ae353c37684b0348f27cb4c832e --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.sample.screencapturesample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/element/string.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a0e0f994dc6eee5c453fca24771359bb7ff37c92 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ScreenCaptureSample" + } + ] +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/background.png b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/README_zh.md b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..7139ec22084ec5c12c2213b3a760b77e728073ee --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/README_zh.md @@ -0,0 +1,83 @@ +# 录屏Sample + +## 介绍 +录屏Sample调用了媒体AVScreenCapture组件提供的接口能力,提供屏幕捕获的功能,包含: +- 录屏存文件 +- 录屏取原始码流 +- 录屏取原始码流Surface模式 + +## 效果预览 +| 获取录音权限 | 应用主界面 | 隐私弹窗 | 录制过程界面 | +|----------------------|----------------------|----------------------|----------------------| +| ![image](./pic1.jpg) | ![image](./pic2.jpg) | ![image](./pic3.jpg) | ![image](./pic4.jpg) | + +使用说明 + +1. 启动应用,首次启动需要用户授予访问麦克风的权限。 +2. 选择对应的功能页签,点击Start按钮,启动屏幕录制。 +3. 启动录制后会弹出隐私弹窗,告知用户将被录屏。 +4. 选择允许后,启动录制后会弹出录制悬浮胶囊,并显示录制时间计时,此时可以操作屏幕,屏幕上的操作过程会被录制下来。 +5. 需要停止录屏时,点击应用停止按钮或点击悬浮半透明的红色按钮,屏幕录制停止。 +6. 录屏存储的文件保存在沙箱目录,录制结果与设备支持的编码格式有关。 + +## 工程目录 + +仓目录结构如下: + +``` +entry/src/main # 录屏Sample业务代码 +│ module.json5 # 编译相关文件 +├─cpp # ndk相关文件 +│ │ CMakeLists.txt +│ │ main.h +│ │ napi_init.cpp +│ │ sample_callback.cpp +│ │ sample_callback.h +│ │ sample_info.h +│ └─types # 映射文件 +│ +├─ets # 页面相关实现 +│ ├─entryability +│ ├─entrybackupability +│ └─pages # ets页面实现 +│ Index.ets # 首页 +│ Menu.ets # 列表文件 +│ Scene1.ets # 录屏存文件场景 +│ Scene2.ets # 录屏取码流场景 +│ Scene3.ets # 录屏取码流Surface场景 +│ Scene4.ets # 录屏存文件js接口 +│ +└─resources # 资源文件 +``` + +## 相关权限 + +ohos.permission.MICROPHONE + +ohos.permission.KEEP_BACKGROUND_RUNNING + +ohos.permission.WRITE_MEDIA + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API19版本SDK,版本号:5.1.1.62; + +3. 本示例已支持使DevEco Studio 5.0.5 Beta1(构建版本:5.0.13.100,构建于:2025年4月25日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/build-profile.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b2ee63d84428b96eccbbfcd28a3c5edeb4199ef1 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/build-profile.json5 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 19, + "compatibleSdkVersion": 19, + "runtimeOS": "OpenHarmony" + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/code-linter.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/.gitignore b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/build-profile.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6125a7467db0b8ece6e5cbf1fabff87bbdcc3999 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/build-profile.json5 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": [ + "armeabi-v7a", + "arm64-v8a" + ] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/hvigorfile.ts b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/obfuscation-rules.txt b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/oh-package.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/oh-package.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/CMakeLists.txt b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..93de6dd25e0801bf1810cd6f4e57e2149f802465 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,20 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.5.0) +project(ScreenCaptureSample) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include) + +add_library(entry SHARED napi_init.cpp sample_callback.cpp muxer.cpp) +target_link_libraries(entry PUBLIC libace_napi.z.so libnative_buffer.so libhilog_ndk.z.so librawfile.z.so libnative_avscreen_capture.so + libace_ndk.z.so libnative_media_codecbase.so libnative_media_core.so libnative_media_venc.so libnative_window.so libnative_media_avdemuxer.so + libnative_media_avsource.so libnative_image.so librawfile.z.so libnative_media_avmuxer.so libnative_media_adec.so libnative_media_aenc.so + libnative_media_vdec.so) \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/main.h b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/main.h new file mode 100644 index 0000000000000000000000000000000000000000..ea7b725fa86fb87ec4ff1344624804ce83e43459 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/main.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVSCREENCAPTURENDKDEMO_MAIN_H +#define AVSCREENCAPTURENDKDEMO_MAIN_H +#endif // AVSCREENCAPTURENDKDEMO_MAIN_H + +#include "napi/native_api.h" +#include +#include +#include +#include +#include +#include +#include "hilog/log.h" +#include +#include "multimedia/player_framework/native_avcodec_videodecoder.h" +#include "multimedia/player_framework/native_avcodec_videoencoder.h" +#include +#include "native_window/external_window.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sample_callback.h" +#include "muxer.h" + +static struct OH_AVScreenCapture *g_avCapture = {}; +static FILE *micFile_ = nullptr; +static FILE *vFile_ = nullptr; +static FILE *innerFile_ = nullptr; +std::unique_ptr g_muxer; + +static char filename[100] = {0}; +bool m_isRunning = false; +bool m_scSaveFileIsRunning = false; +bool m_scSurfaceIsRunning = false; +OH_AVCodec *g_videoEnc; +CodecUserData *g_encContext = nullptr; +SampleInfo sampleInfo_; +std::unique_ptr inputVideoThread_; +std::atomic isStarted_{false}; + +constexpr uint32_t DEFAULT_WIDTH = 4096; +// 配置视频帧高度(必须) +constexpr uint32_t DEFAULT_HEIGHT = 4096; +// 配置视频颜色格式(必须) +constexpr OH_AVPixelFormat DEFAULT_PIXELFORMAT = AV_PIXEL_FORMAT_NV12; \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.cpp b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6eeb60c28671e04b4776ea22f81113ae40f982e3 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "muxer.h" +#include "hilog/log.h" + +#undef LOG_TAG +#define LOG_TAG "Muxer" + +namespace { +constexpr int32_t VERTICAL_ANGLE = 90; +constexpr int32_t HORIZONTAL_ANGLE = 0; +} + +Muxer::~Muxer() +{ + Release(); +} + +int32_t Muxer::Create(int32_t fd) +{ + muxer_ = OH_AVMuxer_Create(fd, AV_OUTPUT_FORMAT_MPEG_4); + return 0; +} + +int32_t Muxer::Config(SampleInfo &sampleInfo) +{ + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== Config"); + OH_AVFormat *formatVideo = OH_AVFormat_CreateVideoFormat(sampleInfo.codecMime.data(), + sampleInfo.videoWidth, sampleInfo.videoHeight); + + OH_AVFormat_SetDoubleValue(formatVideo, OH_MD_KEY_FRAME_RATE, sampleInfo.frameRate); + OH_AVFormat_SetIntValue(formatVideo, OH_MD_KEY_WIDTH, sampleInfo.videoWidth); + OH_AVFormat_SetIntValue(formatVideo, OH_MD_KEY_HEIGHT, sampleInfo.videoHeight); + OH_AVFormat_SetStringValue(formatVideo, OH_MD_KEY_CODEC_MIME, sampleInfo.codecMime.data()); + + int32_t ret = OH_AVMuxer_AddTrack(muxer_, &videoTrackId_, formatVideo); + OH_AVFormat_Destroy(formatVideo); + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== Config End"); + return 0; +} + +int32_t Muxer::Start() +{ + int ret = OH_AVMuxer_Start(muxer_); + return 0; +} + +int32_t Muxer::WriteSample(OH_AVBuffer *buffer, OH_AVCodecBufferAttr &attr) +{ + int32_t ret = OH_AVBuffer_SetBufferAttr(buffer, &attr); + ret = OH_AVMuxer_WriteSampleBuffer(muxer_, videoTrackId_, buffer); + return 0; +} + +int32_t Muxer::Stop() +{ + int32_t ret = OH_AVMuxer_Stop(muxer_); + return 0; +} + +int32_t Muxer::Release() +{ + if (muxer_ != nullptr) { + OH_AVMuxer_Destroy(muxer_); + muxer_ = nullptr; + } + return 0; +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.h b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.h new file mode 100644 index 0000000000000000000000000000000000000000..9930a14a1ee2d17ed96cfecc754cb0c5b9bbc87c --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/muxer.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MUXER_H +#define MUXER_H +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "MY_SCNDKDEMO" +#include +#include "sample_info.h" +#include "multimedia/player_framework/native_avmuxer.h" + +class Muxer { +public: + Muxer() = default; + ~Muxer(); + + int32_t Create(int32_t fd); + int32_t Config(SampleInfo &sampleInfo); + int32_t Start(); + int32_t WriteSample(OH_AVBuffer *buffer, OH_AVCodecBufferAttr &attr); + + int32_t Stop(); + int32_t Release(); + +private: + OH_AVMuxer *muxer_ = nullptr; + int32_t videoTrackId_ = -1; + int32_t audioTrackId_ = -1; + int32_t coverTrackId_ = -1; +}; + +#endif // MUXER_H \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27b60e4b76f1819e71bb7a8cffef959d6e96e87a --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,553 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "main.h" + +using namespace std; +#define LOG_TAG "ScreenCaptureSample" + +void OpenFile(std::string fileName) +{ + std::string filePath = "data/storage/el2/base/files/MIC_" + fileName + ".pcm"; + micFile_ = fopen(filePath.c_str(), "wb"); + if (micFile_ == nullptr) { + OH_LOG_ERROR(LOG_APP, "OpenFile micFile_ audio open failed. %{public}s", strerror(errno)); + } + filePath = "data/storage/el2/base/files/INNER_" + fileName + ".pcm"; + innerFile_ = fopen(filePath.c_str(), "wb"); + if (innerFile_ == nullptr) { + OH_LOG_ERROR(LOG_APP, "OpenFile innerFile_ audio open failed. %{public}s", strerror(errno)); + } + filePath = "data/storage/el2/base/files/VIDEO_" + fileName + ".yuv"; + vFile_ = fopen(filePath.c_str(), "wb"); + if (vFile_ == nullptr) { + OH_LOG_ERROR(LOG_APP, "OpenFile vFile video open failed. %{public}s", strerror(errno)); + } +} + +void CloseFile(void) +{ + if (micFile_ != nullptr) { + fclose(micFile_); + micFile_ = nullptr; + } + if (innerFile_ != nullptr) { + fclose(innerFile_); + innerFile_ = nullptr; + } + if (vFile_ != nullptr) { + fclose(vFile_); + vFile_ = nullptr; + } +} + +void SetConfig(OH_AVScreenCaptureConfig &config) +{ + int32_t width = 720; + int32_t height = 1280; + OH_AudioCaptureInfo micCapInfo = {.audioSampleRate = 48000, .audioChannels = 2, .audioSource = OH_MIC}; + OH_AudioCaptureInfo innerCapInfo = {.audioSampleRate = 48000, .audioChannels = 2, .audioSource = OH_ALL_PLAYBACK}; + OH_AudioEncInfo audioEncInfo = {.audioBitrate = 48000, .audioCodecformat = OH_AudioCodecFormat::OH_AAC_LC}; + OH_AudioInfo audioInfo = {.micCapInfo = micCapInfo, .innerCapInfo = innerCapInfo, .audioEncInfo = audioEncInfo}; + + OH_VideoCaptureInfo videoCapInfo = { + .videoFrameWidth = width, .videoFrameHeight = height, .videoSource = OH_VIDEO_SOURCE_SURFACE_RGBA}; + OH_VideoEncInfo videoEncInfo = { + .videoCodec = OH_VideoCodecFormat::OH_H264, .videoBitrate = 2000000, .videoFrameRate = 30}; + OH_VideoInfo videoInfo = {.videoCapInfo = videoCapInfo, .videoEncInfo = videoEncInfo}; + + config = { + .captureMode = OH_CAPTURE_HOME_SCREEN, + .dataType = OH_ORIGINAL_STREAM, + .audioInfo = audioInfo, + .videoInfo = videoInfo, + }; +} + +void OnError(OH_AVScreenCapture *capture, int32_t errorCode, void *userData) +{ + (void)capture; + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnError errorCode is %{public}d", errorCode); + (void)userData; +} + +void OnStateChange(struct OH_AVScreenCapture *capture, OH_AVScreenCaptureStateCode stateCode, void *userData) +{ + if (stateCode == OH_SCREEN_CAPTURE_STATE_STARTED) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnStateChange started"); + // 处理状态变更 + // 可选 配置录屏旋转 + int32_t ret = OH_AVScreenCapture_SetCanvasRotation(capture, true); + // 可选 修改Canvas分辨率 + ret = OH_AVScreenCapture_ResizeCanvas(g_avCapture, 768, 1280); + // 可选 设置是否显示光标 + ret = OH_AVScreenCapture_ShowCursor(g_avCapture, true); + // 可选 设置视频最大帧率 + ret = OH_AVScreenCapture_SetMaxVideoFrameRate(g_avCapture, 30); + } + if (stateCode == OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER) { + // 处理状态变更 + } + (void)userData; +} + +void OnBufferAvailable(OH_AVScreenCapture *capture, OH_AVBuffer *buffer, OH_AVScreenCaptureBufferType bufferType, + int64_t timestamp, void *userData) +{ + if (m_isRunning) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnBufferAvailable bufferType is %{public}d", + bufferType); + if (bufferType == OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO) { + // 处理视频buffer + OH_NativeBuffer *nativebuffer = OH_AVBuffer_GetNativeBuffer(buffer); + if (nativebuffer != nullptr) { + int bufferLen = OH_AVBuffer_GetCapacity(buffer); + OH_AVCodecBufferAttr info; + int32_t ret = OH_AVBuffer_GetBufferAttr(buffer, &info); + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture size %{public}d", info.size); + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture bufferLen %{public}d", bufferLen); + + OH_NativeBuffer_Config config; + OH_NativeBuffer_GetConfig(nativebuffer, &config); + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture height %{public}d width %{public}d", + config.height, config.width); + // int32_t length = config.height * config.width * 4; + uint8_t *buf = OH_AVBuffer_GetAddr(buffer); + if (buf == nullptr) { + return; + } + fwrite(buf, 1, bufferLen, vFile_); + OH_NativeBuffer_Unreference(nativebuffer); + buffer = nullptr; + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnBufferAvailable inner audio"); + } + } else if (bufferType == OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER) { + // 处理内录buffer + int bufferLen = OH_AVBuffer_GetCapacity(buffer); + uint8_t *buf = OH_AVBuffer_GetAddr(buffer); + if (buf != nullptr) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnBufferAvailable inner audio"); + fwrite(buf, 1, bufferLen, innerFile_); + } + } else if (bufferType == OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC) { + // 处理麦克风buffer + int bufferLen = OH_AVBuffer_GetCapacity(buffer); + uint8_t *buf = OH_AVBuffer_GetAddr(buffer); + if (buf != nullptr) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnBufferAvailable mic audio"); + fwrite(buf, 1, bufferLen, micFile_); + } + } + } + return; +} + +void OnDisplaySelected(struct OH_AVScreenCapture *capture, uint64_t displayId, void *userData) +{ + (void)capture; + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OnError errorCode is %{public}uld", displayId); + (void)userData; +} + +// 开始录屏原始码流 +static napi_value StartScreenCapture_01(napi_env env, napi_callback_info info) +{ + g_avCapture = OH_AVScreenCapture_Create(); + if (g_avCapture == nullptr) { + OH_LOG_ERROR(LOG_APP, "create screen capture failed"); + } + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + OpenFile("Demo"); + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(g_avCapture, isMicrophone); + OH_AVScreenCapture_SetErrorCallback(g_avCapture, OnError, nullptr); + OH_AVScreenCapture_SetStateCallback(g_avCapture, OnStateChange, nullptr); + OH_AVScreenCapture_SetDataCallback(g_avCapture, OnBufferAvailable, nullptr); + OH_AVScreenCapture_SetDisplayCallback(g_avCapture, OnDisplaySelected, nullptr); + // 可选,排除指定窗口/指定音频类型 start + struct OH_AVScreenCapture_ContentFilter *contentFilter = OH_AVScreenCapture_CreateContentFilter(); + OH_AVScreenCapture_ContentFilter_AddAudioContent(contentFilter, OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO); + vector windowIdsExclude = { -111 }; + OH_AVScreenCapture_ContentFilter_AddWindowContent(contentFilter, + &windowIdsExclude[0], static_cast(windowIdsExclude.size())); + OH_AVScreenCapture_ExcludeContent(g_avCapture, contentFilter); + OH_AVScreenCapture_SkipPrivacyMode(g_avCapture, + &windowIdsExclude[0], static_cast(windowIdsExclude.size())); + OH_AVScreenCapture_ReleaseContentFilter(contentFilter); + // 可选,排除指定窗口/指定音频类型 end + int result = OH_AVScreenCapture_Init(g_avCapture, config_); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init failed %{public}d", result); + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init %{public}d", result); + + result = OH_AVScreenCapture_StartScreenCapture(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started failed %{public}d", result); + OH_AVScreenCapture_Release(g_avCapture); + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started %{public}d", result); + + m_isRunning = true; + + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// 开始录屏存文件 +static napi_value StartScreenCapture_02(napi_env env, napi_callback_info info) +{ + g_avCapture = OH_AVScreenCapture_Create(); + if (g_avCapture == nullptr) { + OH_LOG_ERROR(LOG_APP, "create screen capture failed"); + } + OH_AVScreenCaptureConfig config_; + + OH_RecorderInfo recorderInfo; + const std::string filePath = "/data/storage/el2/base/files/"; + int32_t outputFd = open((filePath + "saving_file.mp4").c_str(), O_RDWR | O_CREAT, 0777); + std::string fileUrl = "fd://" + std::to_string(outputFd); + recorderInfo.url = const_cast(fileUrl.c_str()); + recorderInfo.fileFormat = OH_ContainerFormatType::CFT_MPEG_4; + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture fileUrl %{public}s", fileUrl.c_str()); + + SetConfig(config_); + config_.captureMode = OH_CAPTURE_HOME_SCREEN; + config_.dataType = OH_CAPTURE_FILE; + config_.recorderInfo = recorderInfo; + bool isMicrophone = true; + OH_AVScreenCapture_SetMicrophoneEnabled(g_avCapture, isMicrophone); + OH_AVScreenCapture_SetStateCallback(g_avCapture, OnStateChange, nullptr); + OH_AVScreenCapture_SetDisplayCallback(g_avCapture, OnDisplaySelected, nullptr); + OH_AVSCREEN_CAPTURE_ErrCode result = OH_AVScreenCapture_Init(g_avCapture, config_); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init failed %{public}d", result); + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init %{public}d", result); + + result = OH_AVScreenCapture_StartScreenRecording(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started failed %{public}d", result); + OH_AVScreenCapture_Release(g_avCapture); + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started %{public}d", result); + + m_scSaveFileIsRunning = true; + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// 开始录屏原始码流SurfaceMode +void ThreadVideoRunMethod() +{ + while (m_scSurfaceIsRunning) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ThreadVideoRunMethod m_scSurfaceIsRunning %{public}d", + m_scSurfaceIsRunning); + if (!isStarted_.load()) { + return; + } + std::unique_lock lock(g_encContext->outputMutex_); + bool condRet = g_encContext->outputCond_.wait_for( + lock, 2s, [&]() { return !isStarted_.load() || !g_encContext->outputBufferInfoQueue_.empty(); }); + if (!isStarted_.load()) { + return; + } + if (g_encContext->outputBufferInfoQueue_.empty()) { + continue; + } + CodecBufferInfo bufferInfo = g_encContext->outputBufferInfoQueue_.front(); + g_encContext->outputBufferInfoQueue_.pop(); + if (bufferInfo.attr.flags & AVCODEC_BUFFER_FLAGS_EOS) { + lock.unlock(); + break; + } + lock.unlock(); + if (bufferInfo.buffer != nullptr) { + bufferInfo.attr.pts = (bufferInfo.attr.flags & AVCODEC_BUFFER_FLAGS_CODEC_DATA) + ? 0 + : (g_encContext->outputFrameCount_++ * 1000000 / sampleInfo_.frameRate); + g_muxer->WriteSample(reinterpret_cast(bufferInfo.buffer), bufferInfo.attr); + } + OH_VideoEncoder_FreeOutputBuffer(g_videoEnc, bufferInfo.bufferIndex); + } +} + +int SetFormat() +{ + OH_AVFormat *format = OH_AVFormat_Create(); + // 配置视频帧速率 + double frameRate = 30.0; + // 配置视频YUV值范围标志 + bool rangeFlag = false; + // 配置视频原色 + int32_t primary = static_cast(OH_ColorPrimary::COLOR_PRIMARY_BT709); + // 配置传输特性 + int32_t transfer = static_cast(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709); + // 配置最大矩阵系数 + int32_t matrix = static_cast(OH_MatrixCoefficient::MATRIX_COEFFICIENT_IDENTITY); + // 配置编码Profile + int32_t profile = static_cast(OH_AVCProfile::AVC_PROFILE_BASELINE); + // 配置编码比特率模式 + int32_t rateMode = static_cast(OH_VideoEncodeBitrateMode::CBR); + // 配置关键帧的间隔,单位为毫秒 + int32_t iFrameInterval = 23000; + // 配置所需的编码质量。只有在恒定质量模式下配置的编码器才支持此配置 + int32_t quality = 0; + // 配置比特率 + int64_t bitRate = 2000000; + OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH); + sampleInfo_.videoWidth = DEFAULT_WIDTH; + OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT); + sampleInfo_.videoHeight = DEFAULT_HEIGHT; + OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, DEFAULT_PIXELFORMAT); + OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, frameRate); + sampleInfo_.frameRate = frameRate; + sampleInfo_.videoCodecMime = sampleInfo_.codecMime.data(); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_RANGE_FLAG, rangeFlag); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_COLOR_PRIMARIES, primary); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_TRANSFER_CHARACTERISTICS, transfer); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_MATRIX_COEFFICIENTS, matrix); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_I_FRAME_INTERVAL, iFrameInterval); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_PROFILE, profile); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, rateMode); + OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitRate); + OH_AVFormat_SetIntValue(format, OH_MD_KEY_QUALITY, quality); + int result = OH_VideoEncoder_Configure(g_videoEnc, format); + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== OH_VideoEncoder_Configure ret=%{public}d", result); + OH_AVFormat_Destroy(format); + return result; +} + +int GetInputSurface() +{ + // 获取需要输入的Surface,以进行编码 + OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true); + const char *name = OH_AVCapability_GetName(capability); + g_videoEnc = OH_VideoEncoder_CreateByName(name); + g_muxer = std::make_unique(); + const std::string filePath = "/data/storage/el2/base/files/"; + int32_t outputFd = open((filePath + "surface.mp4").c_str(), O_RDWR | O_CREAT, 0777); + g_muxer->Create(outputFd); + g_encContext = new CodecUserData; + g_encContext->sampleInfo = &sampleInfo_; + // 配置异步回调,调用 OH_VideoEncoder_SetCallback 接口 + OH_VideoEncoder_RegisterCallback(g_videoEnc, + {SampleCallback::OnError, SampleCallback::OnStreamChanged, + SampleCallback::OnNeedInputBuffer, SampleCallback::OnNewOutputBuffer}, + g_encContext); + (void)SetFormat(); + // 从视频编码器获取输入Surface + OHNativeWindow *nativeWindow; + int result = OH_VideoEncoder_GetSurface(g_videoEnc, &nativeWindow); + if (result != AV_ERR_OK) { + OH_LOG_ERROR(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started OH_VideoEncoder_GetSurface ret=%{public}d", + result); + return result; + } + result = OH_VideoEncoder_Prepare(g_videoEnc); + g_muxer->Config(sampleInfo_); + g_muxer->Start(); + // 启动编码器 + result = OH_VideoEncoder_Start(g_videoEnc); + isStarted_.store(true); + m_scSurfaceIsRunning = true; + inputVideoThread_ = std::make_unique(ThreadVideoRunMethod); + // 指定surface开始录屏 + result = OH_AVScreenCapture_StartScreenCaptureWithSurface(g_avCapture, nativeWindow); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_ERROR(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started failed %{public}d", result); + OH_AVScreenCapture_Release(g_avCapture); + return result; + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Started %{public}d", result); + return result; +} + +static napi_value StartScreenCapture_03(napi_env env, napi_callback_info info) +{ + isStarted_.store(false); + inputVideoThread_ = nullptr; + g_encContext = nullptr; + g_avCapture = OH_AVScreenCapture_Create(); + if (g_avCapture == nullptr) { + OH_LOG_ERROR(LOG_APP, "create screen capture failed"); + } + OH_AVScreenCaptureConfig config_; + SetConfig(config_); + bool isMicrophone = false; + OH_AVScreenCapture_SetMicrophoneEnabled(g_avCapture, isMicrophone); + OH_AVScreenCapture_SetErrorCallback(g_avCapture, OnError, nullptr); + OH_AVScreenCapture_SetStateCallback(g_avCapture, OnStateChange, nullptr); + OH_AVScreenCapture_SetDataCallback(g_avCapture, OnBufferAvailable, nullptr); + OH_AVScreenCapture_SetDisplayCallback(g_avCapture, OnDisplaySelected, nullptr); + int result = OH_AVScreenCapture_Init(g_avCapture, config_); + if (result != AV_SCREEN_CAPTURE_ERR_OK) { + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init failed %{public}d", result); + } + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture OH_AVScreenCapture_Init %{public}d", result); + (void)GetInputSurface(); + napi_value res; + napi_create_int32(env, result, &res); + return res; +} + +// 停止 +static napi_value StopScreenCapture(napi_env env, napi_callback_info info) +{ + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== ScreenCapture Stop"); + OH_AVSCREEN_CAPTURE_ErrCode result = AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT; + napi_value res; + if (m_scSurfaceIsRunning) { + (void)OH_VideoEncoder_NotifyEndOfStream(g_videoEnc); + (void)OH_VideoEncoder_Stop(g_videoEnc); + (void)OH_VideoEncoder_Destroy(g_videoEnc); + g_videoEnc = nullptr; + g_muxer->Stop(); + m_scSurfaceIsRunning = false; + isStarted_.store(false); + if (inputVideoThread_ && inputVideoThread_->joinable()) { + inputVideoThread_->join(); + } + } + if (g_avCapture == nullptr) { + OH_LOG_ERROR(LOG_APP, "capture_ is null."); + } + if (m_scSaveFileIsRunning) { + result = OH_AVScreenCapture_StopScreenRecording(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_BASE) { + OH_LOG_ERROR(LOG_APP, "StopScreenCapture OH_AVScreenCapture_StopScreenRecording Result: %{public}d", + result); + } + result = OH_AVScreenCapture_Release(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_BASE) { + OH_LOG_ERROR(LOG_APP, "StopScreenCapture OH_AVScreenCapture_Release: %{public}d", result); + } + OH_LOG_INFO(LOG_APP, "OH_AVScreenCapture_Release success"); + m_scSaveFileIsRunning = false; + } else { + result = OH_AVScreenCapture_StopScreenCapture(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_BASE) { + OH_LOG_ERROR(LOG_APP, "StopScreenCapture OH_AVScreenCapture_StopScreenCapture Result: %{public}d", result); + } + result = OH_AVScreenCapture_Release(g_avCapture); + if (result != AV_SCREEN_CAPTURE_ERR_BASE) { + OH_LOG_ERROR(LOG_APP, "StopScreenCapture OH_AVScreenCapture_Release: %{public}d", result); + } + OH_LOG_INFO(LOG_APP, "OH_AVScreenCapture_Release success"); + CloseFile(); + m_isRunning = false; + } + napi_create_int32(env, result, &res); + return res; +} + + +// 调用老接口,仅提供代码实现,不建议使用 +void MockOnAudioBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady, OH_AudioCaptureSourceType type) +{ + if (isReady == true) { + OH_AudioBuffer *audioBuffer = (OH_AudioBuffer *)malloc(sizeof(OH_AudioBuffer)); + if (audioBuffer == nullptr) { + OH_LOG_INFO(LOG_APP, "audio buffer is nullptr"); + return; + } + if (OH_AVScreenCapture_AcquireAudioBuffer(screenCapture, &audioBuffer, type) == AV_SCREEN_CAPTURE_ERR_OK) { + if ((micFile_ != nullptr) && (audioBuffer->buf != nullptr) && (type == OH_MIC)) { + int32_t ret = fwrite(audioBuffer->buf, 1, audioBuffer->size, micFile_); + free(audioBuffer->buf); + audioBuffer->buf = nullptr; + } else if ((innerFile_ != nullptr) && (audioBuffer->buf != nullptr) && (type == OH_ALL_PLAYBACK)) { + int32_t ret = fwrite(audioBuffer->buf, 1, audioBuffer->size, innerFile_); + free(audioBuffer->buf); + audioBuffer->buf = nullptr; + } + free(audioBuffer); + audioBuffer = nullptr; + } + // do something + OH_AVScreenCapture_ReleaseAudioBuffer(screenCapture, type); + } else { + OH_LOG_INFO(LOG_APP, "AcquireAudioBuffer failed"); + } +} + +// 调用老接口,仅提供代码实现,不建议使用 +void MockOnVideoBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady) +{ + if (isReady == true) { + int32_t fence = 0; + int64_t timestamp = 0; + int32_t size = 4; + OH_Rect damage; + OH_NativeBuffer_Config config; + OH_NativeBuffer *nativeBuffer = + OH_AVScreenCapture_AcquireVideoBuffer(screenCapture, &fence, ×tamp, &damage); + if (nativeBuffer != nullptr) { + OH_NativeBuffer_GetConfig(nativeBuffer, &config); + int32_t length = config.height * config.width * size; + OH_NativeBuffer_Unreference(nativeBuffer); + } else { + OH_LOG_INFO(LOG_APP, "AcquireVideoBuffer failed"); + } + // do something + OH_AVScreenCapture_ReleaseVideoBuffer(screenCapture); + } +} + +// 调用老接口,仅提供代码实现,不建议使用 +void MockOnError(OH_AVScreenCapture *screenCapture, int32_t errorCode) +{ + // 错误处理 +} + +// 调用老接口,仅提供代码实现,不建议使用 +void SetScreenCaptureCallback() +{ + struct OH_AVScreenCaptureCallback callback; + callback.onAudioBufferAvailable = MockOnAudioBufferAvailable; + callback.onVideoBufferAvailable = MockOnVideoBufferAvailable; + callback.onError = MockOnError; + OH_AVScreenCapture_SetCallback(g_avCapture, callback); +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + {"startScreenCapture", nullptr, StartScreenCapture_01, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"stopScreenCapture", nullptr, StopScreenCapture, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"startCaptureAsFile", nullptr, StartScreenCapture_02, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"startScreenCaptureWithSurface", nullptr, StartScreenCapture_03, nullptr, nullptr, nullptr, napi_default, + nullptr}, + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0}, +}; + +extern "C" __attribute__((constructor)) void RegisterScreencaptureModule(void) { napi_module_register(&demoModule); } diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.cpp b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28df10fbd9eec9092bdeeb72899defb825583140 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sample_callback.h" +#include "hilog/log.h" + +namespace { +constexpr int LIMIT_LOGD_FREQUENCY = 50; +} + +// 设置 OnError 回调函数 +void SampleCallback::OnError(OH_AVCodec *codec, int32_t errorCode, void *userData) { + // 回调的错误码由用户判断处理 + (void)codec; + (void)errorCode; + (void)userData; + OH_LOG_ERROR(LOG_APP, "On error, error code: %{public}d", errorCode); +} + +// 设置 OnStreamChanged 回调函数 +void SampleCallback::OnStreamChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData) { +// surface模式下,该回调函数无作用 + (void)codec; + (void)format; + (void)userData; +} + +// 设置 OH_AVCodecOnNeedInputBuffer 回调函数,编码输入帧送入数据队列 +void SampleCallback::OnNeedInputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData) { +// surface模式下,该回调函数无作用,用户通过获取的surface输入数据 + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== Video OnNeedInputBuffer"); + (void)userData; + (void)index; + (void)buffer; + if (userData == nullptr) { + return; + } + (void)codec; + CodecUserData *codecUserData = static_cast(userData); + std::unique_lock lock(codecUserData->inputMutex_); + codecUserData->inputBufferInfoQueue_.emplace(index, buffer); + codecUserData->inputCond_.notify_all(); +} + +// 设置 OH_AVCodecOnNewOutputBuffer 回调函数,编码完成帧送入输出队列 +void SampleCallback::OnNewOutputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData) { + // 完成帧buffer对应的index,送入outIndexQueue队列 + // 完成帧的数据buffer送入outBufferQueue队列 + // 数据处理,请参考: + // - 释放编码帧 + OH_LOG_INFO(LOG_APP, "==ScreenCaptureSample== Video OnNewOutputBuffer"); + if (userData == nullptr) { + return; + } + (void)codec; + CodecUserData *codecUserData = static_cast(userData); + std::unique_lock lock(codecUserData->outputMutex_); + codecUserData->outputBufferInfoQueue_.emplace(index, buffer); + codecUserData->outputCond_.notify_all(); +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.h b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..2b6be13ee1c0caf12e124c2a9131c80efa26e870 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_callback.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVCODEC_SAMPLE_CALLBACK_H +#define AVCODEC_SAMPLE_CALLBACK_H +#define LOG_DOMAIN 0x3200 +#define LOG_TAG "MY_SCNDKDEMO" + +#include "sample_info.h" +#include +class SampleCallback { +public: + SampleCallback() {} + SampleCallback(SampleCallback *p1) {} + static void OnError(OH_AVCodec *codec, int32_t errorCode, void *userData); + static void OnStreamChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData); + static void OnNeedInputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData); + static void OnNewOutputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData); + + OH_AVMuxer *muxer_ = nullptr; + int32_t g_videoTrackId = -1; +}; + +#endif //AVCODEC_SAMPLE_CALLBACK_H diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_info.h b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_info.h new file mode 100644 index 0000000000000000000000000000000000000000..9f7726786a4658be8cccec7b60af95f9b1beda6e --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/sample_info.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVCODEC_SAMPLE_INFO_H +#define AVCODEC_SAMPLE_INFO_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ANNEXB_INPUT_ONLY 1 + +const std::string_view MIME_VIDEO_AVC = "video/avc"; +const std::string_view MIME_VIDEO_HEVC = "video/hevc"; + +constexpr int32_t BITRATE_10M = 10 * 1024 * 1024; // 10Mbps +constexpr int32_t BITRATE_20M = 20 * 1024 * 1024; // 20Mbps +constexpr int32_t BITRATE_30M = 30 * 1024 * 1024; // 30Mbps + +struct SampleInfo { + int32_t sampleId = 0; + + int32_t inputFd = -1; + int32_t outFd = -1; + int64_t inputFileOffset = 0; + int64_t inputFileSize = 0; + std::string inputFilePath; + std::string outputFilePath; + std::string videoCodecMime = ""; + std::string audioCodecMime = ""; + std::string codecMime = MIME_VIDEO_AVC.data(); + int32_t videoWidth = 0; + int32_t videoHeight = 0; + double frameRate = 0.0; + int64_t bitrate = 10 * 1024 * 1024; // 10Mbps; + int64_t frameInterval = 0; + int32_t perfmode = 0; + int64_t durationTime = 0; + uint32_t maxFrames = UINT32_MAX; + int32_t isHDRVivid = 0; + uint32_t repeatTimes = 1; + OH_AVPixelFormat pixelFormat = AV_PIXEL_FORMAT_NV12; + bool needDumpOutput = false; + uint32_t bitrateMode = CBR; + int32_t hevcProfile = HEVC_PROFILE_MAIN; + int32_t rotation = 0; + OHNativeWindow *window = nullptr; + + int32_t sampleRate = 44100; + int32_t channelCount = 2; + + uint32_t bufferSize = 0; + double readTime = 0; + double memcpyTime = 0; + double writeTime = 0; + void (*PlayDoneCallback)(void *context) = nullptr; + void *playDoneCallbackData = nullptr; +}; + +struct CodecBufferInfo { + uint32_t bufferIndex = 0; + uintptr_t *buffer = nullptr; + uint8_t *bufferAddr = nullptr; + OH_AVCodecBufferAttr attr = {0, 0, 0, AVCODEC_BUFFER_FLAGS_NONE}; + + CodecBufferInfo(uint8_t *addr) : bufferAddr(addr){}; + CodecBufferInfo(uint8_t *addr, int32_t bufferSize) + : bufferAddr(addr), attr({0, bufferSize, 0, AVCODEC_BUFFER_FLAGS_NONE}){}; + CodecBufferInfo(uint32_t argBufferIndex, OH_AVMemory *argBuffer, OH_AVCodecBufferAttr argAttr) + : bufferIndex(argBufferIndex), buffer(reinterpret_cast(argBuffer)), attr(argAttr){}; + CodecBufferInfo(uint32_t argBufferIndex, OH_AVMemory *argBuffer) + : bufferIndex(argBufferIndex), buffer(reinterpret_cast(argBuffer)){}; + CodecBufferInfo(uint32_t argBufferIndex, OH_AVBuffer *argBuffer) + : bufferIndex(argBufferIndex), buffer(reinterpret_cast(argBuffer)) { + OH_AVBuffer_GetBufferAttr(argBuffer, &attr); + }; +}; + +class AEncBufferSignal { +public: + std::mutex inMutex_; + std::mutex outMutex_; + std::mutex startMutex_; + std::condition_variable inCond_; + std::condition_variable outCond_; + std::condition_variable startCond_; + std::queue inQueue_; + std::queue outQueue_; + std::queue inBufferQueue_; + std::queue outBufferQueue_; + OH_AVCodecBufferAttr audioInfo = {0, 0, 0, AVCODEC_BUFFER_FLAGS_NONE}; +}; + +class CodecUserData { +public: + SampleInfo *sampleInfo = nullptr; + + uint32_t inputFrameCount_ = 0; + std::mutex inputMutex_; + std::condition_variable inputCond_; + std::queue inputBufferInfoQueue_; + + uint32_t outputFrameCount_ = 0; + std::mutex outputMutex_; + std::condition_variable outputCond_; + std::queue outputBufferInfoQueue_; + + void ClearQueue() { + { + std::unique_lock lock(inputMutex_); + auto emptyQueue = std::queue(); + inputBufferInfoQueue_.swap(emptyQueue); + } + { + std::unique_lock lock(outputMutex_); + auto emptyQueue = std::queue(); + outputBufferInfoQueue_.swap(emptyQueue); + } + } +}; + +#endif // AVCODEC_SAMPLE_INFO_H \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/Index.d.ts b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6f4abe9e642cb35006c2e81467cc29c7418a670 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const startScreenCapture: () => number; +export const stopScreenCapture: () => number; +export const startCaptureAsFile: () => number; +export const startScreenCaptureWithSurface: () => number; diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..94c65b96ba958e7df3ae5adb13ab7033b8e4f850 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import common from '@ohos.app.ability.common'; +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; +import { BusinessError } from '@ohos.base'; + +const DOMAIN = 0x0000; + +const permissions: Array = [ + 'ohos.permission.MICROPHONE', + 'ohos.permission.KEEP_BACKGROUND_RUNNING', + 'ohos.permission.WRITE_MEDIA', +]; + +function reqPermissionsFromUser(permissions: Array, context: common.UIAbilityContext): void { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + atManager.requestPermissionsFromUser(context, permissions).then((data) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + return; + } + } + // 授权成功 + }).catch((err: BusinessError) => { + console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); + }) +} + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + reqPermissionsFromUser(permissions, this.context); + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbe0919d380f721d010ca9b262273b3f495760c8 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,99 @@ +import {Scene1} from './Scene1'; +import {Scene2} from './Scene2'; +import {Scene3} from './Scene3'; +import {Scene4} from './Scene4'; + +class DividerTmp { + strokeWidth: Length = 1 + startMargin: Length = 60 + endMargin: Length = 10 + color: ResourceColor = '#ffe9f0f0' + + constructor(strokeWidth: Length, startMargin: Length, endMargin: Length, color: ResourceColor) { + this.strokeWidth = strokeWidth + this.startMargin = startMargin + this.endMargin = endMargin + this.color = color + } +} + +@Entry({ routeName : 'Index' }) +@Component +struct Index { + @Provide('NavPathStack') pageInfos: NavPathStack = new NavPathStack() + @State egDivider: DividerTmp = new DividerTmp(1, 60, 10, '#ffe9f0f0') + + @Builder + PagesMap(name: string) { + if (name == 'Scene1') { + Scene1() + } else if (name == 'Scene2') { + Scene2() + } else if (name == 'Scene3') { + Scene3() + } else if (name == 'Scene4') { + Scene4() + } + } + + build() { + Column({ space: 15 }) { + + Navigation(this.pageInfos) { + List({ space: 12 }) { + ListItem() { + Text($r('app.string.sample_label')) + .fontSize(18) + } + ListItem() { + Text($r('app.string.saving_file_desc')) + .fontSize(20) + } + ListItem() { + Button($r('app.string.saving_file_desc')) + .width('80%') + .onClick(() => { + this.pageInfos.pushPathByName('Scene1', ''); + }) + } + ListItem() { + Button($r('app.string.js_saving_file_desc')) + .width('80%') + .onClick(() => { + this.pageInfos.pushPathByName('Scene4', ''); + }) + } + ListItem() { + Text($r('app.string.streaming_desc')) + .fontSize(20) + } + ListItem() { + Button($r('app.string.streaming_desc'),{ type: ButtonType.Capsule, stateEffect: true }) + .width('80%') + .onClick(() => { + this.pageInfos.pushPathByName('Scene2', ''); + }) + } + ListItem() { + Button($r('app.string.streaming_surface_mode_desc')) + .width('80%') + .onClick(() => { + this.pageInfos.pushPathByName('Scene3', ''); + }) + } + } + .width('100%') + .margin({ top: 12 }) + .alignListItem(ListItemAlign.Center) + .divider(this.egDivider) + + } + .mode(NavigationMode.Stack) + .title($r('app.string.sample_label')) + .titleMode(NavigationTitleMode.Full) + .navDestination(this.PagesMap) + + } + .height('100%') + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Menu.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Menu.ets new file mode 100644 index 0000000000000000000000000000000000000000..2151e9c0572131227218807d72408d6718c0a857 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Menu.ets @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@ohos.router'; + +@Component +export struct MenuSCComponent { + @State select: boolean = true + @Builder + MyMenu(){ + Menu() { + MenuItemGroup({ header: $r('app.string.list_desc') }) { + MenuItem({ content: $r('app.string.index_desc') }) + .onChange((selected) => { + console.info('menuItem select' + selected); + router.pushUrl({ + url: 'pages/Index' // 目标url + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Invoke pushUrl succeeded.'); + }); + }) + + MenuItem({ content: $r('app.string.saving_file_desc') }) + .onChange((selected) => { + router.pushUrl({ + url: 'pages/Scene1' // 目标url + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Invoke pushUrl succeeded.'); + }); + }) + + MenuItem({ content: $r('app.string.streaming_desc') }) + .onChange((selected) => { + router.pushUrl({ + url: 'pages/Scene2' // 目标url + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Invoke pushUrl succeeded.'); + }); + }) + + MenuItem({ content: $r('app.string.streaming_surface_mode_desc')}) + .onChange((selected) => { + router.pushUrl({ + url: 'pages/Scene3' // 目标url + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Invoke pushUrl succeeded.'); + }); + }) + + MenuItem({ content: $r('app.string.js_saving_file_desc')}) + .onChange((selected) => { + router.pushUrl({ + url: 'pages/Scene4' // 目标url + }, router.RouterMode.Single, (err) => { + if (err) { + console.error(`Invoke pushUrl failed, code is ${err.code}, message is ${err.message}`); + return; + } + console.info('Invoke pushUrl succeeded.'); + }); + }) + } + } + } + + build() { + Button($r('app.string.choose_mode_desc'), { type: ButtonType.Capsule, stateEffect: true }) + .fontSize(25) + .backgroundColor(0x317aff) + .fontWeight(800) + .bindMenu(this.MyMenu) + } + } \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene1.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene1.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d93162c36f3c5c6af2644764c6c650cdb66a61f --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene1.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry({ routeName : 'Scene1' }) +@Component +export struct Scene1 { + @State isCapturing: boolean = false; + @Consume('pageInfos') pageInfos: NavPathStack; + + build() { + NavDestination() { + Column({ space: 15 }) { + Column() { + Text($r('app.string.saving_file_desc')) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('20%') + Column() { + List({ space: 40 }) { + ListItem() { + Button($r('app.string.start_desc'), { type: ButtonType.Circle, stateEffect: true }) + .backgroundColor(0xF55A42) + .width(90) + .height(90) + .onClick(() => { + if (testNapi.startCaptureAsFile() == 0) { + this.isCapturing = true; + } + }) + } + ListItem() { + Button($r('app.string.stop_desc'), { type: ButtonType.Normal, stateEffect: true }) + .backgroundColor(0x000000) + .width(85) + .height(85) + .shadow({ radius: 10 }) + .onClick(() => { + if (this.isCapturing) { + testNapi.stopScreenCapture(); + this.isCapturing = false; + } + }) + } + }.listDirection(Axis.Horizontal).lanes({ minLength: 200, maxLength: 300 }) + } + .width('100%') + .height('20%') + + Column() { + } + .width('100%') + .height('20%') + } + .width('100%') + } + .title($r('app.string.saving_file_desc')) + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene2.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene2.ets new file mode 100644 index 0000000000000000000000000000000000000000..16e5b0d412496ac84f5de61c566b2b52fb427594 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene2.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry({ routeName : 'Scene2' }) +@Component +export struct Scene2 { + @State isCapturing: boolean = false; + @Consume('pageInfos') pageInfos: NavPathStack; + + build() { + NavDestination() { + + Column({ space: 15 }) { + Column() { + Text($r('app.string.streaming_desc')) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('20%') + Column() { + List({ space: 40 }) { + ListItem() { + Button($r('app.string.start_desc'), { type: ButtonType.Circle, stateEffect: true }) + .backgroundColor(0xF55A42) + .width(90) + .height(90) + .onClick(() => { + if (testNapi.startScreenCapture() == 0) { + this.isCapturing = true; + } + }) + } + ListItem() { + Button($r('app.string.stop_desc'), { type: ButtonType.Normal, stateEffect: true }) + .backgroundColor(0x000000) + .width(85) + .height(85) + .shadow({ radius: 10 }) + .onClick(() => { + if (this.isCapturing) { + testNapi.stopScreenCapture(); + this.isCapturing = false; + } + }) + } + }.listDirection(Axis.Horizontal).lanes({ minLength: 200, maxLength: 300 }) + } + .width('100%') + .height('20%') + + Column() { + } + .width('100%') + .height('20%') + } + .width('100%') + } + .title($r('app.string.streaming_desc')) + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene3.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene3.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bc43d97fb18957357050872353fb9b1725943e3 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene3.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import testNapi from 'libentry.so'; + +@Entry({ routeName : 'Scene3' }) +@Component +export struct Scene3 { + @State isCapturing: boolean = false; + @Consume('pageInfos') pageInfos: NavPathStack; + + build() { + NavDestination() { + + Column({ space: 15 }) { + Column() { + Text($r('app.string.streaming_surface_mode_desc')) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('20%') + Column() { + List({ space: 40 }) { + ListItem() { + Button($r('app.string.start_desc'), { type: ButtonType.Circle, stateEffect: true }) + .backgroundColor(0xF55A42) + .width(90) + .height(90) + .onClick(() => { + if (testNapi.startScreenCaptureWithSurface() == 0) { + this.isCapturing = true; + } + }) + } + ListItem() { + Button($r('app.string.stop_desc'), { type: ButtonType.Normal, stateEffect: true }) + .backgroundColor(0x000000) + .width(85) + .height(85) + .shadow({ radius: 10 }) + .onClick(() => { + if (this.isCapturing) { + testNapi.stopScreenCapture(); + this.isCapturing = false; + } + }) + } + }.listDirection(Axis.Horizontal).lanes({ minLength: 200, maxLength: 300 }) + } + .width('100%') + .height('20%') + + Column() { + } + .width('100%') + .height('20%') + } + .width('100%') + } + .title($r('app.string.streaming_surface_mode_desc')) + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene4.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene4.ets new file mode 100644 index 0000000000000000000000000000000000000000..be6c6ce618bb8fcc6bddf8454cdcf9324c361aff --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/ets/pages/Scene4.ets @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BusinessError } from '@ohos.base'; +import { media } from '@kit.MediaKit'; +import fs from '@ohos.file.fs'; +import { deviceInfo } from '@kit.BasicServicesKit'; +import { display } from '@kit.ArkUI'; + +@Component +export struct Scene4 { + @Consume('pageInfos') pageInfos: NavPathStack; + private lastSaveTime: string = ''; + private saveIndex: number = 0; + private outputFd: number | null = null; + private avScreenCaptureRecorder?: media.AVScreenCaptureRecorder; + private displayId:number = 0; + private isStarted: boolean = false; + private filepathSC: string = ''; + @State text: string = 'PRESERVE_ASPECT_RATIO' + private displayWidth: number = 0; + private displayHeight: number = 0; + + private initDeviceResolution(): void { + try { + let currentDisplay: display.Display = + this.displayId? display.getDisplayByIdSync(this.displayId as number): display.getDefaultDisplaySync(); + this.displayWidth = currentDisplay.width; + this.displayHeight = currentDisplay.height; + console.info('ScreenCaptureSample displayWidth: ' + this.displayWidth + ', displayHeight: ' + this.displayHeight); + } catch (err) { + console.error('ScreenCaptureSample initDeviceResolution failed, code is ${err.code}, message is ${err.message}'); + } + } + checkName(name: string): string { + if (this.lastSaveTime == name) { + this.saveIndex += 1; + return `${name}_${this.saveIndex}` + } + this.lastSaveTime = name; + this.saveIndex = 0; + return name; + } + + StopRecording() { + if (!this.avScreenCaptureRecorder) { + return; + } + this.avScreenCaptureRecorder?.stopRecording(); + if (this.outputFd != undefined && this.outputFd?.valueOf() > 0) { + fs.close(this.outputFd); + } + this.avScreenCaptureRecorder?.release(); + this.isStarted = false; + this.outputFd = -1; + } + + async createVideoFd(): Promise { + console.info('==ScreenCaptureSample== the value of the deviceType in'); + let deviceTypeInfo: string = deviceInfo.deviceType; + console.info('==ScreenCaptureSample== the value of the deviceType is :' + deviceTypeInfo); + + const displayName = 'js_saving_file.mp4'; + let videoFd: number = 0; + console.info('==ScreenCaptureSample== the value of the deviceType in'); + this.filepathSC = '/data/storage/el2/base/files/' + displayName; + await fs.open(this.filepathSC, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE).then((file) => { + videoFd = file.fd; + console.info('==ScreenCaptureSample== the value of the deviceType in'); + }).catch((err: BusinessError) => { + fs.unlinkSync(this.filepathSC); + console.error('open file failed, code is ${err.code}, message is ${err.message}'); + }) + console.info('==ScreenCaptureSample== the value of the deviceType in'); + console.info('==ScreenCaptureSample== createVideoFd videoFd: ' + videoFd); + return videoFd; + } + + async StartRecording(): Promise { + if (this.isStarted === true) { + console.info('==ScreenCaptureSample== isStarted: ' + this.outputFd); + return; + } + this.outputFd = await this.createVideoFd() + console.info('==ScreenCaptureSample== outputFd: ' + this.outputFd); + if (this.outputFd != 0) { + console.info('selectOutputFilePath outputFd: ' + this.outputFd ); + this.initDeviceResolution(); + let avCaptureConfig: media.AVScreenCaptureRecordConfig = { + fd: this.outputFd, + frameWidth: this.displayWidth, + frameHeight: this.displayHeight, + videoBitrate: 10000000, + audioSampleRate: 48000, + audioChannelCount: 2, + audioBitrate: 96001, + displayId: this.displayId, + preset: media.AVScreenCaptureRecordPreset.SCREEN_RECORD_PRESET_H264_AAC_MP4, + }; + this.avScreenCaptureRecorder = await media.createAVScreenCaptureRecorder(); + await this.avScreenCaptureRecorder.init(avCaptureConfig).then(() => { + console.info('==ScreenCaptureSample== Succeeded in init avScreenCaptureRecorder'); + }).catch((err: BusinessError) => { + fs.unlinkSync(this.filepathSC); + console.error('==ScreenCaptureSample== Failed to init avScreenCaptureRecorder, code is ${err.code},' + + 'message is ${err.message}'); + }) + + this.avScreenCaptureRecorder.setMicEnabled(true).then(() => { + console.info('==ScreenCaptureSample== Succeeded in setMicEnabled avScreenCaptureRecorder'); + }).catch((err: BusinessError) => { + console.error('==ScreenCaptureSample== Failed to setMicEnabled avScreenCaptureRecorder, code is ${err.code},' + + 'message is ${err.message}'); + }) + + this.avScreenCaptureRecorder.on('error', (err: BusinessError) => { + console.error('==ScreenCaptureSample== avScreenCaptureRecorder stateChange to:' + err.message); + fs.unlinkSync(this.filepathSC); + }) + + this.avScreenCaptureRecorder!.on('stateChange', async (state: media.AVScreenCaptureStateCode) => { + console.info('==ScreenCaptureSample== 2 avScreenCaptureRecorder stateChange to ' + state); + switch (state) { + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_STARTED: + console.info('==ScreenCaptureSample== screen capture started'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_CANCELED: + this.avScreenCaptureRecorder?.release(); + this.avScreenCaptureRecorder = undefined; + console.info('==ScreenCaptureSample== delete filepathSC uri: ' + this.filepathSC); + fs.unlinkSync(this.filepathSC); + console.info('==ScreenCaptureSample== screen capture canceled'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_STOPPED_BY_USER: + this.avScreenCaptureRecorder?.stopRecording(); + this.avScreenCaptureRecorder?.release(); + this.avScreenCaptureRecorder = undefined; + console.info('==ScreenCaptureSample== screen capture stopped by user'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_INTERRUPTED_BY_OTHER: + console.info('==ScreenCaptureSample== screen capture stopped by other'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_STOPPED_BY_CALL: + console.info('==ScreenCaptureSample== screen capture stopped by call'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_MIC_UNAVAILABLE: + console.info('==ScreenCaptureSample== screen capture mic unavailable'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_MIC_MUTED_BY_USER: + console.info('==ScreenCaptureSample== screen capture mic muted by user'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_MIC_UNMUTED_BY_USER: + console.info('==ScreenCaptureSample== screen capture mic unmuted by user'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_ENTER_PRIVATE_SCENE: + console.info('==ScreenCaptureSample== screen capture enter private scene'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_EXIT_PRIVATE_SCENE: + console.info('==ScreenCaptureSample== screen capture exit private scene'); + break; + case media.AVScreenCaptureStateCode.SCREENCAPTURE_STATE_STOPPED_BY_USER_SWITCHES: + console.info('==ScreenCaptureSample== screen capture stopped by user switches'); + break; + default: + break; + } + }) + await this.avScreenCaptureRecorder?.startRecording().then(() => { + console.info('==ScreenCaptureSample== Succeeded in starting avScreenCaptureRecorder'); + this.isStarted = true; + }).catch((err: BusinessError) => { + console.error('==ScreenCaptureSample== Failed to start avScreenCaptureRecorder, code is ${err.code}, message is ${err.message}'); + }) + + } + } + + build() { + NavDestination() { + Column({ space: 15 }) { + Column() { + Text($r('app.string.js_saving_file_desc')) + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('20%') + + Column() { + List({ space: 40 }) { + ListItem() { + Button($r('app.string.start_desc'), { type: ButtonType.Circle, stateEffect: true }) + .id(getContext().resourceManager.getStringSync($r('app.string.start_desc'))) + .backgroundColor(0xF55A42) + .width(90) + .height(90) + .onClick(() => { + this.StopRecording(); + this.StartRecording() + }) + } + ListItem() { + Button($r('app.string.stop_desc'), { type: ButtonType.Normal, stateEffect: true }) + .id(getContext().resourceManager.getStringSync($r('app.string.stop_desc'))) + .backgroundColor(0x000000) + .width(85) + .height(85) + .shadow({ radius: 10 }) + .onClick(() => { + this.StopRecording(); + }) + } + }.listDirection(Axis.Horizontal).lanes({ minLength: 200, maxLength: 300 }) + } + .width('100%') + .height('20%') + + Text($r('app.string.display_id_desc')) + TextInput({ + text:'0' + }).onChange((value)=>{ + console.info('==ScreenCaptureSample== displayId:' + value); + this.displayId = parseInt(value); + }) + } + .width('100%') + } + .title($r('app.string.js_saving_file_desc')) + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/module.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0d035f4eaa6adcb091a1f5cef72599feae869e20 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/module.json5 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + + "requestPermissions": [ + { + "name": "ohos.permission.MICROPHONE", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "$string:EntryAbility_desc", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..330b8321a773cc6dffa6c6959772b1021eaa135d --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "录屏Sample" + }, + { + "name": "sample_label", + "value": "AVScreenCapture录屏Sample" + }, + { + "name": "saving_file_desc", + "value": "录屏存文件" + }, + { + "name": "streaming_desc", + "value": "录屏取码流" + }, + { + "name": "streaming_surface_mode_desc", + "value": "录屏取码流Surface模式" + }, + { + "name": "list_desc", + "value": "录屏场景列表" + }, + { + "name": "index_desc", + "value": "主页" + }, + { + "name": "other_mode_desc", + "value": "其他场景" + }, + { + "name": "choose_mode_desc", + "value": "选择录屏场景" + }, + { + "name": "start_desc", + "value": "Start" + }, + { + "name": "stop_desc", + "value": "Stop" + }, + { + "name": "saving_file_eng_desc", + "value": "Saving File" + }, + { + "name": "streaming_eng_desc", + "value": "Original Stream" + }, + { + "name": "streaming_surface_mode_eng_desc", + "value": "Original Stream With Surface" + }, + { + "name": "all_mode_desc", + "value": "全量" + }, + { + "name": "js_saving_file_desc", + "value": "js-录屏存文件" + }, + { + "name": "display_id_desc", + "value": "Display Id" + }, + { + "name": "allow_desc", + "value": "允许" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/Libentry.mock.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..eebf1ed910f6a8f2a9e7e565aa71b179b7b8b537 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2c7d2ba82b796a2850ced0a277d261d7d7355416 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/mock/mock-config.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6756d456e14a632688d863ab85339126bad92bcd --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import Base from '@ohos.base'; +import { Driver, ON } from '@ohos.UiTest'; +import fs from '@ohos.file.fs'; + +const TAG = 'abilityTest'; +const domain: number = 0x0000; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, async () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let want: Want = { + bundleName: 'com.sample.screencapturesample', + abilityName: 'EntryAbility' + }; + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + abilityDelegator.startAbility(want, (err: Base.BusinessError) => { + hilog.info(domain, TAG, 'StartAbility get err ' + JSON.stringify(err)); + expect(err).assertNull(); + }) + let driver = await Driver.create(); + await driver.delayMs(2000); + let allowBtn1 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.allow_desc')))); + await allowBtn1.click(); + let allowBtn2 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.allow_desc')))); + await allowBtn2.click(); + let btn3 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.js_saving_file_desc')))); + await btn3.click(); + let btn4 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.start_desc')))); + await btn4.click(); + await driver.delayMs(2000); + let allowBtn3 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.allow_desc')))); + await allowBtn3.click(); + await driver.delayMs(5000); + let btn5 = await driver.findComponent(ON.text(getContext().resourceManager.getStringSync($r('app.string.stop_desc')))); + await btn5.click(); + let files: string[] = fs.listFileSync('/data/storage/el2/base/files/'); + expect(files).assertContain('js_saving_file.mp4'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/List.test.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigor/hvigor-config.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigorfile.ts b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/oh-package.json5 b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3cd48480d047d47a1f7977cf549e698ee013edbc --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/ohosTest.md b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..cf80279843f81ae436eb2295e3b1475713081219 --- /dev/null +++ b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/ohosTest.md @@ -0,0 +1,11 @@ +# ScreenCaptureSample测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|----------------|-----------|---------------------------------------------------------|---------------------------|------|------| +| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 否 | Pass | +| 录屏存文件功能 | 进入示例应用 | 1. 点击“录屏存文件”按钮
2. 点击Start
3. 一段时间后点击Stop | 生成录屏文件 | 否 | Pass | +| 录屏取码流功能 | 进入示例应用 | 1. 点击“录屏取码流”按钮
2. 点击Start
3. 一段时间后点击Stop | 生成录屏码流文件、麦克风音频文件和设备内录音频文件 | 否 | Pass | +| 录屏取码流Surface模式 | 进入示例应用 | 1. 点击“录屏取码流Surface模式”按钮
2. 点击Start
3. 一段时间后点击Stop | 生成录屏文件 | 否 | Pass | +| js接口录屏存文件功能 | 设备正常运行 | 运行ohosTest中的assertContain用例 | 用例执行通过,生成录屏文件 | 是 | Pass | diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic1.jpg b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0f81da1361eb0a4ab40b23c15a0c8953fc2eb099 Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic1.jpg differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic2.jpg b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b0be059b6ab1b7a647d4641aeebf48e397c74dc7 Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic2.jpg differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic3.jpg b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..635ff4f70f818a2441d17a3fcdc02c0989147e8d Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic3.jpg differ diff --git a/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic4.jpg b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..330f8bc6e522d31a3a2aca747b7583386e9a7416 Binary files /dev/null and b/code/DocsSample/Media/ScreenCapture/ScreenCaptureSample/pic4.jpg differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/.gitignore b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/app.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..bba3859a5fcd7a2ea9516a2df28b5be0f4f80aef --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.SoundPoolArkTS", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/element/string.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a26e4e7f8e4b46f82159367f43ab3edadf5949fc --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "SoundPoolArkTS" + } + ] +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/background.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/foreground.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/layered_image.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/README.md b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/README.md new file mode 100644 index 0000000000000000000000000000000000000000..fb41c663e1b9887565d546e25d4de68dda73320f --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/README.md @@ -0,0 +1,69 @@ +# SoundPoolArkTS + +## 介绍 + +本示例为媒体->Media Kit(媒体服务)->[使用SoundPool播放短音频(ArkTS)](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/using-soundpool-for-playback.md)的配套示例工程。 + +本示例展示了如何使用SoundPool进行低时延播放。 + +## 效果预览 + +| 预览 | +| -------------------------------------------- | + + + +## 使用说明 +1. 安装编译生成的hap包,并打开应用; +2. 点击播放RawFile按钮,进行低时延播放; + +## 工程目录 + +``` +SoundPoolArkTS +entry/src/main/ets/ +└── pages + └── Index.ets (播放界面) +entry/src/main/resources/ +├── base +│ ├── element +│ │ ├── color.json +│ │ ├── float.json +│ │ └── string.json +│ └── media +│ +└── rawfile + └── test.ogg (音频资源) +entry/src/ohosTest/ets/ +└── test + ├── Ability.test.ets (UI测试代码) + └── List.test.ets (测试套件列表) +``` + +## 相关权限 + +不涉及 + +## 依赖 + +不涉及 + +## 约束和限制 + +1. 本示例支持标准系统上运行,支持设备:RK3568; + +2. 本示例支持API20版本SDK,版本号:6.0.0.34; + +3. 本示例已支持使DevEco Studio 5.0.3 Release (构建版本:5.0.9.300,构建 2025年3月13日)编译运行 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Media/SoundPool/SoundPoolArkTS/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/build-profile.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5a2b572d947cd6f7dfba85072fb0313ca83f317c --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 20, + "targetSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "OpenHarmony", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/.gitignore b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/build-profile.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/hvigorfile.ts b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/obfuscation-rules.txt b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/oh-package.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..10cda399b0aec3099b257299a57d284393e4e55a --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3ee54d2beea61d38866762868bd056d3e39e3c9 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f97cb00716ca997bc1013fbee82c56871ce947e --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { media } from '@kit.MediaKit'; +import { audio } from '@kit.AudioKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + private soundPool: media.SoundPool | undefined = undefined; + private soundId: number = 0; + private streamId: number = 0; + + async aboutToAppear(): Promise { + this.create(); + } + + async aboutToDisappear() { + this.release(); + } + + build() { + RelativeContainer() { + Row() { + Button($r('app.string.playSoundPool')) + .width(100) + .height(100) + .onClick(() => { + this.PlaySoundPool() + }) + .id('playSoundPoolButton') + .type(ButtonType.Circle) + }.alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } + + async create() { + try { + // audioRenderInfo中的参数usage取值为STREAM_USAGE_UNKNOWN,STREAM_USAGE_MUSIC,STREAM_USAGE_MOVIE。 + // STREAM_USAGE_AUDIOBOOK时,SoundPool播放短音时为混音模式,不会打断其他音频播放。 + let audioRendererInfo: audio.AudioRendererInfo = { + usage: audio.StreamUsage.STREAM_USAGE_MUSIC, // 音频流使用类型:音乐。根据业务场景配置,参考StreamUsage。 + rendererFlags: 1 // 音频渲染器标志。 + } + //创建soundPool实例。 + this.soundPool = await media.createSoundPool(14,audioRendererInfo); + //注册监听。 + this.loadCallback(); + this.finishPlayCallback(); + this.setErrorCallback(); + + // 加载音频资源。 + let context = this.getUIContext().getHostContext();; + let fileDescriptor = await context!.resourceManager.getRawFd('test.ogg'); + this.soundId = await this.soundPool!.load(fileDescriptor.fd, fileDescriptor.offset, fileDescriptor.length); + console.info(`load soundPool soundId: ${this.soundId}`) + } catch (e) { + console.error('createSoundPool error: ' + e); + } + } + + async loadCallback() { + // 加载完成回调。 + this.soundPool!.on('loadComplete', (soundId_: number) => { + this.soundId = soundId_; + console.info('loadComplete soundId: ' + soundId_); + }) + } + + //设置播放完成监听。 + async finishPlayCallback() { + this.soundPool!.on('playFinished', () => { + console.info('receive play finished message'); + // 可进行下次播放。 + }) + } + //设置错误类型监听。 + async setErrorCallback() { + this.soundPool!.on('error', (error: BusinessError) => { + console.error('error happened,message is :' + error.code); + console.error('error happened,message is :' + error.message); + }) + } + + async PlaySoundPool() { + let playParameters: media.PlayParameters = { + loop: 1, // 循环1次,即播放2次。 + rate: 1, // 1倍速播放。 + leftVolume: 0.5, // 取值范围0.0-1.0。 + rightVolume: 0.5, // 取值范围0.0-1.0。 + priority: 0, // 最低优先级。 + }; + // 开始播放,这边play也可带播放播放的参数PlayParameters,请在音频资源加载完毕,即收到loadComplete回调之后再执行play操作。 + this.soundPool!.play(this.soundId, playParameters, (error, streamID: number) => { + if (error) { + console.error(`play sound Error: errCode is ${error.code}, errMessage is ${error.message}`) + } else { + this.streamId = streamID; + console.info('play success soundid:' + this.streamId); + } + }); + // 设置循环播放次数。 + await this.soundPool!.setLoop(this.streamId, 2); // 播放3次。 + // 设置对应流的优先级。 + await this.soundPool!.setPriority(this.streamId, 1); + // 设置音量。 + await this.soundPool!.setVolume(this.streamId, 0.5, 0.5); + } + + async release() { + // 终止指定流的播放。 + await this.soundPool!.stop(this.streamId); + // 卸载音频资源。 + await this.soundPool!.unload(this.soundId); + //关闭监听。 + this.setOffCallback(); + // 释放SoundPool。 + await this.soundPool!.release(); + } + + + + async setOffCallback() { + this.soundPool!.off('loadComplete'); + this.soundPool!.off('playFinished'); + this.soundPool!.off('error'); + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/module.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9bed6e6fd262f8e7273a9ff5dfdf67d826492b07 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/module.json5 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/color.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/float.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/string.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..023606bd48a81157acfa52d4f92f221535673db2 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "低时延音频播放" + }, + { + "name": "playSoundPool", + "value": "播放RawFile" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/background.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/dark/element/color.json b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/rawfile/test.ogg b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/rawfile/test.ogg new file mode 100644 index 0000000000000000000000000000000000000000..a4bc8b1db0c69505d7771ca9f10db8154c56bbf0 Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/main/resources/rawfile/test.ogg differ diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/mock/mock-config.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4843922017538fb5a2d94bdd587e2a29c96d87fc --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import { Driver, ON } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +export default function abilityTest() { + const TAG = '[Sample_SoundPool]'; + const driver = Driver.create(); + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const bundleName = AbilityDelegatorRegistry.getArguments().bundleName; + + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + + /** + * Test SoundPool play + */ + it('SoundPoolTest_001', 0, async (done: Function) => { + console.info(TAG, 'SoundPoolTest_001 begin'); + try { + await abilityDelegator.startAbility({ + bundleName: bundleName, + abilityName: 'EntryAbility' + }); + } catch (exception) { + expect().assertFail(); + } + await driver.delayMs(1000); + const button = await driver.findComponent(ON.id('playSoundPoolButton')); + await button.click(); + await driver.delayMs(2000); + await button.click(); + await driver.delayMs(2000); + done(); + console.info(TAG, 'SoundPoolTest_001 end'); + }) + }) +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/module.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6b9889e8ccb62f93825d6b26fa53db8e97a974c0 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/List.test.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/LocalUnit.test.ets b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigor/hvigor-config.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2f5b88411d60de67e1d9411dd6c49249aad9dae0 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigor/hvigor-config.json5 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigorfile.ts b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b365cacd0191d3b1178eb6b9807b1ae0add6271 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/oh-package.json5 b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3f6defffff76263f5bc8fffa1be4f07b4343414c --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/oh-package.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "modelVersion": "5.0.3", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/ohosTest.md b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..4086f0ae5985c675089d6aed968cd5653968bce3 --- /dev/null +++ b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/ohosTest.md @@ -0,0 +1,7 @@ +# SoundPoolArkTS测试用例归档 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------- | ------------------ | -------------------- | ---------------------------- | -------- | -------- | +| 拉起应用并播放 | 设备正常运行 | | 成功播放 | 是 | Pass | \ No newline at end of file diff --git a/code/DocsSample/Media/SoundPool/SoundPoolArkTS/screenshots/SoundPoolArkTS.png b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/screenshots/SoundPoolArkTS.png new file mode 100644 index 0000000000000000000000000000000000000000..7c57e2d54a527245a2886be4bb3d2d7436dedc85 Binary files /dev/null and b/code/DocsSample/Media/SoundPool/SoundPoolArkTS/screenshots/SoundPoolArkTS.png differ diff --git a/code/DocsSample/graphic/ArkGraphics2D/ComplexTextDrawing/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/ComplexTextDrawing/entry/src/main/ets/pages/Index.ets index c6375ef3dafd01b7931a6f4bb268893a205fa9ad..6377501e78b474e6351670305f80451646a6756a 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/ComplexTextDrawing/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/ComplexTextDrawing/entry/src/main/ets/pages/Index.ets @@ -326,10 +326,10 @@ struct RenderTest { .shadow(ShadowStyle.OUTER_DEFAULT_LG) } .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .shadow(ShadowStyle.OUTER_DEFAULT_SM) // 设置Row容器外阴影效果 + .alignItems(VerticalAlign.Bottom) // 设置当前Row容器内子元素在交叉轴(垂直方向)上的对齐方式为底部对齐 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } } \ No newline at end of file diff --git a/code/DocsSample/graphic/ArkGraphics2D/CustomFont/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/CustomFont/entry/src/main/ets/pages/Index.ets index 78b39e126b2591501fef0a154d872db73f4dda5d..3b211fb9f1a802e9078bf8536c45d2ede1e7c1d8 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/CustomFont/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/CustomFont/entry/src/main/ets/pages/Index.ets @@ -122,10 +122,10 @@ struct RenderTest { .shadow(ShadowStyle.OUTER_DEFAULT_LG) } .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .shadow(ShadowStyle.OUTER_DEFAULT_SM) // 设置Row容器外阴影效果 + .alignItems(VerticalAlign.Bottom) // 设置当前Row容器内子元素在交叉轴(垂直方向)上的对齐方式为底部对齐 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } } \ No newline at end of file diff --git a/code/DocsSample/graphic/ArkGraphics2D/SimpleTextDrawing/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/SimpleTextDrawing/entry/src/main/ets/pages/Index.ets index 4261a2b9fee42c003cdcfd0aea155d77874ee04e..21bc70a70f91823356bd0140cac45200c15244e0 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/SimpleTextDrawing/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/SimpleTextDrawing/entry/src/main/ets/pages/Index.ets @@ -125,10 +125,10 @@ struct RenderTest { .shadow(ShadowStyle.OUTER_DEFAULT_LG) } .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .shadow(ShadowStyle.OUTER_DEFAULT_SM) // 设置Row容器外阴影效果 + .alignItems(VerticalAlign.Bottom) // 设置当前Row容器内子元素在交叉轴(垂直方向)上的对齐方式为底部对齐 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } } \ No newline at end of file diff --git a/code/DocsSample/graphic/ArkGraphics2D/SystemFontInfoGet/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/SystemFontInfoGet/entry/src/main/ets/pages/Index.ets index ccdfca51a5032286dc55314a34442ef973d325d3..5a12b78f7a7605f52f7fa3ab4fd63920610743b6 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/SystemFontInfoGet/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/SystemFontInfoGet/entry/src/main/ets/pages/Index.ets @@ -146,8 +146,8 @@ struct RenderTest { }.width('100%') } .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .shadow(ShadowStyle.OUTER_DEFAULT_SM) // 设置Row容器外阴影效果 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } \ No newline at end of file diff --git a/code/DocsSample/graphic/ArkGraphics2D/TextMetrics/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/TextMetrics/entry/src/main/ets/pages/Index.ets index 7466ca6243e3e8262f910c97175db6af66a7ca76..56eb942be5bfcaba4804311ad9df004d53c059c4 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/TextMetrics/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/TextMetrics/entry/src/main/ets/pages/Index.ets @@ -155,9 +155,9 @@ struct RenderTest { .height(40) } .width('100%') - .justifyContent(FlexAlign.Center) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .alignItems(VerticalAlign.Bottom) // 设置当前Row容器内子元素在交叉轴(垂直方向)上的对齐方式为底部对齐 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } } \ No newline at end of file diff --git a/code/DocsSample/graphic/ArkGraphics2D/ThemeFont/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/ArkGraphics2D/ThemeFont/entry/src/main/ets/pages/Index.ets index 757a3deb899af877f3640971ea6c1b309af38c73..cd50ae62bf2d0bf7f5992e0639162edbeded4e1a 100644 --- a/code/DocsSample/graphic/ArkGraphics2D/ThemeFont/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/ArkGraphics2D/ThemeFont/entry/src/main/ets/pages/Index.ets @@ -135,10 +135,10 @@ struct RenderTest { .shadow(ShadowStyle.OUTER_DEFAULT_LG) } .width('100%') - .justifyContent(FlexAlign.Center) - .shadow(ShadowStyle.OUTER_DEFAULT_SM) - .alignItems(VerticalAlign.Bottom) - .layoutWeight(1) + .justifyContent(FlexAlign.Center) // 设置当前Row容器内子元素在主轴上居中对齐 + .shadow(ShadowStyle.OUTER_DEFAULT_SM) // 设置Row容器外阴影效果 + .alignItems(VerticalAlign.Bottom) // 设置当前Row容器内子元素在交叉轴(垂直方向)上的对齐方式为底部对齐 + .layoutWeight(1) // 设置当前Row在父容器Column中的布局权重为1 } } } diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/arkgraphic/resource.ets b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/arkgraphic/resource.ets index c06851e8acb2c3d1acad97a9f64fffe8f2d84d75..a7e73caae762657d6a82280fa986719761318bd7 100644 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/arkgraphic/resource.ets +++ b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/arkgraphic/resource.ets @@ -24,103 +24,12 @@ import { SceneResourceFactory, SceneResourceParameters, Shader, - ShaderMaterial + ShaderMaterial, + EnvironmentBackgroundType } from '@kit.ArkGraphics3D'; import { router } from '@kit.ArkUI'; import logger from '../utils/Logger'; -async function createMaterialPromise(): Promise { - try { - logger.info('start to create a new Material.'); - - // Loading scene - const result: Scene = await Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')); - - let sceneFactory: SceneResourceFactory = result.getResourceFactory(); - let sceneMaterialParameter: SceneResourceParameters = { name: 'material' }; - - // Create a material without anything - let material: Material = await sceneFactory.createMaterial(sceneMaterialParameter, MaterialType.SHADER); - - return material; - } catch (error) { - logger.error('Failed to create material: ' + error); - throw new Error('Failed to create material'); - } -} - -async function createShaderPromise(): Promise { - try { - logger.info('start to create a new shader.'); - - let scene: Scene = await Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')); - let sceneFactory: SceneResourceFactory = scene.getResourceFactory(); - - // Create a variable of the SceneResourceParameters type and use it to create a shader. - let sceneResourceParameter: SceneResourceParameters = { - name: 'shaderResource', - uri: $rawfile('shaders/custom_shader/custom_material_sample.shader') - }; - - // Create a material. - let shader: Shader = await sceneFactory.createShader(sceneResourceParameter); - - return shader; - } catch (error) { - logger.error('Failed to create shader: ' + error); - throw new Error('Failed to create shader'); - } -} - -async function createImagePromise(): Promise { - try { - logger.info('start to create a new image.'); - - let scene: Scene = await Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')); - let sceneFactory: SceneResourceFactory = scene.getResourceFactory(); - let sceneImageParameter: SceneResourceParameters = { name: 'image', uri: $rawfile('image/Cube_BaseColor.png') }; - // create image - let image: Image = await sceneFactory.createImage(sceneImageParameter); - - return image; - } catch (error) { - logger.error('Failed to creat image: ' + error); - throw new Error('Failed to create image'); - } -} - -async function createEnvrionmentPromise(): Promise { - try { - logger.info('start to create a new envrionment.'); - - let scene: Scene = await Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')); - let sceneFactory: SceneResourceFactory = scene.getResourceFactory(); - - // create a new environment. - let env: Environment = await sceneFactory.createEnvironment({ - name: 'env', - uri: $rawfile('KTX/quarry_02_2k_radiance.ktx') - }); - - let image: Image = await sceneFactory.createImage({ - name: 'Image', - uri: $rawfile('image/Cube_BaseColor.png') - }); - - env.environmentImage = image; - - env.indirectDiffuseFactor.x = 1; - env.indirectDiffuseFactor.y = 1; - env.indirectDiffuseFactor.z = 1; - env.indirectDiffuseFactor.w = 1; - - return env; - } catch (error) { - logger.error('Failed to creat envrionment: ' + error); - throw new Error('Failed to create envrionment'); - } -} - @Entry @Component struct materialPage { @@ -161,9 +70,99 @@ struct materialPage { this.env = null; } + async createMaterialPromise(): Promise { + try { + logger.info('start to create a new Material.'); + if (!this.rf) { + return null; + } + let sceneMaterialParameter: SceneResourceParameters = { name: 'material' }; + + // Create a material without anything + let material: Material = await this.rf.createMaterial(sceneMaterialParameter, MaterialType.SHADER); + + return material; + } catch (error) { + logger.error('Failed to create material: ' + error); + return null; + } + } + + async createShaderPromise(): Promise { + try { + logger.info('start to create a new shader.'); + if (!this.rf) { + return null; + } + + // Create a variable of the SceneResourceParameters type and use it to create a shader. + let sceneResourceParameter: SceneResourceParameters = { + name: 'shaderResource', + uri: $rawfile('shaders/custom_shader/custom_material_sample.shader') + }; + + // Create a material. + let shader: Shader = await this.rf.createShader(sceneResourceParameter); + + return shader; + } catch (error) { + logger.error('Failed to create shader: ' + error); + return null; + } + } + + async createImagePromise(): Promise { + try { + logger.info('start to create a new image.'); + if (!this.rf) { + return null; + } + let sceneImageParameter: SceneResourceParameters = { name: 'image', uri: $rawfile('image/Cube_BaseColor.png') }; + // create image + let image: Image = await this.rf.createImage(sceneImageParameter); + + return image; + } catch (error) { + logger.error('Failed to create image: ' + error); + return null; + } + } + + async createEnvironmentPromise(): Promise { + try { + logger.info('start to create a new environment.'); + if (!this.rf) { + return null; + } + + // create a new environment. + let env: Environment = await this.rf.createEnvironment({ + name: 'env' + }); + + let image: Image = await this.rf.createImage({ + name: 'Image', + uri: $rawfile('image/Cube_BaseColor.png') + }); + + env.backgroundType = EnvironmentBackgroundType.BACKGROUND_EQUIRECTANGULAR; + env.environmentImage = image; + + env.indirectDiffuseFactor.x = 1; + env.indirectDiffuseFactor.y = 1; + env.indirectDiffuseFactor.z = 1; + env.indirectDiffuseFactor.w = 1; + + return env; + } catch (error) { + logger.error('Failed to create environment: ' + error); + return null; + } + } + init(): void { if (this.scene === null) { - Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')) + Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.glb')) .then(async (result: Scene) => { this.scene = result; this.sceneOpt = { scene: this.scene, modelType: ModelType.SURFACE } as SceneOptions; @@ -173,9 +172,7 @@ struct materialPage { this.cam.position.z = 5; // create a geometry - if (!this.geom) { - this.geom = this.scene.getNodeByPath('rootNode_/Scene/AnimatedCube') as Geometry; - } + this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/AnimatedCube') as Geometry; // record original material this.originalMat = this.geom.mesh.subMeshes[0].material; @@ -207,19 +204,20 @@ struct materialPage { logger.info('Start to replace with a blank material'); if (!this.blankMat) { - this.blankMat = await createMaterialPromise(); + this.blankMat = await this.createMaterialPromise(); } if (!this.scene || !this.rf) { return; } - if (!this.geom) { - this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/Cube') as Geometry; - } + this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/AnimatedCube') as Geometry; this.geom.mesh.materialOverride = undefined; - this.geom.mesh.subMeshes[0].material = this.blankMat; + if (this.blankMat) { + this.geom.mesh.subMeshes[0].material = this.blankMat; + } + }); Button('Replace with a Shader material') @@ -231,7 +229,7 @@ struct materialPage { logger.info('Start to replace with a blank material'); if (!this.shader) { - this.shader = await createShaderPromise(); + this.shader = await this.createShaderPromise(); } if (!this.scene || !this.rf) { @@ -243,13 +241,11 @@ struct materialPage { this.shaderMat = await rf.createMaterial({ name: 'shaderMat' }, MaterialType.SHADER); } - if (this.shaderMat) { + if (this.shader) { this.shaderMat.colorShader = this.shader; } - if (!this.geom) { - this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/Cube') as Geometry; - } + this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/AnimatedCube') as Geometry; this.geom.mesh.materialOverride = undefined; @@ -281,12 +277,14 @@ struct materialPage { // bind between shader and imageMat this.imageMat.colorShader = this.shader; - this.imageMat.colorShader.inputs['BASE_COLOR_Image'] = await createImagePromise(); - - if (!this.geom) { - this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/Cube') as Geometry; + let createdImage = await this.createImagePromise(); + if (createdImage) { + this.imageMat.colorShader.inputs['BASE_COLOR_Image'] = createdImage; } + + this.geom = this.scene.getNodeByPath('rootNode_/Unnamed Node 1/AnimatedCube') as Geometry; + this.geom.mesh.materialOverride = undefined; this.geom.mesh.subMeshes[0].material = this.imageMat; }) @@ -303,8 +301,9 @@ struct materialPage { return; } - this.env = await createEnvrionmentPromise(); - this.scene.environment = this.env; + this.env = await this.createEnvironmentPromise(); + if (this.env) + this.scene.environment = this.env; }); Button('back') diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/camera.ets b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/camera.ets index 76ed38dbb98eb3a85135dae5e51232744056e789..38842e56236c86204253916a4b4a18b7159fb59d 100644 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/camera.ets +++ b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/camera.ets @@ -42,7 +42,7 @@ struct CameraPage { createCameraPromise(): Promise { return new Promise((resolve, reject) => { - Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')) + Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.glb')) .then(async (result: Scene) => { try { this.scene = result; diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/light.ets b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/light.ets index e3174ca0d4b0752c762628fff44e2753ece13c12..9a0d938dd4acd9e759389bfa28604e701d5acbeb 100644 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/light.ets +++ b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/ets/scene/light.ets @@ -30,7 +30,7 @@ struct LightPage { createLightPromise(): Promise { return new Promise((resolve, reject) => { - Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.gltf')) + Scene.load($rawfile('gltf/CubeWithFloor/glTF/AnimatedCube.glb')) .then(async (result: Scene) => { try { this.scene = result; diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.glb b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.glb new file mode 100644 index 0000000000000000000000000000000000000000..c72536ca3be25984c17c30ef662c3983b0c9ba05 Binary files /dev/null and b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.glb differ diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.gltf b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.gltf deleted file mode 100644 index 40347a2feefd43d7b29de3898f80b2ec25e3098a..0000000000000000000000000000000000000000 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Draco/BrainStem.gltf +++ /dev/null @@ -1,9693 +0,0 @@ -{ - "asset": { - "generator": "COLLADA2GLTF", - "version": "2.0" - }, - "scene": 0, - "scenes": [ - { - "nodes": [ - 0 - ] - } - ], - "nodes": [ - { - "children": [ - 21, - 1 - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 0, - -1, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1 - ] - }, - { - "mesh": 0, - "skin": 0 - }, - { - "children": [ - 3 - ], - "rotation": [ - -0.7071066498756409, - 0.00048056046944111586, - 0.0004805605276487768, - -0.7071065306663513 - ], - "translation": [ - 0, - 0, - 0 - ], - "scale": [ - 1, - 1, - 1 - ] - }, - { - "children": [ - 12, - 8, - 4 - ], - "translation": [ - 0, - 0.9148268103599548, - 0 - ], - "rotation": [ - 1.4210853021136108e-14, - -0.0006796148954890668, - 0, - -0.9999997615814208 - ], - "scale": [ - 1, - 0.9999998807907104, - 0.9999998807907104 - ] - }, - { - "children": [ - 5 - ], - "translation": [ - 0.1415490955114365, - -0.03931922093033791, - -1.2286400341565697e-8 - ], - "rotation": [ - 0.7388415336608887, - 1.436989833791813e-7, - -0.6716854572296143, - -0.054411567747592926 - ], - "scale": [ - 1.0000085830688477, - 1.0000001192092896, - 1.000010371208191 - ] - }, - { - "children": [ - 6 - ], - "translation": [ - -7.450580152834618e-9, - 0.3586178123950958, - 0 - ], - "rotation": [ - 0.026200557127594948, - -0.5283005833625793, - 0.015088041312992573, - -0.848518967628479 - ], - "scale": [ - 1, - 1.0000001192092896, - 1 - ] - }, - { - "children": [ - 7 - ], - "translation": [ - -7.450580152834618e-9, - 0.39689669013023376, - -5.5879398885849704e-9 - ], - "rotation": [ - 0.455043375492096, - -0.16150842607021332, - -0.07667787373065948, - -0.8723365664482117 - ], - "scale": [ - 0.9999998807907104, - 1, - 1 - ] - }, - { - "translation": [ - 7.450580152834618e-9, - 0.12854869663715365, - 0 - ], - "rotation": [ - 0.9033632874488832, - 5.500013600112653e-8, - 8.110696114727035e-8, - -0.4288763403892517 - ], - "scale": [ - 1, - 1, - 1.0000003576278689 - ] - }, - { - "children": [ - 9 - ], - "translation": [ - -0.1415490955114365, - -0.03931922093033791, - -1.2220500167359203e-8 - ], - "rotation": [ - 0.7388415336608887, - -1.436989833791813e-7, - 0.6716854572296143, - -0.054411567747592926 - ], - "scale": [ - 1.0000085830688477, - 1.0000001192092896, - 1.000010371208191 - ] - }, - { - "children": [ - 10 - ], - "translation": [ - 7.450580152834618e-9, - 0.3586178123950958, - 0 - ], - "rotation": [ - 0.026200557127594948, - 0.5283005833625793, - -0.015088041312992573, - -0.848518967628479 - ], - "scale": [ - 1, - 1.0000001192092896, - 1 - ] - }, - { - "children": [ - 11 - ], - "translation": [ - 7.450580152834618e-9, - 0.39689669013023376, - -5.5879398885849704e-9 - ], - "rotation": [ - 0.455043375492096, - 0.16150842607021332, - 0.07667787373065948, - -0.8723365664482117 - ], - "scale": [ - 0.9999998807907104, - 1, - 1 - ] - }, - { - "translation": [ - -7.450580152834618e-9, - 0.12854869663715365, - 0 - ], - "rotation": [ - 0.9033632874488832, - -5.500013600112653e-8, - -8.110696114727035e-8, - -0.4288763403892517 - ], - "scale": [ - 1, - 1, - 1.0000003576278689 - ] - }, - { - "children": [ - 20, - 18, - 13 - ], - "translation": [ - -5.492820174396451e-12, - 0.10747220367193222, - -0.02359149046242237 - ], - "rotation": [ - -1.6928350277112262e-8, - -1.1641550223817632e-10, - 0, - -1 - ], - "scale": [ - 1, - 1, - 1 - ] - }, - { - "children": [ - 14 - ], - "translation": [ - 0.4194048047065735, - 0.3407667875289917, - -0.0131063899025321 - ], - "rotation": [ - 0.0097780404612422, - 4.91621790388308e-7, - 0.6920724511146545, - -0.72176194190979 - ], - "scale": [ - 1.0000001192092896, - 1.0000001192092896, - 1 - ] - }, - { - "children": [ - 17, - 16, - 15 - ], - "translation": [ - 1.1920899822825961e-7, - 0.1857225000858307, - 2.7939699442924852e-9 - ], - "rotation": [ - -0.009778017178177834, - -4.709763175014814e-7, - -0.6920723915100098, - -0.7217618823051453 - ], - "scale": [ - 1, - 0.9999998807907104, - 0.9999999403953552 - ] - }, - { - "translation": [ - 0.41257110238075256, - -0.021677140146493912, - 0.055014971643686295 - ], - "rotation": [ - 0, - 0, - -3.165049888842475e-10, - -1 - ], - "scale": [ - 0.9999998807907104, - 1, - 1 - ] - }, - { - "translation": [ - 0.411934107542038, - 0.02158582024276257, - 0.05764370039105415 - ], - "rotation": [ - -1.69283520534691e-8, - 0, - -3.1650501663982306e-10, - -0.9999999403953552 - ], - "scale": [ - 0.9999998807907104, - 0.9999998807907104, - 1 - ] - }, - { - "translation": [ - 0.4094892144203186, - 0.0027067658957093954, - 0.015727709978818897 - ], - "rotation": [ - 0, - 0, - -3.1650501663982306e-10, - -0.9999999403953552 - ], - "scale": [ - 0.9999998807907104, - 0.9999998807907104, - 1 - ] - }, - { - "children": [ - 19 - ], - "translation": [ - -0.41940489411354065, - 0.3407664895057678, - -0.013106339611113071 - ], - "rotation": [ - 0.009349151514470577, - -4.459962354985692e-8, - -0.6824582815170288, - -0.7308647036552429 - ], - "scale": [ - 0.9999999403953552, - 0.9999999403953552, - 1 - ] - }, - { - "translation": [ - 1.1920899822825961e-7, - 0.1918196976184845, - 9.313230187046884e-10 - ], - "rotation": [ - -0.009349144995212557, - 3.408685245176457e-8, - 0.6824582815170288, - -0.7308647036552429 - ], - "scale": [ - 0.9999999403953552, - 0.9999999403953552, - 1 - ] - }, - { - "translation": [ - 0, - 0.5242561101913452, - -0.015727709978818897 - ], - "rotation": [ - 1.66283751212859e-8, - 0, - 0, - -1 - ], - "scale": [ - 1, - 1, - 1 - ] - }, - { - "children": [ - 2 - ] - } - ], - "meshes": [ - { - "primitives": [ - { - "attributes": { - "JOINTS_0": 78, - "NORMAL": 79, - "POSITION": 80, - "WEIGHTS_0": 81 - }, - "indices": 77, - "mode": 4, - "material": 0, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 4, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 83, - "NORMAL": 84, - "POSITION": 85, - "WEIGHTS_0": 86 - }, - "indices": 82, - "mode": 4, - "material": 1, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 5, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 88, - "NORMAL": 89, - "POSITION": 90, - "WEIGHTS_0": 91 - }, - "indices": 87, - "mode": 4, - "material": 2, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 6, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 93, - "NORMAL": 94, - "POSITION": 95, - "WEIGHTS_0": 96 - }, - "indices": 92, - "mode": 4, - "material": 3, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 7, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 98, - "NORMAL": 99, - "POSITION": 100, - "WEIGHTS_0": 101 - }, - "indices": 97, - "mode": 4, - "material": 4, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 8, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 103, - "NORMAL": 104, - "POSITION": 105, - "WEIGHTS_0": 106 - }, - "indices": 102, - "mode": 4, - "material": 5, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 9, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 108, - "NORMAL": 109, - "POSITION": 110, - "WEIGHTS_0": 111 - }, - "indices": 107, - "mode": 4, - "material": 6, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 10, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 113, - "NORMAL": 114, - "POSITION": 115, - "WEIGHTS_0": 116 - }, - "indices": 112, - "mode": 4, - "material": 7, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 11, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 118, - "NORMAL": 119, - "POSITION": 120, - "WEIGHTS_0": 121 - }, - "indices": 117, - "mode": 4, - "material": 8, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 12, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 123, - "NORMAL": 124, - "POSITION": 125, - "WEIGHTS_0": 126 - }, - "indices": 122, - "mode": 4, - "material": 9, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 13, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 128, - "NORMAL": 129, - "POSITION": 130, - "WEIGHTS_0": 131 - }, - "indices": 127, - "mode": 4, - "material": 10, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 14, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 133, - "NORMAL": 134, - "POSITION": 135, - "WEIGHTS_0": 136 - }, - "indices": 132, - "mode": 4, - "material": 11, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 15, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 138, - "NORMAL": 139, - "POSITION": 140, - "WEIGHTS_0": 141 - }, - "indices": 137, - "mode": 4, - "material": 12, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 16, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 143, - "NORMAL": 144, - "POSITION": 145, - "WEIGHTS_0": 146 - }, - "indices": 142, - "mode": 4, - "material": 13, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 17, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 148, - "NORMAL": 149, - "POSITION": 150, - "WEIGHTS_0": 151 - }, - "indices": 147, - "mode": 4, - "material": 14, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 18, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 153, - "NORMAL": 154, - "POSITION": 155, - "WEIGHTS_0": 156 - }, - "indices": 152, - "mode": 4, - "material": 15, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 19, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 158, - "NORMAL": 159, - "POSITION": 160, - "WEIGHTS_0": 161 - }, - "indices": 157, - "mode": 4, - "material": 16, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 20, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 163, - "NORMAL": 164, - "POSITION": 165, - "WEIGHTS_0": 166 - }, - "indices": 162, - "mode": 4, - "material": 17, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 21, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 168, - "NORMAL": 169, - "POSITION": 170, - "WEIGHTS_0": 171 - }, - "indices": 167, - "mode": 4, - "material": 18, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 22, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 173, - "NORMAL": 174, - "POSITION": 175, - "WEIGHTS_0": 176 - }, - "indices": 172, - "mode": 4, - "material": 19, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 23, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 178, - "NORMAL": 179, - "POSITION": 180, - "WEIGHTS_0": 181 - }, - "indices": 177, - "mode": 4, - "material": 20, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 24, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 183, - "NORMAL": 184, - "POSITION": 185, - "WEIGHTS_0": 186 - }, - "indices": 182, - "mode": 4, - "material": 21, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 25, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 188, - "NORMAL": 189, - "POSITION": 190, - "WEIGHTS_0": 191 - }, - "indices": 187, - "mode": 4, - "material": 22, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 26, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 193, - "NORMAL": 194, - "POSITION": 195, - "WEIGHTS_0": 196 - }, - "indices": 192, - "mode": 4, - "material": 23, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 27, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 198, - "NORMAL": 199, - "POSITION": 200, - "WEIGHTS_0": 201 - }, - "indices": 197, - "mode": 4, - "material": 24, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 28, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 203, - "NORMAL": 204, - "POSITION": 205, - "WEIGHTS_0": 206 - }, - "indices": 202, - "mode": 4, - "material": 25, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 29, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 208, - "NORMAL": 209, - "POSITION": 210, - "WEIGHTS_0": 211 - }, - "indices": 207, - "mode": 4, - "material": 26, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 30, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 213, - "NORMAL": 214, - "POSITION": 215, - "WEIGHTS_0": 216 - }, - "indices": 212, - "mode": 4, - "material": 27, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 31, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 218, - "NORMAL": 219, - "POSITION": 220, - "WEIGHTS_0": 221 - }, - "indices": 217, - "mode": 4, - "material": 28, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 32, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 223, - "NORMAL": 224, - "POSITION": 225, - "WEIGHTS_0": 226 - }, - "indices": 222, - "mode": 4, - "material": 29, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 33, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 228, - "NORMAL": 229, - "POSITION": 230, - "WEIGHTS_0": 231 - }, - "indices": 227, - "mode": 4, - "material": 30, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 34, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 233, - "NORMAL": 234, - "POSITION": 235, - "WEIGHTS_0": 236 - }, - "indices": 232, - "mode": 4, - "material": 31, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 35, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 238, - "NORMAL": 239, - "POSITION": 240, - "WEIGHTS_0": 241 - }, - "indices": 237, - "mode": 4, - "material": 32, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 36, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 243, - "NORMAL": 244, - "POSITION": 245, - "WEIGHTS_0": 246 - }, - "indices": 242, - "mode": 4, - "material": 33, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 37, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 248, - "NORMAL": 249, - "POSITION": 250, - "WEIGHTS_0": 251 - }, - "indices": 247, - "mode": 4, - "material": 34, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 38, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 253, - "NORMAL": 254, - "POSITION": 255, - "WEIGHTS_0": 256 - }, - "indices": 252, - "mode": 4, - "material": 35, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 39, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 258, - "NORMAL": 259, - "POSITION": 260, - "WEIGHTS_0": 261 - }, - "indices": 257, - "mode": 4, - "material": 36, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 40, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 263, - "NORMAL": 264, - "POSITION": 265, - "WEIGHTS_0": 266 - }, - "indices": 262, - "mode": 4, - "material": 37, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 41, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 268, - "NORMAL": 269, - "POSITION": 270, - "WEIGHTS_0": 271 - }, - "indices": 267, - "mode": 4, - "material": 38, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 42, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 273, - "NORMAL": 274, - "POSITION": 275, - "WEIGHTS_0": 276 - }, - "indices": 272, - "mode": 4, - "material": 39, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 43, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 278, - "NORMAL": 279, - "POSITION": 280, - "WEIGHTS_0": 281 - }, - "indices": 277, - "mode": 4, - "material": 40, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 44, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 283, - "NORMAL": 284, - "POSITION": 285, - "WEIGHTS_0": 286 - }, - "indices": 282, - "mode": 4, - "material": 41, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 45, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 288, - "NORMAL": 289, - "POSITION": 290, - "WEIGHTS_0": 291 - }, - "indices": 287, - "mode": 4, - "material": 42, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 46, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 293, - "NORMAL": 294, - "POSITION": 295, - "WEIGHTS_0": 296 - }, - "indices": 292, - "mode": 4, - "material": 43, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 47, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 298, - "NORMAL": 299, - "POSITION": 300, - "WEIGHTS_0": 301 - }, - "indices": 297, - "mode": 4, - "material": 44, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 48, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 303, - "NORMAL": 304, - "POSITION": 305, - "WEIGHTS_0": 306 - }, - "indices": 302, - "mode": 4, - "material": 45, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 49, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 308, - "NORMAL": 309, - "POSITION": 310, - "WEIGHTS_0": 311 - }, - "indices": 307, - "mode": 4, - "material": 46, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 50, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 313, - "NORMAL": 314, - "POSITION": 315, - "WEIGHTS_0": 316 - }, - "indices": 312, - "mode": 4, - "material": 47, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 51, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 318, - "NORMAL": 319, - "POSITION": 320, - "WEIGHTS_0": 321 - }, - "indices": 317, - "mode": 4, - "material": 48, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 52, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 323, - "NORMAL": 324, - "POSITION": 325, - "WEIGHTS_0": 326 - }, - "indices": 322, - "mode": 4, - "material": 49, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 53, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 328, - "NORMAL": 329, - "POSITION": 330, - "WEIGHTS_0": 331 - }, - "indices": 327, - "mode": 4, - "material": 50, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 54, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 333, - "NORMAL": 334, - "POSITION": 335, - "WEIGHTS_0": 336 - }, - "indices": 332, - "mode": 4, - "material": 51, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 55, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 338, - "NORMAL": 339, - "POSITION": 340, - "WEIGHTS_0": 341 - }, - "indices": 337, - "mode": 4, - "material": 52, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 56, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 343, - "NORMAL": 344, - "POSITION": 345, - "WEIGHTS_0": 346 - }, - "indices": 342, - "mode": 4, - "material": 53, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 57, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 348, - "NORMAL": 349, - "POSITION": 350, - "WEIGHTS_0": 351 - }, - "indices": 347, - "mode": 4, - "material": 54, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 58, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 353, - "NORMAL": 354, - "POSITION": 355, - "WEIGHTS_0": 356 - }, - "indices": 352, - "mode": 4, - "material": 55, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 59, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 358, - "NORMAL": 359, - "POSITION": 360, - "WEIGHTS_0": 361 - }, - "indices": 357, - "mode": 4, - "material": 56, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 60, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 363, - "NORMAL": 364, - "POSITION": 365, - "WEIGHTS_0": 366 - }, - "indices": 362, - "mode": 4, - "material": 57, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 61, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - }, - { - "attributes": { - "JOINTS_0": 368, - "NORMAL": 369, - "POSITION": 370, - "WEIGHTS_0": 371 - }, - "indices": 367, - "mode": 4, - "material": 58, - "extensions": { - "KHR_draco_mesh_compression": { - "bufferView": 62, - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - } - } - } - } - ], - "name": "Figure_2_geometry" - } - ], - "animations": [ - { - "channels": [ - { - "sampler": 0, - "target": { - "node": 2, - "path": "translation" - } - }, - { - "sampler": 1, - "target": { - "node": 2, - "path": "rotation" - } - }, - { - "sampler": 2, - "target": { - "node": 2, - "path": "scale" - } - }, - { - "sampler": 3, - "target": { - "node": 3, - "path": "translation" - } - }, - { - "sampler": 4, - "target": { - "node": 3, - "path": "rotation" - } - }, - { - "sampler": 5, - "target": { - "node": 3, - "path": "scale" - } - }, - { - "sampler": 6, - "target": { - "node": 12, - "path": "translation" - } - }, - { - "sampler": 7, - "target": { - "node": 12, - "path": "rotation" - } - }, - { - "sampler": 8, - "target": { - "node": 12, - "path": "scale" - } - }, - { - "sampler": 9, - "target": { - "node": 20, - "path": "translation" - } - }, - { - "sampler": 10, - "target": { - "node": 20, - "path": "rotation" - } - }, - { - "sampler": 11, - "target": { - "node": 20, - "path": "scale" - } - }, - { - "sampler": 12, - "target": { - "node": 18, - "path": "translation" - } - }, - { - "sampler": 13, - "target": { - "node": 18, - "path": "rotation" - } - }, - { - "sampler": 14, - "target": { - "node": 18, - "path": "scale" - } - }, - { - "sampler": 15, - "target": { - "node": 19, - "path": "translation" - } - }, - { - "sampler": 16, - "target": { - "node": 19, - "path": "rotation" - } - }, - { - "sampler": 17, - "target": { - "node": 19, - "path": "scale" - } - }, - { - "sampler": 18, - "target": { - "node": 13, - "path": "translation" - } - }, - { - "sampler": 19, - "target": { - "node": 13, - "path": "rotation" - } - }, - { - "sampler": 20, - "target": { - "node": 13, - "path": "scale" - } - }, - { - "sampler": 21, - "target": { - "node": 14, - "path": "translation" - } - }, - { - "sampler": 22, - "target": { - "node": 14, - "path": "rotation" - } - }, - { - "sampler": 23, - "target": { - "node": 14, - "path": "scale" - } - }, - { - "sampler": 24, - "target": { - "node": 17, - "path": "translation" - } - }, - { - "sampler": 25, - "target": { - "node": 17, - "path": "rotation" - } - }, - { - "sampler": 26, - "target": { - "node": 17, - "path": "scale" - } - }, - { - "sampler": 27, - "target": { - "node": 16, - "path": "translation" - } - }, - { - "sampler": 28, - "target": { - "node": 16, - "path": "rotation" - } - }, - { - "sampler": 29, - "target": { - "node": 16, - "path": "scale" - } - }, - { - "sampler": 30, - "target": { - "node": 15, - "path": "translation" - } - }, - { - "sampler": 31, - "target": { - "node": 15, - "path": "rotation" - } - }, - { - "sampler": 32, - "target": { - "node": 15, - "path": "scale" - } - }, - { - "sampler": 33, - "target": { - "node": 8, - "path": "translation" - } - }, - { - "sampler": 34, - "target": { - "node": 8, - "path": "rotation" - } - }, - { - "sampler": 35, - "target": { - "node": 8, - "path": "scale" - } - }, - { - "sampler": 36, - "target": { - "node": 9, - "path": "translation" - } - }, - { - "sampler": 37, - "target": { - "node": 9, - "path": "rotation" - } - }, - { - "sampler": 38, - "target": { - "node": 9, - "path": "scale" - } - }, - { - "sampler": 39, - "target": { - "node": 10, - "path": "translation" - } - }, - { - "sampler": 40, - "target": { - "node": 10, - "path": "rotation" - } - }, - { - "sampler": 41, - "target": { - "node": 10, - "path": "scale" - } - }, - { - "sampler": 42, - "target": { - "node": 11, - "path": "translation" - } - }, - { - "sampler": 43, - "target": { - "node": 11, - "path": "rotation" - } - }, - { - "sampler": 44, - "target": { - "node": 11, - "path": "scale" - } - }, - { - "sampler": 45, - "target": { - "node": 4, - "path": "translation" - } - }, - { - "sampler": 46, - "target": { - "node": 4, - "path": "rotation" - } - }, - { - "sampler": 47, - "target": { - "node": 4, - "path": "scale" - } - }, - { - "sampler": 48, - "target": { - "node": 5, - "path": "translation" - } - }, - { - "sampler": 49, - "target": { - "node": 5, - "path": "rotation" - } - }, - { - "sampler": 50, - "target": { - "node": 5, - "path": "scale" - } - }, - { - "sampler": 51, - "target": { - "node": 6, - "path": "translation" - } - }, - { - "sampler": 52, - "target": { - "node": 6, - "path": "rotation" - } - }, - { - "sampler": 53, - "target": { - "node": 6, - "path": "scale" - } - }, - { - "sampler": 54, - "target": { - "node": 7, - "path": "translation" - } - }, - { - "sampler": 55, - "target": { - "node": 7, - "path": "rotation" - } - }, - { - "sampler": 56, - "target": { - "node": 7, - "path": "scale" - } - } - ], - "samplers": [ - { - "input": 0, - "interpolation": "LINEAR", - "output": 1 - }, - { - "input": 0, - "interpolation": "LINEAR", - "output": 2 - }, - { - "input": 0, - "interpolation": "LINEAR", - "output": 3 - }, - { - "input": 4, - "interpolation": "LINEAR", - "output": 5 - }, - { - "input": 4, - "interpolation": "LINEAR", - "output": 6 - }, - { - "input": 4, - "interpolation": "LINEAR", - "output": 7 - }, - { - "input": 8, - "interpolation": "LINEAR", - "output": 9 - }, - { - "input": 8, - "interpolation": "LINEAR", - "output": 10 - }, - { - "input": 8, - "interpolation": "LINEAR", - "output": 11 - }, - { - "input": 12, - "interpolation": "LINEAR", - "output": 13 - }, - { - "input": 12, - "interpolation": "LINEAR", - "output": 14 - }, - { - "input": 12, - "interpolation": "LINEAR", - "output": 15 - }, - { - "input": 16, - "interpolation": "LINEAR", - "output": 17 - }, - { - "input": 16, - "interpolation": "LINEAR", - "output": 18 - }, - { - "input": 16, - "interpolation": "LINEAR", - "output": 19 - }, - { - "input": 20, - "interpolation": "LINEAR", - "output": 21 - }, - { - "input": 20, - "interpolation": "LINEAR", - "output": 22 - }, - { - "input": 20, - "interpolation": "LINEAR", - "output": 23 - }, - { - "input": 24, - "interpolation": "LINEAR", - "output": 25 - }, - { - "input": 24, - "interpolation": "LINEAR", - "output": 26 - }, - { - "input": 24, - "interpolation": "LINEAR", - "output": 27 - }, - { - "input": 28, - "interpolation": "LINEAR", - "output": 29 - }, - { - "input": 28, - "interpolation": "LINEAR", - "output": 30 - }, - { - "input": 28, - "interpolation": "LINEAR", - "output": 31 - }, - { - "input": 32, - "interpolation": "LINEAR", - "output": 33 - }, - { - "input": 32, - "interpolation": "LINEAR", - "output": 34 - }, - { - "input": 32, - "interpolation": "LINEAR", - "output": 35 - }, - { - "input": 36, - "interpolation": "LINEAR", - "output": 37 - }, - { - "input": 36, - "interpolation": "LINEAR", - "output": 38 - }, - { - "input": 36, - "interpolation": "LINEAR", - "output": 39 - }, - { - "input": 40, - "interpolation": "LINEAR", - "output": 41 - }, - { - "input": 40, - "interpolation": "LINEAR", - "output": 42 - }, - { - "input": 40, - "interpolation": "LINEAR", - "output": 43 - }, - { - "input": 44, - "interpolation": "LINEAR", - "output": 45 - }, - { - "input": 44, - "interpolation": "LINEAR", - "output": 46 - }, - { - "input": 44, - "interpolation": "LINEAR", - "output": 47 - }, - { - "input": 48, - "interpolation": "LINEAR", - "output": 49 - }, - { - "input": 48, - "interpolation": "LINEAR", - "output": 50 - }, - { - "input": 48, - "interpolation": "LINEAR", - "output": 51 - }, - { - "input": 52, - "interpolation": "LINEAR", - "output": 53 - }, - { - "input": 52, - "interpolation": "LINEAR", - "output": 54 - }, - { - "input": 52, - "interpolation": "LINEAR", - "output": 55 - }, - { - "input": 56, - "interpolation": "LINEAR", - "output": 57 - }, - { - "input": 56, - "interpolation": "LINEAR", - "output": 58 - }, - { - "input": 56, - "interpolation": "LINEAR", - "output": 59 - }, - { - "input": 60, - "interpolation": "LINEAR", - "output": 61 - }, - { - "input": 60, - "interpolation": "LINEAR", - "output": 62 - }, - { - "input": 60, - "interpolation": "LINEAR", - "output": 63 - }, - { - "input": 64, - "interpolation": "LINEAR", - "output": 65 - }, - { - "input": 64, - "interpolation": "LINEAR", - "output": 66 - }, - { - "input": 64, - "interpolation": "LINEAR", - "output": 67 - }, - { - "input": 68, - "interpolation": "LINEAR", - "output": 69 - }, - { - "input": 68, - "interpolation": "LINEAR", - "output": 70 - }, - { - "input": 68, - "interpolation": "LINEAR", - "output": 71 - }, - { - "input": 72, - "interpolation": "LINEAR", - "output": 73 - }, - { - "input": 72, - "interpolation": "LINEAR", - "output": 74 - }, - { - "input": 72, - "interpolation": "LINEAR", - "output": 75 - } - ] - } - ], - "skins": [ - { - "inverseBindMatrices": 76, - "skeleton": 2, - "joints": [ - 3, - 12, - 20, - 18, - 19, - 13, - 14, - 17, - 16, - 15, - 8, - 9, - 10, - 11, - 4, - 5, - 6, - 7 - ], - "name": "Poser_scene_root" - } - ], - "accessors": [ - { - "bufferView": 0, - "byteOffset": 0, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 0, - "componentType": 5126, - "count": 1309, - "max": [ - 0, - 0, - 0 - ], - "min": [ - 0, - 0, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 0, - "componentType": 5126, - "count": 1309, - "max": [ - -0.7071066498756409, - 0.00048056046944111586, - 0.0004805605276487768, - -0.7071065306663513 - ], - "min": [ - -0.7071066498756409, - 0.00048056046944111586, - 0.0004805605276487768, - -0.7071065306663513 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 15708, - "componentType": 5126, - "count": 1309, - "max": [ - 1, - 1, - 1 - ], - "min": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 5236, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 31416, - "componentType": 5126, - "count": 1309, - "max": [ - 0, - 0.9148268103599548, - 0 - ], - "min": [ - 0, - 0.9148268103599548, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 20944, - "componentType": 5126, - "count": 1309, - "max": [ - 0.22994717955589297, - 0.99963116645813, - 0.24422451853752136, - 0.999263107776642 - ], - "min": [ - -0.21882909536361697, - -0.9982082843780518, - -0.2034148871898651, - -0.9998023509979248 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 47124, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000009536743164, - 1.000000238418579, - 1.000001072883606 - ], - "min": [ - 0.9999996423721313, - 0.999999701976776, - 0.9999995231628418 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 10472, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 62832, - "componentType": 5126, - "count": 1309, - "max": [ - 2.980229965032777e-7, - 0.10747259855270386, - -0.023591449484229088 - ], - "min": [ - -2.38419005427204e-7, - 0.10747189819812776, - -0.023591849952936176 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 41888, - "componentType": 5126, - "count": 1309, - "max": [ - 0.08071999251842499, - 0.4829065203666687, - 0.23370222747325897, - -0.875069797039032 - ], - "min": [ - -0.2940012216567993, - -0.4205382764339447, - -0.3637002110481262, - -0.9999121427536012 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 78540, - "componentType": 5126, - "count": 1309, - "max": [ - 1.000000238418579, - 1.000000238418579, - 1.000000238418579 - ], - "min": [ - 0.9999996423721313, - 0.9999995827674866, - 0.9999995827674866 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 15708, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 94248, - "componentType": 5126, - "count": 1309, - "max": [ - 2.682209867543861e-7, - 0.5242568254470825, - -0.015727100893855095 - ], - "min": [ - -2.682209867543861e-7, - 0.5242558121681213, - -0.015728000551462177 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 62832, - "componentType": 5126, - "count": 1309, - "max": [ - 0.46409425139427185, - 0.5351784229278564, - 0.1608593612909317, - -0.7751519680023193 - ], - "min": [ - -0.29117903113365173, - -0.5687214732170105, - -0.2105143815279007, - -0.9996994137763976 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 109956, - "componentType": 5126, - "count": 1309, - "max": [ - 1.000000238418579, - 1.0000003576278689, - 1.0000003576278689 - ], - "min": [ - 0.9999996423721313, - 0.9999997615814208, - 0.999999701976776 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 20944, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 125664, - "componentType": 5126, - "count": 1309, - "max": [ - -0.4194045960903168, - 0.3407667875289917, - -0.01310619991272688 - ], - "min": [ - -0.41940510272979736, - 0.3407663106918335, - -0.013106689788401129 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 83776, - "componentType": 5126, - "count": 1309, - "max": [ - 0.2547066807746887, - 0.3725568354129791, - -0.10216578841209412, - 0.02369661815464497 - ], - "min": [ - -0.7071006298065186, - -0.538973331451416, - -0.9599624872207642, - -0.9599091410636902 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 141372, - "componentType": 5126, - "count": 1309, - "max": [ - 1.000000238418579, - 1.0000003576278689, - 1.0000004768371584 - ], - "min": [ - 0.9999995231628418, - 0.9999993443489076, - 0.9999996423721313 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 26180, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 157080, - "componentType": 5126, - "count": 1309, - "max": [ - 4.842879874900064e-8, - 0.1918196976184845, - 0 - ], - "min": [ - 4.842879874900064e-8, - 0.1918196976184845, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 104720, - "componentType": 5126, - "count": 1309, - "max": [ - 0.10535851866006853, - 0.008949832059442997, - 0.9193236827850342, - 0.20621219277381897 - ], - "min": [ - -0.540235698223114, - -0.5158300995826721, - 0.5870917439460754, - -0.7372239232063293 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 172788, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000005960464478, - 1.0000003576278689, - 1.0000007152557373 - ], - "min": [ - 0.9999995231628418, - 0.999999463558197, - 0.999999701976776 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 31416, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 188496, - "componentType": 5126, - "count": 1309, - "max": [ - 0.4194050133228302, - 0.3407658040523529, - -0.013106119818985464 - ], - "min": [ - 0.4194045066833496, - 0.34076550602912903, - -0.013106719590723516 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 125664, - "componentType": 5126, - "count": 1309, - "max": [ - 0.16515624523162845, - 0.749225914478302, - 0.9655215740203856, - 0.0222143717110157 - ], - "min": [ - -0.7774010896682739, - -0.5799198746681213, - 0.1723635494709015, - -0.9414708614349364 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 204204, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000009536743164, - 1.000001072883606, - 1.0000008344650269 - ], - "min": [ - 1, - 1.000000238418579, - 0.9999998807907104 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 36652, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 219912, - "componentType": 5126, - "count": 1309, - "max": [ - 1.4901200273698123e-8, - 0.18572239577770233, - 0 - ], - "min": [ - 1.4901200273698123e-8, - 0.18572239577770233, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 146608, - "componentType": 5126, - "count": 1309, - "max": [ - 0.1826249808073044, - 0.6476022005081177, - -0.6235807538032532, - 0.1337534636259079 - ], - "min": [ - -0.500301718711853, - -0.03818349167704582, - -0.8916640877723694, - -0.7264519929885864 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 235620, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000003576278689, - 1, - 1.0000001192092896 - ], - "min": [ - 0.9999993443489076, - 0.9999993443489076, - 0.9999993443489076 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 41888, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 251328, - "componentType": 5126, - "count": 1309, - "max": [ - 0.4094895124435425, - 0.0027066469192504883, - 0.015727730467915535 - ], - "min": [ - 0.4094895124435425, - 0.0027066469192504883, - 0.015727730467915535 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 167552, - "componentType": 5126, - "count": 1309, - "max": [ - 5.587948326279957e-9, - -3.7253005125137414e-9, - 0, - -0.9999999403953552 - ], - "min": [ - 5.587948326279957e-9, - -3.7253005125137414e-9, - 0, - -0.9999999403953552 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 267036, - "componentType": 5126, - "count": 1309, - "max": [ - 1, - 0.9999998807907104, - 0.9999998807907104 - ], - "min": [ - 1, - 0.9999998807907104, - 0.9999998807907104 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 47124, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 282744, - "componentType": 5126, - "count": 1309, - "max": [ - 0.4119338095188141, - 0.02158593945205212, - 0.05764375999569893 - ], - "min": [ - 0.4119338095188141, - 0.02158593945205212, - 0.05764375999569893 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 188496, - "componentType": 5126, - "count": 1309, - "max": [ - -1.3969826184734302e-8, - 0, - 0, - -0.9999999403953552 - ], - "min": [ - -1.3969826184734302e-8, - 0, - 0, - -0.9999999403953552 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 298452, - "componentType": 5126, - "count": 1309, - "max": [ - 0.9999998807907104, - 1, - 0.9999998807907104 - ], - "min": [ - 0.9999998807907104, - 1, - 0.9999998807907104 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 52360, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 314160, - "componentType": 5126, - "count": 1309, - "max": [ - 0.41257110238075256, - -0.021677669137716297, - 0.05501500889658928 - ], - "min": [ - 0.41257110238075256, - -0.021677669137716297, - 0.05501500889658928 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 209440, - "componentType": 5126, - "count": 1309, - "max": [ - 1.8626450382086542e-9, - -3.725300068424531e-9, - -2.98022992950564e-8, - -1 - ], - "min": [ - 1.8626450382086542e-9, - -3.725300068424531e-9, - -2.98022992950564e-8, - -1 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 329868, - "componentType": 5126, - "count": 1309, - "max": [ - 1, - 1, - 0.9999998807907104 - ], - "min": [ - 1, - 1, - 0.9999998807907104 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 57596, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 345576, - "componentType": 5126, - "count": 1309, - "max": [ - -0.1415490061044693, - -0.039318621158599854, - 4.991890136807342e-7 - ], - "min": [ - -0.14154960215091705, - -0.03931945934891701, - -1.1175900027637908e-7 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 230384, - "componentType": 5126, - "count": 1309, - "max": [ - 0.8133829236030579, - 0.5989649295806885, - 0.8436978459358215, - 0.6449698805809021 - ], - "min": [ - 0.3702203333377838, - -0.06241266801953316, - 0.3116881549358368, - -0.13473054766654968 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 361284, - "componentType": 5126, - "count": 1309, - "max": [ - 1.000016689300537, - 1.0000189542770386, - 1.0000169277191164 - ], - "min": [ - 0.9999995827674866, - 0.9999997615814208, - 0.9999993443489076 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 62832, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 376992, - "componentType": 5126, - "count": 1309, - "max": [ - 2.98022992950564e-8, - 0.3586176931858063, - 0 - ], - "min": [ - 2.98022992950564e-8, - 0.3586176931858063, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 251328, - "componentType": 5126, - "count": 1309, - "max": [ - 0.008941872045397758, - 0.6418942213058472, - -0.04780912771821022, - -0.17511217296123505 - ], - "min": [ - -0.5697520971298218, - 0.0517999567091465, - -0.8109263181686401, - -0.8936039209365845 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 392700, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000007152557373, - 1.0000009536743164, - 1 - ], - "min": [ - 0.9999998807907104, - 0.999999701976776, - 0.999998927116394 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 68068, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 408408, - "componentType": 5126, - "count": 1309, - "max": [ - 0, - 0.3968968093395233, - 0 - ], - "min": [ - 0, - 0.3968968093395233, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 272272, - "componentType": 5126, - "count": 1309, - "max": [ - 0.8207381367683411, - 0.3076615631580353, - 0.3662434220314026, - -0.5708383917808533 - ], - "min": [ - 0.08248570561408997, - -0.08690406382083893, - -0.289207935333252, - -0.9902410507202148 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 424116, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000003576278689, - 1.0000007152557373, - 1.0000005960464478 - ], - "min": [ - 0.9999994039535524, - 0.9999994039535524, - 0.9999994039535524 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 73304, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 439824, - "componentType": 5126, - "count": 1309, - "max": [ - -2.98022992950564e-8, - 0.12854869663715365, - 0 - ], - "min": [ - -2.98022992950564e-8, - 0.12854869663715365, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 293216, - "componentType": 5126, - "count": 1309, - "max": [ - 0.9033632278442384, - -7.4743859102e-8, - -1.0567234198788357e-7, - -0.4288764894008637 - ], - "min": [ - 0.9033632278442384, - -7.4743859102e-8, - -1.0567234198788357e-7, - -0.4288764894008637 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 455532, - "componentType": 5126, - "count": 1309, - "max": [ - 1, - 1.0000001192092896, - 1.0000003576278689 - ], - "min": [ - 1, - 1.0000001192092896, - 1.0000003576278689 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 78540, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 471240, - "componentType": 5126, - "count": 1309, - "max": [ - 0.1415494978427887, - -0.03931879997253418, - 4.842880230171431e-7 - ], - "min": [ - 0.14154890179634097, - -0.03931939974427223, - -1.1920899822825961e-7 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 314160, - "componentType": 5126, - "count": 1309, - "max": [ - 0.8340531587600708, - 0.21584154665470123, - -0.3745410144329071, - 0.719398558139801 - ], - "min": [ - 0.20705875754356384, - -0.5725383162498474, - -0.8548761010169983, - -0.18284621834754944 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 486948, - "componentType": 5126, - "count": 1309, - "max": [ - 1.000017762184143, - 1.0000197887420657, - 1.0000158548355105 - ], - "min": [ - 0.9999998211860656, - 0.9999998211860656, - 0.9999992847442628 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 83776, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 502656, - "componentType": 5126, - "count": 1309, - "max": [ - 0, - 0.3586178123950958, - 0 - ], - "min": [ - 0, - 0.3586178123950958, - 0 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 335104, - "componentType": 5126, - "count": 1309, - "max": [ - -0.018084827810525898, - -0.04664610326290131, - 0.7690947651863098, - -0.22867438197135928 - ], - "min": [ - -0.6566932797431946, - -0.6220959424972534, - -0.05792725831270218, - -0.9092845916748048 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 518364, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000009536743164, - 1.0000008344650269, - 1 - ], - "min": [ - 0.9999998807907104, - 0.9999998807907104, - 0.9999991655349731 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 89012, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 534072, - "componentType": 5126, - "count": 1309, - "max": [ - -2.98022992950564e-8, - 0.3968968093395233, - -1.8626499453944237e-8 - ], - "min": [ - -2.98022992950564e-8, - 0.3968968093395233, - -1.8626499453944237e-8 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 356048, - "componentType": 5126, - "count": 1309, - "max": [ - 0.7374019622802734, - 0.1331629455089569, - 0.04225348681211472, - -0.6565166115760803 - ], - "min": [ - 0.1277473121881485, - -0.36822667717933655, - -0.3809806108474732, - -0.9684229493141174 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 549780, - "componentType": 5126, - "count": 1309, - "max": [ - 1.0000003576278689, - 1.0000005960464478, - 1.0000004768371584 - ], - "min": [ - 0.9999994039535524, - 0.999999463558197, - 0.999999225139618 - ], - "type": "VEC3" - }, - { - "bufferView": 0, - "byteOffset": 94248, - "componentType": 5126, - "count": 1309, - "max": [ - 34.880001068115234 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "bufferView": 1, - "byteOffset": 565488, - "componentType": 5126, - "count": 1309, - "max": [ - 1.4901200273698123e-8, - 0.128548800945282, - 7.450580152834618e-9 - ], - "min": [ - 1.4901200273698123e-8, - 0.128548800945282, - 7.450580152834618e-9 - ], - "type": "VEC3" - }, - { - "bufferView": 2, - "byteOffset": 376992, - "componentType": 5126, - "count": 1309, - "max": [ - 0.9033632278442384, - 5.67022482300672e-8, - 1.0154858642863475e-7, - -0.42887642979621887 - ], - "min": [ - 0.9033632278442384, - 5.67022482300672e-8, - 1.0154858642863475e-7, - -0.42887642979621887 - ], - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 581196, - "componentType": 5126, - "count": 1309, - "max": [ - 1, - 1, - 1.0000003576278689 - ], - "min": [ - 1, - 1, - 1.0000003576278689 - ], - "type": "VEC3" - }, - { - "bufferView": 3, - "byteOffset": 0, - "componentType": 5126, - "count": 18, - "max": [ - 1, - 0.9990230202674866, - 0.9925193190574646, - 0, - 0.992519199848175, - 0.0804019495844841, - 0.9333313703536988, - 0, - 0.997569501399994, - 1, - 0.08040130138397217, - 0, - 1.3445860147476196, - 0.880669891834259, - 0.07009822130203247, - 1 - ], - "min": [ - 0.042071811854839325, - -0.997569501399994, - -0.9925193190574646, - 0, - -0.992519199848175, - -0.7748532295227051, - -1, - 0, - -0.999022901058197, - -0.9972699284553528, - -0.7748619914054871, - 0, - -1.331490993499756, - -1.5465550422668457, - -0.04193788021802902, - 1 - ], - "type": "MAT4" - }, - { - "componentType": 5123, - "count": 2778, - "max": [ - 537 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 548, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 548, - "max": [ - 1.0078367097705017, - 1.0084210141032348, - 1.0086971624224792 - ], - "min": [ - -1.0078367693751467, - -1.0072524650424135, - -1.0069763167231691 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 548, - "max": [ - 0.2746078359480887, - -0.03236697446036235, - 1.4565151921702293 - ], - "min": [ - -0.27460783594808874, - -0.1503049420710593, - 1.0477529180649727 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 548, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 5928, - "max": [ - 1018 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1019, - "max": [ - 9, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1019, - "max": [ - 1.009707630148121, - 1.007843137254902, - 1.0078449253942452 - ], - "min": [ - -1.005978644361683, - -1.007843137254902, - -1.007841349115559 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1019, - "max": [ - 1.0665446500924953, - 0.18429765694524, - 1.4782141673023317 - ], - "min": [ - -0.6088296752122768, - -0.06181638498581731, - 1.2811594028326148 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1019, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1134, - "max": [ - 194 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 195, - "max": [ - 9, - 0, - 0, - 0 - ], - "min": [ - 7, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 195, - "max": [ - 1.0001543760299683, - 1.00785809357961, - 1.0077086051305133 - ], - "min": [ - -1.0074282248814899, - -1.0075666268666583, - -1.0077161153157552 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 195, - "max": [ - 1.1626107958275107, - 0.07008955876639136, - 1.4374306770901477 - ], - "min": [ - 1.0579913285632336, - -0.04982142624662281, - 1.306879344310304 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 195, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 6240, - "max": [ - 1063 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1064, - "max": [ - 17, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1064, - "max": [ - 0.9894092220886079, - 0.9988433580772549, - 0.9852540034873811 - ], - "min": [ - -0.9906002145187528, - -0.9966955643074186, - -0.9947554331199796 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1064, - "max": [ - 0.30012722696107375, - 0.15664983224373377, - 1.018114377205556 - ], - "min": [ - -0.30022247547406494, - -0.18455969208974188, - -0.001037686000408402 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1064, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 312, - "max": [ - 55 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 56, - "max": [ - 17, - 0, - 0, - 0 - ], - "min": [ - 13, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 0.9934929861741909, - 0.89382156905006, - 0.9638688536251294 - ], - "min": [ - -0.9934929861741909, - -0.930803681822384, - -0.8684878601747401 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 0.138653238772123, - -0.009217342095195702, - 0.08156272670018437 - ], - "min": [ - -0.138653238772123, - -0.1496976367222954, - 0.009021842384071221 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1512, - "max": [ - 255 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 256, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 0.9513761139383502, - 0.9077552456481781, - 0.9077552456481781 - ], - "min": [ - -0.9513761139383502, - -0.9061525202264973, - -0.9061525202264973 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 0.19430945887906875, - 0.11223086354772696, - 0.5912015931048391 - ], - "min": [ - -0.19430945887906875, - -0.04499953314407198, - 0.43378153369085465 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 4740, - "max": [ - 801 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 806, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 806, - "max": [ - 1.007843137254902, - 0.980511304911445, - 1.007843137254902 - ], - "min": [ - -1.007843137254902, - -0.9802730088140451, - -1.007843137254902 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 806, - "max": [ - 0.23124912002637554, - 0.08289774557512797, - 0.9717451894230882 - ], - "min": [ - -0.23124912002637552, - -0.0834571606810348, - 0.7900413908664925 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 806, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 912, - "max": [ - 255 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 256, - "max": [ - 16, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 0.9653960227966307, - 0.9818436781565347, - 0.8887706160545348 - ], - "min": [ - -0.9677281061808268, - -0.9818436781565348, - -0.8151293079058329 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 0.2134047844649657, - 0.1351187331579229, - 0.9198555861061515 - ], - "min": [ - -0.21334896128830325, - -0.07782267671284089, - 0.027591887077122824 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 256, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 216, - "max": [ - 39 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 40, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 0.8908350089017081, - 0.9360252148964825, - 0.8481213506530312 - ], - "min": [ - -0.8936570412972394, - -0.8766801483490888, - -0.8940507299759809 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 0.20255470494264266, - 0.09506434143958117, - 0.7939878226374788 - ], - "min": [ - -0.2025547049426427, - -0.09394717434877062, - 0.5444768049336085 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2136, - "max": [ - 359 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 360, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 360, - "max": [ - 1.0025498270988467, - 1.0076210014960347, - 0.9879335087888382 - ], - "min": [ - -1.0038769953391131, - -1.0066434257170733, - -0.9714676849982319 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 360, - "max": [ - 0.21127501669515908, - -0.00887011933542195, - 0.8113689640119242 - ], - "min": [ - -0.21127501669515908, - -0.13404721561064065, - 0.5608085488976067 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 360, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3696, - "max": [ - 751 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 752, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 752, - "max": [ - 0.9769793372528226, - 0.8900846177456425, - 0.9660385407653509 - ], - "min": [ - -0.9769793372528226, - -0.8890061598198087, - -0.9651112776176602 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 752, - "max": [ - 0.23576612215858583, - 0.11586916019742408, - 0.9124453836059244 - ], - "min": [ - -0.23576612215858583, - -0.08019988429170734, - 0.7002673800625216 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 752, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2286, - "max": [ - 844 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 845, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 845, - "max": [ - 0.9540647913427912, - 1.0028367584826898, - 0.902489677363751 - ], - "min": [ - -0.9548889940860226, - -1.007823581087823, - -0.9047575539233638 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 845, - "max": [ - 0.9565517491955378, - 0.11440786104203435, - 1.7048410027709657 - ], - "min": [ - -0.48193245002218266, - -0.15938854583688755, - 0.8413292579989813 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 845, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2160, - "max": [ - 383 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 384, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 1.0059312815759696, - 1.007317983636669, - 0.9994100098516425 - ], - "min": [ - -1.0059312815759696, - -1.00454457951527, - -0.9967960352991142 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 0.2378890020386091, - 0.07518748131739436, - 0.6668404856279063 - ], - "min": [ - -0.2378890020386091, - 0.009707053230632263, - 0.49524461202465386 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2400, - "max": [ - 415 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 416, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 416, - "max": [ - 0.9231721887401507, - 0.9670001256699655, - 0.9702460158104992 - ], - "min": [ - -0.9212476599450204, - -0.9677586543793772, - -0.9645127642388436 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 416, - "max": [ - 0.222485592533276, - 0.164112340183005, - 0.8091151915967435 - ], - "min": [ - -0.22257817317843145, - -0.023648935976621578, - 0.26107693682313254 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 416, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 192, - "max": [ - 39 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 40, - "max": [ - 14, - 0, - 0, - 0 - ], - "min": [ - 10, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 0.6047777970631918, - 0.8078730543454486, - 0.7809370319048563 - ], - "min": [ - -0.6018921295801799, - -0.7700799266497295, - -0.8093920509020488 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 0.20028318991064736, - 0.06968083026972256, - 0.672448428508766 - ], - "min": [ - -0.20028318991064734, - -0.0026518005423218694, - 0.4806692100584536 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 40, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2772, - "max": [ - 451 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 452, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 11, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 452, - "max": [ - 0.8958697297993827, - 0.9796444402021519, - 0.9531441625426796 - ], - "min": [ - -0.8930444345754736, - -1.0020406470579262, - -0.989986740140354 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 452, - "max": [ - 0.21652484307739875, - -0.05555573510552943, - 0.571005376246014 - ], - "min": [ - -0.21652484307739875, - -0.10522224376652377, - 0.38734496762301784 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 452, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 312, - "max": [ - 55 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 56, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 11, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 0.9653980308888006, - 0.9280303583425635, - 0.9280231097165277 - ], - "min": [ - -0.9653980308888005, - -0.860022025716071, - -0.7924138480541753 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 0.1763535419876656, - 0.15929399840952307, - 0.399704607350103 - ], - "min": [ - -0.17635354198766562, - 0.010740453523866244, - 0.23118326268839032 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 56, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2280, - "max": [ - 383 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 384, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 11, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 0.9297050347515178, - 1.003530190738977, - 0.9096218782312726 - ], - "min": [ - -0.9325728876917971, - -0.9741781814425599, - -0.9680467708438051 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 0.17920311575670855, - 0.11735192172931763, - 0.2147571074457418 - ], - "min": [ - -0.17920311575670853, - 0.010827082787555313, - 0.09633786941031801 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 384, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1680, - "max": [ - 283 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 284, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 11, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 284, - "max": [ - 1.007843137254902, - 1.0078432564641915, - 1.0078432564641915 - ], - "min": [ - -1.007843137254902, - -1.0078430180456124, - -1.0078430180456124 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 284, - "max": [ - 0.14644264551011538, - 0.11746130264949387, - 0.18257497406451365 - ], - "min": [ - -0.14644264551011538, - -0.000607633603659186, - 0.06450603781136059 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 284, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1080, - "max": [ - 183 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 184, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 11, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 184, - "max": [ - 1.0025759526327545, - 0.8945289277562909, - 0.8905625962743573 - ], - "min": [ - -1.0025759526327545, - -0.9545800276831085, - -0.958546359165042 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 184, - "max": [ - 0.19806092658681176, - 0.08236686135931137, - 0.41030123864783274 - ], - "min": [ - -0.1980609265868118, - -0.04793383607310554, - 0.2637612851555894 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 184, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1296, - "max": [ - 205 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 246, - "max": [ - 15, - 0, - 0, - 0 - ], - "min": [ - 0, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 0.9769793372528226, - 0.9111420572972765, - 0.964364986559924 - ], - "min": [ - -0.9769793372528226, - -0.9135664325134428, - -0.9135641675369413 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 0.1907530239094858, - 0.11141450443993445, - 1.0107479976571123 - ], - "min": [ - -0.19087011982565344, - -0.1528595225966495, - 0.3591264797293622 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3456, - "max": [ - 605 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 606, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 0, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 606, - "max": [ - 1.008369327058979, - 1.007843137254902, - 1.0079268221761666 - ], - "min": [ - -1.0073169474508248, - -1.007843137254902, - -1.0077594523336373 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 606, - "max": [ - 0.11789775501097709, - 0.130446941162763, - 1.5080995462146922 - ], - "min": [ - -0.11798453845655156, - -0.15289304175054264, - 0.787797281959899 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 606, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 6996, - "max": [ - 1213 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1214, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 0, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1214, - "max": [ - 1.0077530290566235, - 1.0044090747833248, - 1.0080981995545177 - ], - "min": [ - -1.0077530290566237, - -1.0032545473061356, - -1.0074078585587296 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1214, - "max": [ - 0.38557311168925956, - 0.17315141730006867, - 1.522950663878735 - ], - "min": [ - -0.709612094080617, - -0.1951173024536868, - 0.8740708006261091 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1214, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 9453, - "max": [ - 1693 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1705, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 0, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1705, - "max": [ - 1.002485990524292, - 1.0076384011436912, - 1.004033386707306 - ], - "min": [ - -1.0048856202293845, - -1.007574504964492, - -1.0033382240463706 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1705, - "max": [ - 0.39746335734084126, - 0.15292484849385662, - 1.5552891912434705 - ], - "min": [ - -0.31775553250056565, - -0.2560786428425914, - 0.8214466748263234 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1705, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 7077, - "max": [ - 1235 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1236, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1236, - "max": [ - 1.006605831548279, - 1.0028427243232723, - 1.0058655418601687 - ], - "min": [ - -1.0066058315482793, - -1.0025354303565681, - -1.0073461212363897 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1236, - "max": [ - 0.4366162735104387, - 0.1882601835135722, - 1.625341915420398 - ], - "min": [ - -0.4366162735104387, - -0.09301530747411889, - 1.1331098061919387 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1236, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 19842, - "max": [ - 3349 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 3354, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 3354, - "max": [ - 1.007709416688657, - 1.0096149175774816, - 1.0044505596160884 - ], - "min": [ - -1.0077094166886573, - -1.0058039157998329, - -1.0031261771332984 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 3354, - "max": [ - 0.20081773480381349, - 0.13051300972671007, - 1.5316998015162886 - ], - "min": [ - -0.20077904565309862, - -0.065644818079227, - 1.0177261580708088 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 3354, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 8064, - "max": [ - 1353 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1352, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1352, - "max": [ - 1.0064001120773018, - 1.0058521665778817, - 0.9803937598770742 - ], - "min": [ - -1.0053042210784615, - -1.0058521665778815, - -1.0078276433196722 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1352, - "max": [ - 0.16546398835119294, - 0.14584654742514266, - 1.5681400912298362 - ], - "min": [ - -0.07691172199186373, - -0.0694408087604909, - 1.47859474582735 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1352, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 5736, - "max": [ - 1082 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1083, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1083, - "max": [ - 0.9974482555015414, - 0.9580873559502995, - 0.9835891127586364 - ], - "min": [ - -0.9974482555015415, - -0.9591867227180331, - -1.0035451550109715 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1083, - "max": [ - 0.4522937675423895, - 0.15138747733273794, - 1.566726734333057 - ], - "min": [ - -0.44917566976025447, - -0.039993296325949265, - 1.2350000599913327 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1083, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3318, - "max": [ - 760 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 761, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 761, - "max": [ - 0.9807992872069862, - 1.0078415622898174, - 1.0078398933597636 - ], - "min": [ - -0.9799787154384688, - -1.0078382244297102, - -1.0078398933597639 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 761, - "max": [ - 0.9404309334030487, - 0.14667998759861278, - 1.5726445385113423 - ], - "min": [ - -0.7416525425186493, - -0.0339243875613548, - 1.2434520183334015 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 761, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2928, - "max": [ - 660 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 661, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 661, - "max": [ - 0.948692391432968, - 0.9028303013128396, - 0.948692391432968 - ], - "min": [ - -0.9486923914329679, - -0.8985778193847805, - -0.9486923914329679 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 661, - "max": [ - 0.47209000275900265, - 0.2043406131732381, - 1.572685764484657 - ], - "min": [ - -0.4720900027590027, - -0.011313970810376587, - 1.393895211951233 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 661, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1584, - "max": [ - 439 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 440, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 440, - "max": [ - 1.007843137254902, - 0.9535032454658956, - 1.007843137254902 - ], - "min": [ - -1.007843137254902, - -0.9602222447301827, - -1.007843137254902 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 440, - "max": [ - 0.055621786817405997, - 0.3288372464980302, - 1.705380404933115 - ], - "min": [ - -0.05573769156517607, - -0.062262608303447785, - 1.0181045880478419 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 440, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 7209, - "max": [ - 1262 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1263, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1263, - "max": [ - 0.9575726852697485, - 1.007247394440221, - 1.0067170919156543 - ], - "min": [ - -0.9549034298634997, - -1.00712293994193, - -1.0076532424664966 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1263, - "max": [ - 0.1567910791688217, - 0.3417705384824238, - 1.7178137412464904 - ], - "min": [ - -0.08210939524534218, - -0.0769138446247863, - 1.0052852520549012 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1263, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3531, - "max": [ - 597 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 598, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 598, - "max": [ - 1.003164529800415, - 1.0063870598288145, - 1.006922087949865 - ], - "min": [ - -1.0029750683728387, - -0.9370606759015251, - -1.007053993028753 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 598, - "max": [ - 0.2488041471054802, - 0.12642459832332048, - 1.4473609738252078 - ], - "min": [ - -0.2488041471054802, - -0.05328752354886628, - 1.1437932003924598 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 598, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1344, - "max": [ - 246 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 247, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 247, - "max": [ - 1.0079485694567363, - 1.0078420559565227, - 0.850913127263387 - ], - "min": [ - -1.007735542456309, - -1.0078420559565227, - -0.8432027022043864 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 247, - "max": [ - 0.1738580972480378, - 0.12952224014515287, - 1.4686422433629522 - ], - "min": [ - -0.1738580972480378, - 0.04738722885374214, - 1.2091702758741776 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 247, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 5406, - "max": [ - 1198 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1199, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1199, - "max": [ - 1.007843137254902, - 1.007843137254902, - 1.007843137254902 - ], - "min": [ - -1.007843137254902, - -1.007843137254902, - -1.007843137254902 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1199, - "max": [ - 0.7168417754962961, - 0.20867953992175314, - 1.5606817732686582 - ], - "min": [ - -1.0712996307209055, - -0.1307967934206048, - 1.0161233362361868 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1199, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1098, - "max": [ - 286 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 287, - "max": [ - 1, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 287, - "max": [ - 0.9772379994392393, - 0.7406020875070607, - 0.9777558590851577 - ], - "min": [ - -0.9736476685486588, - -0.996905460544661, - -0.9807504560433181 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 287, - "max": [ - 0.16115479597855498, - 0.12317308206265881, - 1.2676969774915465 - ], - "min": [ - -0.161154795978555, - -0.1300814045410245, - 1.0103526668805987 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 287, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 954, - "max": [ - 245 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 246, - "max": [ - 3, - 0, - 0, - 0 - ], - "min": [ - 1, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 0.9738623382998448, - 0.9970439099798016, - 0.9821625281782712 - ], - "min": [ - -0.9736709022054485, - -0.9970439099798015, - -0.9808889054784586 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 0.27573772716009737, - 0.1659764384220272, - 1.3922315060830315 - ], - "min": [ - -0.5014858190962088, - -0.07564942734921101, - 1.0899146850160348 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 246, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1842, - "max": [ - 321 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 322, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 322, - "max": [ - 0.9546499062986934, - 0.9945137919164171, - 0.9620862058564729 - ], - "min": [ - -0.9569836081243029, - -0.9945137919164171, - -0.965026122448491 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 322, - "max": [ - 0.9851401470670713, - 0.12691195982153028, - 1.4712970891870052 - ], - "min": [ - -0.5681127332220092, - -0.03985994533395907, - 1.287847993515967 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 322, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1260, - "max": [ - 241 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 242, - "max": [ - 5, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 242, - "max": [ - 1.0053894508118724, - 0.9992151868109611, - 0.9445548887346307 - ], - "min": [ - -1.0057774770493602, - -0.9963006365532968, - -0.9022754419083688 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 242, - "max": [ - 0.4866266241874937, - 0.10076781427173802, - 1.5128318002937946 - ], - "min": [ - -0.5213097921219114, - -0.024178915714884192, - 1.3406611093673466 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 242, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 471, - "max": [ - 112 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 113, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 113, - "max": [ - 0.8480681253414528, - 0.8132639616143469, - 0.8512362854153501 - ], - "min": [ - -0.8446162415485756, - -0.8267298413257973, - -0.7821711970310585 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 113, - "max": [ - 0.9796491765836186, - 0.13453159791758193, - 1.4712363644582678 - ], - "min": [ - -0.614248802647919, - -0.00860028503927651, - 1.3164361214777522 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 113, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 5925, - "max": [ - 1039 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1042, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1042, - "max": [ - 1.0078434352781258, - 1.007843137254902, - 1.0078433160688363 - ], - "min": [ - -1.007842839231678, - -1.007843137254902, - -1.0078429584409676 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1042, - "max": [ - 1.0590425654335842, - 0.09434317622350144, - 1.4315311777690707 - ], - "min": [ - -0.6571115775986538, - -0.05976729830940817, - 1.3100854233817234 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1042, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 1482, - "max": [ - 325 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 358, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 358, - "max": [ - 1.0078433149001178, - 1.009210466637331, - 1.0078429572722492 - ], - "min": [ - -1.0078426592490253, - -1.0064755075118121, - -1.007843016876894 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 358, - "max": [ - 0.9623084108190065, - 0.15493000019569192, - 1.4938385765553686 - ], - "min": [ - -0.5490574876622684, - -0.06709105175299708, - 1.3005843718691343 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 358, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 8688, - "max": [ - 1561 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1562, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 3, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1562, - "max": [ - 1.0081479554082833, - 1.007843137254902, - 1.009707630148121 - ], - "min": [ - -1.0075383191015208, - -1.007843137254902, - -1.005978644361683 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1562, - "max": [ - 0.9061331546591966, - 0.11779850930645225, - 1.45664194315075 - ], - "min": [ - -0.503937402992174, - -0.041169913737699355, - 1.2907917701912672 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1562, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 768, - "max": [ - 125 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 126, - "max": [ - 6, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 126, - "max": [ - 0.9510778286877801, - 1.0093073325998643, - 0.9205925983541152 - ], - "min": [ - -0.8171772283666274, - -0.8162191433065078, - -0.919251732265248 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 126, - "max": [ - 0.9184200172606014, - 0.08676070740658465, - 1.4274674550929067 - ], - "min": [ - -0.6110139494123957, - -0.014007269899835369, - 1.2625065440949894 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 126, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 294, - "max": [ - 76 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 77, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 77, - "max": [ - 0.9601136747528526, - 1.00781965676476, - 0.9079962506013759 - ], - "min": [ - -0.9869808596723221, - -1.0018321317784926, - -1.0078196567647597 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 77, - "max": [ - -0.5943777832567954, - 0.1601568776977662, - 1.391697980044933 - ], - "min": [ - -1.1324265923917032, - -0.0664590921818948, - 1.2585643801272177 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 77, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 2286, - "max": [ - 377 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 378, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 378, - "max": [ - 0.9778070300233132, - 0.9271944915547091, - 0.9358626012708627 - ], - "min": [ - -0.9596136062752968, - -0.9348401277673012, - -0.9337106197488075 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 378, - "max": [ - -0.7961777272198802, - 0.21015804179074654, - 1.4469796944142086 - ], - "min": [ - -1.1698092994715565, - -0.049870568278014046, - 1.3076656284306651 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 378, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 231, - "max": [ - 46 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 47, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 47, - "max": [ - 0.9779778340283564, - 0.9421422088847444, - 0.9361880575909335 - ], - "min": [ - -1.0033394315663506, - -0.8695681312504937, - -0.9371975281659296 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 47, - "max": [ - -0.796201171732904, - 0.21623377138716918, - 1.4443670650138818 - ], - "min": [ - -1.121794936799048, - 0.11548879966831349, - 1.3353590987691892 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 47, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 249, - "max": [ - 67 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 68, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 68, - "max": [ - 0.9871047805337344, - 0.9144062014187082, - 0.9144397202660054 - ], - "min": [ - -0.9415134261636172, - -0.9016467402963078, - -0.9241262744454776 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 68, - "max": [ - -0.6844591234856602, - 0.13111826039361166, - 1.448840644601851 - ], - "min": [ - -1.2524172331160548, - 0.0058293069758769585, - 1.342954847686863 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 68, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 132, - "max": [ - 45 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 46, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 46, - "max": [ - 0.9509570290060605, - 0.7481275074622211, - 0.7490112143404344 - ], - "min": [ - -0.6833623521468218, - -0.9387001269003924, - -0.7474740021369036 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 46, - "max": [ - -0.6846474995832066, - 0.07239758644869954, - 1.4093968657440947 - ], - "min": [ - -0.8666229853411098, - -0.023430402391113825, - 1.3431432237844092 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 46, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 903, - "max": [ - 162 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 163, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 163, - "max": [ - 0.960080369313558, - 0.9421598354975382, - 0.949181306362152 - ], - "min": [ - -0.9639670689900716, - -0.9444547732671101, - -0.9449198683102926 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 163, - "max": [ - -0.7179843317198649, - 0.10199743258604405, - 1.5358738364623594 - ], - "min": [ - -1.123062657244216, - -0.0235392861586914, - 1.3134662638831036 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 163, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 4497, - "max": [ - 773 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 774, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 774, - "max": [ - 0.9295084925258861, - 0.931529146082261, - 0.9422573117648853 - ], - "min": [ - -0.9341153320144204, - -1.0075450357268838, - -0.9289115485023051 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 774, - "max": [ - -0.816784769194733, - 0.0707329131074115, - 1.5474347581383538 - ], - "min": [ - -1.0790589750832211, - 0.004940359751294896, - 1.4587300120765079 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 774, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 480, - "max": [ - 163 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 164, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 4, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 164, - "max": [ - 1.0078461174871407, - 1.007843137254902, - 0.011767984137815546 - ], - "min": [ - -1.0078401570226632, - -1.007843137254902, - -1.0078398589994393 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 164, - "max": [ - -0.8252332169193143, - 0.13561145422191273, - 1.539483354420096 - ], - "min": [ - -1.0637614172321443, - 0.013378847912263306, - 1.3685905295986054 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 164, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 426, - "max": [ - 98 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 99, - "max": [ - 4, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 99, - "max": [ - 1.0078408505402359, - 0.7124067788030586, - 1.0078401948891433 - ], - "min": [ - -1.0078398372612747, - -0.7150402452431474, - -1.0078404929123674 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 99, - "max": [ - 0.06651697737680284, - 0.13627099020849745, - 1.6289529697919511 - ], - "min": [ - -1.0537437616060814, - -0.032670233971937496, - 1.3681602062512797 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 99, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3156, - "max": [ - 587 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 589, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 589, - "max": [ - 1.007843137254902, - 0.9465931621252323, - 1.007843137254902 - ], - "min": [ - -1.007843137254902, - -1.006348014345356, - -1.007843137254902 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 589, - "max": [ - 0.0915547036722805, - 0.08406548871752922, - 1.7336755573247256 - ], - "min": [ - -0.0851927317595214, - -0.14370526298043435, - 1.5251358158970147 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 589, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 4626, - "max": [ - 815 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 815, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 815, - "max": [ - 1.0078290644813985, - 1.007721716516158, - 1.0017951726913452 - ], - "min": [ - -1.0073501411606285, - -1.0074574891258687, - -1.0055428687263936 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 815, - "max": [ - 0.09248313447164802, - 0.11879980917173766, - 1.7182537902548771 - ], - "min": [ - -0.09015420432287598, - -0.16193830574947737, - 1.5076659509996757 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 815, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 8925, - "max": [ - 1594 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 1609, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 1609, - "max": [ - 1.007843137254902, - 0.9991212477871018, - 1.007843137254902 - ], - "min": [ - -1.007843137254902, - -0.9930356149579963, - -1.007843137254902 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1609, - "max": [ - 0.09455850363709487, - 0.08326217966744767, - 1.7183158925657571 - ], - "min": [ - -0.07804981308648455, - -0.14850350903937684, - 1.4953729094319594 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 1609, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 3069, - "max": [ - 526 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 527, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 527, - "max": [ - 1.0073169841485865, - 1.0069106592851527, - 1.0078259482103236 - ], - "min": [ - -1.0072145237642174, - -1.0076208486276514, - -1.0067055597024805 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 527, - "max": [ - 0.11273145392850153, - 0.06463151501922088, - 1.8344616187626293 - ], - "min": [ - -0.06110630611719361, - -0.14759280214847798, - 1.6201453911250663 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 527, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 576, - "max": [ - 130 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 133, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 133, - "max": [ - 0.831161355271059, - -0.2847540764247669, - 0.963512445197386 - ], - "min": [ - -0.8290635592797223, - -0.9753518349984113, - -0.8292514331200543 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 133, - "max": [ - -0.028944918719308002, - -0.1408826182193737, - 1.6526907821020735 - ], - "min": [ - -0.09305817529770241, - -0.157474025042976, - 1.5876892666497577 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 133, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - }, - { - "componentType": 5123, - "count": 654, - "max": [ - 126 - ], - "min": [ - 0 - ], - "type": "SCALAR" - }, - { - "componentType": 5123, - "count": 127, - "max": [ - 2, - 0, - 0, - 0 - ], - "min": [ - 2, - 0, - 0, - 0 - ], - "type": "VEC4" - }, - { - "componentType": 5126, - "count": 127, - "max": [ - 0.9704353865455179, - 0.8653218080015743, - 0.9701011833022622 - ], - "min": [ - -0.9701614435981301, - -0.5769116338561563, - -0.9704956468413857 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 127, - "max": [ - -0.02805504041237522, - -0.13873470257594633, - 1.65269121689277 - ], - "min": [ - -0.09394744200187016, - -0.1422399596639185, - 1.586798815303275 - ], - "type": "VEC3" - }, - { - "componentType": 5126, - "count": 127, - "max": [ - 1.003921568627451, - 0.00392156862745098, - 0.00392156862745098, - 0.00392156862745098 - ], - "min": [ - 0.996078431372549, - -0.00392156862745098, - -0.00392156862745098, - -0.00392156862745098 - ], - "type": "VEC4" - } - ], - "materials": [ - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.16862699389457703, - 0.1411760002374649, - 0.10980399698019028, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "frameInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.7450979948043823, - 0.45097988843917847, - 0, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "componentsStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.5411760210990906, - 0.5411760210990906, - 0.5411760210990906, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "Stem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.019607799127697945, - 0.1450980007648468, - 0.17647099494934085, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "footStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.9686279892921448, - 0.9686279892921448, - 0.9686279892921448, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "footFlangeStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4823530018329621, - 0.4352940022945404, - 0.36078399419784546, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "kneeStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.2627449929714203, - 0.2627449929714203, - 0.2627449929714203, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "hipSphereStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.9882349967956544, - 0.9882349967956544, - 0.9882349967956544, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "filletStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.8980389833450317, - 0.8980389833450317, - 0.8980389833450317, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "thighStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4980390071868897, - 0.45097988843917847, - 0.3803919851779938, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "thighPadStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4588240087032318, - 0.4588240087032318, - 0.4588240087032318, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "plugStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4627450108528137, - 0.4078429937362671, - 0.3294120132923126, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "discInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.0784313976764679, - 0.18431399762630463, - 0.20784300565719604, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "TubeStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.521569013595581, - 0.4627450108528137, - 0.37647101283073425, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "componentStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.243137001991272, - 0.19607800245285037, - 0.1568630039691925, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "hexStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4980390071868897, - 0.45097988843917847, - 0.3803919851779938, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "kneeGuardStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.6823530197143555, - 0.6352940201759338, - 0.5333330035209656, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "calfStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4823530018329621, - 0.4352940022945404, - 0.36078399419784546, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "ankleBracketStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "ankleStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.35686299204826355, - 0.3254899978637696, - 0.2784309983253479, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "calfCoverStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "knee2Stem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.2705880105495453, - 0.243137001991272, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "skeletonStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.38431400060653687, - 0.34902000427246094, - 0.282353013753891, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "bracketStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4823530018329621, - 0.4352940022945404, - 0.36078399419784546, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "coverStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.19215700030326843, - 0.243137001991272, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "barStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4313730001449585, - 0.20000000298023224, - 0, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "intestineOutStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.9176470041275024, - 0.6862750053405762, - 0.2705880105495453, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "neckSinkStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.2666670083999634, - 0.3372550010681153, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "shockOutStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.4823530018329621, - 0.8705880045890808, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "shockInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.18823499977588656, - 0.1568630039691925, - 0.12156900018453598, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "discStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4980390071868897, - 0.4980390071868897, - 0.4980390071868897, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "canisterInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.5372549891471863, - 0.5372549891471863, - 0.5372549891471863, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "canisterOutStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.36078399419784546, - 0.36078399419784546, - 0.36078399419784546, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "canInnerStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4549019932746887, - 0.21960799396038055, - 0.019607799127697945, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "pipeStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.6705880165100098, - 0.4078429937362671, - 0.05882349982857704, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "off-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.2901960015296936, - 0.2901960015296936, - 0.2901960015296936, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "boltStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.20729400217533112, - 0.19880999624729156, - 0.7099869847297668, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "intestineInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.5098040103912354, - 0.4588240087032318, - 0.37647101283073425, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "armPlateStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "shoulderPodStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "armFilletStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.019607799127697945, - 0.1647060066461563, - 0.20000000298023224, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "bStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.20000000298023224, - 0.20000000298023224, - 0.20000000298023224, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "armBoltStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.02352939918637276, - 0.11764699965715408, - 0.1411760002374649, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "shoulderBStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.513725996017456, - 0.4549019932746887, - 0.3725489974021912, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "armTrussStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.268193006515503, - 0.2585029900074005, - 0.549996018409729, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "pinStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.764706015586853, - 0.48627498745918274, - 0.0784313976764679, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "radiatorStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "rpgStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.9882349967956544, - 0.9882349967956544, - 0.9882349967956544, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "bayonetStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.1254899948835373, - 0.1254899948835373, - 0.1254899948835373, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "barrel2Stem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.3529410064220429, - 0.3529410064220429, - 0.3529410064220429, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "barrel1Stem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.4196079969406128, - 0.4196079969406128, - 0.4117650091648102, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "filterOutStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.35999101400375366, - 0.35999101400375366, - 0.35999101400375366, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "filterInStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.5058820247650146, - 0.5058820247650146, - 0.5058820247650146, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "exhaustGunStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.2549020051956177, - 0.2549020051956177, - 0.2549020051956177, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "headFilletStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.8627449870109558, - 0.6509799957275391, - 0.243137001991272, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "headCaseStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.7098039984703064, - 0.5411760210990906, - 0.2549020051956177, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "headGrillStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.8274509906768799, - 0.5176470279693604, - 0.062745101749897, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "headHornStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.9882349967956544, - 0.9882349967956544, - 0.9882349967956544, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "eyeStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - }, - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 1, - 1, - 1, - 1 - ], - "metallicFactor": 0, - "roughnessFactor": 1 - }, - "emissiveFactor": [ - 0, - 0, - 0 - ], - "name": "eyeRimStem-effect", - "alphaMode": "OPAQUE", - "doubleSided": false - } - ], - "bufferViews": [ - { - "buffer": 0, - "byteOffset": 0, - "byteLength": 99484 - }, - { - "buffer": 0, - "byteOffset": 99484, - "byteLength": 596904 - }, - { - "buffer": 0, - "byteOffset": 696388, - "byteLength": 397936 - }, - { - "buffer": 0, - "byteOffset": 1094324, - "byteLength": 1152 - }, - { - "buffer": 0, - "byteOffset": 1095476, - "byteLength": 11503 - }, - { - "buffer": 0, - "byteOffset": 1106980, - "byteLength": 20204 - }, - { - "buffer": 0, - "byteOffset": 1127184, - "byteLength": 4310 - }, - { - "buffer": 0, - "byteOffset": 1131496, - "byteLength": 21274 - }, - { - "buffer": 0, - "byteOffset": 1152772, - "byteLength": 1408 - }, - { - "buffer": 0, - "byteOffset": 1154180, - "byteLength": 5506 - }, - { - "buffer": 0, - "byteOffset": 1159688, - "byteLength": 16721 - }, - { - "buffer": 0, - "byteOffset": 1176412, - "byteLength": 5597 - }, - { - "buffer": 0, - "byteOffset": 1182012, - "byteLength": 1060 - }, - { - "buffer": 0, - "byteOffset": 1183072, - "byteLength": 7505 - }, - { - "buffer": 0, - "byteOffset": 1190580, - "byteLength": 15367 - }, - { - "buffer": 0, - "byteOffset": 1205948, - "byteLength": 17190 - }, - { - "buffer": 0, - "byteOffset": 1223140, - "byteLength": 7844 - }, - { - "buffer": 0, - "byteOffset": 1230984, - "byteLength": 9066 - }, - { - "buffer": 0, - "byteOffset": 1240052, - "byteLength": 1038 - }, - { - "buffer": 0, - "byteOffset": 1241092, - "byteLength": 9712 - }, - { - "buffer": 0, - "byteOffset": 1250804, - "byteLength": 1416 - }, - { - "buffer": 0, - "byteOffset": 1252220, - "byteLength": 8285 - }, - { - "buffer": 0, - "byteOffset": 1260508, - "byteLength": 5954 - }, - { - "buffer": 0, - "byteOffset": 1266464, - "byteLength": 4127 - }, - { - "buffer": 0, - "byteOffset": 1270592, - "byteLength": 5284 - }, - { - "buffer": 0, - "byteOffset": 1275876, - "byteLength": 12741 - }, - { - "buffer": 0, - "byteOffset": 1288620, - "byteLength": 24730 - }, - { - "buffer": 0, - "byteOffset": 1313352, - "byteLength": 35443 - }, - { - "buffer": 0, - "byteOffset": 1348796, - "byteLength": 24550 - }, - { - "buffer": 0, - "byteOffset": 1373348, - "byteLength": 63931 - }, - { - "buffer": 0, - "byteOffset": 1437280, - "byteLength": 28662 - }, - { - "buffer": 0, - "byteOffset": 1465944, - "byteLength": 22531 - }, - { - "buffer": 0, - "byteOffset": 1488476, - "byteLength": 15639 - }, - { - "buffer": 0, - "byteOffset": 1504116, - "byteLength": 13095 - }, - { - "buffer": 0, - "byteOffset": 1517212, - "byteLength": 8990 - }, - { - "buffer": 0, - "byteOffset": 1526204, - "byteLength": 26418 - }, - { - "buffer": 0, - "byteOffset": 1552624, - "byteLength": 12820 - }, - { - "buffer": 0, - "byteOffset": 1565444, - "byteLength": 5203 - }, - { - "buffer": 0, - "byteOffset": 1570648, - "byteLength": 23555 - }, - { - "buffer": 0, - "byteOffset": 1594204, - "byteLength": 6177 - }, - { - "buffer": 0, - "byteOffset": 1600384, - "byteLength": 5297 - }, - { - "buffer": 0, - "byteOffset": 1605684, - "byteLength": 6957 - }, - { - "buffer": 0, - "byteOffset": 1612644, - "byteLength": 5281 - }, - { - "buffer": 0, - "byteOffset": 1617928, - "byteLength": 2568 - }, - { - "buffer": 0, - "byteOffset": 1620496, - "byteLength": 20301 - }, - { - "buffer": 0, - "byteOffset": 1640800, - "byteLength": 7583 - }, - { - "buffer": 0, - "byteOffset": 1648384, - "byteLength": 31337 - }, - { - "buffer": 0, - "byteOffset": 1679724, - "byteLength": 2854 - }, - { - "buffer": 0, - "byteOffset": 1682580, - "byteLength": 1801 - }, - { - "buffer": 0, - "byteOffset": 1684384, - "byteLength": 8203 - }, - { - "buffer": 0, - "byteOffset": 1692588, - "byteLength": 1226 - }, - { - "buffer": 0, - "byteOffset": 1693816, - "byteLength": 1646 - }, - { - "buffer": 0, - "byteOffset": 1695464, - "byteLength": 1122 - }, - { - "buffer": 0, - "byteOffset": 1696588, - "byteLength": 3572 - }, - { - "buffer": 0, - "byteOffset": 1700160, - "byteLength": 16602 - }, - { - "buffer": 0, - "byteOffset": 1716764, - "byteLength": 3343 - }, - { - "buffer": 0, - "byteOffset": 1720108, - "byteLength": 2232 - }, - { - "buffer": 0, - "byteOffset": 1722340, - "byteLength": 12161 - }, - { - "buffer": 0, - "byteOffset": 1734504, - "byteLength": 16658 - }, - { - "buffer": 0, - "byteOffset": 1751164, - "byteLength": 34235 - }, - { - "buffer": 0, - "byteOffset": 1785400, - "byteLength": 10910 - }, - { - "buffer": 0, - "byteOffset": 1796312, - "byteLength": 2905 - }, - { - "buffer": 0, - "byteOffset": 1799220, - "byteLength": 2790 - } - ], - "buffers": [ - { - "name": "BrainStem0", - "byteLength": 1802012, - "uri": "BrainStem0.bin" - } - ], - "extensionsRequired": [ - "KHR_draco_mesh_compression" - ], - "extensionsUsed": [ - "KHR_draco_mesh_compression" - ] -} diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.glb b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.glb new file mode 100644 index 0000000000000000000000000000000000000000..c600aeb2fa4df27b6537fe3960d589d82a290a36 Binary files /dev/null and b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.glb differ diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.gltf b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.gltf deleted file mode 100644 index a4e693500e7c7b8a971791d8d3cd8873d7048e0b..0000000000000000000000000000000000000000 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/BrainStem/glTF-Meshopt/BrainStem.gltf +++ /dev/null @@ -1,4255 +0,0 @@ -{ - "buffers": [ - { - "uri": "BrainStem.bin", - "byteLength": 347840 - }, - { - "byteLength": 1302348, - "extensions": { - "EXT_meshopt_compression": { - "fallback": true - } - } - } - ], - "asset": { - "version": "2.0", - "generator": "gltfpack 0.18" - }, - "extensionsUsed": [ - "KHR_mesh_quantization", - "EXT_meshopt_compression" - ], - "extensionsRequired": [ - "KHR_mesh_quantization", - "EXT_meshopt_compression" - ], - "bufferViews": [ - { - "buffer": 1, - "byteOffset": 0, - "byteLength": 136336, - "byteStride": 4, - "target": 34962, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 0, - "byteLength": 2646, - "byteStride": 4, - "mode": "ATTRIBUTES", - "count": 34084 - } - } - }, - { - "buffer": 1, - "byteOffset": 136336, - "byteLength": 136336, - "byteStride": 4, - "target": 34962, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 2648, - "byteLength": 68972, - "byteStride": 4, - "mode": "ATTRIBUTES", - "filter": "OCTAHEDRAL", - "count": 34084 - } - } - }, - { - "buffer": 1, - "byteOffset": 272672, - "byteLength": 409008, - "byteStride": 12, - "target": 34962, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 71620, - "byteLength": 148194, - "byteStride": 12, - "mode": "ATTRIBUTES", - "filter": "EXPONENTIAL", - "count": 34084 - } - } - }, - { - "buffer": 1, - "byteOffset": 681680, - "byteLength": 136336, - "byteStride": 4, - "target": 34962, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 219816, - "byteLength": 2165, - "byteStride": 4, - "mode": "ATTRIBUTES", - "count": 34084 - } - } - }, - { - "buffer": 1, - "byteOffset": 818016, - "byteLength": 369996, - "target": 34963, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 221984, - "byteLength": 68380, - "byteStride": 2, - "mode": "TRIANGLES", - "count": 184998 - } - } - }, - { - "buffer": 1, - "byteOffset": 1188012, - "byteLength": 1152, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 290364, - "byteLength": 1044, - "byteStride": 64, - "mode": "ATTRIBUTES", - "count": 18 - } - } - }, - { - "buffer": 1, - "byteOffset": 1189164, - "byteLength": 4192, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 291408, - "byteLength": 2542, - "byteStride": 4, - "mode": "ATTRIBUTES", - "count": 1048 - } - } - }, - { - "buffer": 1, - "byteOffset": 1193356, - "byteLength": 108992, - "extensions": { - "EXT_meshopt_compression": { - "buffer": 0, - "byteOffset": 293952, - "byteLength": 53886, - "byteStride": 8, - "mode": "ATTRIBUTES", - "filter": "QUATERNION", - "count": 13624 - } - } - } - ], - "accessors": [ - { - "bufferView": 0, - "byteOffset": 0, - "componentType": 5121, - "count": 491, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 0, - "componentType": 5120, - "count": 491, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 0, - "componentType": 5126, - "count": 491, - "type": "VEC3", - "min": [ - -0.274337769, - -0.150039673, - 1.04803467 - ], - "max": [ - 0.274337769, - -0.0327472687, - 1.45635986 - ] - }, - { - "bufferView": 3, - "byteOffset": 0, - "componentType": 5121, - "count": 491, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 0, - "componentType": 5123, - "count": 2778, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 1964, - "componentType": 5121, - "count": 1019, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 1964, - "componentType": 5120, - "count": 1019, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 5892, - "componentType": 5126, - "count": 1019, - "type": "VEC3", - "min": [ - -0.608001709, - -0.0609989166, - 1.28198242 - ], - "max": [ - 1.06573486, - 0.183105469, - 1.47711182 - ] - }, - { - "bufferView": 3, - "byteOffset": 1964, - "componentType": 5121, - "count": 1019, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 5556, - "componentType": 5123, - "count": 5928, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 6040, - "componentType": 5121, - "count": 195, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 6040, - "componentType": 5120, - "count": 195, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 18120, - "componentType": 5126, - "count": 195, - "type": "VEC3", - "min": [ - 1.05804443, - -0.0497570038, - 1.3069458 - ], - "max": [ - 1.16253662, - 0.0700035095, - 1.43737793 - ] - }, - { - "bufferView": 3, - "byteOffset": 6040, - "componentType": 5121, - "count": 195, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 17412, - "componentType": 5123, - "count": 1134, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 6820, - "componentType": 5121, - "count": 1064, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 6820, - "componentType": 5120, - "count": 1064, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 20460, - "componentType": 5126, - "count": 1064, - "type": "VEC3", - "min": [ - -0.299728394, - -0.184059143, - -0.000540286303 - ], - "max": [ - 0.299728394, - 0.156242371, - 1.01763916 - ] - }, - { - "bufferView": 3, - "byteOffset": 6820, - "componentType": 5121, - "count": 1064, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 19680, - "componentType": 5123, - "count": 6240, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 11076, - "componentType": 5121, - "count": 56, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 11076, - "componentType": 5120, - "count": 56, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 33228, - "componentType": 5126, - "count": 56, - "type": "VEC3", - "min": [ - -0.138519287, - -0.149559021, - 0.00915718079 - ], - "max": [ - 0.138519287, - -0.00933551788, - 0.0813789368 - ] - }, - { - "bufferView": 3, - "byteOffset": 11076, - "componentType": 5121, - "count": 56, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 32160, - "componentType": 5123, - "count": 312, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 11300, - "componentType": 5121, - "count": 2330, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 11300, - "componentType": 5120, - "count": 2330, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 33900, - "componentType": 5126, - "count": 2330, - "type": "VEC3", - "min": [ - -0.317398071, - -0.255722046, - 0.0965118408 - ], - "max": [ - 0.396957397, - 0.15247345, - 1.55493164 - ] - }, - { - "bufferView": 3, - "byteOffset": 11300, - "componentType": 5121, - "count": 2330, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 32784, - "componentType": 5123, - "count": 13245, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 20620, - "componentType": 5121, - "count": 802, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 20620, - "componentType": 5120, - "count": 802, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 61860, - "componentType": 5126, - "count": 802, - "type": "VEC3", - "min": [ - -0.231025696, - -0.0832328796, - 0.790252686 - ], - "max": [ - 0.231025696, - 0.0827407837, - 0.971557617 - ] - }, - { - "bufferView": 3, - "byteOffset": 20620, - "componentType": 5121, - "count": 802, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 59274, - "componentType": 5123, - "count": 4740, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 23828, - "componentType": 5121, - "count": 455, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 23828, - "componentType": 5120, - "count": 455, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 71484, - "componentType": 5126, - "count": 455, - "type": "VEC3", - "min": [ - -1.25213623, - -0.157440186, - 0.0280275345 - ], - "max": [ - 0.212913513, - 0.134750366, - 1.65264893 - ] - }, - { - "bufferView": 3, - "byteOffset": 23828, - "componentType": 5121, - "count": 455, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 68754, - "componentType": 5123, - "count": 1737, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 25648, - "componentType": 5121, - "count": 40, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 25648, - "componentType": 5120, - "count": 40, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 76944, - "componentType": 5126, - "count": 40, - "type": "VEC3", - "min": [ - -0.202354431, - -0.09375, - 0.544677734 - ], - "max": [ - 0.202354431, - 0.0949478149, - 0.793731689 - ] - }, - { - "bufferView": 3, - "byteOffset": 25648, - "componentType": 5121, - "count": 40, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 72228, - "componentType": 5123, - "count": 216, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 25808, - "componentType": 5121, - "count": 812, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 25808, - "componentType": 5120, - "count": 812, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 77424, - "componentType": 5126, - "count": 812, - "type": "VEC3", - "min": [ - -0.216316223, - -0.133842468, - 0.387557983 - ], - "max": [ - 0.216316223, - -0.00897932053, - 0.811218262 - ] - }, - { - "bufferView": 3, - "byteOffset": 25808, - "componentType": 5121, - "count": 812, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 72660, - "componentType": 5123, - "count": 4908, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 29056, - "componentType": 5121, - "count": 752, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 29056, - "componentType": 5120, - "count": 752, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 87168, - "componentType": 5126, - "count": 752, - "type": "VEC3", - "min": [ - -0.235534668, - -0.0799713135, - 0.700500488 - ], - "max": [ - 0.235534668, - 0.115581512, - 0.912109375 - ] - }, - { - "bufferView": 3, - "byteOffset": 29056, - "componentType": 5121, - "count": 752, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 82476, - "componentType": 5123, - "count": 3696, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 32064, - "componentType": 5121, - "count": 845, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 32064, - "componentType": 5120, - "count": 845, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 96192, - "componentType": 5126, - "count": 845, - "type": "VEC3", - "min": [ - -0.481231689, - -0.158683777, - 0.842041016 - ], - "max": [ - 0.955841064, - 0.113918304, - 1.70410156 - ] - }, - { - "bufferView": 3, - "byteOffset": 32064, - "componentType": 5121, - "count": 845, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 89868, - "componentType": 5123, - "count": 2286, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 35444, - "componentType": 5121, - "count": 384, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 35444, - "componentType": 5120, - "count": 384, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 106332, - "componentType": 5126, - "count": 384, - "type": "VEC3", - "min": [ - -0.23765564, - 0.00993919373, - 0.495483398 - ], - "max": [ - 0.23765564, - 0.0749855042, - 0.666534424 - ] - }, - { - "bufferView": 3, - "byteOffset": 35444, - "componentType": 5121, - "count": 384, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 94440, - "componentType": 5123, - "count": 2160, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 36980, - "componentType": 5121, - "count": 416, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 36980, - "componentType": 5120, - "count": 416, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 110940, - "componentType": 5126, - "count": 416, - "type": "VEC3", - "min": [ - -0.222312927, - -0.0233812332, - 0.26133728 - ], - "max": [ - 0.222312927, - 0.163825989, - 0.808837891 - ] - }, - { - "bufferView": 3, - "byteOffset": 36980, - "componentType": 5121, - "count": 416, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 98760, - "componentType": 5123, - "count": 2400, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 38644, - "componentType": 5121, - "count": 40, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 38644, - "componentType": 5120, - "count": 40, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 115932, - "componentType": 5126, - "count": 40, - "type": "VEC3", - "min": [ - -0.200088501, - -0.00245630741, - 0.480865479 - ], - "max": [ - 0.200088501, - 0.069519043, - 0.672210693 - ] - }, - { - "bufferView": 3, - "byteOffset": 38644, - "componentType": 5121, - "count": 40, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 103560, - "componentType": 5123, - "count": 192, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 38804, - "componentType": 5121, - "count": 56, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 38804, - "componentType": 5120, - "count": 56, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 116412, - "componentType": 5126, - "count": 56, - "type": "VEC3", - "min": [ - -0.176177979, - 0.0109124184, - 0.23135376 - ], - "max": [ - 0.176177979, - 0.159118652, - 0.399612427 - ] - }, - { - "bufferView": 3, - "byteOffset": 38804, - "componentType": 5121, - "count": 56, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 103944, - "componentType": 5123, - "count": 312, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 39028, - "componentType": 5121, - "count": 1013, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 39028, - "componentType": 5120, - "count": 1013, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 117084, - "componentType": 5126, - "count": 1013, - "type": "VEC3", - "min": [ - -1.12164307, - -0.152542114, - 0.0646476746 - ], - "max": [ - 0.978881836, - 0.216117859, - 1.65264893 - ] - }, - { - "bufferView": 3, - "byteOffset": 39028, - "componentType": 5121, - "count": 1013, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 104568, - "componentType": 5123, - "count": 5592, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 43080, - "componentType": 5121, - "count": 184, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 43080, - "componentType": 5120, - "count": 184, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 129240, - "componentType": 5126, - "count": 184, - "type": "VEC3", - "min": [ - -0.197868347, - -0.0477409363, - 0.263961792 - ], - "max": [ - 0.197868347, - 0.0822525024, - 0.410110474 - ] - }, - { - "bufferView": 3, - "byteOffset": 43080, - "componentType": 5121, - "count": 184, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 115752, - "componentType": 5123, - "count": 1080, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 43816, - "componentType": 5121, - "count": 606, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 43816, - "componentType": 5120, - "count": 606, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 131448, - "componentType": 5126, - "count": 606, - "type": "VEC3", - "min": [ - -0.11763382, - -0.152542114, - 0.788146973 - ], - "max": [ - 0.11763382, - 0.129989624, - 1.50775146 - ] - }, - { - "bufferView": 3, - "byteOffset": 43816, - "componentType": 5121, - "count": 606, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 117912, - "componentType": 5123, - "count": 3456, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 46240, - "componentType": 5121, - "count": 1214, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 46240, - "componentType": 5120, - "count": 1214, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 138720, - "componentType": 5126, - "count": 1214, - "type": "VEC3", - "min": [ - -0.709075928, - -0.194580078, - 0.874603271 - ], - "max": [ - 0.385040283, - 0.172561646, - 1.5223999 - ] - }, - { - "bufferView": 3, - "byteOffset": 46240, - "componentType": 5121, - "count": 1214, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 124824, - "componentType": 5123, - "count": 6996, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 51096, - "componentType": 5121, - "count": 1236, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 51096, - "componentType": 5120, - "count": 1236, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 153288, - "componentType": 5126, - "count": 1236, - "type": "VEC3", - "min": [ - -0.436187744, - -0.092590332, - 1.13354492 - ], - "max": [ - 0.436187744, - 0.187843323, - 1.62487793 - ] - }, - { - "bufferView": 3, - "byteOffset": 51096, - "componentType": 5121, - "count": 1236, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 138816, - "componentType": 5123, - "count": 7077, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 56040, - "componentType": 5121, - "count": 3350, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 56040, - "componentType": 5120, - "count": 3350, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 168120, - "componentType": 5126, - "count": 3350, - "type": "VEC3", - "min": [ - -0.200531006, - -0.0653953552, - 1.01800537 - ], - "max": [ - 0.200531006, - 0.130363464, - 1.53143311 - ] - }, - { - "bufferView": 3, - "byteOffset": 56040, - "componentType": 5121, - "count": 3350, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 152970, - "componentType": 5123, - "count": 19842, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 69440, - "componentType": 5121, - "count": 1350, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 69440, - "componentType": 5120, - "count": 1350, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 208320, - "componentType": 5126, - "count": 1350, - "type": "VEC3", - "min": [ - -0.0767936707, - -0.0693206787, - 1.47869873 - ], - "max": [ - 0.165344238, - 0.145690918, - 1.56799316 - ] - }, - { - "bufferView": 3, - "byteOffset": 69440, - "componentType": 5121, - "count": 1350, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 192654, - "componentType": 5123, - "count": 8064, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 74840, - "componentType": 5121, - "count": 1083, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 74840, - "componentType": 5120, - "count": 1083, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 224520, - "componentType": 5126, - "count": 1083, - "type": "VEC3", - "min": [ - -0.448730469, - -0.0395526886, - 1.2354126 - ], - "max": [ - 0.451858521, - 0.150924683, - 1.56628418 - ] - }, - { - "bufferView": 3, - "byteOffset": 74840, - "componentType": 5121, - "count": 1083, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 208782, - "componentType": 5123, - "count": 5736, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 79172, - "componentType": 5121, - "count": 761, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 79172, - "componentType": 5120, - "count": 761, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 237516, - "componentType": 5126, - "count": 761, - "type": "VEC3", - "min": [ - -0.740844727, - -0.0331039429, - 1.2442627 - ], - "max": [ - 0.939605713, - 0.145881653, - 1.57220459 - ] - }, - { - "bufferView": 3, - "byteOffset": 79172, - "componentType": 5121, - "count": 761, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 220254, - "componentType": 5123, - "count": 3318, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 82216, - "componentType": 5121, - "count": 661, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 82216, - "componentType": 5120, - "count": 661, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 246648, - "componentType": 5126, - "count": 661, - "type": "VEC3", - "min": [ - -0.471633911, - -0.0108532906, - 1.39434814 - ], - "max": [ - 0.471633911, - 0.20401001, - 1.57220459 - ] - }, - { - "bufferView": 3, - "byteOffset": 82216, - "componentType": 5121, - "count": 661, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 226890, - "componentType": 5123, - "count": 2928, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 84860, - "componentType": 5121, - "count": 440, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 84860, - "componentType": 5120, - "count": 440, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 254580, - "componentType": 5126, - "count": 440, - "type": "VEC3", - "min": [ - -0.0554027557, - -0.0619277954, - 1.01843262 - ], - "max": [ - 0.0554027557, - 0.328491211, - 1.70501709 - ] - }, - { - "bufferView": 3, - "byteOffset": 84860, - "componentType": 5121, - "count": 440, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 232746, - "componentType": 5123, - "count": 1584, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 86620, - "componentType": 5121, - "count": 1263, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 86620, - "componentType": 5120, - "count": 1263, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 259860, - "componentType": 5126, - "count": 1263, - "type": "VEC3", - "min": [ - -0.0817604065, - -0.0765647888, - 1.00561523 - ], - "max": [ - 0.156585693, - 0.341384888, - 1.71746826 - ] - }, - { - "bufferView": 3, - "byteOffset": 86620, - "componentType": 5121, - "count": 1263, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 235914, - "componentType": 5123, - "count": 7209, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 91672, - "componentType": 5121, - "count": 598, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 91672, - "componentType": 5120, - "count": 598, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 275016, - "componentType": 5126, - "count": 598, - "type": "VEC3", - "min": [ - -0.248558044, - -0.0530452728, - 1.14404297 - ], - "max": [ - 0.248558044, - 0.126174927, - 1.44714355 - ] - }, - { - "bufferView": 3, - "byteOffset": 91672, - "componentType": 5121, - "count": 598, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 250332, - "componentType": 5123, - "count": 3531, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 94064, - "componentType": 5121, - "count": 247, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 94064, - "componentType": 5120, - "count": 247, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 282192, - "componentType": 5126, - "count": 247, - "type": "VEC3", - "min": [ - -0.173690796, - 0.0475578308, - 1.20935059 - ], - "max": [ - 0.173690796, - 0.129386902, - 1.46850586 - ] - }, - { - "bufferView": 3, - "byteOffset": 94064, - "componentType": 5121, - "count": 247, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 257394, - "componentType": 5123, - "count": 1344, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 95052, - "componentType": 5121, - "count": 1199, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 95052, - "componentType": 5120, - "count": 1199, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 285156, - "componentType": 5126, - "count": 1199, - "type": "VEC3", - "min": [ - -1.07043457, - -0.129920959, - 1.01696777 - ], - "max": [ - 0.7159729, - 0.207572937, - 1.55938721 - ] - }, - { - "bufferView": 3, - "byteOffset": 95052, - "componentType": 5121, - "count": 1199, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 260082, - "componentType": 5123, - "count": 5406, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 99848, - "componentType": 5121, - "count": 287, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 99848, - "componentType": 5120, - "count": 287, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 299544, - "componentType": 5126, - "count": 287, - "type": "VEC3", - "min": [ - -0.160995483, - -0.129920959, - 1.01049805 - ], - "max": [ - 0.160995483, - 0.123073578, - 1.26751709 - ] - }, - { - "bufferView": 3, - "byteOffset": 99848, - "componentType": 5121, - "count": 287, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 270894, - "componentType": 5123, - "count": 1098, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 100996, - "componentType": 5121, - "count": 246, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 100996, - "componentType": 5120, - "count": 246, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 302988, - "componentType": 5126, - "count": 246, - "type": "VEC3", - "min": [ - -0.501098633, - -0.0752716064, - 1.090271 - ], - "max": [ - 0.275360107, - 0.165626526, - 1.3918457 - ] - }, - { - "bufferView": 3, - "byteOffset": 100996, - "componentType": 5121, - "count": 246, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 273090, - "componentType": 5123, - "count": 954, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 101980, - "componentType": 5121, - "count": 322, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 101980, - "componentType": 5120, - "count": 322, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 305940, - "componentType": 5126, - "count": 322, - "type": "VEC3", - "min": [ - -0.567352295, - -0.0391025543, - 1.28863525 - ], - "max": [ - 0.984375, - 0.126083374, - 1.47021484 - ] - }, - { - "bufferView": 3, - "byteOffset": 101980, - "componentType": 5121, - "count": 322, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 274998, - "componentType": 5123, - "count": 1842, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 103268, - "componentType": 5121, - "count": 1040, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 103268, - "componentType": 5120, - "count": 1040, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 309804, - "componentType": 5126, - "count": 1040, - "type": "VEC3", - "min": [ - -0.656280518, - -0.0589294434, - 1.31091309 - ], - "max": [ - 1.05822754, - 0.0934638977, - 1.43054199 - ] - }, - { - "bufferView": 3, - "byteOffset": 103268, - "componentType": 5121, - "count": 1040, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 278682, - "componentType": 5123, - "count": 5925, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 107428, - "componentType": 5121, - "count": 326, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 107428, - "componentType": 5120, - "count": 326, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 322284, - "componentType": 5126, - "count": 326, - "type": "VEC3", - "min": [ - -0.548309326, - -0.0663528442, - 1.30133057 - ], - "max": [ - 0.961578369, - 0.153846741, - 1.49291992 - ] - }, - { - "bufferView": 3, - "byteOffset": 107428, - "componentType": 5121, - "count": 326, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 290532, - "componentType": 5123, - "count": 1482, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 108732, - "componentType": 5121, - "count": 1562, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 108732, - "componentType": 5120, - "count": 1562, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 326196, - "componentType": 5126, - "count": 1562, - "type": "VEC3", - "min": [ - -0.503234863, - -0.0404815674, - 1.29150391 - ], - "max": [ - 0.905456543, - 0.117263794, - 1.45629883 - ] - }, - { - "bufferView": 3, - "byteOffset": 108732, - "componentType": 5121, - "count": 1562, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 293496, - "componentType": 5123, - "count": 8688, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 114980, - "componentType": 5121, - "count": 126, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 114980, - "componentType": 5120, - "count": 126, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 344940, - "componentType": 5126, - "count": 126, - "type": "VEC3", - "min": [ - -0.61026001, - -0.0132608414, - 1.26324463 - ], - "max": [ - 0.917663574, - 0.0857200623, - 1.42675781 - ] - }, - { - "bufferView": 3, - "byteOffset": 114980, - "componentType": 5121, - "count": 126, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 310872, - "componentType": 5123, - "count": 768, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 115484, - "componentType": 5121, - "count": 77, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 115484, - "componentType": 5120, - "count": 77, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 346452, - "componentType": 5126, - "count": 77, - "type": "VEC3", - "min": [ - -1.13214111, - -0.0661964417, - 1.2588501 - ], - "max": [ - -0.59463501, - 0.159858704, - 1.39141846 - ] - }, - { - "bufferView": 3, - "byteOffset": 115484, - "componentType": 5121, - "count": 77, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 312408, - "componentType": 5123, - "count": 294, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 115792, - "componentType": 5121, - "count": 378, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 115792, - "componentType": 5120, - "count": 378, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 347376, - "componentType": 5126, - "count": 378, - "type": "VEC3", - "min": [ - -1.1696167, - -0.0496883392, - 1.30786133 - ], - "max": [ - -0.796356201, - 0.209983826, - 1.44683838 - ] - }, - { - "bufferView": 3, - "byteOffset": 115792, - "componentType": 5121, - "count": 378, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 312996, - "componentType": 5123, - "count": 2286, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 117304, - "componentType": 5121, - "count": 46, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 117304, - "componentType": 5120, - "count": 46, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 351912, - "componentType": 5126, - "count": 46, - "type": "VEC3", - "min": [ - -0.866546631, - -0.0233411789, - 1.34326172 - ], - "max": [ - -0.6847229, - 0.0723266602, - 1.40930176 - ] - }, - { - "bufferView": 3, - "byteOffset": 117304, - "componentType": 5121, - "count": 46, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 317568, - "componentType": 5123, - "count": 132, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 117488, - "componentType": 5121, - "count": 163, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 117488, - "componentType": 5120, - "count": 163, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 352464, - "componentType": 5126, - "count": 163, - "type": "VEC3", - "min": [ - -1.12286377, - -0.0233411789, - 1.31365967 - ], - "max": [ - -0.718170166, - 0.101772308, - 1.5357666 - ] - }, - { - "bufferView": 3, - "byteOffset": 117488, - "componentType": 5121, - "count": 163, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 317832, - "componentType": 5123, - "count": 903, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 118140, - "componentType": 5121, - "count": 774, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 118140, - "componentType": 5120, - "count": 774, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 354420, - "componentType": 5126, - "count": 774, - "type": "VEC3", - "min": [ - -1.07891846, - 0.00506830215, - 1.4588623 - ], - "max": [ - -0.816925049, - 0.0705680847, - 1.54724121 - ] - }, - { - "bufferView": 3, - "byteOffset": 118140, - "componentType": 5121, - "count": 774, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 319638, - "componentType": 5123, - "count": 4497, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 121236, - "componentType": 5121, - "count": 164, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 121236, - "componentType": 5120, - "count": 164, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 363708, - "componentType": 5126, - "count": 164, - "type": "VEC3", - "min": [ - -1.06365967, - 0.0134954453, - 1.36871338 - ], - "max": [ - -0.8253479, - 0.135498047, - 1.53936768 - ] - }, - { - "bufferView": 3, - "byteOffset": 121236, - "componentType": 5121, - "count": 164, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 328632, - "componentType": 5123, - "count": 480, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 121892, - "componentType": 5121, - "count": 99, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 121892, - "componentType": 5120, - "count": 99, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 365676, - "componentType": 5126, - "count": 99, - "type": "VEC3", - "min": [ - -1.05322266, - -0.0321235657, - 1.36871338 - ], - "max": [ - 0.0659713745, - 0.135498047, - 1.62860107 - ] - }, - { - "bufferView": 3, - "byteOffset": 121892, - "componentType": 5121, - "count": 99, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 329592, - "componentType": 5123, - "count": 426, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 122288, - "componentType": 5121, - "count": 588, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 122288, - "componentType": 5120, - "count": 588, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 366864, - "componentType": 5126, - "count": 588, - "type": "VEC3", - "min": [ - -0.0850830078, - -0.143592834, - 1.52526855 - ], - "max": [ - 0.0914535522, - 0.0839538574, - 1.73358154 - ] - }, - { - "bufferView": 3, - "byteOffset": 122288, - "componentType": 5121, - "count": 588, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 330444, - "componentType": 5123, - "count": 3156, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 124640, - "componentType": 5121, - "count": 815, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 124640, - "componentType": 5120, - "count": 815, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 373920, - "componentType": 5126, - "count": 815, - "type": "VEC3", - "min": [ - -0.0900154114, - -0.161804199, - 1.5078125 - ], - "max": [ - 0.0922966003, - 0.118663788, - 1.71807861 - ] - }, - { - "bufferView": 3, - "byteOffset": 124640, - "componentType": 5121, - "count": 815, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 336756, - "componentType": 5123, - "count": 4626, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 127900, - "componentType": 5121, - "count": 1583, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 127900, - "componentType": 5120, - "count": 1583, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 383700, - "componentType": 5126, - "count": 1583, - "type": "VEC3", - "min": [ - -0.0779380798, - -0.148391724, - 1.4954834 - ], - "max": [ - 0.0943908691, - 0.0831489563, - 1.71820068 - ] - }, - { - "bufferView": 3, - "byteOffset": 127900, - "componentType": 5121, - "count": 1583, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 346008, - "componentType": 5123, - "count": 8925, - "type": "SCALAR" - }, - { - "bufferView": 0, - "byteOffset": 134232, - "componentType": 5121, - "count": 526, - "type": "VEC4" - }, - { - "bufferView": 1, - "byteOffset": 134232, - "componentType": 5120, - "count": 526, - "type": "VEC3", - "normalized": true - }, - { - "bufferView": 2, - "byteOffset": 402696, - "componentType": 5126, - "count": 526, - "type": "VEC3", - "min": [ - -0.061000824, - -0.147491455, - 1.62023926 - ], - "max": [ - 0.112598419, - 0.0645370483, - 1.83435059 - ] - }, - { - "bufferView": 3, - "byteOffset": 134232, - "componentType": 5121, - "count": 526, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 4, - "byteOffset": 363858, - "componentType": 5123, - "count": 3069, - "type": "SCALAR" - }, - { - "bufferView": 5, - "byteOffset": 0, - "componentType": 5126, - "count": 18, - "type": "MAT4" - }, - { - "bufferView": 6, - "byteOffset": 0, - "componentType": 5126, - "count": 1048, - "type": "SCALAR", - "min": [ - 0 - ], - "max": [ - 34.9000015 - ] - }, - { - "bufferView": 7, - "byteOffset": 0, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 8384, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 16768, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 25152, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 33536, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 41920, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 50304, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 58688, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 67072, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 75456, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 83840, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 92224, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - }, - { - "bufferView": 7, - "byteOffset": 100608, - "componentType": 5122, - "count": 1048, - "type": "VEC4", - "normalized": true - } - ], - "materials": [ - { - "name": "frameInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.168626994, - 0.141176, - 0.109803997, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "componentsStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.745097995, - 0.450979888, - 0, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "Stem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.541176021, - 0.541176021, - 0.541176021, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "footStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.0196077991, - 0.145098001, - 0.176470995, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "footFlangeStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.968627989, - 0.968627989, - 0.968627989, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "kneeStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.482353002, - 0.435294002, - 0.360783994, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "hipSphereStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.262744993, - 0.262744993, - 0.262744993, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "filletStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.988234997, - 0.988234997, - 0.988234997, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "thighStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.898038983, - 0.898038983, - 0.898038983, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "thighPadStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.498039007, - 0.450979888, - 0.380391985, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "plugStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.458824009, - 0.458824009, - 0.458824009, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "discInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.462745011, - 0.407842994, - 0.329412013, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "TubeStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.0784313977, - 0.184313998, - 0.207843006, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "componentStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.521569014, - 0.462745011, - 0.376471013, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "hexStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.243137002, - 0.196078002, - 0.156863004, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "calfStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.68235302, - 0.63529402, - 0.533333004, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "ankleStem-effect", - "pbrMetallicRoughness": { - "metallicFactor": 0 - } - }, - { - "name": "calfCoverStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.356862992, - 0.325489998, - 0.278430998, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "skeletonStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.270588011, - 0.243137002, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "bracketStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.384314001, - 0.349020004, - 0.282353014, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "barStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.192157, - 0.243137002, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "intestineOutStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.431373, - 0.200000003, - 0, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "neckSinkStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.917647004, - 0.686275005, - 0.270588011, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "shockOutStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.266667008, - 0.337255001, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "shockInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0, - 0.482353002, - 0.870588005, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "discStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.188235, - 0.156863004, - 0.121569, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "canisterInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.498039007, - 0.498039007, - 0.498039007, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "canisterOutStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.537254989, - 0.537254989, - 0.537254989, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "canInnerStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.360783994, - 0.360783994, - 0.360783994, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "pipeStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.454901993, - 0.219607994, - 0.0196077991, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "off-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.670588017, - 0.407842994, - 0.0588234998, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "boltStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.290196002, - 0.290196002, - 0.290196002, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "intestineInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.207294002, - 0.198809996, - 0.709986985, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "armPlateStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.50980401, - 0.458824009, - 0.376471013, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "bStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.0196077991, - 0.164706007, - 0.200000003, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "armBoltStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.200000003, - 0.200000003, - 0.200000003, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "shoulderBStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.0235293992, - 0.117647, - 0.141176, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "armTrussStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.513725996, - 0.454901993, - 0.372548997, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "pinStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.268193007, - 0.25850299, - 0.549996018, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "radiatorStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.764706016, - 0.486274987, - 0.0784313977, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "barrel2Stem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.125489995, - 0.125489995, - 0.125489995, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "barrel1Stem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.352941006, - 0.352941006, - 0.352941006, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "filterOutStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.419607997, - 0.419607997, - 0.411765009, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "filterInStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.359991014, - 0.359991014, - 0.359991014, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "exhaustGunStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.505882025, - 0.505882025, - 0.505882025, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "headFilletStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.254902005, - 0.254902005, - 0.254902005, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "headCaseStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.862744987, - 0.650979996, - 0.243137002, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "headGrillStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.709803998, - 0.541176021, - 0.254902005, - 1 - ], - "metallicFactor": 0 - } - }, - { - "name": "headHornStem-effect", - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.827450991, - 0.517647028, - 0.0627451017, - 1 - ], - "metallicFactor": 0 - } - } - ], - "meshes": [ - { - "primitives": [ - { - "attributes": { - "JOINTS_0": 0, - "NORMAL": 1, - "POSITION": 2, - "WEIGHTS_0": 3 - }, - "indices": 4, - "material": 0 - }, - { - "attributes": { - "JOINTS_0": 5, - "NORMAL": 6, - "POSITION": 7, - "WEIGHTS_0": 8 - }, - "indices": 9, - "material": 1 - }, - { - "attributes": { - "JOINTS_0": 10, - "NORMAL": 11, - "POSITION": 12, - "WEIGHTS_0": 13 - }, - "indices": 14, - "material": 2 - }, - { - "attributes": { - "JOINTS_0": 15, - "NORMAL": 16, - "POSITION": 17, - "WEIGHTS_0": 18 - }, - "indices": 19, - "material": 3 - }, - { - "attributes": { - "JOINTS_0": 20, - "NORMAL": 21, - "POSITION": 22, - "WEIGHTS_0": 23 - }, - "indices": 24, - "material": 4 - }, - { - "attributes": { - "JOINTS_0": 25, - "NORMAL": 26, - "POSITION": 27, - "WEIGHTS_0": 28 - }, - "indices": 29, - "material": 5 - }, - { - "attributes": { - "JOINTS_0": 30, - "NORMAL": 31, - "POSITION": 32, - "WEIGHTS_0": 33 - }, - "indices": 34, - "material": 6 - }, - { - "attributes": { - "JOINTS_0": 35, - "NORMAL": 36, - "POSITION": 37, - "WEIGHTS_0": 38 - }, - "indices": 39, - "material": 7 - }, - { - "attributes": { - "JOINTS_0": 40, - "NORMAL": 41, - "POSITION": 42, - "WEIGHTS_0": 43 - }, - "indices": 44, - "material": 8 - }, - { - "attributes": { - "JOINTS_0": 45, - "NORMAL": 46, - "POSITION": 47, - "WEIGHTS_0": 48 - }, - "indices": 49, - "material": 9 - }, - { - "attributes": { - "JOINTS_0": 50, - "NORMAL": 51, - "POSITION": 52, - "WEIGHTS_0": 53 - }, - "indices": 54, - "material": 10 - }, - { - "attributes": { - "JOINTS_0": 55, - "NORMAL": 56, - "POSITION": 57, - "WEIGHTS_0": 58 - }, - "indices": 59, - "material": 11 - }, - { - "attributes": { - "JOINTS_0": 60, - "NORMAL": 61, - "POSITION": 62, - "WEIGHTS_0": 63 - }, - "indices": 64, - "material": 12 - }, - { - "attributes": { - "JOINTS_0": 65, - "NORMAL": 66, - "POSITION": 67, - "WEIGHTS_0": 68 - }, - "indices": 69, - "material": 13 - }, - { - "attributes": { - "JOINTS_0": 70, - "NORMAL": 71, - "POSITION": 72, - "WEIGHTS_0": 73 - }, - "indices": 74, - "material": 14 - }, - { - "attributes": { - "JOINTS_0": 75, - "NORMAL": 76, - "POSITION": 77, - "WEIGHTS_0": 78 - }, - "indices": 79, - "material": 15 - }, - { - "attributes": { - "JOINTS_0": 80, - "NORMAL": 81, - "POSITION": 82, - "WEIGHTS_0": 83 - }, - "indices": 84, - "material": 16 - }, - { - "attributes": { - "JOINTS_0": 85, - "NORMAL": 86, - "POSITION": 87, - "WEIGHTS_0": 88 - }, - "indices": 89, - "material": 17 - }, - { - "attributes": { - "JOINTS_0": 90, - "NORMAL": 91, - "POSITION": 92, - "WEIGHTS_0": 93 - }, - "indices": 94, - "material": 18 - }, - { - "attributes": { - "JOINTS_0": 95, - "NORMAL": 96, - "POSITION": 97, - "WEIGHTS_0": 98 - }, - "indices": 99, - "material": 19 - }, - { - "attributes": { - "JOINTS_0": 100, - "NORMAL": 101, - "POSITION": 102, - "WEIGHTS_0": 103 - }, - "indices": 104, - "material": 20 - }, - { - "attributes": { - "JOINTS_0": 105, - "NORMAL": 106, - "POSITION": 107, - "WEIGHTS_0": 108 - }, - "indices": 109, - "material": 21 - }, - { - "attributes": { - "JOINTS_0": 110, - "NORMAL": 111, - "POSITION": 112, - "WEIGHTS_0": 113 - }, - "indices": 114, - "material": 22 - }, - { - "attributes": { - "JOINTS_0": 115, - "NORMAL": 116, - "POSITION": 117, - "WEIGHTS_0": 118 - }, - "indices": 119, - "material": 23 - }, - { - "attributes": { - "JOINTS_0": 120, - "NORMAL": 121, - "POSITION": 122, - "WEIGHTS_0": 123 - }, - "indices": 124, - "material": 24 - }, - { - "attributes": { - "JOINTS_0": 125, - "NORMAL": 126, - "POSITION": 127, - "WEIGHTS_0": 128 - }, - "indices": 129, - "material": 25 - }, - { - "attributes": { - "JOINTS_0": 130, - "NORMAL": 131, - "POSITION": 132, - "WEIGHTS_0": 133 - }, - "indices": 134, - "material": 26 - }, - { - "attributes": { - "JOINTS_0": 135, - "NORMAL": 136, - "POSITION": 137, - "WEIGHTS_0": 138 - }, - "indices": 139, - "material": 27 - }, - { - "attributes": { - "JOINTS_0": 140, - "NORMAL": 141, - "POSITION": 142, - "WEIGHTS_0": 143 - }, - "indices": 144, - "material": 28 - }, - { - "attributes": { - "JOINTS_0": 145, - "NORMAL": 146, - "POSITION": 147, - "WEIGHTS_0": 148 - }, - "indices": 149, - "material": 29 - }, - { - "attributes": { - "JOINTS_0": 150, - "NORMAL": 151, - "POSITION": 152, - "WEIGHTS_0": 153 - }, - "indices": 154, - "material": 30 - }, - { - "attributes": { - "JOINTS_0": 155, - "NORMAL": 156, - "POSITION": 157, - "WEIGHTS_0": 158 - }, - "indices": 159, - "material": 31 - }, - { - "attributes": { - "JOINTS_0": 160, - "NORMAL": 161, - "POSITION": 162, - "WEIGHTS_0": 163 - }, - "indices": 164, - "material": 32 - }, - { - "attributes": { - "JOINTS_0": 165, - "NORMAL": 166, - "POSITION": 167, - "WEIGHTS_0": 168 - }, - "indices": 169, - "material": 33 - }, - { - "attributes": { - "JOINTS_0": 170, - "NORMAL": 171, - "POSITION": 172, - "WEIGHTS_0": 173 - }, - "indices": 174, - "material": 34 - }, - { - "attributes": { - "JOINTS_0": 175, - "NORMAL": 176, - "POSITION": 177, - "WEIGHTS_0": 178 - }, - "indices": 179, - "material": 35 - }, - { - "attributes": { - "JOINTS_0": 180, - "NORMAL": 181, - "POSITION": 182, - "WEIGHTS_0": 183 - }, - "indices": 184, - "material": 36 - }, - { - "attributes": { - "JOINTS_0": 185, - "NORMAL": 186, - "POSITION": 187, - "WEIGHTS_0": 188 - }, - "indices": 189, - "material": 37 - }, - { - "attributes": { - "JOINTS_0": 190, - "NORMAL": 191, - "POSITION": 192, - "WEIGHTS_0": 193 - }, - "indices": 194, - "material": 38 - }, - { - "attributes": { - "JOINTS_0": 195, - "NORMAL": 196, - "POSITION": 197, - "WEIGHTS_0": 198 - }, - "indices": 199, - "material": 39 - }, - { - "attributes": { - "JOINTS_0": 200, - "NORMAL": 201, - "POSITION": 202, - "WEIGHTS_0": 203 - }, - "indices": 204, - "material": 40 - }, - { - "attributes": { - "JOINTS_0": 205, - "NORMAL": 206, - "POSITION": 207, - "WEIGHTS_0": 208 - }, - "indices": 209, - "material": 41 - }, - { - "attributes": { - "JOINTS_0": 210, - "NORMAL": 211, - "POSITION": 212, - "WEIGHTS_0": 213 - }, - "indices": 214, - "material": 42 - }, - { - "attributes": { - "JOINTS_0": 215, - "NORMAL": 216, - "POSITION": 217, - "WEIGHTS_0": 218 - }, - "indices": 219, - "material": 43 - }, - { - "attributes": { - "JOINTS_0": 220, - "NORMAL": 221, - "POSITION": 222, - "WEIGHTS_0": 223 - }, - "indices": 224, - "material": 44 - }, - { - "attributes": { - "JOINTS_0": 225, - "NORMAL": 226, - "POSITION": 227, - "WEIGHTS_0": 228 - }, - "indices": 229, - "material": 45 - }, - { - "attributes": { - "JOINTS_0": 230, - "NORMAL": 231, - "POSITION": 232, - "WEIGHTS_0": 233 - }, - "indices": 234, - "material": 46 - }, - { - "attributes": { - "JOINTS_0": 235, - "NORMAL": 236, - "POSITION": 237, - "WEIGHTS_0": 238 - }, - "indices": 239, - "material": 47 - }, - { - "attributes": { - "JOINTS_0": 240, - "NORMAL": 241, - "POSITION": 242, - "WEIGHTS_0": 243 - }, - "indices": 244, - "material": 48 - } - ] - } - ], - "skins": [ - { - "joints": [ - 3, - 12, - 20, - 18, - 19, - 13, - 14, - 17, - 16, - 15, - 8, - 9, - 10, - 11, - 4, - 5, - 6, - 7 - ], - "inverseBindMatrices": 245, - "skeleton": 2 - } - ], - "animations": [ - { - "samplers": [ - { - "input": 246, - "output": 247 - }, - { - "input": 246, - "output": 248 - }, - { - "input": 246, - "output": 249 - }, - { - "input": 246, - "output": 250 - }, - { - "input": 246, - "output": 251 - }, - { - "input": 246, - "output": 252 - }, - { - "input": 246, - "output": 253 - }, - { - "input": 246, - "output": 254 - }, - { - "input": 246, - "output": 255 - }, - { - "input": 246, - "output": 256 - }, - { - "input": 246, - "output": 257 - }, - { - "input": 246, - "output": 258 - }, - { - "input": 246, - "output": 259 - } - ], - "channels": [ - { - "sampler": 0, - "target": { - "node": 3, - "path": "rotation" - } - }, - { - "sampler": 1, - "target": { - "node": 12, - "path": "rotation" - } - }, - { - "sampler": 2, - "target": { - "node": 20, - "path": "rotation" - } - }, - { - "sampler": 3, - "target": { - "node": 18, - "path": "rotation" - } - }, - { - "sampler": 4, - "target": { - "node": 19, - "path": "rotation" - } - }, - { - "sampler": 5, - "target": { - "node": 13, - "path": "rotation" - } - }, - { - "sampler": 6, - "target": { - "node": 14, - "path": "rotation" - } - }, - { - "sampler": 7, - "target": { - "node": 8, - "path": "rotation" - } - }, - { - "sampler": 8, - "target": { - "node": 9, - "path": "rotation" - } - }, - { - "sampler": 9, - "target": { - "node": 10, - "path": "rotation" - } - }, - { - "sampler": 10, - "target": { - "node": 4, - "path": "rotation" - } - }, - { - "sampler": 11, - "target": { - "node": 5, - "path": "rotation" - } - }, - { - "sampler": 12, - "target": { - "node": 6, - "path": "rotation" - } - } - ] - } - ], - "nodes": [ - { - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 0, - -1, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1 - ], - "children": [ - 21, - 1 - ] - }, - { - "mesh": 0, - "skin": 0 - }, - { - "rotation": [ - -0.70710665, - 0.000480560469, - 0.000480560528, - -0.707106531 - ], - "children": [ - 3 - ] - }, - { - "translation": [ - 0, - 0.91482681, - 0 - ], - "rotation": [ - 1.4210853e-14, - -0.000679614895, - 0, - -0.999999762 - ], - "scale": [ - 1, - 0.999999881, - 0.999999881 - ], - "children": [ - 12, - 8, - 4 - ] - }, - { - "translation": [ - 0.141549096, - -0.0393192209, - -1.22864003e-08 - ], - "rotation": [ - 0.738841534, - 1.43698983e-07, - -0.671685457, - -0.0544115677 - ], - "scale": [ - 1.00000858, - 1.00000012, - 1.00001037 - ], - "children": [ - 5 - ] - }, - { - "translation": [ - -7.45058015e-09, - 0.358617812, - 0 - ], - "rotation": [ - 0.0262005571, - -0.528300583, - 0.0150880413, - -0.848518968 - ], - "scale": [ - 1, - 1.00000012, - 1 - ], - "children": [ - 6 - ] - }, - { - "translation": [ - -7.45058015e-09, - 0.39689669, - -5.58793989e-09 - ], - "rotation": [ - 0.455043375, - -0.161508426, - -0.0766778737, - -0.872336566 - ], - "scale": [ - 0.999999881, - 1, - 1 - ], - "children": [ - 7 - ] - }, - { - "translation": [ - 7.45058015e-09, - 0.128548697, - 0 - ], - "rotation": [ - 0.903363287, - 5.5000136e-08, - 8.11069611e-08, - -0.42887634 - ], - "scale": [ - 1, - 1, - 1.00000036 - ] - }, - { - "translation": [ - -0.141549096, - -0.0393192209, - -1.22205002e-08 - ], - "rotation": [ - 0.738841534, - -1.43698983e-07, - 0.671685457, - -0.0544115677 - ], - "scale": [ - 1.00000858, - 1.00000012, - 1.00001037 - ], - "children": [ - 9 - ] - }, - { - "translation": [ - 7.45058015e-09, - 0.358617812, - 0 - ], - "rotation": [ - 0.0262005571, - 0.528300583, - -0.0150880413, - -0.848518968 - ], - "scale": [ - 1, - 1.00000012, - 1 - ], - "children": [ - 10 - ] - }, - { - "translation": [ - 7.45058015e-09, - 0.39689669, - -5.58793989e-09 - ], - "rotation": [ - 0.455043375, - 0.161508426, - 0.0766778737, - -0.872336566 - ], - "scale": [ - 0.999999881, - 1, - 1 - ], - "children": [ - 11 - ] - }, - { - "translation": [ - -7.45058015e-09, - 0.128548697, - 0 - ], - "rotation": [ - 0.903363287, - -5.5000136e-08, - -8.11069611e-08, - -0.42887634 - ], - "scale": [ - 1, - 1, - 1.00000036 - ] - }, - { - "translation": [ - -5.49282017e-12, - 0.107472204, - -0.0235914905 - ], - "rotation": [ - -1.69283503e-08, - -1.16415502e-10, - 0, - -1 - ], - "children": [ - 20, - 18, - 13 - ] - }, - { - "translation": [ - 0.419404805, - 0.340766788, - -0.0131063899 - ], - "rotation": [ - 0.00977804046, - 4.9162179e-07, - 0.692072451, - -0.721761942 - ], - "scale": [ - 1.00000012, - 1.00000012, - 1 - ], - "children": [ - 14 - ] - }, - { - "translation": [ - 1.19208998e-07, - 0.1857225, - 2.79396994e-09 - ], - "rotation": [ - -0.00977801718, - -4.70976318e-07, - -0.692072392, - -0.721761882 - ], - "scale": [ - 1, - 0.999999881, - 0.99999994 - ], - "children": [ - 17, - 16, - 15 - ] - }, - { - "translation": [ - 0.412571102, - -0.0216771401, - 0.0550149716 - ], - "rotation": [ - 0, - 0, - -3.16504989e-10, - -1 - ], - "scale": [ - 0.999999881, - 1, - 1 - ] - }, - { - "translation": [ - 0.411934108, - 0.0215858202, - 0.0576437004 - ], - "rotation": [ - -1.69283521e-08, - 0, - -3.16505017e-10, - -0.99999994 - ], - "scale": [ - 0.999999881, - 0.999999881, - 1 - ] - }, - { - "translation": [ - 0.409489214, - 0.0027067659, - 0.01572771 - ], - "rotation": [ - 0, - 0, - -3.16505017e-10, - -0.99999994 - ], - "scale": [ - 0.999999881, - 0.999999881, - 1 - ] - }, - { - "translation": [ - -0.419404894, - 0.34076649, - -0.0131063396 - ], - "rotation": [ - 0.00934915151, - -4.45996235e-08, - -0.682458282, - -0.730864704 - ], - "scale": [ - 0.99999994, - 0.99999994, - 1 - ], - "children": [ - 19 - ] - }, - { - "translation": [ - 1.19208998e-07, - 0.191819698, - 9.31323019e-10 - ], - "rotation": [ - -0.009349145, - 3.40868525e-08, - 0.682458282, - -0.730864704 - ], - "scale": [ - 0.99999994, - 0.99999994, - 1 - ] - }, - { - "translation": [ - 0, - 0.52425611, - -0.01572771 - ], - "rotation": [ - 1.66283751e-08, - 0, - 0, - -1 - ] - }, - { - "children": [ - 2 - ] - } - ], - "scenes": [ - { - "nodes": [ - 0 - ] - } - ], - "scene": 0 -} diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/cube.bin b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.bin similarity index 33% rename from code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/cube.bin rename to code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.bin index 56eda29b853c889122420fb2b21095a1430b6463..08e89dbf82fcc9987e3b55b600114d064a6d75fc 100644 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/cube.bin +++ b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:31a094151a9161765f4af6f5a64269637e97a81e0651a1b8a8609f8a017770fc -size 1608 +oid sha256:82de770fc82b48a77a33bb26abd4d7e75620491b36ddf98e8dca69fa73dd798c +size 1860 diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.glb b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.glb new file mode 100644 index 0000000000000000000000000000000000000000..ff0f71c3156997419e45c91bfe9bc75c23318596 Binary files /dev/null and b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.glb differ diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.gltf b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.gltf deleted file mode 100644 index 10368be3e2e5ec7ecfbbb0b4f2c3c6b4e7bb7359..0000000000000000000000000000000000000000 --- a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube.gltf +++ /dev/null @@ -1,222 +0,0 @@ -{ - "asset":{ - "generator":"Khronos glTF Blender I/O v4.1.63", - "version":"2.0" - }, - "scene":0, - "scenes":[ - { - "name":"Scene", - "nodes":[ - 0, - 1 - ] - } - ], - "nodes":[ - { - "mesh":0, - "name":"AnimatedCube", - "rotation":[ - 0, - -0.0437992662191391, - 0, - 0.9990403652191162 - ] - }, - { - "mesh":1, - "name":"Floor", - "rotation":[ - 0, - 1, - 0, - 0 - ], - "scale":[ - 10, - 0.20000000298023224, - 10 - ], - "translation":[ - 0, - -4, - 0 - ] - } - ], - "materials":[ - { - "doubleSided":true, - "name":"AnimatedCube", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.5 - } - }, - { - "doubleSided":true, - "name":"Floor", - "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], - "metallicFactor":0, - "roughnessFactor":0.5 - } - } - ], - "meshes":[ - { - "name":"AnimatedCube", - "primitives":[ - { - "attributes":{ - "POSITION":0, - "NORMAL":1, - "TEXCOORD_0":2 - }, - "indices":3, - "material":0 - } - ] - }, - { - "name":"Floor", - "primitives":[ - { - "attributes":{ - "POSITION":4, - "NORMAL":5, - "TEXCOORD_0":6 - }, - "indices":3, - "material":1 - } - ] - } - ], - "accessors":[ - { - "bufferView":0, - "componentType":5126, - "count":24, - "max":[ - 1, - 1, - 1 - ], - "min":[ - -1, - -1, - -1 - ], - "type":"VEC3" - }, - { - "bufferView":1, - "componentType":5126, - "count":24, - "type":"VEC3" - }, - { - "bufferView":2, - "componentType":5126, - "count":24, - "type":"VEC2" - }, - { - "bufferView":3, - "componentType":5123, - "count":36, - "type":"SCALAR" - }, - { - "bufferView":4, - "componentType":5126, - "count":24, - "max":[ - 1, - 1, - 1 - ], - "min":[ - -1, - -1, - -1 - ], - "type":"VEC3" - }, - { - "bufferView":5, - "componentType":5126, - "count":24, - "type":"VEC3" - }, - { - "bufferView":6, - "componentType":5126, - "count":24, - "type":"VEC2" - } - ], - "bufferViews":[ - { - "buffer":0, - "byteLength":288, - "byteOffset":0, - "target":34962 - }, - { - "buffer":0, - "byteLength":288, - "byteOffset":288, - "target":34962 - }, - { - "buffer":0, - "byteLength":192, - "byteOffset":576, - "target":34962 - }, - { - "buffer":0, - "byteLength":72, - "byteOffset":768, - "target":34963 - }, - { - "buffer":0, - "byteLength":288, - "byteOffset":840, - "target":34962 - }, - { - "buffer":0, - "byteLength":288, - "byteOffset":1128, - "target":34962 - }, - { - "buffer":0, - "byteLength":192, - "byteOffset":1416, - "target":34962 - } - ], - "buffers":[ - { - "byteLength":1608, - "uri":"cube.bin" - } - ] -} diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_BaseColor.png b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_BaseColor.png new file mode 100644 index 0000000000000000000000000000000000000000..5e5cb2068fa85aec944bd75c981fa6420c1cea87 Binary files /dev/null and b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_BaseColor.png differ diff --git a/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_MetallicRoughness.png b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_MetallicRoughness.png new file mode 100644 index 0000000000000000000000000000000000000000..efd20260218a92d097c4005a8167dcdf08180664 Binary files /dev/null and b/code/DocsSample/graphic/ArkGraphics3D/entry/src/main/resources/rawfile/gltf/CubeWithFloor/glTF/AnimatedCube_MetallicRoughness.png differ diff --git a/code/DocsSample/graphic/NDKGraphics2D/NDKComplextext/entry/src/main/cpp/samples/sample_bitmap.cpp b/code/DocsSample/graphic/NDKGraphics2D/NDKComplextext/entry/src/main/cpp/samples/sample_bitmap.cpp index 9bb784bcac76696e2807c764c94071568d8ddd0e..89980f8f4dc46056214c64bc7357612a1e8c3943 100644 --- a/code/DocsSample/graphic/NDKGraphics2D/NDKComplextext/entry/src/main/cpp/samples/sample_bitmap.cpp +++ b/code/DocsSample/graphic/NDKGraphics2D/NDKComplextext/entry/src/main/cpp/samples/sample_bitmap.cpp @@ -187,9 +187,9 @@ void SampleBitMap::AddFontVariation() { OH_Drawing_SetTextStyleFontWeight(txtStyleNoVar, FONT_WEIGHT_400); // 创建 FontCollection,FontCollection 用于管理字体匹配逻辑 - OH_Drawing_FontCollection *fc = OH_Drawing_CreateSharedFontCollection(); + OH_Drawing_FontCollection *fontCollection = OH_Drawing_CreateSharedFontCollection(); // 使用 FontCollection 和 之前创建的 TypographyStyle 创建 TypographyCreate。TypographyCreate 用于创建 Typography - OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fc); + OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection); // 加入带有可变字体的文本样式 OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyleWithVar); @@ -218,7 +218,7 @@ void SampleBitMap::AddFontVariation() { OH_Drawing_DestroyTypographyStyle(typoStyle); OH_Drawing_DestroyTextStyle(txtStyleWithVar); OH_Drawing_DestroyTextStyle(txtStyleNoVar); - OH_Drawing_DestroyFontCollection(fc); + OH_Drawing_DestroyFontCollection(fontCollection); OH_Drawing_DestroyTypographyHandler(handler); OH_Drawing_DestroyTypography(typography); } @@ -238,7 +238,7 @@ void SampleBitMap::SetTextShadow() OH_Drawing_SetTextStyleFontSize(txtStyleWithShadow, 100); OH_Drawing_SetTextStyleFontWeight(txtStyleWithShadow, FONT_WEIGHT_400); // 设置阴影偏移量 - OH_Drawing_Point *offset = OH_Drawing_PointCreate(1, 1); + OH_Drawing_Point *offset = OH_Drawing_PointCreate(10, 10); OH_Drawing_TextShadow *shadow = OH_Drawing_CreateTextShadow(); // 为 TextShadow 设置样式 OH_Drawing_SetTextShadow(shadow, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00), offset, 10); @@ -253,9 +253,9 @@ void SampleBitMap::SetTextShadow() OH_Drawing_SetTextStyleFontWeight(txtStyleNoShadow, FONT_WEIGHT_400); // 创建 FontCollection,FontCollection 用于管理字体匹配逻辑 - OH_Drawing_FontCollection *fc = OH_Drawing_CreateSharedFontCollection(); + OH_Drawing_FontCollection *fontCollection = OH_Drawing_CreateSharedFontCollection(); // 使用 FontCollection 和 之前创建的 TypographyStyle 创建 TypographyCreate。TypographyCreate 用于创建 Typography - OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fc); + OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection); // 加入带有阴影的文本样式 OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyleWithShadow); @@ -281,7 +281,7 @@ void SampleBitMap::SetTextShadow() OH_Drawing_DestroyTextStyle(txtStyleWithShadow); OH_Drawing_DestroyTextShadow(shadow); OH_Drawing_DestroyTextStyle(txtStyleNoShadow); - OH_Drawing_DestroyFontCollection(fc); + OH_Drawing_DestroyFontCollection(fontCollection); OH_Drawing_DestroyTypographyHandler(handler); OH_Drawing_DestroyTypography(typography); } @@ -315,25 +315,26 @@ void SampleBitMap::SetTextBrush() OH_Drawing_SetTextStyleLocale(txtStyleWithBackgroundBrush, "zh-Hans"); // 设置文本的单词间距。 OH_Drawing_SetTextStyleWordSpacing(txtStyleWithBackgroundBrush, 5.0); - + // 设置文本大小。 OH_Drawing_SetTextStyleFontSize(txtStyleWithBackgroundBrush, 60); OH_Drawing_SetTextStyleFontWeight(txtStyleWithBackgroundBrush, FONT_WEIGHT_400); - //创建文本样式设置其前景色 + // 创建文本样式设置其前景色。 OH_Drawing_TextStyle *txtStyleWithForegrounddBrush = OH_Drawing_CreateTextStyle(); + // 设置文本大小。 OH_Drawing_SetTextStyleFontSize(txtStyleWithForegrounddBrush, 60); OH_Drawing_Brush* foregrounddBrush = OH_Drawing_BrushCreate(); - //设置字体前景色为绿色 + // 设置字体前景色为绿色。 OH_Drawing_BrushSetColor(foregrounddBrush, OH_Drawing_ColorSetArgb(255, 0, 255, 0)); // 设置指定文本样式中的前景色画刷。 OH_Drawing_SetTextStyleForegroundBrush(txtStyleWithForegrounddBrush, foregrounddBrush); - // 设置文本颜色为蓝色 + // 设置文本颜色为蓝色。 OH_Drawing_SetTextStyleColor(txtStyleWithForegrounddBrush, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0xFF)); // 创建 FontCollection,FontCollection 用于管理字体匹配逻辑 - OH_Drawing_FontCollection *fc = OH_Drawing_CreateSharedFontCollection(); - // 使用 FontCollection 和 之前创建的 TypographyStyle 创建 TypographyCreate。TypographyCreate 用于创建 Typography - OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fc); + OH_Drawing_FontCollection *fontCollection = OH_Drawing_CreateSharedFontCollection(); + // 使用 FontCollection 和 之前创建的 TypographyStyle 创建 TypographyCreate。TypographyCreate 用于创建 Typography。 + OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection); // 创建一个 placeholder,并且初始化其成员变量 OH_Drawing_PlaceholderSpan placeholder; @@ -376,7 +377,7 @@ void SampleBitMap::SetTextBrush() OH_Drawing_DestroyTypographyStyle(typoStyle); OH_Drawing_DestroyTextStyle(txtStyleWithBackgroundBrush); OH_Drawing_DestroyTextStyle(txtStyleWithForegrounddBrush); - OH_Drawing_DestroyFontCollection(fc); + OH_Drawing_DestroyFontCollection(fontCollection); OH_Drawing_DestroyTypographyHandler(handler); OH_Drawing_DestroyTypography(typography); } @@ -414,9 +415,9 @@ void SampleBitMap::SetTextEllipsis() OH_Drawing_SetTypographyTextMaxLines(typoStyle, 1); // 创建 FontCollection,FontCollection 用于管理字体匹配逻辑 - OH_Drawing_FontCollection *fc = OH_Drawing_CreateSharedFontCollection(); + OH_Drawing_FontCollection *fontCollection = OH_Drawing_CreateSharedFontCollection(); // 使用 FontCollection 和 之前创建的 TypographyStyle 创建 TypographyCreate。TypographyCreate 用于创建 Typography - OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fc); + OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection); // 将之前创建的 TextStyle 加入 handler 中 OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle); @@ -455,7 +456,7 @@ void SampleBitMap::SetTextEllipsis() // 释放内存 OH_Drawing_DestroyTypographyStyle(typoStyle); OH_Drawing_DestroyTextStyle(txtStyle); - OH_Drawing_DestroyFontCollection(fc); + OH_Drawing_DestroyFontCollection(fontCollection); OH_Drawing_DestroyTypographyHandler(handler); OH_Drawing_DestroyTypography(typography); } diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/.gitignore b/code/LanguageBaseClassLibrary/ConcurrentModule/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/.gitignore rename to code/LanguageBaseClassLibrary/ConcurrentModule/.gitignore diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 similarity index 97% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 index dd320f51bca402384b154865275d0e418d1bec87..5a35ef2b308d10bbbcf9098abdb27a128fdd3cc0 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/app.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "app": { - "bundleName": "com.samples.concurrentmodule", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name" - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.concurrentmodule", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json similarity index 92% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json index bc6e0a7a403c2a92add277ff53937decb9b4cdb8..33d5dba8d042bb35eb2f204d772df8ca550489f2 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ConcurrentModule" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "ConcurrentModule" + } + ] +} diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/media/app_icon.png b/code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/media/app_icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/media/app_icon.png rename to code/LanguageBaseClassLibrary/ConcurrentModule/AppScope/resources/base/media/app_icon.png diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/README.md b/code/LanguageBaseClassLibrary/ConcurrentModule/README.md similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/README.md rename to code/LanguageBaseClassLibrary/ConcurrentModule/README.md diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/README_zh.md b/code/LanguageBaseClassLibrary/ConcurrentModule/README_zh.md similarity index 91% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/README_zh.md rename to code/LanguageBaseClassLibrary/ConcurrentModule/README_zh.md index ac511faabaaf46b26f01e1d6fbb105abe0e026e8..a6625fe92bc9d3aba700cd8f9566b4dc0786da60 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/README_zh.md +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/README_zh.md @@ -52,19 +52,23 @@ ``` entry/src/main/ets/ |---common -| |---Common.ts // 公用方法,如bufferToString +| |---Common.ets // 公用方法,如bufferToString |   |---Logger.ts             // 日志 |---component +| |---SendableTest.ets // 传递SendableClass页签 | |---TaskPoolTab.ets // taskpool页签 +| |---test.ets // Sendable Class | |---WorkerTab.ets // worker页签 |---entryability +|---fileFs +| |---MyWorker.ets // 批量拷贝文件 |---pages | |---CopyFile.ets // 拷贝文件界面,可选择把文件进行拷贝并显示触发事件后日志 | |---Index.ets // 首页 | |---StrSort.ets // worker和taskpool页签都在这里调用 |---workers | |---Worker.ts // worker线程 -| |---Worker03.ts // 拷贝文件的worker线程 +| |---WorkerCopy.ts // 拷贝文件的worker线程 ``` ### 具体实现 @@ -87,7 +91,7 @@ entry/src/main/ets/ * 拷贝文件:在[CopyFile.ets](entry/src/main/ets/pages/CopyFile.ets) - 中调用MyWorker.WorkToCopyFiles(),在WorkToCopyFiles方法中向worker03线程发消息,并在worker03线程中批量拷贝,拷贝完成后将结果返回。 + 中调用MyWorker.WorkToCopyFiles(),在WorkToCopyFiles方法中向WorkerCopy线程发消息,并在WorkerCopy线程中批量拷贝,拷贝完成后将结果返回。 ### 相关权限 @@ -112,7 +116,7 @@ entry/src/main/ets/ ```` git init git config core.sparsecheckout true -echo code/LaunguageBaseClassLibrary/ConcurrentModule/ > .git/info/sparse-checkout +echo code/LanguageBaseClassLibrary/ConcurrentModule/ > .git/info/sparse-checkout git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ```` \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/build-profile.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/build-profile.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/build-profile.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/build-profile.json5 index 611c4b002d256b0fdda47ae9ece5ad0dfa9e6bb8..6755644553d13a6cb28e3537529701e3952c61e6 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/build-profile.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/build-profile.json5 @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compileSdkVersion": 12, - "compatibleSdkVersion": 12, - "runtimeOS": "OpenHarmony", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/code/LanguageBaseClassLibrary/ConcurrentModule/entry/.gitignore b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 index cc72131cc3db1118a2204916114100244c74a1eb..0d0cc70644830558add6a79f59c8d47815428d92 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/build-profile.json5 @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": 'stageMode', - "buildOption": { - "sourceOption": { - "workers": [ - './src/main/ets/workers/Worker.ts', - "./src/main/ets/workers/WorkerCopy.ts", - ] - } - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + "sourceOption": { + "workers": [ + './src/main/ets/workers/Worker.ts', + "./src/main/ets/workers/WorkerCopy.ts", + ] + } + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/hvigorfile.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/hvigorfile.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 index 4be95c59ce0dede7a66d6fcb2e3018c8011f838a..3fbe67bbf8193c883bab1ccea7be318bc3a65bdb 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/oh-package.json5 @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "license": "", - "devDependencies": {}, - "author": "", - "name": "entry", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Common.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Common.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Common.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Common.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Logger.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Logger.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Logger.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/common/Logger.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/SendableTest.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets similarity index 97% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets index 74c4f818f2cad063cc3b1afebf37fdc8891368de..3c31ad51e26d94f433349a92ddc87bbaae5cb0fd 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/TaskPoolTab.ets @@ -1,430 +1,430 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import taskpool from '@ohos.taskpool'; -import utils from '@arkts.utils'; -import stack from '@ohos.util.Stack'; -import { BusinessError } from '@ohos.base'; -import { SendableClass, a } from './SendableTest'; -import { TestA, TestB } from './test' - -@Component -export struct TaskPoolTab { - @State taskPoolOutPutStr: string = ''; - @State taskPoolInPutStr: string = ''; - taskPoolInPutArr: string[] = []; - isTaskGroup : boolean = false; - gStack: stack = new stack(); - taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup(); - - - build() { - Column() { - Text($r('app.string.Text_desc')) - .width("100%") - .height("48vp") - .position({ x: "7%", y: "0" }) - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#182431") - .lineHeight(22) - .fontWeight(500) - - Button() { - Row() { - Image($r('app.media.public_add')) - .width(20) - .height(20) - .margin({ left: 4 }) - Text($r('app.string.Add_task')) - .width("75%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("14fp") - .fontColor("#182431") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - } - .id("addButton") - .height("10vp") - .borderRadius("10vp") - .backgroundColor("#00000000") - .position({ x: "67%", y: "1.5%" }) - .width(135) - .height(35) - .onClick(() => { - this.taskAdd(); - }) - - Button() { - Row() { - Image($r('app.media.empties')) - .width(20) - .height(20) - .margin({ left: 4 }) - Text($r('app.string.Clear_desc')) - .width("35%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("14fp") - .fontColor("#182431") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - } - .id("taskPoolClearButton") - .height("10vp") - .borderRadius("10vp") - .backgroundColor("#00000000") - .position({ x: "71%", y: "31.5%" }) - .width(135) - .height(35) - .onClick(() => { - this.Clear(); - }) - - TextArea({placeholder:$r('app.string.Default_desc'), text:this.taskPoolInPutStr}) - .id("taskPoolInPutTextArea") - .width("93.3%") - .height("139vp") - .position({ x: "3.3%", y: "48vp" }) - .textAlign(TextAlign.Start) - .borderRadius("24vp") - .backgroundColor("#ffffff") - .fontFamily("HarmonyHeiTi") - .fontSize("16fp") - .fontColor("#182431") - .fontWeight(400) - .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) - .onChange((value: string) => { - this.taskPoolInPutStr = value; - this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); - this.taskPoolOutPutStr = ''; - }) - - Text($r('app.string.Result_desc')) - .width("50%") - .height("48") - .position({ x: "7%", y: "187vp" }) - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#182431") - .lineHeight(22) - .fontWeight(500) - - Scroll() { - Text(this.taskPoolOutPutStr) - .id("taskPoolOutPutText") - .fontFamily("HarmonyHeiTi") - .fontSize("16fp") - .fontColor("#182431") - .fontWeight(400) - .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) - } - .id("taskPoolOutPutScroll") - .width("93.3%") - .height("139vp") - .position({ x: "3.3%", y: "235vp" }) - .borderRadius("24vp") - .backgroundColor("#ffffff") - .align(Alignment.TopStart) - - GridRow({columns: 4, - gutter: { x: 12, y: 12 }, - breakpoints: { value: ["360vp", "480vp"]}, - direction: GridRowDirection.Row}) { - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.Execute_After_3s_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#007DFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("exeDelayButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("rgba(24,36,49,0.05)") - .onClick(()=>{ - this.executeDelay(); - }) - } - - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.Execute_Immediately_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#FFFFFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("exeImmButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("#007DFF") - .onClick(()=>{ - if(this.isTaskGroup == true) { - this.TaskGroupExec(); - } else { - this.executeImmediately(); - } - }) - } - - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.Function_Task_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#007DFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("exeFunctionButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("rgba(24,36,49,0.05)") - .onClick(()=>{ - this.executeFunc(); - }) - } - - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.Cancel_Task_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#FFFFFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("exeCancelButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("#007DFF") - .onClick(()=>{ - this.cancelTask(); - }) - } - - GridCol ({ span: 4, offset: 0 }) { - Button() { - Text($r('app.string.transferSendableClass')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#007DFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("sendableButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("rgba(24,36,49,0.05)") - .onClick(()=>{ - this.sendableTask(); - }) - } - } - .width("100%") - .height("168vp") - .position({ x: "0", y: "73%" }) - .padding({ left: "25vp", right: "25vp" }) - } - .width("100%") - .height("100%") - .justifyContent(FlexAlign.Center) - } - - async executeImmediately(): Promise { - if (!this.taskPoolInPutStr.length) { - this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; - return; - } - let task = new taskpool.Task(strSort,this.taskPoolInPutArr); - this.gStack.push(task); - try { - let result: taskpool.Task = await taskpool.execute(task) as taskpool.Task; - this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; - } catch(e) { - this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; - } - this.gStack.pop(); - } - - async executeDelay(): Promise { - if (!this.taskPoolInPutStr.length) { - this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; - return; - } - let task = new taskpool.Task(strSortDelay,this.taskPoolInPutArr); - this.gStack.push(task); - try { - let result: string[] = await taskpool.execute(task) as string[]; - this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; - } catch(e) { - this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString() + "\n"; - } - this.gStack.pop(); - } - - async executeFunc(): Promise { - if (!this.taskPoolInPutStr.length) { - this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; - return; - } - try { - let result: string[] = await taskpool.execute(strSort,this.taskPoolInPutArr) as string[]; - this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; - } catch(e) { - this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; - } - } - - async taskAdd(): Promise { - if (!this.taskPoolInPutStr.length) { - this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; - return; - } - try { - let task: taskpool.Task = new taskpool.Task(strSort, this.taskPoolInPutArr); - this.taskGroup.addTask(task); - this.isTaskGroup = true; - this.taskPoolOutPutStr += "TaskGroup addTask successfully.\n"; - } catch (e) { - this.taskPoolOutPutStr += "TaskGroup addTask failed: "+ (e as BusinessError).toString()+ "\n"; - } - } - - Clear(): void { - this.taskPoolInPutStr = ''; - this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); - this.taskPoolOutPutStr = ''; - } - - async TaskGroupExec(): Promise { - try { - let res: string[] = await taskpool.execute(this.taskGroup) as string[]; - this.taskPoolOutPutStr += "TaskGroup executed successfully: "+ res.toString()+ "\n"; - } catch(e) { - this.taskPoolOutPutStr += "TaskGroup executed failed: "+ (e as BusinessError).toString()+ "\n"; - } - this.isTaskGroup = false; - } - - async cancelTask(): Promise { - if (this.gStack.isEmpty()) { - this.taskPoolOutPutStr += "The current task queue has no cancellable tasks."+ "\n"; - } else { - let task: taskpool.Task = this.gStack.peek() as taskpool.Task; - try { - taskpool.cancel(task); - this.taskPoolOutPutStr += "Task canceled successfully."+ "\n"; - this.gStack.pop(); - } catch(e) { - this.taskPoolOutPutStr += "Task canceled failed: "+ (e as BusinessError).toString()+ "\n"; - } - } - } - - async sendableTask(): Promise { - // 定义主线程异步锁sendableTask_lock - let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); - let count: number = 0; - lock.lockAsync(async () => { - // 主线程调用实例a.data1的方法setCount、getCount - a.data1.setCount(111); - count = await a.data1.getCount(); - console.info("this data1 count is: " + await a.data1.getCount()); - }) - let task: taskpool.Task = new taskpool.Task(createSendableData, a); - try { - await taskpool.execute(task); - this.taskPoolOutPutStr += "sendableTask execute successfully."+ "\n"; - // 访问子线程返回的实例a中的各个属性 - this.taskPoolOutPutStr += "Sendable data TestA v1 is: " + a.data1.v1 + "\n"; - this.taskPoolOutPutStr += "Sendable data TestA v2 is: " + a.data1.v2 + "\n"; - this.taskPoolOutPutStr += "Sendable data TestA v3 is: " + a.data1.v3 + "\n"; - this.taskPoolOutPutStr += "Sendable data TestA count is: " + count + "\n"; - this.taskPoolOutPutStr += "Sendable data TestB v1 length is: " + a.data2.v1.length + "\n"; - this.taskPoolOutPutStr += "Sendable data TestB v2 has key: " + a.data2.v2.has(100) + "\n"; - this.taskPoolOutPutStr += "Sendable data TestB v3 size is: " + a.data2.v3.size + "\n"; - } catch(e) { - this.taskPoolOutPutStr += "Task execute failed: "+ (e as BusinessError).toString()+ "\n"; - } - } -} - -@Concurrent -function strSort(inPutArr: string[]) : string[] { - let newArr: string[] = inPutArr.sort(); - return newArr; -} - -@Concurrent -function strSortDelay(inPutArr: string[]) : string[] { - let start: number= new Date().getTime(); - while (new Date().getTime() - start < 3000) { - continue; - } - let newArr: string[] = inPutArr.sort(); - return newArr; -} - -@Concurrent -async function createSendableData(data: SendableClass): Promise { - // 定义taskpool子线程异步锁sendableTask_lock - let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); - - // 构造TestA、TestB实例,组装SendableClass实例 - let d1: TestA = new TestA(); - d1.v1 = 1010; - d1.v2 = "aaa"; - d1.v3 = true; - let d2: TestB = new TestB(); - d2.v2.set(100, "aaa"); - for(let i = 0;i < 1000;i++) { - d2.v1.push(i); - } - d2.v3.add("hello"); - - lock.lockAsync(async () => { - // 子线程调用实例方法setCount、getCount - await d1.setCount(10); - console.info("taskpool: this data1 count is: " + await d1.getCount()); - }) - - data.data1 = d1; - data.data2 = d2; +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import taskpool from '@ohos.taskpool'; +import utils from '@arkts.utils'; +import stack from '@ohos.util.Stack'; +import { BusinessError } from '@ohos.base'; +import { SendableClass, a } from './SendableTest'; +import { TestA, TestB } from './test' + +@Component +export struct TaskPoolTab { + @State taskPoolOutPutStr: string = ''; + @State taskPoolInPutStr: string = ''; + taskPoolInPutArr: string[] = []; + isTaskGroup : boolean = false; + gStack: stack = new stack(); + taskGroup: taskpool.TaskGroup = new taskpool.TaskGroup(); + + + build() { + Column() { + Text($r('app.string.Text_desc')) + .width("100%") + .height("48vp") + .position({ x: "7%", y: "0" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Button() { + Row() { + Image($r('app.media.public_add')) + .width(20) + .height(20) + .margin({ left: 4 }) + Text($r('app.string.Add_task')) + .width("75%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("14fp") + .fontColor("#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + } + .id("addButton") + .height("10vp") + .borderRadius("10vp") + .backgroundColor("#00000000") + .position({ x: "67%", y: "1.5%" }) + .width(135) + .height(35) + .onClick(() => { + this.taskAdd(); + }) + + Button() { + Row() { + Image($r('app.media.empties')) + .width(20) + .height(20) + .margin({ left: 4 }) + Text($r('app.string.Clear_desc')) + .width("35%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("14fp") + .fontColor("#182431") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + } + .id("taskPoolClearButton") + .height("10vp") + .borderRadius("10vp") + .backgroundColor("#00000000") + .position({ x: "71%", y: "31.5%" }) + .width(135) + .height(35) + .onClick(() => { + this.Clear(); + }) + + TextArea({placeholder:$r('app.string.Default_desc'), text:this.taskPoolInPutStr}) + .id("taskPoolInPutTextArea") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "48vp" }) + .textAlign(TextAlign.Start) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + .onChange((value: string) => { + this.taskPoolInPutStr = value; + this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); + this.taskPoolOutPutStr = ''; + }) + + Text($r('app.string.Result_desc')) + .width("50%") + .height("48") + .position({ x: "7%", y: "187vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Scroll() { + Text(this.taskPoolOutPutStr) + .id("taskPoolOutPutText") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + } + .id("taskPoolOutPutScroll") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "235vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .align(Alignment.TopStart) + + GridRow({columns: 4, + gutter: { x: 12, y: 12 }, + breakpoints: { value: ["360vp", "480vp"]}, + direction: GridRowDirection.Row}) { + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Execute_After_3s_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeDelayButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.executeDelay(); + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Execute_Immediately_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeImmButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + if(this.isTaskGroup == true) { + this.TaskGroupExec(); + } else { + this.executeImmediately(); + } + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Function_Task_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeFunctionButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.executeFunc(); + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Cancel_Task_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("exeCancelButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + this.cancelTask(); + }) + } + + GridCol ({ span: 4, offset: 0 }) { + Button() { + Text($r('app.string.transferSendableClass')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("sendableButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.sendableTask(); + }) + } + } + .width("100%") + .height("168vp") + .position({ x: "0", y: "73%" }) + .padding({ left: "25vp", right: "25vp" }) + } + .width("100%") + .height("100%") + .justifyContent(FlexAlign.Center) + } + + async executeImmediately(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + let task = new taskpool.Task(strSort,this.taskPoolInPutArr); + this.gStack.push(task); + try { + let result: taskpool.Task = await taskpool.execute(task) as taskpool.Task; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + this.gStack.pop(); + } + + async executeDelay(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + let task = new taskpool.Task(strSortDelay,this.taskPoolInPutArr); + this.gStack.push(task); + try { + let result: string[] = await taskpool.execute(task) as string[]; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString() + "\n"; + } + this.gStack.pop(); + } + + async executeFunc(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + try { + let result: string[] = await taskpool.execute(strSort,this.taskPoolInPutArr) as string[]; + this.taskPoolOutPutStr += "Task executed successfully: "+ result.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + + async taskAdd(): Promise { + if (!this.taskPoolInPutStr.length) { + this.taskPoolOutPutStr = "No input for the string to be sorted.\n"; + return; + } + try { + let task: taskpool.Task = new taskpool.Task(strSort, this.taskPoolInPutArr); + this.taskGroup.addTask(task); + this.isTaskGroup = true; + this.taskPoolOutPutStr += "TaskGroup addTask successfully.\n"; + } catch (e) { + this.taskPoolOutPutStr += "TaskGroup addTask failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + + Clear(): void { + this.taskPoolInPutStr = ''; + this.taskPoolInPutArr = this.taskPoolInPutStr.trim().split(','); + this.taskPoolOutPutStr = ''; + } + + async TaskGroupExec(): Promise { + try { + let res: string[] = await taskpool.execute(this.taskGroup) as string[]; + this.taskPoolOutPutStr += "TaskGroup executed successfully: "+ res.toString()+ "\n"; + } catch(e) { + this.taskPoolOutPutStr += "TaskGroup executed failed: "+ (e as BusinessError).toString()+ "\n"; + } + this.isTaskGroup = false; + } + + async cancelTask(): Promise { + if (this.gStack.isEmpty()) { + this.taskPoolOutPutStr += "The current task queue has no cancellable tasks."+ "\n"; + } else { + let task: taskpool.Task = this.gStack.peek() as taskpool.Task; + try { + taskpool.cancel(task); + this.taskPoolOutPutStr += "Task canceled successfully."+ "\n"; + this.gStack.pop(); + } catch(e) { + this.taskPoolOutPutStr += "Task canceled failed: "+ (e as BusinessError).toString()+ "\n"; + } + } + } + + async sendableTask(): Promise { + // 定义主线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); + let count: number = 0; + lock.lockAsync(async () => { + // 主线程调用实例a.data1的方法setCount、getCount + a.data1.setCount(111); + count = await a.data1.getCount(); + console.info("this data1 count is: " + await a.data1.getCount()); + }) + let task: taskpool.Task = new taskpool.Task(createSendableData, a); + try { + await taskpool.execute(task); + this.taskPoolOutPutStr += "sendableTask execute successfully."+ "\n"; + // 访问子线程返回的实例a中的各个属性 + this.taskPoolOutPutStr += "Sendable data TestA v1 is: " + a.data1.v1 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA v2 is: " + a.data1.v2 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA v3 is: " + a.data1.v3 + "\n"; + this.taskPoolOutPutStr += "Sendable data TestA count is: " + count + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v1 length is: " + a.data2.v1.length + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v2 has key: " + a.data2.v2.has(100) + "\n"; + this.taskPoolOutPutStr += "Sendable data TestB v3 size is: " + a.data2.v3.size + "\n"; + } catch(e) { + this.taskPoolOutPutStr += "Task execute failed: "+ (e as BusinessError).toString()+ "\n"; + } + } +} + +@Concurrent +function strSort(inPutArr: string[]) : string[] { + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +function strSortDelay(inPutArr: string[]) : string[] { + let start: number= new Date().getTime(); + while (new Date().getTime() - start < 3000) { + continue; + } + let newArr: string[] = inPutArr.sort(); + return newArr; +} + +@Concurrent +async function createSendableData(data: SendableClass): Promise { + // 定义taskpool子线程异步锁sendableTask_lock + let lock: utils.locks.AsyncLock = utils.locks.AsyncLock.request("sendableTask_lock"); + + // 构造TestA、TestB实例,组装SendableClass实例 + let d1: TestA = new TestA(); + d1.v1 = 1010; + d1.v2 = "aaa"; + d1.v3 = true; + let d2: TestB = new TestB(); + d2.v2.set(100, "aaa"); + for(let i = 0;i < 1000;i++) { + d2.v1.push(i); + } + d2.v3.add("hello"); + + lock.lockAsync(async () => { + // 子线程调用实例方法setCount、getCount + await d1.setCount(10); + console.info("taskpool: this data1 count is: " + await d1.getCount()); + }) + + data.data1 = d1; + data.data2 = d2; } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets index 410038a827d6f7cc4c40ab980888612102531828..1f8c1885a6e492ab63779bce308f6bb76b21f9b6 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/WorkerTab.ets @@ -1,168 +1,168 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import worker from '@ohos.worker'; - -@Component -export struct WorkerTab { - @State jsWorkerOutPutStr: string = ''; - @State jsWorkerInPutStr: string = ''; - jsWorkerInPutArr: string[] = []; - isDone: boolean = false; - myWorker: worker.ThreadWorker = new worker.ThreadWorker("entry/ets/workers/Worker.ts"); - - build() { - Column() { - Text($r('app.string.Text_desc')) - .width("100%") - .height("48vp") - .position({ x: "7%", y: "0vp" }) - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#182431") - .lineHeight(22) - .fontWeight(500) - - TextArea({text:this.jsWorkerInPutStr}) - .id("jsWorkerInPutTextArea") - .width("93.3%") - .height("139vp") - .position({ x: "3.3%", y: "48vp" }) - .textAlign(TextAlign.Start) - .fontFamily("HarmonyHeiTi") - .fontSize("16fp") - .fontColor("#182431") - .fontWeight(400) - .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) - .borderRadius("24vp") - .backgroundColor("#ffffff") - .onChange((value: string) => { - this.jsWorkerInPutStr = value; - this.jsWorkerInPutArr = value.trim().split(','); - this.jsWorkerOutPutStr = ''; - }) - - Text($r('app.string.Result_desc')) - .width("100%") - .height("48") - .position({ x: "7%", y: "187vp" }) - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#182431") - .lineHeight(22) - .fontWeight(500) - - Scroll() { - Text(this.jsWorkerOutPutStr) - .id("jsWorkerOutPutText") - .fontFamily("HarmonyHeiTi") - .fontSize("16fp") - .fontColor("#182431") - .fontWeight(400) - .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) - } - .id("jsWorkerOutPutScroll") - .width("93.3%") - .height("139vp") - .position({ x: "3.3%", y: "235vp" }) - .borderRadius("24vp") - .backgroundColor("#ffffff") - .align(Alignment.TopStart) - - GridRow({columns: 4, - gutter: { x: 12, y: 12 }, - breakpoints: { value: ["360vp", "480vp"]}, - direction: GridRowDirection.Row}) { - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.Clear_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#007DFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("workerClearButton") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("rgba(24,36,49,0.05)") - .onClick(()=>{ - this.jsWorkerInPutStr = ''; - this.jsWorkerOutPutStr = ''; - }) - } - - GridCol ({ span: 2, offset: 0 }) { - Button() { - Text($r('app.string.SortString_desc')) - .width("100%") - .height("22") - .fontFamily("HarmonyHeiTi-Medium") - .fontSize("16fp") - .fontColor("#FFFFFF") - .textAlign(TextAlign.Center) - .lineHeight(22) - .fontWeight(500) - } - .id("workerStrSort") - .height("40vp") - .borderRadius("20vp") - .backgroundColor("#007DFF") - .onClick(()=>{ - this.executeWorkerFunc(this.jsWorkerInPutArr); - }) - } - } - .width("100%") - .height("40vp") - .position({ x: "0", y: "555vp" }) - .padding({ left: "24vp", right: "24vp" }) - } - .width("100%") - .height("100%") - .justifyContent(FlexAlign.Center) - } - - async executeWorkerFunc(inPutArr: string[]): Promise { - if (!this.jsWorkerInPutStr.length) { - this.jsWorkerOutPutStr = "No input for the string to be sorted.\n"; - return; - } - this.myWorker.postMessage(inPutArr); - let strFlag = false; - let outPutStr = ''; - this.myWorker.onmessage = (e) => { - outPutStr = e.data.toString(); - strFlag = true; - } - while(!strFlag) { - await promiseCase(); - } - this.jsWorkerOutPutStr = outPutStr; - } -} - -function promiseCase() : Promise { - let p: Promise = new Promise((resolve: Function, reject: Function) => { - setTimeout(() => { - resolve(1) - }, 100) - }).then(undefined, () => { - }) - return p; +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import worker from '@ohos.worker'; + +@Component +export struct WorkerTab { + @State jsWorkerOutPutStr: string = ''; + @State jsWorkerInPutStr: string = ''; + jsWorkerInPutArr: string[] = []; + isDone: boolean = false; + myWorker: worker.ThreadWorker = new worker.ThreadWorker("entry/ets/workers/Worker.ts"); + + build() { + Column() { + Text($r('app.string.Text_desc')) + .width("100%") + .height("48vp") + .position({ x: "7%", y: "0vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + TextArea({text:this.jsWorkerInPutStr}) + .id("jsWorkerInPutTextArea") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "48vp" }) + .textAlign(TextAlign.Start) + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .onChange((value: string) => { + this.jsWorkerInPutStr = value; + this.jsWorkerInPutArr = value.trim().split(','); + this.jsWorkerOutPutStr = ''; + }) + + Text($r('app.string.Result_desc')) + .width("100%") + .height("48") + .position({ x: "7%", y: "187vp" }) + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#182431") + .lineHeight(22) + .fontWeight(500) + + Scroll() { + Text(this.jsWorkerOutPutStr) + .id("jsWorkerOutPutText") + .fontFamily("HarmonyHeiTi") + .fontSize("16fp") + .fontColor("#182431") + .fontWeight(400) + .padding({ top: "8vp" , left: "16vp", right: "16vp", bottom: "21vp" }) + } + .id("jsWorkerOutPutScroll") + .width("93.3%") + .height("139vp") + .position({ x: "3.3%", y: "235vp" }) + .borderRadius("24vp") + .backgroundColor("#ffffff") + .align(Alignment.TopStart) + + GridRow({columns: 4, + gutter: { x: 12, y: 12 }, + breakpoints: { value: ["360vp", "480vp"]}, + direction: GridRowDirection.Row}) { + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.Clear_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#007DFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("workerClearButton") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("rgba(24,36,49,0.05)") + .onClick(()=>{ + this.jsWorkerInPutStr = ''; + this.jsWorkerOutPutStr = ''; + }) + } + + GridCol ({ span: 2, offset: 0 }) { + Button() { + Text($r('app.string.SortString_desc')) + .width("100%") + .height("22") + .fontFamily("HarmonyHeiTi-Medium") + .fontSize("16fp") + .fontColor("#FFFFFF") + .textAlign(TextAlign.Center) + .lineHeight(22) + .fontWeight(500) + } + .id("workerStrSort") + .height("40vp") + .borderRadius("20vp") + .backgroundColor("#007DFF") + .onClick(()=>{ + this.executeWorkerFunc(this.jsWorkerInPutArr); + }) + } + } + .width("100%") + .height("40vp") + .position({ x: "0", y: "555vp" }) + .padding({ left: "24vp", right: "24vp" }) + } + .width("100%") + .height("100%") + .justifyContent(FlexAlign.Center) + } + + async executeWorkerFunc(inPutArr: string[]): Promise { + if (!this.jsWorkerInPutStr.length) { + this.jsWorkerOutPutStr = "No input for the string to be sorted.\n"; + return; + } + this.myWorker.postMessage(inPutArr); + let strFlag = false; + let outPutStr = ''; + this.myWorker.onmessage = (e) => { + outPutStr = e.data.toString(); + strFlag = true; + } + while(!strFlag) { + await promiseCase(); + } + this.jsWorkerOutPutStr = outPutStr; + } +} + +function promiseCase() : Promise { + let p: Promise = new Promise((resolve: Function, reject: Function) => { + setTimeout(() => { + resolve(1) + }, 100) + }).then(undefined, () => { + }) + return p; } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/test.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/test.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/component/test.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/entryability/EntryAbility.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/fileFs/MyWorker.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/CopyFile.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/Index.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/Index.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/pages/StrSort.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/Worker.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/Worker.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/Worker.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/Worker.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/ets/workers/WorkerCopy.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 index c4c3c62e25cdb37fe6ef344e49f845297440a6f3..e42c2962094ce21b5300a2e19e780aa0b1b84002 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/module.json5 @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry", - "type": "entry", - "description": "$string:module_desc", - "mainElement": "EntryAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "EntryAbility", - "srcEntry": "./ets/entryability/EntryAbility.ets", - "description": "$string:EntryAbility_desc", - "icon": "$media:icon", - "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "exported": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/c_Checkbox_Selected.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/empties.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/empties.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/empties.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/empties.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_Checkbox_Selected_Enabled.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_back.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_backward_right.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_delete.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_edit.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/ic_ok.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/media/public_add.svg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/TestAbility.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/ets/testability/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 index 0511adbc861eba4c62107d508b88a550567331aa..c6ad62fbbd46259bb51381022bcdce57349e123c 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntry": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "exported": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/base/profile/test_pages.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/en/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json b/code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json rename to code/LanguageBaseClassLibrary/ConcurrentModule/entry/src/ohosTest/resources/zh/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 similarity index 97% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 index 97147e6cf70998c11d749a4146796115c5ae9c7c..909bc9a52c9871b7a12b665460a7cb3cea6d50c5 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-config.json5 @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "hvigorVersion": "4.0.4", - "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.4" - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "hvigorVersion": "4.0.4", + "dependencies": { + "@ohos/hvigor-ohos-plugin": "4.0.4" + } } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-wrapper.js b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-wrapper.js similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-wrapper.js rename to code/LanguageBaseClassLibrary/ConcurrentModule/hvigor/hvigor-wrapper.js diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorfile.ts b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorfile.ts rename to code/LanguageBaseClassLibrary/ConcurrentModule/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorw b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigorw similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorw rename to code/LanguageBaseClassLibrary/ConcurrentModule/hvigorw diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorw.bat b/code/LanguageBaseClassLibrary/ConcurrentModule/hvigorw.bat similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/hvigorw.bat rename to code/LanguageBaseClassLibrary/ConcurrentModule/hvigorw.bat diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/oh-package.json5 b/code/LanguageBaseClassLibrary/ConcurrentModule/oh-package.json5 similarity index 96% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/oh-package.json5 rename to code/LanguageBaseClassLibrary/ConcurrentModule/oh-package.json5 index 84f6ca3ba8fd8a59bfa8db14c123316c1d886621..ac21a550a2b71be3fcb99c6577a806b43240c96e 100644 --- a/code/LaunguageBaseClassLibrary/ConcurrentModule/oh-package.json5 +++ b/code/LanguageBaseClassLibrary/ConcurrentModule/oh-package.json5 @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.6" - }, - "author": "", - "name": "concurrentmodule", - "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} -} +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "author": "", + "name": "concurrentmodule", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/ohosTest.md b/code/LanguageBaseClassLibrary/ConcurrentModule/ohosTest.md similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/ohosTest.md rename to code/LanguageBaseClassLibrary/ConcurrentModule/ohosTest.md diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/copyFile.jpg b/code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/copyFile.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/copyFile.jpg rename to code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/copyFile.jpg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/index.jpg b/code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/index.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/index.jpg rename to code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/index.jpg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/taskpoolTab.jpg b/code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/taskpoolTab.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/taskpoolTab.jpg rename to code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/taskpoolTab.jpg diff --git a/code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/workerTab.jpg b/code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/workerTab.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/ConcurrentModule/screenshots/device/workerTab.jpg rename to code/LanguageBaseClassLibrary/ConcurrentModule/screenshots/device/workerTab.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/.gitignore b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/.gitignore rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/.gitignore diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/app.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/app.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/app.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/app.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/AppScope/resources/base/media/app_icon.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md similarity index 99% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md index 31c58ee866a611ed833ff095333598fd508f3a52..8b189b1ce2a5239a61757f52b1912ca56932c3d9 100644 --- a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md +++ b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/README_zh.md @@ -178,7 +178,7 @@ LanguageBaseClassLibrary ``` git init git config core.sparsecheckout true -echo code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/ > .git/info/sparse-checkout +echo code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/ > .git/info/sparse-checkout git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/build-profile.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/build-profile.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/.gitignore b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/.gitignore rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/.gitignore diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/Index.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/Index.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/Index.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/build-profile.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/build-profile.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/hvigorfile.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/hvigorfile.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/oh-package.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/oh-package.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/BaseDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/CustomDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/components/EmptyPage.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/Logger.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/ets/util/ResourceUtil.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/module.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/module.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/module.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/color.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/base/media/bg_empty_page.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/common/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/.gitignore b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/.gitignore rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/.gitignore diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/build-profile.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/build-profile.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/hvigorfile.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/hvigorfile.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/oh-package.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/oh-package.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/entryability/EntryAbility.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddInformationView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddKeyValuePairView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/AddStringView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/ets/pages/components/Capabilities.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/module.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/module.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/module.json5 diff --git a/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_age.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_back.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_confirm.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_phone.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_spinner_down.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/ic_public_user.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/TestAbility.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/testability/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/ets/util/Logger.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/module.json5 diff --git a/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/base/profile/test_pages.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/entry/src/ohosTest/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/.gitignore b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/.gitignore rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/.gitignore diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/index.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/index.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/index.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/Constant.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ArrayListView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ConvertXml.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/DequeView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashMapView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/HashSetView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightMapView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LightWeightSetView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/LinkedListView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ListView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/PlainArrayView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Process.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/ProcessMessage.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/QueueView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/StackView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TaskPool.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeMapView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/TreeSetView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Url.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/Util.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/capabilities/VectorView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ColumnOperation.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/DeleteView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/GridOperation.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/InformationItemView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/KeyValueItemView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/ValueItemView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/AddDialog.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/ArrayListItem.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/arraylistcomponents/MyDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/dequecomponents/DequeDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashmapcomponents/HashMapDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/hashsetcomponents/HashSetDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightmapcomponents/LightWeightMapDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/lightweightsetcomponents/LightWeightSetDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/linkedlistcomponents/LinkedListDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/listcomponents/ListDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/plainarraycomponents/PlainArrayDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/queuecomponents/QueueDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/stackcomponents/StackDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treemapcomponents/TreeMapDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/treesetcomponents/TreeSetDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/Base64Helper.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/LRUCache.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/RationalNumber.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/ScopeHelper.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/StringCode.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/TypeCheck.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/lrucache/ActionSheetDialog.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/InputItem.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/SleepView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/scopehelper/TempView.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/stringcode/SpecInput.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/CheckType.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/utilcomponents/typecheck/ShowKey.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/components/vectorcomponents/VectorDataSource.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/Information.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/KeyValuePair.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/model/ScopeNumber.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/ConvertXmlUtil.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/LRUCacheUtil.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/RationalNumberUtil.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/ets/util/UrlUtil.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/module.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/color.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/bg_empty_page.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/contact.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_add.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/base/media/ic_delete_plane.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/strarray.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/capabilities/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/.gitignore b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/.gitignore rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/.gitignore diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/index.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/index.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/index.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/ItemGroup.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MainItem.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/components/MenuNavRouter.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/ets/menulist/MenuList.ets diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/module.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/color.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_add.png diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_arrow.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/base/media/ic_public_add.svg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/feature/menuitems/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-config.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigor/hvigor-wrapper.js diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorfile.ts b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorfile.ts rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw.bat b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw.bat similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw.bat rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/hvigorw.bat diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.hap diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/oh-package.json5 b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/oh-package.json5 rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/ohosTest.md b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/ohosTest.md similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/ohosTest.md rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/ohosTest.md diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/arraylist.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/base64.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/base64.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/base64.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/base64.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/convertxml.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/home.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/home.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/home.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/home.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/lrucache.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/process.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/process.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/process.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/process.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/rationalnumber.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/scopehelper.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/stringcode.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/typecheck.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/url.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/url.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/url.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/url.jpg diff --git a/code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/util.jpg b/code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/util.jpg similarity index 100% rename from code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/util.jpg rename to code/LanguageBaseClassLibrary/LanguageBaseClassLibrary/screenshots/devices/util.jpg diff --git a/code/LaunguageBaseClassLibrary/ZipLib/.gitignore b/code/LanguageBaseClassLibrary/ZipLib/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/.gitignore rename to code/LanguageBaseClassLibrary/ZipLib/.gitignore diff --git a/code/LaunguageBaseClassLibrary/ZipLib/AppScope/app.json5 b/code/LanguageBaseClassLibrary/ZipLib/AppScope/app.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/AppScope/app.json5 rename to code/LanguageBaseClassLibrary/ZipLib/AppScope/app.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/AppScope/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ZipLib/AppScope/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/AppScope/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ZipLib/AppScope/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/AppScope/resources/base/media/app_icon.png b/code/LanguageBaseClassLibrary/ZipLib/AppScope/resources/base/media/app_icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/AppScope/resources/base/media/app_icon.png rename to code/LanguageBaseClassLibrary/ZipLib/AppScope/resources/base/media/app_icon.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/README.md b/code/LanguageBaseClassLibrary/ZipLib/README.md similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/README.md rename to code/LanguageBaseClassLibrary/ZipLib/README.md diff --git a/code/LaunguageBaseClassLibrary/ZipLib/README_zh.md b/code/LanguageBaseClassLibrary/ZipLib/README_zh.md similarity index 99% rename from code/LaunguageBaseClassLibrary/ZipLib/README_zh.md rename to code/LanguageBaseClassLibrary/ZipLib/README_zh.md index dc4e62fb567b00015894b765225779b6b8803be1..1fb4f6743fbfeb2e6337541f65ba96c0cdd5d093 100644 --- a/code/LaunguageBaseClassLibrary/ZipLib/README_zh.md +++ b/code/LanguageBaseClassLibrary/ZipLib/README_zh.md @@ -150,7 +150,7 @@ entry/src/main/ets/ ``` git init git config core.sparsecheckout true -echo code/LaunguageBaseClassLibrary/ZipLib/ > .git/info/sparse-checkout +echo code/LanguageBaseClassLibrary/ZipLib/ > .git/info/sparse-checkout git remote add origin https://gitee.com/openharmony/applications_app_samples.git git pull origin master ``` \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ZipLib/build-profile.json5 b/code/LanguageBaseClassLibrary/ZipLib/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/build-profile.json5 rename to code/LanguageBaseClassLibrary/ZipLib/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/.gitignore b/code/LanguageBaseClassLibrary/ZipLib/entry/.gitignore similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/.gitignore rename to code/LanguageBaseClassLibrary/ZipLib/entry/.gitignore diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/build-profile.json5 b/code/LanguageBaseClassLibrary/ZipLib/entry/build-profile.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/build-profile.json5 rename to code/LanguageBaseClassLibrary/ZipLib/entry/build-profile.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/hvigorfile.ts b/code/LanguageBaseClassLibrary/ZipLib/entry/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/hvigorfile.ts rename to code/LanguageBaseClassLibrary/ZipLib/entry/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/oh-package.json5 b/code/LanguageBaseClassLibrary/ZipLib/entry/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/oh-package.json5 rename to code/LanguageBaseClassLibrary/ZipLib/entry/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/AddDialog.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/AddDialog.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/AddDialog.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/AddDialog.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets similarity index 97% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets index 2b199c183eafc27140eb552f3c5d82ad40764bc9..0e16604204feaf206574b4900ed672dfa45be60f 100644 --- a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets +++ b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/common/DeleteDialog.ets @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { hilog } from '@kit.PerformanceAnalysisKit'; - -const DOMAIN = 0xF811; -const BUNDLE = 'ZipLib_'; -const TAG: string = '[DeleteDialog]'; - -@CustomDialog -export struct DeleteDialog { - private fileNames: string[] = []; - private isInserted: boolean = false; - private deleteFiles: (isInserted: boolean, fileNames: Array) => void = - (isInserted: boolean, fileNames: Array) => { - }; - private controller: CustomDialogController; - @State buttonColor: Resource = $r('app.color.button_light_color'); - - build() { - Column() { - Text($r('app.string.delete_file')) - .fontSize(16) - .width('100%') - .height('40%') - .margin({ top: '3%' }) - .textAlign(TextAlign.Center) - - Row() { - Text($r('app.string.button_cancel')) - .fontColor($r('app.color.button_color')) - .fontSize(16) - .height('18.5%') - .width('44%') - .margin({ left: '23%', top: '3%' }) - .onClick(() => { - this.controller.close(); - }) - - Text($r('app.string.button_confirm')) - .fontColor($r('app.color.button_color')) - .fontSize(16) - .height('18.5%') - .width('44%') - .margin({ right: '23%', top: '3%' }) - .onClick(() => { - this.isInserted = true; - hilog.info(DOMAIN, TAG, BUNDLE + `fileName = ${this.fileNames}`); - this.deleteFiles(this.isInserted, this.fileNames); - hilog.info(DOMAIN, TAG, BUNDLE + `isInserted = ${this.isInserted}`); - this.controller.close(); - }) - } - .width('100%') - } - .width('100%') - .height('18%') - .backgroundColor($r('app.color.start_window_background')) - } +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const DOMAIN = 0xF811; +const BUNDLE = 'ZipLib_'; +const TAG: string = '[DeleteDialog]'; + +@CustomDialog +export struct DeleteDialog { + private fileNames: string[] = []; + private isInserted: boolean = false; + private deleteFiles: (isInserted: boolean, fileNames: Array) => void = + (isInserted: boolean, fileNames: Array) => { + }; + private controller: CustomDialogController; + @State buttonColor: Resource = $r('app.color.button_light_color'); + + build() { + Column() { + Text($r('app.string.delete_file')) + .fontSize(16) + .width('100%') + .height('40%') + .margin({ top: '3%' }) + .textAlign(TextAlign.Center) + + Row() { + Text($r('app.string.button_cancel')) + .fontColor($r('app.color.button_color')) + .fontSize(16) + .height('18.5%') + .width('44%') + .margin({ left: '23%', top: '3%' }) + .onClick(() => { + this.controller.close(); + }) + + Text($r('app.string.button_confirm')) + .fontColor($r('app.color.button_color')) + .fontSize(16) + .height('18.5%') + .width('44%') + .margin({ right: '23%', top: '3%' }) + .onClick(() => { + this.isInserted = true; + hilog.info(DOMAIN, TAG, BUNDLE + `fileName = ${this.fileNames}`); + this.deleteFiles(this.isInserted, this.fileNames); + hilog.info(DOMAIN, TAG, BUNDLE + `isInserted = ${this.isInserted}`); + this.controller.close(); + }) + } + .width('100%') + } + .width('100%') + .height('18%') + .backgroundColor($r('app.color.start_window_background')) + } } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/entryability/EntryAbility.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/entryability/EntryAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/entryability/EntryAbility.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/entryability/EntryAbility.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/DataSource.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/DataSource.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/DataSource.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/DataSource.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/Logger.ts b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/Logger.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/Logger.ts rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/model/Logger.ts diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/pages/Index.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/pages/Index.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets similarity index 97% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets index d17ad9bc38840bae61f8dba797e0ee75873d001b..46a56f4771a7103c8f2ef014964e1d0f7baff156 100644 --- a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets +++ b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/CompressFilesPage.ets @@ -1,246 +1,246 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { common } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { preferences } from '@kit.ArkData'; -import { promptAction, router } from '@kit.ArkUI'; -import { zlib } from '@kit.BasicServicesKit'; -import fileio from '@ohos.fileio'; -import { AddDialog } from '../common/AddDialog'; -import { ZipLibSource } from '../model/DataSource'; - -const DOMAIN = 0xF811; -const BUNDLE = 'ZipLib_'; -const TAG: string = '[CompressFilesPage]'; -let fileList: preferences.Preferences; - -@Entry -@Component -struct CompressFilesPage { - @State isInserted: boolean = false; - @State files: ZipLibSource = new ZipLibSource([]); - @State fileName: string = ''; - @State slectFileName: string[] = []; - @State zipFileNames: string[] = []; - @State fileContent: string = ''; - @State isSelect: boolean = false; - private path: string = ''; - private title: Resource = $r('app.string.CompressFiles'); - private dialogController: CustomDialogController = new CustomDialogController({ - builder: AddDialog({ - fileName: this.fileName, - fileContent: this.fileContent, - isInserted: this.isInserted, - createFile: async (isInserted: boolean, fileName: string, fileContent: string) => { - hilog.info(DOMAIN, TAG, BUNDLE + `enter the createFile`); - this.fileName = `${fileName}.txt`; - let isDuplication = this.files.fileData.includes(this.fileName); - hilog.info(DOMAIN, TAG, BUNDLE + `isInserted = ${isInserted} isDuplication = ${isDuplication}`); - if (!isInserted || isDuplication) { - return; - } - let fd = fileio.openSync(`${this.path}/${this.fileName}`, 0o100 | 0o2, 0o666); - let number = fileio.writeSync(fd, fileContent); - hilog.info(DOMAIN, TAG, BUNDLE + `fd = ${fd} number = ${number}`); - this.files.pushData(this.fileName); - hilog.info(DOMAIN, TAG, BUNDLE + `this.files = ${JSON.stringify(this.files.fileData)}`); - await fileList.put('fileNames', JSON.stringify(this.files.fileData)); - await fileList.flush(); - } - }), - autoCancel: true, - }) - - async aboutToAppear() { - fileList = await preferences.getPreferences(getContext(this), 'fileList'); - let ctx = getContext(this) as common.Context; - this.path = ctx.filesDir; - let value = await fileList.get('fileNames', ''); - this.files.fileData = JSON.parse(`${value}`); - this.files.notifyDataReload(); - this.zipFileNames.length = 0; - this.zipFileNames = this.files.fileData.filter(item => item.endsWith('.zip')); - } - - async zipcompressFiles(path: string, zipfileNames: Array): Promise { - let files: string[] = []; - for (let index = 0; index < zipfileNames.length; index++) { - files[index] = `${path}/${zipfileNames[index]}`; - } - let zipFiles = Array.from(files); - hilog.debug(DOMAIN, TAG, BUNDLE + `zipFile = ${zipFiles}`); - let newName = `test_` + this.zipFileNames.length + `.zip`; - let zipOutFile = `${this.path}/${newName}`; - hilog.debug(DOMAIN, TAG, BUNDLE + `zipOutFile = ${zipOutFile}`); - - if (this.files.fileData.includes(newName)) { - promptAction.showToast({ - message: $r('app.string.warning_failed'), - bottom: '11%' - }); - return; - } - try { - await zlib.compressFiles(zipFiles, zipOutFile, {}).then(data => { - zlib.getOriginalSize(zipOutFile).then((num) => { - promptAction.showToast({ - message: $r('app.string.CompressFiles_success_size', num), - bottom: '11%' - }); - }) - this.files.pushData(`${newName}`); - this.zipFileNames.push(newName); - }) - } catch { - promptAction.showToast({ - message: $r('app.string.CompressFiles_failure'), - bottom: '11%' - }); - } - await fileList.put('fileNames', JSON.stringify(this.files.fileData)); - await fileList.flush(); - } - - build() { - Column() { - Column() { - Row() { - Row() { - Image($r('app.media.icon_back')) - .size({ height: '71%' }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.pushUrl({ - url: 'zlib/ZLibInterfaceListPage' - }); - }) - Text(this.title) - .fontSize(20) - .margin({ left: 8 }) - .fontWeight(FontWeight.Bold) - } - - Row() { - Image($r('app.media.add')) - .size({ height: '71%' }) - .id('addFile') - .margin({ left: '3%' }) - .objectFit(ImageFit.Contain) - .onClick(() => { - this.dialogController.open(); - }) - } - } - .justifyContent(FlexAlign.SpaceBetween) - .width('91%') - .height('9.75%') - .backgroundColor($r('app.color.backGrounding')) - - List({ initialIndex: 0 }) { - LazyForEach(this.files, (item: string, index: number) => { - ListItem() { - Row() { - Row() { - Image(item.includes('.zip') ? $r('app.media.zip') : $r('app.media.file')) - .size({ height: '66.7%' }) - .objectFit(ImageFit.Contain) - Column() { - Text(item) - .width('50%') - .fontSize(16) - .margin({ left: 16 }) - } - } - - Checkbox() - .visibility(item.includes('.zip') ? Visibility.Hidden : Visibility.Visible) - .width('6%') - .select(this.slectFileName.indexOf(item) != -1 ? true : false) - .id('file_' + index) - .selectedColor($r('app.color.checkbox_color')) - .shape(CheckBoxShape.CIRCLE) - .onChange((value: boolean) => { - if (value) { - this.isSelect = true; - this.slectFileName.push(item); - } else { - this.isSelect = false; - let index = this.slectFileName.indexOf(item); - if (index !== -1) { - this.slectFileName.splice(index, 1); - } - } - }) - } - .justifyContent(FlexAlign.SpaceBetween) - .padding({ right: 12, left: 12 }) - .width('100%') - .height('14.2%') - .borderRadius(16) - .backgroundColor($r('app.color.start_window_background')) - } - .margin({ bottom: 12 }) - }, (item: string) => item) - } - .margin({ top: 8 }) - .height('85.875%') - .width('91%') - .backgroundColor($r('app.color.index_bg')) - } - .height('80%') - .width('100%') - - - Column() { - Text($r('app.string.tip_CompressFiles')) - .textAlign(TextAlign.Start) - .fontSize(12) - .fontColor($r('app.color.tip_Gzip_backeGround')) - .width('86.4%') - .height('22.3%') - .margin({ bottom: 24 }) - - Row() { - Button($r('app.string.zip')) - .id('compress') - .height('100%') - .width('100%') - .fontSize(16) - .fontFamily('HarmonyHeiTi') - .type(ButtonType.Capsule) - .backgroundColor($r('app.color.button_color')) - .fontColor($r('app.color.text_white_color')) - .borderRadius(20) - .onClick(() => { - if (this.isSelect) { - this.zipcompressFiles(this.path, this.slectFileName); - } - }) - } - .margin({ bottom: 16 }) - .height('28%') - .width('91%') - } - .justifyContent(FlexAlign.End) - .alignItems(HorizontalAlign.Center) - .height('20%') - .width('100%') - } - .height('100%') - .width('100%') - .backgroundColor($r('app.color.index_bg')) - } -} +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { preferences } from '@kit.ArkData'; +import { promptAction, router } from '@kit.ArkUI'; +import { zlib } from '@kit.BasicServicesKit'; +import fileio from '@ohos.fileio'; +import { AddDialog } from '../common/AddDialog'; +import { ZipLibSource } from '../model/DataSource'; + +const DOMAIN = 0xF811; +const BUNDLE = 'ZipLib_'; +const TAG: string = '[CompressFilesPage]'; +let fileList: preferences.Preferences; + +@Entry +@Component +struct CompressFilesPage { + @State isInserted: boolean = false; + @State files: ZipLibSource = new ZipLibSource([]); + @State fileName: string = ''; + @State slectFileName: string[] = []; + @State zipFileNames: string[] = []; + @State fileContent: string = ''; + @State isSelect: boolean = false; + private path: string = ''; + private title: Resource = $r('app.string.CompressFiles'); + private dialogController: CustomDialogController = new CustomDialogController({ + builder: AddDialog({ + fileName: this.fileName, + fileContent: this.fileContent, + isInserted: this.isInserted, + createFile: async (isInserted: boolean, fileName: string, fileContent: string) => { + hilog.info(DOMAIN, TAG, BUNDLE + `enter the createFile`); + this.fileName = `${fileName}.txt`; + let isDuplication = this.files.fileData.includes(this.fileName); + hilog.info(DOMAIN, TAG, BUNDLE + `isInserted = ${isInserted} isDuplication = ${isDuplication}`); + if (!isInserted || isDuplication) { + return; + } + let fd = fileio.openSync(`${this.path}/${this.fileName}`, 0o100 | 0o2, 0o666); + let number = fileio.writeSync(fd, fileContent); + hilog.info(DOMAIN, TAG, BUNDLE + `fd = ${fd} number = ${number}`); + this.files.pushData(this.fileName); + hilog.info(DOMAIN, TAG, BUNDLE + `this.files = ${JSON.stringify(this.files.fileData)}`); + await fileList.put('fileNames', JSON.stringify(this.files.fileData)); + await fileList.flush(); + } + }), + autoCancel: true, + }) + + async aboutToAppear() { + fileList = await preferences.getPreferences(getContext(this), 'fileList'); + let ctx = getContext(this) as common.Context; + this.path = ctx.filesDir; + let value = await fileList.get('fileNames', ''); + this.files.fileData = JSON.parse(`${value}`); + this.files.notifyDataReload(); + this.zipFileNames.length = 0; + this.zipFileNames = this.files.fileData.filter(item => item.endsWith('.zip')); + } + + async zipcompressFiles(path: string, zipfileNames: Array): Promise { + let files: string[] = []; + for (let index = 0; index < zipfileNames.length; index++) { + files[index] = `${path}/${zipfileNames[index]}`; + } + let zipFiles = Array.from(files); + hilog.debug(DOMAIN, TAG, BUNDLE + `zipFile = ${zipFiles}`); + let newName = `test_` + this.zipFileNames.length + `.zip`; + let zipOutFile = `${this.path}/${newName}`; + hilog.debug(DOMAIN, TAG, BUNDLE + `zipOutFile = ${zipOutFile}`); + + if (this.files.fileData.includes(newName)) { + promptAction.showToast({ + message: $r('app.string.warning_failed'), + bottom: '11%' + }); + return; + } + try { + await zlib.compressFiles(zipFiles, zipOutFile, {}).then(data => { + zlib.getOriginalSize(zipOutFile).then((num) => { + promptAction.showToast({ + message: $r('app.string.CompressFiles_success_size', num), + bottom: '11%' + }); + }) + this.files.pushData(`${newName}`); + this.zipFileNames.push(newName); + }) + } catch { + promptAction.showToast({ + message: $r('app.string.CompressFiles_failure'), + bottom: '11%' + }); + } + await fileList.put('fileNames', JSON.stringify(this.files.fileData)); + await fileList.flush(); + } + + build() { + Column() { + Column() { + Row() { + Row() { + Image($r('app.media.icon_back')) + .size({ height: '71%' }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.pushUrl({ + url: 'zlib/ZLibInterfaceListPage' + }); + }) + Text(this.title) + .fontSize(20) + .margin({ left: 8 }) + .fontWeight(FontWeight.Bold) + } + + Row() { + Image($r('app.media.add')) + .size({ height: '71%' }) + .id('addFile') + .margin({ left: '3%' }) + .objectFit(ImageFit.Contain) + .onClick(() => { + this.dialogController.open(); + }) + } + } + .justifyContent(FlexAlign.SpaceBetween) + .width('91%') + .height('9.75%') + .backgroundColor($r('app.color.backGrounding')) + + List({ initialIndex: 0 }) { + LazyForEach(this.files, (item: string, index: number) => { + ListItem() { + Row() { + Row() { + Image(item.includes('.zip') ? $r('app.media.zip') : $r('app.media.file')) + .size({ height: '66.7%' }) + .objectFit(ImageFit.Contain) + Column() { + Text(item) + .width('50%') + .fontSize(16) + .margin({ left: 16 }) + } + } + + Checkbox() + .visibility(item.includes('.zip') ? Visibility.Hidden : Visibility.Visible) + .width('6%') + .select(this.slectFileName.indexOf(item) != -1 ? true : false) + .id('file_' + index) + .selectedColor($r('app.color.checkbox_color')) + .shape(CheckBoxShape.CIRCLE) + .onChange((value: boolean) => { + if (value) { + this.isSelect = true; + this.slectFileName.push(item); + } else { + this.isSelect = false; + let index = this.slectFileName.indexOf(item); + if (index !== -1) { + this.slectFileName.splice(index, 1); + } + } + }) + } + .justifyContent(FlexAlign.SpaceBetween) + .padding({ right: 12, left: 12 }) + .width('100%') + .height('14.2%') + .borderRadius(16) + .backgroundColor($r('app.color.start_window_background')) + } + .margin({ bottom: 12 }) + }, (item: string) => item) + } + .margin({ top: 8 }) + .height('85.875%') + .width('91%') + .backgroundColor($r('app.color.index_bg')) + } + .height('80%') + .width('100%') + + + Column() { + Text($r('app.string.tip_CompressFiles')) + .textAlign(TextAlign.Start) + .fontSize(12) + .fontColor($r('app.color.tip_Gzip_backeGround')) + .width('86.4%') + .height('22.3%') + .margin({ bottom: 24 }) + + Row() { + Button($r('app.string.zip')) + .id('compress') + .height('100%') + .width('100%') + .fontSize(16) + .fontFamily('HarmonyHeiTi') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_color')) + .fontColor($r('app.color.text_white_color')) + .borderRadius(20) + .onClick(() => { + if (this.isSelect) { + this.zipcompressFiles(this.path, this.slectFileName); + } + }) + } + .margin({ bottom: 16 }) + .height('28%') + .width('91%') + } + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Center) + .height('20%') + .width('100%') + } + .height('100%') + .width('100%') + .backgroundColor($r('app.color.index_bg')) + } +} diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets similarity index 97% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets index fc7a9ff2480ca292a785b03d3540e027f39cb369..1339c29568c6741f8c3b30daf0faf7a7c3cd2612 100644 --- a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets +++ b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZLibInterfaceListPage.ets @@ -1,292 +1,292 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { fileIo } from '@kit.CoreFileKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { promptAction, router } from '@kit.ArkUI'; -import { zlib } from '@kit.BasicServicesKit'; - -const DOMAIN = 0xF811; -const BUNDLE = 'ZipLib_'; -const TAG: string = '[ZLibInterfaceListPage]'; -const SLEEP_TIME = 3000; -const BUFFER_SIZE = 13; -const OFFSET = 0; -const STRING_DATA = 'hello, hello!'; - -function sleep(time: number) { - return new Promise((resolve) => setTimeout(resolve, time)); -}; - -@Entry -@Component -struct ZLibInterfaceListPage { - async zlibDecompression(): Promise { - hilog.info(DOMAIN, TAG, BUNDLE + `zlibDecompression begin`); - let context = AppStorage.get('context') as Context; - let pathDir = context.cacheDir; - let zlibFile = fileIo.openSync(pathDir + '/zlibFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - fileIo.writeSync(zlibFile.fd, STRING_DATA); - let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE); - fileIo.readSync(zlibFile.fd, arrayBufferIn, { offset: OFFSET }); - fileIo.closeSync(zlibFile); - - let arrayBufferOut = new ArrayBuffer(BUFFER_SIZE); - // 创建zip对象 - let zip = zlib.createZipSync(); - // 压缩初始化 - await zip.deflateInit({}, zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED); - // 校验数据 - let checksum = zlib.createChecksumSync(); - checksum.crc32(0, arrayBufferIn); - try { - // 压缩数据 - await zip.deflate({ - nextIn: arrayBufferIn, - availableIn: BUFFER_SIZE, - nextOut: arrayBufferOut, - availableOut: BUFFER_SIZE - }, zlib.CompressFlushMode.FINISH).then((data) => { - // 将压缩后的buffer写入zlibDeflateFile.txt文件中 - let zlibDeflateFile = - fileIo.openSync(pathDir + '/zlibDeflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - fileIo.writeSync(zlibDeflateFile.fd, arrayBufferOut); - fileIo.closeSync(zlibDeflateFile); - promptAction.showToast({ - message: $r('app.string.zlib_compress_success', STRING_DATA), - bottom: '11%' - }); - }) - } catch (errData) { - promptAction.showToast({ - message: $r('app.string.zlib_compress_failure'), - bottom: '11%' - }); - } - // 释放动态分配的数据结构 - await zip.deflateEnd({ nextOut: arrayBufferOut }); - await sleep(SLEEP_TIME); - // 解压初始化 - await zip.inflateInit({}); - let inflateArrayBufferOut = new ArrayBuffer(BUFFER_SIZE); - // 校验数据 - checksum.crc32(0, arrayBufferOut); - try { - // 解压数据 - await zip.inflate({ - nextIn: arrayBufferOut, - availableIn: BUFFER_SIZE, - nextOut: inflateArrayBufferOut, - availableOut: BUFFER_SIZE - }, zlib.CompressFlushMode.NO_FLUSH).then((data) => { - let array = new Uint8Array(inflateArrayBufferOut); - let dataString = ''; - for (let i = 0; i < array.length; i++) { - dataString += String.fromCharCode(array[i]); - } - // 将解压后的数据写入zlibInflateFile.txt文件中 - let zlibInflateFile = - fileIo.openSync(pathDir + '/zlibInflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - fileIo.writeSync(zlibInflateFile.fd, dataString); - fileIo.closeSync(zlibInflateFile); - // 验证压缩与解压的数据是否一致 - if (STRING_DATA == dataString) { - promptAction.showToast({ - message: $r('app.string.zlib_uncompress_success', dataString), - bottom: '11%' - }); - } - }) - } catch (errData) { - promptAction.showToast({ - message: $r('app.string.zlib_uncompress_failure'), - bottom: '11%' - }); - } - // 释放动态分配的数据结构 - await zip.inflateEnd({ nextOut: arrayBufferOut }); - hilog.info(DOMAIN, TAG, BUNDLE + `zlibDecompression end`); - } - - async gzipDecompression(): Promise { - hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression begin`); - let context = AppStorage.get('context') as Context; - let pathDir = context.cacheDir; - let file = fileIo.openSync(pathDir + '/gzipTest.gz', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - let path = pathDir + '/gzipTest.gz'; - fileIo.closeSync(file); - - // 创建gzip对象 - let gzip = zlib.createGZipSync(); - // 打开.gz文件,对文件进行写操作 - await gzip.gzopen(path, 'wb'); - let str = STRING_DATA; - let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE); - let byteArray = new Uint8Array(arrayBufferIn); - for (let i = 0, j = str.length; i < j; i++) { - byteArray[i] = str.charCodeAt(i); - } - try { - // 将bufferWithData压缩并写入文件 - await gzip.gzfwrite(arrayBufferIn, 8, 2).then((data) => { - promptAction.showToast({ - message: $r('app.string.gzip_compress_success', str), - bottom: '11%' - }); - }) - } catch (errData) { - promptAction.showToast({ - message: $r('app.string.gzip_compress_failure'), - bottom: '11%' - }); - } - await gzip.gzflush(0); - await gzip.gzclose(); - - await sleep(SLEEP_TIME); - // 打开.gz文件,对文件进行读操作 - await gzip.gzopen(path, 'rb'); - try { - let bufferWithDataOut = new ArrayBuffer(BUFFER_SIZE); - // 从.gz文件中读取和解压数据 - await gzip.gzfread(bufferWithDataOut, 8, 2).then((data) => { - let array = new Uint8Array(bufferWithDataOut); - let dataString = ''; - for (let i = 0; i < array.length; i++) { - dataString += String.fromCharCode(array[i]); - } - if (dataString == str) { - promptAction.showToast({ - message: $r('app.string.gzip_uncompress_success', dataString), - bottom: '11%' - }); - let gzipFile = - fileIo.openSync(pathDir + '/gzipTest.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - fileIo.writeSync(gzipFile.fd, dataString); - fileIo.closeSync(gzipFile); - } - }) - } catch (errData) { - promptAction.showToast({ - message: $r('app.string.gzip_uncompress_failure'), - bottom: '11%' - }); - } - await gzip.gzclose(); - hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression end`); - } - - build() { - Column() { - Column() { - Row() { - Image($r('app.media.icon_back')) - .size({ height: '71%' }) - .objectFit(ImageFit.Contain) - .onClick(() => { - router.pushUrl({ - url: 'pages/Index' - }); - }) - Text($r('app.string.zlibInterface')) - .fontSize(20) - .margin({ left: 8 }) - .width('100%') - .height('100%') - .fontWeight(FontWeight.Bold) - } - .height('15.64%') - .width('91%') - - Row() { - Text($r('app.string.CompressFiles')) - .textAlign(TextAlign.Start) - .fontSize(16) - .fontColor($r('app.color.text_color')) - Image($r('app.media.icon_next')) - .size({ height: '42.8%' }) - .objectFit(ImageFit.Contain) - } - .id('compressFiles') - .onClick(() => { - router.pushUrl({ - url: 'zlib/CompressFilesPage' - }); - }) - .justifyContent(FlexAlign.SpaceBetween) - .padding({ right: 12, left: 12 }) - .height('15.64%') - .width('91%') - .backgroundColor($r('app.color.start_window_background')) - .borderRadius(15) - .margin({ top: 8 }) - } - .alignItems(HorizontalAlign.Center) - .width('100%') - .height('50%') - - Column() { - Text($r('app.string.tip_Gzip')) - .textAlign(TextAlign.Start) - .fontSize(12) - .fontColor($r('app.color.tip_Gzip_backeGround')) - .width('86.4%') - .height('9%') - .margin({ bottom: 24 }) - - Button($r('app.string.gzip_interface')) - .id('gzipinterface') - .width('100%') - .height('100%') - .fontSize(16) - .fontFamily('HarmonyHeiTi') - .type(ButtonType.Capsule) - .backgroundColor($r('app.color.button_backeGround')) - .fontColor($r('app.color.button_color')) - .borderRadius(20) - .onClick(() => { - this.gzipDecompression(); - }) - .margin({ bottom: 12 }) - .width('91%') - .height('11.2%') - - Button($r('app.string.zlib_interface')) - .id('zlibinterface') - .width('100%') - .height('100%') - .fontSize(16) - .fontFamily('HarmonyHeiTi') - .type(ButtonType.Capsule) - .backgroundColor($r('app.color.button_backeGround')) - .fontColor($r('app.color.button_color')) - .borderRadius(20) - .onClick(() => { - this.zlibDecompression(); - }) - .margin({ bottom: 16 }) - .width('91%') - .height('11.2%') - } - .justifyContent(FlexAlign.End) - .alignItems(HorizontalAlign.Center) - .width('100%') - .height('50%') - } - .backgroundColor($r('app.color.backGrounding')) - .width('100%') - .height('100%') - } +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { fileIo } from '@kit.CoreFileKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction, router } from '@kit.ArkUI'; +import { zlib } from '@kit.BasicServicesKit'; + +const DOMAIN = 0xF811; +const BUNDLE = 'ZipLib_'; +const TAG: string = '[ZLibInterfaceListPage]'; +const SLEEP_TIME = 3000; +const BUFFER_SIZE = 13; +const OFFSET = 0; +const STRING_DATA = 'hello, hello!'; + +function sleep(time: number) { + return new Promise((resolve) => setTimeout(resolve, time)); +}; + +@Entry +@Component +struct ZLibInterfaceListPage { + async zlibDecompression(): Promise { + hilog.info(DOMAIN, TAG, BUNDLE + `zlibDecompression begin`); + let context = AppStorage.get('context') as Context; + let pathDir = context.cacheDir; + let zlibFile = fileIo.openSync(pathDir + '/zlibFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + fileIo.writeSync(zlibFile.fd, STRING_DATA); + let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE); + fileIo.readSync(zlibFile.fd, arrayBufferIn, { offset: OFFSET }); + fileIo.closeSync(zlibFile); + + let arrayBufferOut = new ArrayBuffer(BUFFER_SIZE); + // 创建zip对象 + let zip = zlib.createZipSync(); + // 压缩初始化 + await zip.deflateInit({}, zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED); + // 校验数据 + let checksum = zlib.createChecksumSync(); + checksum.crc32(0, arrayBufferIn); + try { + // 压缩数据 + await zip.deflate({ + nextIn: arrayBufferIn, + availableIn: BUFFER_SIZE, + nextOut: arrayBufferOut, + availableOut: BUFFER_SIZE + }, zlib.CompressFlushMode.FINISH).then((data) => { + // 将压缩后的buffer写入zlibDeflateFile.txt文件中 + let zlibDeflateFile = + fileIo.openSync(pathDir + '/zlibDeflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + fileIo.writeSync(zlibDeflateFile.fd, arrayBufferOut); + fileIo.closeSync(zlibDeflateFile); + promptAction.showToast({ + message: $r('app.string.zlib_compress_success', STRING_DATA), + bottom: '11%' + }); + }) + } catch (errData) { + promptAction.showToast({ + message: $r('app.string.zlib_compress_failure'), + bottom: '11%' + }); + } + // 释放动态分配的数据结构 + await zip.deflateEnd({ nextOut: arrayBufferOut }); + await sleep(SLEEP_TIME); + // 解压初始化 + await zip.inflateInit({}); + let inflateArrayBufferOut = new ArrayBuffer(BUFFER_SIZE); + // 校验数据 + checksum.crc32(0, arrayBufferOut); + try { + // 解压数据 + await zip.inflate({ + nextIn: arrayBufferOut, + availableIn: BUFFER_SIZE, + nextOut: inflateArrayBufferOut, + availableOut: BUFFER_SIZE + }, zlib.CompressFlushMode.NO_FLUSH).then((data) => { + let array = new Uint8Array(inflateArrayBufferOut); + let dataString = ''; + for (let i = 0; i < array.length; i++) { + dataString += String.fromCharCode(array[i]); + } + // 将解压后的数据写入zlibInflateFile.txt文件中 + let zlibInflateFile = + fileIo.openSync(pathDir + '/zlibInflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + fileIo.writeSync(zlibInflateFile.fd, dataString); + fileIo.closeSync(zlibInflateFile); + // 验证压缩与解压的数据是否一致 + if (STRING_DATA == dataString) { + promptAction.showToast({ + message: $r('app.string.zlib_uncompress_success', dataString), + bottom: '11%' + }); + } + }) + } catch (errData) { + promptAction.showToast({ + message: $r('app.string.zlib_uncompress_failure'), + bottom: '11%' + }); + } + // 释放动态分配的数据结构 + await zip.inflateEnd({ nextOut: arrayBufferOut }); + hilog.info(DOMAIN, TAG, BUNDLE + `zlibDecompression end`); + } + + async gzipDecompression(): Promise { + hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression begin`); + let context = AppStorage.get('context') as Context; + let pathDir = context.cacheDir; + let file = fileIo.openSync(pathDir + '/gzipTest.gz', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + let path = pathDir + '/gzipTest.gz'; + fileIo.closeSync(file); + + // 创建gzip对象 + let gzip = zlib.createGZipSync(); + // 打开.gz文件,对文件进行写操作 + await gzip.gzopen(path, 'wb'); + let str = STRING_DATA; + let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE); + let byteArray = new Uint8Array(arrayBufferIn); + for (let i = 0, j = str.length; i < j; i++) { + byteArray[i] = str.charCodeAt(i); + } + try { + // 将bufferWithData压缩并写入文件 + await gzip.gzfwrite(arrayBufferIn, 8, 2).then((data) => { + promptAction.showToast({ + message: $r('app.string.gzip_compress_success', str), + bottom: '11%' + }); + }) + } catch (errData) { + promptAction.showToast({ + message: $r('app.string.gzip_compress_failure'), + bottom: '11%' + }); + } + await gzip.gzflush(0); + await gzip.gzclose(); + + await sleep(SLEEP_TIME); + // 打开.gz文件,对文件进行读操作 + await gzip.gzopen(path, 'rb'); + try { + let bufferWithDataOut = new ArrayBuffer(BUFFER_SIZE); + // 从.gz文件中读取和解压数据 + await gzip.gzfread(bufferWithDataOut, 8, 2).then((data) => { + let array = new Uint8Array(bufferWithDataOut); + let dataString = ''; + for (let i = 0; i < array.length; i++) { + dataString += String.fromCharCode(array[i]); + } + if (dataString == str) { + promptAction.showToast({ + message: $r('app.string.gzip_uncompress_success', dataString), + bottom: '11%' + }); + let gzipFile = + fileIo.openSync(pathDir + '/gzipTest.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + fileIo.writeSync(gzipFile.fd, dataString); + fileIo.closeSync(gzipFile); + } + }) + } catch (errData) { + promptAction.showToast({ + message: $r('app.string.gzip_uncompress_failure'), + bottom: '11%' + }); + } + await gzip.gzclose(); + hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression end`); + } + + build() { + Column() { + Column() { + Row() { + Image($r('app.media.icon_back')) + .size({ height: '71%' }) + .objectFit(ImageFit.Contain) + .onClick(() => { + router.pushUrl({ + url: 'pages/Index' + }); + }) + Text($r('app.string.zlibInterface')) + .fontSize(20) + .margin({ left: 8 }) + .width('100%') + .height('100%') + .fontWeight(FontWeight.Bold) + } + .height('15.64%') + .width('91%') + + Row() { + Text($r('app.string.CompressFiles')) + .textAlign(TextAlign.Start) + .fontSize(16) + .fontColor($r('app.color.text_color')) + Image($r('app.media.icon_next')) + .size({ height: '42.8%' }) + .objectFit(ImageFit.Contain) + } + .id('compressFiles') + .onClick(() => { + router.pushUrl({ + url: 'zlib/CompressFilesPage' + }); + }) + .justifyContent(FlexAlign.SpaceBetween) + .padding({ right: 12, left: 12 }) + .height('15.64%') + .width('91%') + .backgroundColor($r('app.color.start_window_background')) + .borderRadius(15) + .margin({ top: 8 }) + } + .alignItems(HorizontalAlign.Center) + .width('100%') + .height('50%') + + Column() { + Text($r('app.string.tip_Gzip')) + .textAlign(TextAlign.Start) + .fontSize(12) + .fontColor($r('app.color.tip_Gzip_backeGround')) + .width('86.4%') + .height('9%') + .margin({ bottom: 24 }) + + Button($r('app.string.gzip_interface')) + .id('gzipinterface') + .width('100%') + .height('100%') + .fontSize(16) + .fontFamily('HarmonyHeiTi') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_backeGround')) + .fontColor($r('app.color.button_color')) + .borderRadius(20) + .onClick(() => { + this.gzipDecompression(); + }) + .margin({ bottom: 12 }) + .width('91%') + .height('11.2%') + + Button($r('app.string.zlib_interface')) + .id('zlibinterface') + .width('100%') + .height('100%') + .fontSize(16) + .fontFamily('HarmonyHeiTi') + .type(ButtonType.Capsule) + .backgroundColor($r('app.color.button_backeGround')) + .fontColor($r('app.color.button_color')) + .borderRadius(20) + .onClick(() => { + this.zlibDecompression(); + }) + .margin({ bottom: 16 }) + .width('91%') + .height('11.2%') + } + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Center) + .width('100%') + .height('50%') + } + .backgroundColor($r('app.color.backGrounding')) + .width('100%') + .height('100%') + } } \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZipLibDecompressionPage.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZipLibDecompressionPage.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZipLibDecompressionPage.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/ets/zlib/ZipLibDecompressionPage.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/module.json5 b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/module.json5 rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/module.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/color.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/color.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/color.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/color.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/add.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/add.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/add.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/add.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/file.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/file.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/file.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/file.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_back.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_back.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_back.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_back.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_next.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_next.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_next.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/icon_next.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/zip.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/zip.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/zip.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/media/zip.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/profile/main_pages.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/profile/main_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/profile/main_pages.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/base/profile/main_pages.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/en_US/element/string.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/en_US/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/en_US/element/string.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/en_US/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/zh_CN/element/string.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/zh_CN/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/main/resources/zh_CN/element/string.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/main/resources/zh_CN/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/Ability.test.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/Ability.test.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/List.test.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/List.test.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/test/List.test.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/TestAbility.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/TestAbility.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/TestAbility.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/pages/Index.ets similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/pages/Index.ets rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/ets/testability/pages/Index.ets diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/module.json5 b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/module.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/module.json5 rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/module.json5 diff --git a/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/color.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/string.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/string.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/string.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/element/string.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/media/icon.png b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/media/icon.png similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/media/icon.png rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/media/icon.png diff --git a/code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/profile/test_pages.json similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/profile/test_pages.json rename to code/LanguageBaseClassLibrary/ZipLib/entry/src/ohosTest/resources/base/profile/test_pages.json diff --git a/code/LaunguageBaseClassLibrary/ZipLib/hvigor/hvigor-config.json5 b/code/LanguageBaseClassLibrary/ZipLib/hvigor/hvigor-config.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/hvigor/hvigor-config.json5 rename to code/LanguageBaseClassLibrary/ZipLib/hvigor/hvigor-config.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/hvigor/hvigor-wrapper.js b/code/LanguageBaseClassLibrary/ZipLib/hvigor/hvigor-wrapper.js similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/hvigor/hvigor-wrapper.js rename to code/LanguageBaseClassLibrary/ZipLib/hvigor/hvigor-wrapper.js diff --git a/code/LaunguageBaseClassLibrary/ZipLib/hvigorfile.ts b/code/LanguageBaseClassLibrary/ZipLib/hvigorfile.ts similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/hvigorfile.ts rename to code/LanguageBaseClassLibrary/ZipLib/hvigorfile.ts diff --git a/code/LaunguageBaseClassLibrary/ZipLib/hvigorw b/code/LanguageBaseClassLibrary/ZipLib/hvigorw similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/hvigorw rename to code/LanguageBaseClassLibrary/ZipLib/hvigorw diff --git a/code/LaunguageBaseClassLibrary/ZipLib/hvigorw.bat b/code/LanguageBaseClassLibrary/ZipLib/hvigorw.bat similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/hvigorw.bat rename to code/LanguageBaseClassLibrary/ZipLib/hvigorw.bat diff --git a/code/LaunguageBaseClassLibrary/ZipLib/oh-package.json5 b/code/LanguageBaseClassLibrary/ZipLib/oh-package.json5 similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/oh-package.json5 rename to code/LanguageBaseClassLibrary/ZipLib/oh-package.json5 diff --git a/code/LaunguageBaseClassLibrary/ZipLib/ohosTest.md b/code/LanguageBaseClassLibrary/ZipLib/ohosTest.md similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/ohosTest.md rename to code/LanguageBaseClassLibrary/ZipLib/ohosTest.md diff --git a/code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg b/code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg rename to code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg diff --git a/code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg b/code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg rename to code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg diff --git a/code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg b/code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg rename to code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg diff --git a/code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091651506.jpeg b/code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091651506.jpeg similarity index 100% rename from code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091651506.jpeg rename to code/LanguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091651506.jpeg diff --git a/code/Project/HapBuild/compile-tool/config/samples_master.config b/code/Project/HapBuild/compile-tool/config/samples_master.config index 37c986967a4571b0c29e8ee68a91a787d77a1f23..24b9e57d1d1c0e5f1eeb14eeac47185f5d252589 100644 --- a/code/Project/HapBuild/compile-tool/config/samples_master.config +++ b/code/Project/HapBuild/compile-tool/config/samples_master.config @@ -1,7 +1,7 @@ name=samples_master url=https://gitee.com/openharmony/applications_app_samples.git branch=master -fullSdkAssembleList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LaunguageBaseClassLibrary/Process;code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility +fullSdkAssembleList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LanguageBaseClassLibrary/Process;code/LanguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility basicSignList=code/BasicFeature/WindowManagement/WindowRatio;code/BasicFeature/Media/Recorder;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/Solutions/Game/DistributedDataGobang;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/Internationalnation/International;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/Solutions/InputMethod/KikaInput;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/BasicFeature/WindowManagement/WindowManage;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Contact;code/BasicFeature/Telephony/Call;code/BasicFeature/Media/Audio;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;ability/FormLauncher;common/International;device/DeviceUsageStatistics;Telephony/Contact;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Observer;code/BasicFeature/Telephony/SimManager;Account/DistributeAccount;code/BasicFeature/TaskManagement/Flybird;UI/JsTimer;ETSUI/BringApp; coreSignList=code_BasicFeature_Web_RunJsInWeb;code/BasicFeature/Web/Browser;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Media/MultiMedia;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/Solutions/Tools/FlipClock;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/ApplicationModels/CustomShare;media/ScreenRecorder;ability/GalleryForm;FileManager/StorageStatistic;Graphics/Screenshot;ability/MissionManager;Communication/Wlan;code/BasicFeature/Media/QRCodeScan;Safety/AbilityAccessCtrl;Basic/Screenshot;Notification/Notification;code/SystemFeature/ApplicationModels/Launcher systemAppList=code_BasicFeature_Web_RunJsInWeb;code/BasicFeature/Web/Browser;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/Solutions/Game/DistributedDataGobang;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/SuperFeature/DistributedAppDev/DistributedRdb;code/BasicFeature/Security/PaySecurely;code/SystemFeature/Connectivity/Bluetooth;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Telephony/Message;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/SystemFeature/Internationalnation/International;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/Media/QRCodeScan;code/SystemFeature/ApplicationModels/MissionManager;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/SystemFeature/DeviceManagement/StorageStatistic;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/BasicFeature/Media/Recorder;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/SystemFeature/Media/Screenshot;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Connectivity/Wlan;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/Solutions/Media/MultiMedia;code/Solutions/Tools/JsClock;code/Solutions/Tools/FlipClock;code/SystemFeature/ApplicationModels/Launcher;FileManager/FileManager diff --git a/code/Project/HapBuild/compile-tool/config/ut_samples_master.config b/code/Project/HapBuild/compile-tool/config/ut_samples_master.config index 0007e60512d7983571330629a5371bcb6c2a29a3..1789c7a27cbed38192ce0b38472348f7ce401d64 100644 --- a/code/Project/HapBuild/compile-tool/config/ut_samples_master.config +++ b/code/Project/HapBuild/compile-tool/config/ut_samples_master.config @@ -1,7 +1,7 @@ name=ut_samples_master url=https://gitee.com/openharmony/applications_app_samples branch=master -fullSdkAssembleList=code/BasicFeature/Notification/CustomCommonEvent;code/DocsSample/ApplicationModels/WidgetUpdateByProxy;code/DocsSample/ApplicationModels/FAModelAbilityDevelop;code/DocsSample/ApplicationModels/StageModelAbilityInteraction;code/DocsSample/ApplicationModels/StageModelAbilityDevelop;code/DocsSample/ApplicationModels/StageProcessThread;code/DocsSample/ApplicationModels/StageServiceWidgetCards;code/SystemFeature/InsightIntent/IntentExecute;code/BasicFeature/Media/Image;code/BasicFeature/Security/Huks;code/BasicFeature/Ads/OAIDSample;code/BasicFeature/Connectivity/VPN;code/BasicFeature/Resource/ResourceManager;code/BasicFeature/Telephony/Call;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LaunguageBaseClassLibrary/Process;code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility +fullSdkAssembleList=code/BasicFeature/Notification/CustomCommonEvent;code/DocsSample/ApplicationModels/WidgetUpdateByProxy;code/DocsSample/ApplicationModels/FAModelAbilityDevelop;code/DocsSample/ApplicationModels/StageModelAbilityInteraction;code/DocsSample/ApplicationModels/StageModelAbilityDevelop;code/DocsSample/ApplicationModels/StageProcessThread;code/DocsSample/ApplicationModels/StageServiceWidgetCards;code/SystemFeature/InsightIntent/IntentExecute;code/BasicFeature/Media/Image;code/BasicFeature/Security/Huks;code/BasicFeature/Ads/OAIDSample;code/BasicFeature/Connectivity/VPN;code/BasicFeature/Resource/ResourceManager;code/BasicFeature/Telephony/Call;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LanguageBaseClassLibrary/Process;code/LanguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility basicSignList=code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/BasicFeature/WindowManagement/WindowRatio;code/BasicFeature/Media/Recorder;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/Solutions/Game/DistributedDataGobang;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/Internationalnation/International;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/Solutions/InputMethod/KikaInput;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/BasicFeature/WindowManagement/WindowManage;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Contact;code/BasicFeature/Telephony/Call;code/BasicFeature/Media/Audio;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;ability/FormLauncher;common/International;device/DeviceUsageStatistics;Telephony/Contact;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Observer;code/BasicFeature/Telephony/SimManager;Account/DistributeAccount;code/BasicFeature/TaskManagement/Flybird;UI/JsTimer;ETSUI/BringApp; coreSignList=code/BasicFeature/Connectivity/VPN;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Media/MultiMedia;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/Solutions/Tools/FlipClock;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/ApplicationModels/CustomShare;media/ScreenRecorder;ability/GalleryForm;FileManager/StorageStatistic;Graphics/Screenshot;ability/MissionManager;Communication/Wlan;code/BasicFeature/Media/QRCodeScan;Safety/AbilityAccessCtrl;Basic/Screenshot;Notification/Notification;code/SystemFeature/ApplicationModels/Launcher systemAppList=code/BasicFeature/Connectivity/VPN;code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/Solutions/Game/DistributedDataGobang;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/SuperFeature/DistributedAppDev/DistributedRdb;code/BasicFeature/Security/PaySecurely;code/SystemFeature/Connectivity/Bluetooth;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Telephony/Message;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/SystemFeature/Internationalnation/International;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/Media/QRCodeScan;code/SystemFeature/ApplicationModels/MissionManager;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/SystemFeature/DeviceManagement/StorageStatistic;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/BasicFeature/Media/Recorder;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/SystemFeature/Media/Screenshot;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Connectivity/Wlan;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/Solutions/Media/MultiMedia;code/Solutions/Tools/JsClock;code/Solutions/Tools/FlipClock;code/SystemFeature/ApplicationModels/Launcher;FileManager/FileManager diff --git a/code/Project/HapBuild/compile-tool/config/ut_samples_master_ohpm.config b/code/Project/HapBuild/compile-tool/config/ut_samples_master_ohpm.config index 287460acc5235b6839c22f679a0d54c699f9fdbc..66a3066f65f09188ad9e51031b2b89728bb3ba35 100644 --- a/code/Project/HapBuild/compile-tool/config/ut_samples_master_ohpm.config +++ b/code/Project/HapBuild/compile-tool/config/ut_samples_master_ohpm.config @@ -1,7 +1,7 @@ name=ut_samples_master_ohpm url=https://gitee.com/username/applications_app_samples.git branch=master -fullSdkAssembleList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LaunguageBaseClassLibrary/Process;code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility +fullSdkAssembleList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/BasicFeature/DataManagement/Preferences;code/BasicFeature/FileManagement/MediaCollections;code/BasicFeature/Media/GamePuzzle;code/BasicFeature/Media/AVRecorder;code/BasicFeature/DFX/AppRecovery;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Tools/JsClock;code/BasicFeature/Media/Audio;code/BasicFeature/Media/QRCodeScan;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/IDL/AbilityConnectServiceExtension;code/BasicFeature/Media/Recorder;code/BasicFeature/TaskManagement/ContinuousTask;code/BasicFeature/TaskManagement/Flybird;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/Telephony/Message;code/BasicFeature/Web/Browser;code/LanguageBaseClassLibrary/Process;code/LanguageBaseClassLibrary/LanguageBaseClassLibrary;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/Solutions/Game/DistributedDataGobang;code/Solutions/Game/Lottie;code/Solutions/Media/MultiMedia;code/Solutions/Tools/FlipClock;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/Widget/FormGame;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/SystemFeature/ApplicationModels/Launcher;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/Connectivity/Upload;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Internationalnation/International;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/SystemFeature/WindowManagement/WindowExtAbility basicSignList=code/BasicFeature/WindowManagement/WindowRatio;code/BasicFeature/Media/Recorder;code/SuperFeature/DistributedAppDev/DistributedRdb;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/Kvstore;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/SuperFeature/DistributedAppDev/ArkTSDistributedCalc;code/Solutions/Game/DistributedDataGobang;code/SystemFeature/Connectivity/Bluetooth;code/SystemFeature/DeviceManagement/PowerManager;code/SystemFeature/Internationalnation/International;code/SuperFeature/DistributedAppDev/ArkTSDistributedMusicPlayer;code/Solutions/InputMethod/KikaInput;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/BasicFeature/WindowManagement/WindowManage;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Contact;code/BasicFeature/Telephony/Call;code/BasicFeature/Media/Audio;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/BasicFeature/FileManagement/FileManager;ability/FormLauncher;common/International;device/DeviceUsageStatistics;Telephony/Contact;code/BasicFeature/Telephony/Message;code/BasicFeature/Telephony/Observer;code/BasicFeature/Telephony/SimManager;Account/DistributeAccount;code/BasicFeature/TaskManagement/Flybird;UI/JsTimer;ETSUI/BringApp; coreSignList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/BasicFeature/Security/PaySecurely;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Media/VoiceCallDemo;code/SuperFeature/DistributedAppDev/DistributeCalc;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/Solutions/Media/MultiMedia;code/SystemFeature/ApplicationModels/MissionManager;code/SystemFeature/ApplicationModels/StaticSubscriber;code/SystemFeature/Connectivity/Wlan;code/SystemFeature/DeviceManagement/StorageStatistic;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Media/Screenshot;code/SystemFeature/Security/AbilityAccessCtrl;code/Solutions/Tools/FlipClock;code/Solutions/Shopping/OrangeShopping;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/TaskManagement/TransientTask;code/BasicFeature/ApplicationModels/CustomShare;media/ScreenRecorder;ability/GalleryForm;FileManager/StorageStatistic;Graphics/Screenshot;ability/MissionManager;Communication/Wlan;code/BasicFeature/Media/QRCodeScan;Safety/AbilityAccessCtrl;Basic/Screenshot;Notification/Notification;code/SystemFeature/ApplicationModels/Launcher systemAppList=code/BasicFeature/FileManagement/Photos;code/BasicFeature/FileManagement/FileShare/SandboxShare;code/BasicFeature/FileManagement/FileShare/Picker;code/SuperFeature/Widget/FormExtAbility;code/SuperFeature/DistributedAppDev/DistributedNote;code/SuperFeature/DistributedAppDev/JsDistributedMusicPlayer;code/SystemFeature/ApplicationModels/StaticSubscriber;code/Solutions/Game/DistributedDataGobang;code/UI/ArkTsComponentCollection/ComponentCollection;code/BasicFeature/ApplicationModels/CustomShare;code/BasicFeature/Notification/CustomNotificationPush;code/BasicFeature/FileManagement/FileBackupExtension;code/SuperFeature/DistributedAppDev/DistributedRdb;code/BasicFeature/Security/PaySecurely;code/SystemFeature/Connectivity/Bluetooth;code/BasicFeature/Connectivity/WebSocket;code/SystemFeature/Interantionalnation/International;code/BasicFeature/Connectivity/Bluetooth;code/SystemFeature/ApplicationModels/PersistentProxyForm;code/SystemFeature/ApplicationModels/Template;code/SuperFeature/Widget/RequestAddForm;code/SystemFeature/ApplicationModels/Receiver;code/SystemFeature/ApplicationModels/ProcessProxyForm;code/SystemFeature/ApplicationModels/Template;code/BasicFeature/Telephony/Message;code/SuperFeature/DistributedAppDev/DistributedAuthentication;code/BasicFeature/Media/VoiceCallDemo;code/BasicFeature/WindowManagement/WindowRatio;code/SuperFeature/DistributedAppDev/DistributeCalc;code/SystemFeature/Internationalnation/International;code/BasicFeature/Connectivity/Socket;code/SystemFeature/Media/Camera;code/SuperFeature/DistributedAppDev/DistributedAccount;code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack;code/Project/ResourceAllocation/ApplicationThemeSwitch;code/SystemFeature/DeviceManagement/DeviceManagementCollection;code/BasicFeature/Notification/CustomNotification;code/Solutions/InputMethod/KikaInputMethod;code/BasicFeature/FileManagement/FileManager;code/BasicFeature/Media/QRCodeScan;code/SystemFeature/ApplicationModels/MissionManager;code/BasicFeature/Media/AVSession/MediaController;code/BasicFeature/Media/AVSession/MediaProvider;code/SystemFeature/Connectivity/Upload;code/SystemFeature/DeviceManagement/StorageStatistic;code/BasicFeature/Notification/CustomCommonEvent;code/BasicFeature/ApplicationModels/StageModel;code/BasicFeature/Media/GamePuzzle;code/SystemFeature/DataManagement/CrossAppDataShare;code/BasicFeature/Media/Recorder;code/SystemFeature/DeviceManagement/Screen;code/SystemFeature/ApplicationModels/EnterpriseAdminExtensionAbility;code/BasicFeature/Media/AVRecorder;code/SystemFeature/Security/AbilityAccessCtrl;code/SuperFeature/Widget/ArkTSCard/MusicControl;code/SystemFeature/Media/Screenshot;code/SystemFeature/Media/ScreenRecorder;code/SystemFeature/Connectivity/Wlan;code/BasicFeature/TaskManagement/WorkScheduler;code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics;code/Solutions/Media/MultiMedia;code/Solutions/Tools/JsClock;code/Solutions/Tools/FlipClock;code/SystemFeature/ApplicationModels/Launcher;FileManager/FileManager diff --git a/code/Project/Test/README_zh.md b/code/Project/Test/README_zh.md index bb37d66412608fbed222944b3c233db955626589..a463a83d0a691e0a98881a5531b5be51c4f17750 100644 --- a/code/Project/Test/README_zh.md +++ b/code/Project/Test/README_zh.md @@ -2,7 +2,7 @@ ## 介绍 本示例展示测试框架的使用示例,主要介绍了单元测试框架和UI测试框架的使用示例。 -测试框架arkxtest的详细介绍请[参考](https://gitee.com/openharmony/testfwk_arkxtest)。 +测试框架arkxtest的详细介绍请[参考](https://docs.openharmony.cn/pages/v5.1/zh-cn/application-dev/application-test/arkxtest-guidelines.md)。 ## 效果预览 diff --git a/code/Project/Test/jsunit/README_zh.md b/code/Project/Test/jsunit/README_zh.md index 1f5ff38b94762e447aa1ac2909596d915f90075e..c4a4d8b448bcb20124376ec535083bbecdbe1782 100644 --- a/code/Project/Test/jsunit/README_zh.md +++ b/code/Project/Test/jsunit/README_zh.md @@ -3,7 +3,7 @@ ### 介绍 本示例展示测试框架中单元测试框架的使用示例。 -本实例用到了自动化测试框架代码部件仓arkXtest,测试框架的详细介绍[arkXtest](https://gitee.com/openharmony/testfwk_arkxtest#%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) 。 +本实例用到了自动化测试框架代码部件仓arkXtest,测试框架的详细介绍[arkXtest](https://docs.openharmony.cn/pages/v5.1/zh-cn/application-dev/application-test/arkxtest-guidelines.md)。 如需日志打印调试,需要引入日志打印接口[@ohos.hilog](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hilog.md) 。 diff --git a/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/paramExampleTest/paramExample.test.ets b/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/paramExampleTest/paramExample.test.ets index 3ea051ecbec51ed18e2fa84ef24720ae6cf92efa..186f0025534b9a8e564e3b78a28335a5f2992309 100644 --- a/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/paramExampleTest/paramExample.test.ets +++ b/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/paramExampleTest/paramExample.test.ets @@ -54,7 +54,7 @@ * Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) * * 指导文档 - * https://gitee.com/openharmony/testfwk_arkxtest#%E6%95%B0%E6%8D%AE%E9%A9%B1%E5%8A%A8 + * https://docs.openharmony.cn/pages/v5.1/zh-cn/application-dev/application-test/arkxtest-guidelines.md#%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%E9%A9%B1%E5%8A%A8%E8%83%BD%E5%8A%9B%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B */ import {describe, it, expect, TestType} from '@ohos/hypium'; diff --git a/code/Project/Test/uitest/README_zh.md b/code/Project/Test/uitest/README_zh.md index 833bcb4adcef01fdc6a9e7515d2418404b8558ce..5a737a4a593cdea8ae9c577c0294ca2162d59cbd 100644 --- a/code/Project/Test/uitest/README_zh.md +++ b/code/Project/Test/uitest/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 本示例展示测试框架中UI测试框架的使用示例。 -测试框架arkxtest的详细介绍请[参考](https://gitee.com/openharmony/testfwk_arkxtest) 。 +测试框架arkxtest的详细介绍请[参考](https://docs.openharmony.cn/pages/v5.1/zh-cn/application-dev/application-test/arkxtest-guidelines.md) 。 本实例需要引入UiTest接口[@ohos.UiTest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-test-kit/js-apis-uitest.md) 。 diff --git a/code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/pages/CasesSwiperCard.ets b/code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/pages/CasesSwiperCard.ets index 448823eb2cd366494f31ec0c920b0e06a6ef721d..a0fc01f9240d25dbbe5cc8d23efeb301bd6da8fb 100644 --- a/code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/pages/CasesSwiperCard.ets +++ b/code/SuperFeature/Widget/ArkTSCard/CardInteractionCase/entry/src/main/ets/widget/pages/CasesSwiperCard.ets @@ -80,6 +80,10 @@ struct Widget_DynamicCard { }) } .autoPlay(true) + } else { + Image($r('app.media.share_button')) + .width('100%') + .height('100%') } } .width($r('app.string.widget_display_full_width_percent')) diff --git a/code/SystemFeature/ApplicationModels/CustomShare/README_zh.md b/code/SystemFeature/ApplicationModels/CustomShare/README_zh.md index aa812a56f08bede7f847511a468992ec79f74bfb..4782b217f5f612515f406431b0a1b28b2514c05f 100644 --- a/code/SystemFeature/ApplicationModels/CustomShare/README_zh.md +++ b/code/SystemFeature/ApplicationModels/CustomShare/README_zh.md @@ -112,7 +112,7 @@ entry中测试[Share.test.ets](./entry/src/ohosTest/ets/test/Share.test.ets)需 4.本示例使用的screenshot API属于SystemAPI,需要使用Full SDK 手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 5.本示例涉及相关权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看), 需要手动配置高级别的权限签名( -具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md)) 。 +具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)) 。 6.本示例类型为系统应用,需要手动配置对应级别的应用类型("app-feature": "hos_system_app")。具体可参考profile配置文件[bundle-info对象内部结构]( https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/application-dev/security/app-provision-structure.md#bundle-info%E5%AF%B9%E8%B1%A1%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84 )。 diff --git a/code/SystemFeature/ApplicationModels/Launcher/README_zh.md b/code/SystemFeature/ApplicationModels/Launcher/README_zh.md index 7b4f5385fe4d155c84430229577652533475204c..57f1c3c274bf6c620bd8bd553e75cb37c1b5d58d 100644 --- a/code/SystemFeature/ApplicationModels/Launcher/README_zh.md +++ b/code/SystemFeature/ApplicationModels/Launcher/README_zh.md @@ -80,7 +80,7 @@ entry/src/main/ets/ * 点击桌面应用拉起最近任务至前台功能模块 * 使用ServiceExtensionContext模块的startRecentAbility接口(系统能力:SystemCapability.Ability.AbilityRuntime.Core),拉起最近任务至前台显示,若应用Ability未启动时,则拉起新创建的应用Ability显示到前台。 * 源码链接:[LauncherAbilityManager.ts](./base/src/main/ets/default/manager/LauncherAbilityManager.ts) - * 接口参考:[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.ServiceExtensionAbility.d.ts) + * 接口参考:[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-serviceExtensionAbility-sys.md) ### 相关权限 | 权限名 | 权限说明 | 级别 | diff --git a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/README_zh.md b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/README_zh.md index 67b76c97f85732ec6fa1dace0f8054a5b1473ef2..9fefb1d9bcc573ae08a22a16a035ceffae401e17 100644 --- a/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/README_zh.md +++ b/code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 -本示例为一个仿桌面应用测试demo,使用[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.ServiceExtensionAbility.d.ts)接口中ServiceExtensionContext类的startRecentAbility能力(系统能力:SystemCapability.Ability.AbilityRuntime.Core),实现了跨任务链返回的功能。 +本示例为一个仿桌面应用测试demo,使用[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-serviceExtensionAbility-sys.md)接口中ServiceExtensionContext类的startRecentAbility能力(系统能力:SystemCapability.Ability.AbilityRuntime.Core),实现了跨任务链返回的功能。 ### 效果预览 @@ -46,7 +46,7 @@ entry/src/main/ets/ - 拉起任务至前台显示的功能接口封装在LauncherAbilityManager,源码参考:[LauncherAbilityManager.ts](../../../Launcher/base/src/main/ets/default/manager/LauncherAbilityManager.ts)。 - 跨任务链返回:在ServiceExtensionAbility,使用ServiceExtensionContext.startRecentAbility(),将Want中将"ABILITY_BACK_TO_OTHER_MISSION_STACK"(返回当前任务链字段)设置为"true",以实现返回至打开ServiceExtensionAbility的ability的功能。 - - 接口参考:[@ohos.app.ability.wantConstant](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.wantConstant.d.ts)、[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.ServiceExtensionAbility.d.ts) + - 接口参考:[@ohos.app.ability.wantConstant](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-wantConstant.md)、[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-serviceExtensionAbility-sys.md) ### 相关权限 diff --git a/code/SystemFeature/AutoFill/AutoFill/README_zh.md b/code/SystemFeature/AutoFill/AutoFill/README_zh.md index 4f4a403fd5f51663fba035bbc277f726d7ab78f2..a9efb17c2a30c499a7b3de9c032a00e7e41f267b 100644 --- a/code/SystemFeature/AutoFill/AutoFill/README_zh.md +++ b/code/SystemFeature/AutoFill/AutoFill/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 -本示例使用[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts),[application/ViewData](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ViewData.d.ts),[@ohos.app.ability.autoFillManager ](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts)等接口,展示了如何使用AutoFill自动填充框架。具体而言实现了如下几点功能: +本示例使用[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md),[application/ViewData](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-viewData-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md)等接口,展示了如何使用AutoFill自动填充框架。具体而言实现了如下几点功能: 1.账号和密码的自动保存; 2.账号和密码的自动填充; @@ -57,32 +57,32 @@ entry/src/main/ets/ * USER_NAME类型的TextInput控件获焦后拉起AutoFillExtensionAbility,并触发onFillRequest回调,将选择的账号密码返回到textInput组件。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/AutoFillAbility.ts),[AutoFillControl.ets](entry/src/main/ets/autofillpages/AutoFillControl.ets) - * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts),[application/ViewData](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ViewData.d.ts) + * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md),[application/ViewData](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-viewData-sys.md) 2. Password类型的AutoFill控件自动填充 * Password类型的TextInput控件获焦后拉起AutoFillExtensionAbility,并触发onFillRequest回调,将选择的账号密码返回到textInput组件。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/AutoFillAbility.ts),[AutoFillControl.ets](entry/src/main/ets/autofillpages/AutoFillControl.ets) - * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts), [application/ViewData](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ViewData.d.ts) + * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md), [application/ViewData](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-viewData-sys.md) 3. NEW_PASSWORD类型的AutoFill控件自动填充 * NEW_PASSWORD类型的TextInput控件获焦后拉起AutoFillExtensionAbility,并触发onFillRequest回调,将选择的账号密码返回到textInput组件。 * 源码链接:[RegisterPage.ets](entry/src/main/ets/autofillpages/RegisterPage.ets), [AutoFillAbility.ts](entry/src/main/ets/autofillability/AutoFillAbility.ts),[AutoFillNewPassWord.ets](entry/src/main/ets/autofillpages/AutoFillNewPassWord.ets) - * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts), [application/ViewData](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ViewData.d.ts) + * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md), [application/ViewData](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-viewData-sys.md) 4. 自动保存能力 * 当登录页面消失,发起自动保存请求,触发onSaveRequest生命周期。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/AutoFillAbility.ts),[LoginSuccessPage.ets](entry/src/main/ets/autofillpages/LoginSuccessPage.ets),[SavePage.ets](entry/src/main/ets/autofillpages/SavePage.ets) - * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts) + * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md) 5. 用户主动调用保存接口 * 用户主动调用requestAutoSave接口保存账号密码。 * 源码链接:[RegisterPage.ets](entry/src/main/ets/autofillpages/RegisterPage.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/AutoFillAbility.ts),[SavePage.ets](entry/src/main/ets/autofillpages/SavePage.ets) - * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts) + * 参考接口:[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md) ### 安装命令 diff --git a/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md b/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md index 74e064e16878521d112a30bfa73296d5b8154aaf..91b9795279608c22bc245907fb08a4fc80d1d348 100755 --- a/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md +++ b/code/SystemFeature/AutoFill/AutoFillScenarioization/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 -本示例使用[application/AutoFillRequest](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AutoFillRequest.d.ts),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.AutoFillExtensionAbility.d.ts),[@ohos.app.ability.autoFillManager ](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts)等接口,展示了情景化填充能力。具体而言实现了如下几点功能: +本示例使用[application/AutoFillRequest](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-autoFillRequest-sys.md),[@ohos.app.ability.AutoFillExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillExtensionAbility-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md)等接口,展示了情景化填充能力。具体而言实现了如下几点功能: 1.数据的自动保存; 2.数据的手动保存; @@ -50,25 +50,25 @@ entry/src/main/ets/ * FULL_PHONE_NUMBER类型的TextInput控件获焦后拉起AutoFillExtensionAbility。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/TextAutoFillAbility.ts),[SelectorList.ets](entry/src/main/ets/autofillpages/SelectorList.ets) - * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.UIExtensionContentSession.d.ts),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts) + * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md) 2. PERSON_FULL_NAME类型的情景化自动填充。 * PERSON_FULL_NAME类型的TextInput控件获焦后拉起AutoFillExtensionAbility,输入字符进行联想页面弹出select弹窗并触发onUpdateRequest回调,将选择的名字返回到textInput组件。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/TextAutoFillAbility.ts),[SelectorList.ets](entry/src/main/ets/autofillpages/SelectorList.ets) - * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.UIExtensionContentSession.d.ts),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts) + * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md) 3. 自动保存能力。 * 当登录页面消失,发起自动保存请求,触发onSaveRequest生命周期。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/TextAutoFillAbility.ts),[ReturnMainPage.ets](entry/src/main/ets/autofillpages/ReturnMainPage.ets),[SavePage.ets](entry/src/main/ets/autofillpages/SavePage.ets) - * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.UIExtensionContentSession.d.ts),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts) + * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md) 4. 用户主动调用保存接口。 * 用户主动调用requestAutoSave接口保存账号密码。 * 源码链接:[SelectorList.ets](entry/src/main/ets/autofillpages/SelectorList.ets),[AutoFillAbility.ts](entry/src/main/ets/autofillability/TextAutoFillAbility.ts),[SavePage.ets](entry/src/main/ets/autofillpages/SavePage.ets) - * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.UIExtensionContentSession.d.ts),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.autoFillManager.d.ts) + * 参考接口:[@ohos.app.ability.UIExtensionContentSession](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md),[@ohos.app.ability.autoFillManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-autoFillManager-sys.md) ### 相关权限 diff --git a/code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md b/code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md index c7af7e747665eebb0b4b4dbd95fb1469639a59c5..04f5d2d169c1c2c508590bf8edb22038b108e0c2 100644 --- a/code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md +++ b/code/SystemFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md @@ -59,7 +59,7 @@ entry/src/main/ets/ 4.本示例涉及使用系统接口:queryBundleStateInfos(),需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 -5.本示例所配置的权限为ohos.permission.BUNDLE_ACTIVE_INFO为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md)。 +5.本示例所配置的权限为ohos.permission.BUNDLE_ACTIVE_INFO为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)。 ### 下载 如需单独下载本工程,执行如下命令: diff --git a/code/SystemFeature/FullScreenStart/FullScreenStart/README_zh.md b/code/SystemFeature/FullScreenStart/FullScreenStart/README_zh.md index 7052daa05d5d194c00549c7de29ec1ca122b55aa..28d51a4b00a77561a3768121e58c3f20a1fa8097 100644 --- a/code/SystemFeature/FullScreenStart/FullScreenStart/README_zh.md +++ b/code/SystemFeature/FullScreenStart/FullScreenStart/README_zh.md @@ -2,7 +2,7 @@ ### 介绍 -本示例使用[@ohos.app.ability.EmbeddableUIAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.EmbeddableUIAbility.d.ts),[@ohos.arkui.advanced.FullScreenLaunchComponent](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.arkui.advanced.FullScreenLaunchComponent.d.ets),[UIAbilityContext.openAtomicService](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/UIAbilityContext.d.ts),[UIExtensionContext.openAtomicService](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/UIExtensionContext.d.ts)等接口,展示了如何全屏启动原子化服务。 +本示例使用[@ohos.app.ability.EmbeddableUIAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-embeddableUIAbility.md),[@ohos.arkui.advanced.FullScreenLaunchComponent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ohos-arkui-advanced-FullScreenLaunchComponent.md),[UIAbilityContext.openAtomicService](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md),[UIExtensionContext.openAtomicService](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiExtensionContext.md)等接口,展示了如何全屏启动原子化服务。 ### 效果预览 @@ -40,17 +40,17 @@ entry/src/main/ets/ * FullScreenLaunchComponent (全屏启动原子化服务组件) * 调用FullScreenLaunchComponent全屏启动原子化服务组件,当被拉起方授权使用方可以嵌入式运行原子化服务时,使用方全屏嵌入式运行原子化服务。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets) - * 参考接口:[@ohos.arkui.advanced.FullScreenLaunchComponent](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.arkui.advanced.FullScreenLaunchComponent.d.ets) + * 参考接口:[@ohos.arkui.advanced.FullScreenLaunchComponent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ohos-arkui-advanced-FullScreenLaunchComponent.md) * UIAbility全屏启动原子化服务 * 调用UIAbilityContext.openAtomicService(),使用方全屏跳出式启动原子化服务。 * 源码链接:[Index.ets](entry/src/main/ets/pages/Index.ets) - * 参考接口:[UIAbilityContext.openAtomicService](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/UIAbilityContext.d.ts) + * 参考接口:[UIAbilityContext.openAtomicService](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) * UIExtension全屏启动原子化服务 * 调用UIExtensionContext.openAtomicService(),使用方全屏跳出式启动原子化服务。 * 源码链接:[ExtensionIndex.ets](entry/src/main/ets/pages/ExtensionIndex.ets) - * 参考接口:[UIExtensionContext.openAtomicService](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/UIExtensionContext.d.ts) + * 参考接口:[UIExtensionContext.openAtomicService](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiExtensionContext.md) ### 相关权限 diff --git a/code/SystemFeature/Media/Audio/README.md b/code/SystemFeature/Media/Audio/README.md index fb0ca8738b4535ec5d513cc043d6f30207eb4daf..b4807eee5cb623e9d9979f1870201fb22bf68181 100644 --- a/code/SystemFeature/Media/Audio/README.md +++ b/code/SystemFeature/Media/Audio/README.md @@ -3,7 +3,7 @@ ### 介绍 此Sample展示 -[空间音频API](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.multimedia.audio.d.ts) 的用法,相关API包括: +[空间音频API](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-audio-kit/js-apis-audio-sys.md) 的用法,相关API包括: 1. isSpatializationSupported(): 查询系统是否支持空间音频, 2. isHeadTrackingSupported():查询系统是否支持头动跟踪, 3. isSpatializationSupportedForDevice(deviceDescriptor: AudioDeviceDescriptor):查询设备是否支持空间音频, @@ -68,7 +68,7 @@ entry/src/main/ets/ 4.本示例需要使用系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 -5.本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/) ,把配置文件中的“app-feature”字段信息改为“hos_system_app”,再将“apl”字段信息改为“system_core”。 +5.本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) ,把配置文件中的“app-feature”字段信息改为“hos_system_app”,再将“apl”字段信息改为“system_core”。 ### 下载 diff --git a/code/SystemFeature/Media/Screenshot/README_zh.md b/code/SystemFeature/Media/Screenshot/README_zh.md index a4bc744c44ed655eaa6bcb29b5deb8f31a2ae817..9b5556945b850dcc51eaec39a07058bf942aa8ae 100644 --- a/code/SystemFeature/Media/Screenshot/README_zh.md +++ b/code/SystemFeature/Media/Screenshot/README_zh.md @@ -49,7 +49,7 @@ entry/src/main/ets/ ; 3. 本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行; 4. 本示例所配置的权限 ohos.permission.CAPTURE_SCREEN 为 system_core 级别( - 相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/)); + 相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)); 5. 本示例需要设置为系统应用才可使用接口 hasPrivacyWindow 判断隐私窗口,签名文件中修改 app-feature 为 hos_system_app。 ### 下载 diff --git a/code/SystemFeature/Notification/Publish/README_zh.md b/code/SystemFeature/Notification/Publish/README_zh.md index 26f932619acf8e1da72ba6a493f14d5fec118dee..9255d00d6f6052157485af0fe39c24ec4917ee4d 100644 --- a/code/SystemFeature/Notification/Publish/README_zh.md +++ b/code/SystemFeature/Notification/Publish/README_zh.md @@ -58,7 +58,7 @@ entry/src/ohosTest/ets/ 2. 本示例为stage模型,仅适配API version11版本SDK,SDK版本号(API Version 11 Release)。 3. 本示例需要使用DevEco Studio 版本号(3.1.1 Release)版本才可编译运行。 -本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://docs.openharmony.cn/pages/v3.2Beta/zh-cn/application-dev/security/hapsigntool-overview.md/) +本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) ,把配置文件中的“app-feature”字段信息改为“hos_system_app”,"apl"字段修改为“system_basic”。 ### 下载 diff --git a/code/SystemFeature/Notification/Subscribe/README_zh.md b/code/SystemFeature/Notification/Subscribe/README_zh.md index d921f452b8643ad84d03c119a610d98bb062c47e..71653fea996c90e9673f7a3964e5492ac328d36b 100644 --- a/code/SystemFeature/Notification/Subscribe/README_zh.md +++ b/code/SystemFeature/Notification/Subscribe/README_zh.md @@ -58,7 +58,7 @@ entry/src/ohosTest/ets/ 2. 本示例为stage模型,仅适配API version11版本SDK,SDK版本号(API Version 11 Release)。 3. 本示例需要使用DevEco Studio 版本号(3.1.1 Release)版本才可编译运行。 -本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://docs.openharmony.cn/pages/v3.2Beta/zh-cn/application-dev/security/hapsigntool-overview.md/) +本示例涉及系统接口,需要配置系统应用签名,可以参考[特殊权限配置方法](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md) ,把配置文件中的“app-feature”字段信息改为“hos_system_app”,"apl"字段修改为“system_basic”。 ### 下载 diff --git a/code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/README_zh.md b/code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/README_zh.md index 1dc73ddd95a7d6e5e360b96f342f02f8b74871a9..c9b37031b75bdd8bfe712789b94dcb50f97c9484 100644 --- a/code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/README_zh.md +++ b/code/SystemFeature/ResourceAllocation/ApplicationThemeSwitch/README_zh.md @@ -73,7 +73,7 @@ entry/src/main/resources/ 1. 本示例仅支持标准系统上运行,支持设备:RK3568。 2. 本示例已适配 API version 9 版本 SDK,本示例涉及使用系统接口:@ohos.application.abilityManager,需要手动替换 Full SDK 才能编译通过,具体操作可以参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md) 。 3. 本示例需要使用 DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。 -4. 本示例所配置的权限 ohos.permission.UPDATE_CONFIGURATION 为 system_basic 级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md) 查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md))。 +4. 本示例所配置的权限 ohos.permission.UPDATE_CONFIGURATION 为 system_basic 级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md) 查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))。 ### 下载 diff --git a/code/SystemFeature/Security/AbilityAccessCtrl/README_zh.md b/code/SystemFeature/Security/AbilityAccessCtrl/README_zh.md index 134a057fc1a499f391154760c3cd0b712700d08b..5843b6469395277c797aef6ba2bb3345f2141297 100644 --- a/code/SystemFeature/Security/AbilityAccessCtrl/README_zh.md +++ b/code/SystemFeature/Security/AbilityAccessCtrl/README_zh.md @@ -72,7 +72,7 @@ entry/src/main/ets/ 5.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。 -6.本示例所配置的权限ohos.permission.GET_SENSITIVE_PERMISSIONS、ohos.permission.REVOKE_SENSITIVE_PERMISSIONS、ohos.permission.GRANT_SENSITIVE_PERMISSIONS为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/security/hapsigntool-overview.md/))。 +6.本示例所配置的权限ohos.permission.GET_SENSITIVE_PERMISSIONS、ohos.permission.REVOKE_SENSITIVE_PERMISSIONS、ohos.permission.GRANT_SENSITIVE_PERMISSIONS为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))。 ### 下载 diff --git a/code/SystemFeature/TaskManagement/Flybird/README_zh.md b/code/SystemFeature/TaskManagement/Flybird/README_zh.md index 5deeb74dee522dd3e20005c4cbbe9cf37ffd0788..cc830134aaf5e6ef2c3cce61dfbeaa8adea400ef 100644 --- a/code/SystemFeature/TaskManagement/Flybird/README_zh.md +++ b/code/SystemFeature/TaskManagement/Flybird/README_zh.md @@ -68,7 +68,7 @@ entry/src/main/ets/ 3.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400 构建 2023年4月7日)及以上版本才可编译运行。 -4.本示例所配置的权限ohos.permission.BUNDLE_ACTIVE_INFO为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看) ,需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md) 。 +4.本示例所配置的权限ohos.permission.BUNDLE_ACTIVE_INFO为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看) ,需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))。 5.本示例需要使用@ohos.resourceschedule.usageStatistics、@ohos.app.ability.ServiceExtensionAbility系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 diff --git a/code/SystemFeature/Widget/FormExtAbility/README_zh.md b/code/SystemFeature/Widget/FormExtAbility/README_zh.md index 973bf8564ecdc35bc8d33e49a0e9743481010cb3..45bdfe8c1cc00100c40ae6108a6205777f721693 100644 --- a/code/SystemFeature/Widget/FormExtAbility/README_zh.md +++ b/code/SystemFeature/Widget/FormExtAbility/README_zh.md @@ -161,7 +161,7 @@ return formInfo.FormState.READY }。 4.本示需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南]( https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 -5.本示例所配置的权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md/))。 +5.本示例所配置的权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md/))。 6.本示例类型为系统应用,需要手动配置对应级别的应用类型("app-feature": "hos_system_app")。具体可参考profile配置文件[bundle-info对象内部结构]( https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/app-provision-structure.md#bundle-info%E5%AF%B9%E8%B1%A1%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84) diff --git a/code/SystemFeature/Widget/RequestAddForm/README_zh.md b/code/SystemFeature/Widget/RequestAddForm/README_zh.md index c3160897a90f37fafe691311d3dcd96595e68182..fe05819acf20810398c3219815277610e1e8400c 100644 --- a/code/SystemFeature/Widget/RequestAddForm/README_zh.md +++ b/code/SystemFeature/Widget/RequestAddForm/README_zh.md @@ -73,7 +73,7 @@ entry/src/main/ 4.本示例需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 -5.本示例所配置的权限为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md)) +5.本示例所配置的权限为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)) 6.本示例类型为系统应用,需要手动配置对应级别的应用类型("app-feature": "hos_system_app")。具体可参考profile配置文件[bundle-info对象内部结构](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/app-provision-structure.md#bundle-info%E5%AF%B9%E8%B1%A1%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84) diff --git a/code/SystemFeature/WindowManagement/WindowManage/README_zh.md b/code/SystemFeature/WindowManagement/WindowManage/README_zh.md index 034186277bc845993569ff4cb38f744c0a3bad88..e3c4454befe36027aadeaf069dfc66a0040c224d 100644 --- a/code/SystemFeature/WindowManagement/WindowManage/README_zh.md +++ b/code/SystemFeature/WindowManagement/WindowManage/README_zh.md @@ -112,7 +112,7 @@ entry/src/main/ets/ 4.本示例需要使用DevEco Studio 版本号(Build Version: 4.1.3.500, built on January 20, 2024)及以上版本才可编译运行。 -5.本示例所配置的权限ohos.permission.SYSTEM_FLOAT_WINDOW为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md)。 +5.本示例所配置的权限ohos.permission.SYSTEM_FLOAT_WINDOW为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md)。 ### 下载 diff --git a/code/SystemFeature/WindowManagement/WindowRatio/README_zh.md b/code/SystemFeature/WindowManagement/WindowRatio/README_zh.md index 09d8fe94f3ae60c421244ed03651b4026941e78c..565ff5e324df490150ab4801a9679c07d9c56b28 100644 --- a/code/SystemFeature/WindowManagement/WindowRatio/README_zh.md +++ b/code/SystemFeature/WindowManagement/WindowRatio/README_zh.md @@ -69,7 +69,7 @@ entry/src/main/ets/ 2.本示例为Stage模型,仅支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0Release);本示例涉及使用系统接口:@ohos.window中的WindowMode属性,需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 -3.本示例所配置的权限ohos.permission.SYSTEM_FLOAT_WINDOW为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/security/hapsigntool-overview.md))。 +3.本示例所配置的权限ohos.permission.SYSTEM_FLOAT_WINDOW为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))。 4.本示例需要使用DevEco Studio 版本号(4.0Release)及以上版本才可编译运行。 diff --git a/code/UI/ImageViewer/entry/src/main/ets/view/PicturePreviewImage.ets b/code/UI/ImageViewer/entry/src/main/ets/view/PicturePreviewImage.ets index 997df0a80297a2da34d54b1403b3dfc06804b452..c52ba251bb51332c921c8330dc2c81f8806e8fce 100644 --- a/code/UI/ImageViewer/entry/src/main/ets/view/PicturePreviewImage.ets +++ b/code/UI/ImageViewer/entry/src/main/ets/view/PicturePreviewImage.ets @@ -306,7 +306,7 @@ export struct PicturePreviewImage { if ((calculatedOffset > maxAllowedOffset) && (this.imageIndex !== 0)) { // 右滑 -- 当前滑动超过最大值时 并且 不是第一个元素去设置list偏移量显“下一张”图片 - let listOffset :number= calculatedOffset - maxAllowedOffset; + let listOffset: number = calculatedOffset - maxAllowedOffset; this.setListOffset(-listOffset) this.imageListOffset = listOffset; } else if ((calculatedOffset < -maxAllowedOffset) && (this.imageIndex < this.imageMaxLength - 1)) { @@ -413,17 +413,12 @@ export struct PicturePreviewImage { .onActionEnd((event: GestureEvent) => { this.imageOffsetInfo.stash(); this.evaluateBound(); - }) - ), - ) - // 两根手指操作 - .gesture( - GestureGroup( - GestureMode.Parallel, + }), + // 两根手指操作 // 双指旋转图片 RotationGesture({ angle: this.imageRotateInfo.startAngle }) .onActionUpdate((event: GestureEvent) => { - let angle :number= this.imageRotateInfo.lastRotate + event.angle; + let angle: number = this.imageRotateInfo.lastRotate + event.angle; if (event.angle > 0) { angle -= this.imageRotateInfo.startAngle; } else { @@ -461,7 +456,7 @@ export struct PicturePreviewImage { // TODO:知识点:双指捏合缩放图片 PinchGesture({ fingers: 2, distance: 1 }) .onActionUpdate((event: GestureEvent) => { - let scale :number= this.imageScaleInfo.lastValue * event.scale; + let scale: number = this.imageScaleInfo.lastValue * event.scale; // TODO:知识点:缩放时不允许大于最大缩放因子+额外缩放因子,不允许小于默认大小-额外缩放因子,额外缩放因子用于提升用户体验4 if (scale > this.imageScaleInfo.maxScaleValue * (1 + this.imageScaleInfo.extraScaleValue)