diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/.gitignore b/code/DocsSample/ArkUISample/UIExtensionComponent/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/.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/UIExtensionComponent/AppScope/app.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..50fe9b39a63031f9df7234b0af4e5207b2fe1d6e --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.uiextensioncomponent", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/element/string.json b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a05bd74e24bd0d972c56653be6cb0d249d845ac7 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "UIExtensionComponent" + } + ] +} diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/media/app_icon.png b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/README_zh.md b/code/DocsSample/ArkUISample/UIExtensionComponent/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..de43d260f6dcfbced2c8be9c81188ee28ab6cf00 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/README_zh.md @@ -0,0 +1,87 @@ +# ArkUI使用UIExtension控件指南文档示例 + +### 介绍 + +本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/ui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接: + +1. [UIExtensionComponent 组件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-ui-extension-components.md)。 +2. [EmbeddedComponent 组件](https://gitee.com/hanshu12138/docs/blob/dev250429/zh-cn/application-dev/ui/arkts-embedded-components.md)。 +3. [FullScreenLaunchComponent 组件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-FullScreenComponent.md)。 +4. [IsolatedComponent 组件](https://gitee.com/hanshu12138/docs/blob/dev250429/zh-cn/application-dev/ui/arkts-isolated-components.md)。 +5. [ArkUI 无障碍能力](https://gitee.com/hanshu12138/docs/blob/dev250429/zh-cn/application-dev/ui/arkts-universal-attributes-accessibility.md)。 + +### 效果预览 + +| 首页选项目录 | Isolated目录 | Isolated示例 | +|------------------------------------|------------------------------------|------------------------------------| +| ![](screenshots/device/image1.jpg) | ![](screenshots/device/image2.jpg) | ![](screenshots/device/image3.jpg) | + +### 使用说明 + +1. 在主界面,可以点击对应卡片,选择需要参考的组件示例。 + +2. 在组件目录选择详细的示例参考。 + +3. 进入示例界面,查看参考示例。 + +4. 通过自动测试框架可进行测试及维护。 + +### 工程目录 +``` +entry/src/main/ets/ +|---entryability +|---pages +| |---EmbeddedComponent // EmbeddedComponent 组件 +| | |---Embedded.ets +| | |---Extension.ets +| | |---Index.ets +| |---FullScreenLaunchComponent // FullScreenLaunchComponent 组件 +| | |---FullScreenLaunch.ets +| | |---Index.ets +| |---IsolatedComponent // IsolatedComponent 组件 +| | |---Extension.ets +| | |---Index.ets +| | |---Isolated.ets +| |---UIExtensionComponent // UIExtensionComponent 组件 +| | |---Extension.ets +| | |---Index.ets +| | |---UIExtension.ets +| |---UniversalAttributesAccessibility // ArkUI 无障碍能力 +| | |---AccessibilityGroup.ets +| | |---AccessibilityText.ets +| | |---Index.ets +|---pages +| |---Index.ets // 应用主页面 +entry/src/ohosTest/ +|---ets +| |---index.test.ets // 示例代码测试代码 +``` + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行, 支持设备:RK3568。 + +2.本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.57,镜像版本号:OpenHarmony_5.0.2.57。 + +3.本示例需要使用DevEco Studio NEXT Developer Preview2 (Build Version: 5.0.5.306, built on December 12, 2024)及以上版本才可编译运行。 + + +### 下载 + +如需单独下载本工程,执行如下命令: + +```` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkUIDocSample/UIExtensionComponent > .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/UIExtensionComponent/build-profile.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..59493d7e25d29f523194fa20c5370365f02ab8ba --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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", + "runtimeOS": "OpenHarmony", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "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/UIExtensionComponent/code-linter.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/DocsSample/ArkUISample/UIExtensionComponent/entry/.gitignore b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/UIExtensionComponent/entry/build-profile.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/hvigorfile.ts b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/obfuscation-rules.txt b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/UIExtensionComponent/entry/oh-package.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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": {} +} + diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Card.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Card.ets new file mode 100644 index 0000000000000000000000000000000000000000..608bc4912c7f033aaeb2332b290b1d0ea0b7cb82 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Card.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. + */ + +@Component +export struct CompletedRoutableCard { + @Prop + symbol: Resource = $r('sys.symbol.label'); + @Prop + @Require + title: string; + @Prop + @Require + description: ResourceStr; + + build() { + Card({ verticalAlign: VerticalAlign.Top }) { + Button({ type: ButtonType.Circle }) { + SymbolGlyph(this.symbol) + .fontColor(['#fff']) + .fontSize(16) + } + .borderRadius(14) + + Column({ space: 8 }) { + Text(this.title) + .fontColor($r('sys.color.font_primary')) + + Text(this.description) + .fontColor($r('sys.color.font_secondary')) + .fontSize($r('sys.float.Body_S')) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + } + } +} + +@Component +export struct Card { + @Prop + verticalAlign: VerticalAlign = VerticalAlign.Center; + @BuilderParam + content: () => void; + + build() { + Row({ space: 12 }) { + this.content() + } + .alignItems(this.verticalAlign) + .backgroundColor('#fff') + .borderRadius(12) + .padding(12) + .width('100%') + } +} + +@Component +export struct RoutableCard { + @Prop + icon: Resource = $r('sys.symbol.label'); + @Prop + @Require + title: ResourceStr; + + build() { + Card() { + Button({ type: ButtonType.Circle }) { + SymbolGlyph(this.icon) + .fontColor(['#fff']) + .fontSize(16) + } + .borderRadius(14) + + Text(this.title) + .fontColor($r('sys.color.font_primary')) + .minFontSize(12) + .maxFontSize(16) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + + Blank() + + Button({ type: ButtonType.Normal, buttonStyle: ButtonStyleMode.TEXTUAL }) { + SymbolGlyph($r('sys.symbol.chevron_right')) + .fontSize(18) + .fontColor([$r('sys.color.font_secondary')]) + } + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Route.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Route.ets new file mode 100644 index 0000000000000000000000000000000000000000..859fec8c9ebd491e575d5baf8d43bd0512add60c --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/Route.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. + */ + +export interface Route { + title: string; + name: string; + items?: Route[]; + description?: ResourceStr; +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/resource.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/common/resource.ets new file mode 100644 index 0000000000000000000000000000000000000000..e240a1079ad09a0f19080b49b57a6a0720416e6c --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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 ResourceManager { + public resourceToString(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } +} + +// 默认导出let +let resourceToStringManager = new ResourceManager(); + +export default resourceToStringManager as ResourceManager; \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bd9072c5090c332be2f707ecc88ce7c4d993b38 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/entryability/EntryAbility.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 { AbilityConstant, ConfigurationConstant, 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 { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + 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'); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/main/ets/extensionability/ExampleEmbeddedAbility.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/extensionability/ExampleEmbeddedAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..083f9f44df274b8fdb447fefcc5adce82631fc15 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/extensionability/ExampleEmbeddedAbility.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. + */ + +import { EmbeddedUIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; + +const TAG: string = '[ExampleEmbeddedAbility]' + +export default class ExampleEmbeddedAbility extends EmbeddedUIExtensionAbility { + onCreate() { + console.log(TAG, `onCreate`); + } + + onForeground() { + console.log(TAG, `onForeground`); + } + + onBackground() { + console.log(TAG, `onBackground`); + } + + onDestroy() { + console.log(TAG, `onDestroy`); + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + console.log(TAG, `onSessionCreate, want: ${JSON.stringify(want)}`); + let param: Record = { + 'session': session + }; + let storage: LocalStorage = new LocalStorage(param); + // 加载 Extension.ets 页面内容 + session.loadContent('pages/EmbeddedComponent/Extension', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + console.log(TAG, `onSessionDestroy`); + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Embedded.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Embedded.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b736ff2987d2e8cd115bb4b5d9bc2aabc0ed2fe --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Embedded.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 { UIExtensionContentSession } from '@kit.AbilityKit'; + +let storage = LocalStorage.getShared(); + +@Component +export struct Embedded { + @State message: string = 'EmbeddedUIExtensionAbility Index'; + private session: UIExtensionContentSession | undefined = storage.get('session'); + + build() { + NavDestination() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button("terminateSelfWithResult").fontSize(20).onClick(() => { + // 点击按钮后调用terminateSelfWithResult退出 + this.session?.terminateSelfWithResult({ + resultCode: 1, + want: { + bundleName: "com.example.embeddeddemo", + abilityName: "ExampleEmbeddedAbility", + } + }); + }) + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.Embedded_Component_title')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Extension.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Extension.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a1804da0f35717fdcc83dce0d30e428f64bbf2c --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Extension.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. + */ + +import { UIExtensionContentSession } from '@kit.AbilityKit'; + +let storage = LocalStorage.getShared() + +@Entry(storage) +@Component +struct Extension { + @State message: string = 'EmbeddedUIExtensionAbility Index'; + private session: UIExtensionContentSession | undefined = storage.get('session'); + + build() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button("terminateSelfWithResult").fontSize(20).onClick(() => { + // 点击按钮后调用terminateSelfWithResult退出 + this.session?.terminateSelfWithResult({ + resultCode: 1, + want: { + bundleName: "com.example.embeddeddemo", + abilityName: "ExampleEmbeddedAbility", + } + }); + }) + }.width('100%').height('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e3f2e0d01d21eaff834c90f25a61e27019c2e92 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/EmbeddedComponent/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 { CompletedRoutableCard } from '../../common/Card' +import { Route } from '../../common/Route' +import { Embedded } from './Embedded' +import resource from '../../common/resource' + +export const EMBEDDED_ROUTE_PREFIX: string = "EmbeddedComponent"; + +const routes: Route[] = [ + { + name: `${EMBEDDED_ROUTE_PREFIX}/Embedded`, + title: resource.resourceToString($r('app.string.Embedded_Component_title')), + description: resource.resourceToString($r('app.string.Embedded_Component_description')), + } +] + +@Builder +export function EmbeddedDestination(name: string) { + if (name == EMBEDDED_ROUTE_PREFIX) { + EmbeddedExample(); + } else if (name == routes[0].name) { + Embedded(); + } +} + +@Entry +@Component +struct EmbeddedExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title(resource.resourceToString($r('app.string.pageIndex_EmbeddedComponent')), { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/FullScreenLaunch.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/FullScreenLaunch.ets new file mode 100644 index 0000000000000000000000000000000000000000..54dfb67ad759f568b15564a64df3f55758de6c30 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/FullScreenLaunch.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. + */ + +import { FullScreenLaunchComponent } from '@kit.ArkUI' + +@Builder +function ColumnChild() { + Column() { + Image($r('app.media.app_icon')) + Text('test') + } +} + +@Component +export struct FullScreenLaunch { + @State appId: string = "5432123456789"; // 原子化服务appId + + build() { + NavDestination() { + Column() { + FullScreenLaunchComponent({ + content: ColumnChild, + appId: this.appId, + options: {}, + onTerminated: (info) => { + console.info("onTerminated code: " + info.code.toString()); + }, + onError: (err) => { + console.error("onError code: " + err.code + ", message: ", err.message); + } + }).width("80vp").height("80vp") + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.Full_Screen_Launch_Component_title')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5514984c7153bf1e6ba857664ff2ef1c2743a44d --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/FullScreenLaunchComponent/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 { CompletedRoutableCard } from '../../common/Card' +import { Route } from '../../common/Route' +import { FullScreenLaunch } from './FullScreenLaunch' +import resource from '../../common/resource' + +export const SCREEN_ROUTE_PREFIX: string = "FullScreenLaunchComponent"; + +const routes: Route[] = [ + { + name: `${SCREEN_ROUTE_PREFIX}/FullScreenLaunch`, + title: resource.resourceToString($r('app.string.Full_Screen_Launch_Component_title')), + description: resource.resourceToString($r('app.string.Full_Screen_Launch_Component_description')), + } +]; + +@Builder +export function FullScreenDestination(name: string) { + if (name == SCREEN_ROUTE_PREFIX) { + FullScreenExample(); + } else if (name == routes [0].name) { + FullScreenLaunch(); + } +} + +@Entry +@Component +struct FullScreenExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title(resource.resourceToString($r('app.string.pageIndex_FullScreenComponent')), { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e9f8fb0445e052029f1ea734a3f0a5c1cc123bf --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 { RoutableCard } from '../common/Card'; +import { Route } from '../common/Route'; +import resource from '../common/resource'; +import { UI_EXTENSION_ROUTE_PREFIX, UIExtensionDestination } from './UIExtensionComponent/Index' +import { EMBEDDED_ROUTE_PREFIX, EmbeddedDestination } from './EmbeddedComponent/Index' +import { SCREEN_ROUTE_PREFIX, FullScreenDestination } from './FullScreenLaunchComponent/Index' +import { ISOLATED_ROUTE_PREFIX, IsolatedDestination } from './IsolatedComponent/Index' +import { ACCESSIBILITY_ROUTE_PREFIX, AccessibilityDestination } from './UniversalAttributesAccessibility/Index' + +const routes: Route[] = [ + { + title: resource.resourceToString($r('app.string.pageIndex_UIExtensionComponent')), + name: UI_EXTENSION_ROUTE_PREFIX + }, + { + title: resource.resourceToString($r('app.string.pageIndex_EmbeddedComponent')), + name: EMBEDDED_ROUTE_PREFIX + }, + { + title: resource.resourceToString($r('app.string.pageIndex_FullScreenComponent')), + name: SCREEN_ROUTE_PREFIX + }, + { + title: resource.resourceToString($r('app.string.pageIndex_IsolatedComponent')), + name: ISOLATED_ROUTE_PREFIX + }, + { + title: resource.resourceToString($r('app.string.pageIndex_UniversalAttributesAccessibility')), + name: ACCESSIBILITY_ROUTE_PREFIX + } +] + +@Builder +function Destination(name: string) { + if (name.startsWith(UI_EXTENSION_ROUTE_PREFIX)) { + UIExtensionDestination(name); + } else if (name.startsWith(EMBEDDED_ROUTE_PREFIX)) { + EmbeddedDestination(name); + } else if (name.startsWith(SCREEN_ROUTE_PREFIX)) { + FullScreenDestination(name); + } else if (name.startsWith(ISOLATED_ROUTE_PREFIX)) { + IsolatedDestination(name); + } else if (name.startsWith(ACCESSIBILITY_ROUTE_PREFIX)) { + AccessibilityDestination(name); + } +} + +@Entry +@Component +struct Index { + @State condition: string = ''; + @Provide pathStack: NavPathStack = new NavPathStack(); + + getFilteredRoutes(): Route[] { + if (!this.condition) { + return routes; + } + return routes.filter((route: Route) => { + return route.title.includes(this.condition); + }) + } + + @LocalBuilder + Title() { + Column() { + Search({ value: this.condition }) + .onChange(value => { + this.condition = value; + }) + .margin({ start: LengthMetrics.vp(16), end: LengthMetrics.vp(16) }) + } + .justifyContent(FlexAlign.Center) + .height('100%') + } + + build() { + Navigation(this.pathStack) { + List({ space: 12 }) { + ForEach(this.getFilteredRoutes(), (route: Route) => { + ListItem() { + RoutableCard({ title: route.title }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .padding({ start: LengthMetrics.vp(16), end: LengthMetrics.vp(16) }) + .contentStartOffset(56) + .height('100%') + .width('100%') + } + .backgroundColor('#f1f3f5') + .title({ builder: this.Title, height: 56 }, { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + .navDestination(Destination) + } +} diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Extension.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Extension.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee7a575f273e723d96f73d4dd044f43516fdbfec --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Extension.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 Extension { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..03ba40a9f45fcea08cf05f89a030f055d8166a1c --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/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 { CompletedRoutableCard } from '../../common/Card' +import { Route } from '../../common/Route' +import { Isolated } from './Isolated' +import resource from '../../common/resource' + +export const ISOLATED_ROUTE_PREFIX: string = "IsolatedComponent"; + +const routes: Route[] = [ + { + name: `${ISOLATED_ROUTE_PREFIX}/Isolated`, + title: resource.resourceToString($r('app.string.Isolated_Component_title')), + description: resource.resourceToString($r('app.string.Isolated_Component_description')), + } +]; + +@Builder +export function IsolatedDestination(name: string) { + if (name == ISOLATED_ROUTE_PREFIX) { + IsolatedExample(); + } else if (name == routes[0].name) { + Isolated(); + } +} + +@Entry +@Component +struct IsolatedExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title(resource.resourceToString($r('app.string.pageIndex_IsolatedComponent')), { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Isolated.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Isolated.ets new file mode 100644 index 0000000000000000000000000000000000000000..44cee5223ab8e0ccaf5a568dfe133756d8fe4500 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/IsolatedComponent/Isolated.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 { worker } from '@kit.ArkTS'; +import { bundleManager } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +// 对abc文件进行校验,并拷贝到指定沙箱路径下 +function VerifyAbc(abcPaths: Array, deleteOriginalFiles: boolean) { + try { + bundleManager.verifyAbc(abcPaths, deleteOriginalFiles, (err) => { + if (err) { + console.error("VerifyAbc failed, error message: " + err.message); + } else { + console.info("VerifyAbc successfully."); + } + }); + } catch (err) { + let message = (err as BusinessError).message; + console.error("VerifyAbc failed, error message: " + message); + } +} + +@Component +export struct Isolated { + @State isShow: boolean = false; + @State resourcePath: string = ""; + @State abcPath: string = ""; + @State entryPoint: string = ""; + // abc文件名 + private fileName: string = "modules"; + // abc文件所属应用的bundleName + private bundleName: string = "com.example.uiextensioncomponent"; + // 受限worker + private worker ?: worker.RestrictedWorker = new worker.RestrictedWorker("entry/ets/workers/OhCardWorker.ets"); + + build() { + NavDestination() { + Row() { + Column() { + // 1.调用verifyAbc接口校验abc文件 + Button("verifyAbc").onClick(() => { + let abcFilePath = `${getContext(this).filesDir}/${this.fileName}.abc`; + console.log("abcFilePath: " + abcFilePath); + VerifyAbc([abcFilePath], false); + }).height(100).width(100) + + // 2.显示IsolatedComponent + Button("showIsolatedComponent").onClick(() => { + if (!this.isShow) { + // 资源路径 + this.resourcePath = `${getContext(this).filesDir}/${this.fileName}.hap`; + // abc文件校验后的沙箱路径 + this.abcPath = `/abcs${getContext(this).filesDir}/${this.fileName}`; + // 需要显示页面的入口路径 + this.entryPoint = `${this.bundleName}/entry/ets/pages/IsolatedComponent/Extension`; + this.isShow = true; + } + }).height(100).width(100) + + if (this.isShow) { + IsolatedComponent({ + want: { + "parameters": { + "resourcePath": this.resourcePath, + "abcPath": this.abcPath, + "entryPoint": this.entryPoint + } + }, + worker: this.worker + }) + .width(300) + .height(300) + .onError((err) => { + console.info("onError : " + JSON.stringify(err)); + }) + } + } + .width('100%') + } + .width('100%') + .height('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.Isolated_Component_title')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/Extension.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/Extension.ets new file mode 100644 index 0000000000000000000000000000000000000000..5416588f1f16a6e4dd10bf1337f3342bf27c2bc7 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/Extension.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 { UIExtensionContentSession } from '@kit.AbilityKit'; + +let storage = LocalStorage.getShared() +AppStorage.setOrCreate('message', 'UIExtensionAbility') + +@Entry(storage) +@Component +struct Extension { + @StorageLink('message') storageLink: string = ''; + private session: UIExtensionContentSession | undefined = storage.get('session'); + pathStack: NavPathStack = new NavPathStack() + + @Builder + PageMap(name: string) { + if (name === "hello") { + pageOneTmp() + } + } + + onPageShow() { + if (this.session != undefined) { + this.session.setReceiveDataCallback((data)=> { + this.storageLink = JSON.stringify(data) + console.info("invoke for test, handle callback set by setReceiveDataCallback successfully"); + }) + + this.session.setReceiveDataForResultCallback(func1) + } + } + + build() { + Navigation(this.pathStack) { + Row() { + Column() { + Text(this.storageLink) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button("点击向Component发送数据").onClick(()=>{ + if (this.session != undefined) { + this.session.sendData({"data": 543321}) + console.info('send 543321, for test') + } + }) + Button("terminate").onClick(()=> { + if (this.session != undefined) { + this.session.terminateSelf(); + } + storage.clear() + }) + Button("terminate with result").onClick(()=>{ + if (this.session != undefined) { + this.session.terminateSelfWithResult({ + resultCode: 0, + want: { + bundleName: "myBundleName", + parameters: { "result": 123456 } + } + }) + } + storage.clear() + }) + + Button("点击跳转").onClick(()=> { + this.pathStack.pushPath({ name: "hello"}) + }) + } + } + .height('100%') + }.navDestination(this.PageMap) + .mode(NavigationMode.Stack) + } +} + +// pageOne +@Component +export struct pageOneTmp { + pathStack: NavPathStack = new NavPathStack() + + build() { + NavDestination() { + Column() { + Text("Hello World") + }.width('100%').height('100%') + }.title("pageOne") + .onBackPressed(() => { + const popDestinationInfo = this.pathStack.pop() // 弹出路由栈栈顶元素 + console.log('pop' + '返回值' + JSON.stringify(popDestinationInfo)) + return true + }) + .onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack + }) + } +} + +function func1(data: Record): Record { + let linkToMsg: SubscribedAbstractProperty = AppStorage.link('message'); + linkToMsg.set(JSON.stringify(data)) + console.info("invoke for test, handle callback set by setReceiveDataForResultCallback successfully"); + return data; +} diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..76b6ce97b14234fead85e3c0bc13db09604ad659 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/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 { CompletedRoutableCard } from '../../common/Card' +import { Route } from '../../common/Route' +import { UIExtension } from './UIExtension' +import resource from '../../common/resource' + +export const UI_EXTENSION_ROUTE_PREFIX: string = "UIExtensionComponent"; + +const routes: Route[] = [ + { + name: `${UI_EXTENSION_ROUTE_PREFIX}/UIExtension`, + title: resource.resourceToString($r('app.string.UI_Extension_Component_title')), + description: resource.resourceToString($r('app.string.UI_Extension_Component_description')), + } +]; + +@Builder +export function UIExtensionDestination(name: string) { + if (name == UI_EXTENSION_ROUTE_PREFIX) { + UIExtensionExample(); + } else if (name == routes[0].name) { + UIExtension(); + } +} + +@Entry +@Component +struct UIExtensionExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title(resource.resourceToString($r('app.string.pageIndex_UIExtensionComponent')), { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/UIExtension.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/UIExtension.ets new file mode 100644 index 0000000000000000000000000000000000000000..6918460fead34a9b9657b78f7d4caa269e5a6deb --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UIExtensionComponent/UIExtension.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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) + } +} + +@Builder +function AreaChangePlaceholderBuilder(params: Params) { + Column() { + } + .width('100%') + .height('100') + .backgroundColor(Color.Orange) +} + +@Component +export struct UIExtension { + @State message1: string = 'Hello World 1' + @State message2: string = 'Hello World 2' + @State message3: string = 'Hello World 3' + @State visible: Visibility = Visibility.Hidden + @State wid: number = 300 + @State hei: number = 300 + @State windowStrategy: WindowModeFollowStrategy = WindowModeFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_WINDOW_MODE; + private scroller: Scroller = new Scroller(); + private arr: number[] = [0, 1, 2, 3, 4, 5, 6] + private proxy: UIExtensionProxy | null = null; + private initPlaceholder = new ComponentContent(this.getUIContext(), wrapBuilder(LoadingBuilder), new Params); + private areaChangePlaceholder = + new ComponentContent(this.getUIContext(), wrapBuilder(AreaChangePlaceholderBuilder), new Params); + + build() { + NavDestination() { + Column() { + // 可滚动的容器组件 + Scroll(this.scroller) { + Column() { + Text(this.message1).fontSize(25) + Text(this.message2).fontSize(25) + Text(this.message3).fontSize(25) + + // 重复设置组件,构造滚动内容 + ForEach(this.arr, (item: number) => { + UIExtensionComponent({ + bundleName: "com.example.newdemo", + abilityName: "UIExtensionProvider", + parameters: { + "ability.want.params.uiExtensionType": "sys/commonUI" + }}, + { + placeholder: this.initPlaceholder, + areaChangePlaceholder: { + "FOLD:TO:EXPAND": this.areaChangePlaceholder, + }, + windowModeFollowStrategy : this.windowStrategy + }) + .width(this.wid) + .height(this.hei)// 设置手势拦截,UEC外部组件不响应滚动 + .gesture(PanGesture().onActionStart(() => { + console.info('UIExtensionComponent PanGesture onAction') + })) + .border({ width: 5, color: Color.Blue }) + .onReceive((data) => { + console.info('Lee onReceive, for test') + this.message3 = JSON.stringify(data['data']) + }) + .onTerminated((info) => { + console.info('onTerminated: code =' + info.code + ', want = ' + JSON.stringify(info.want)); + }) + .onRemoteReady((proxy) => { + console.info('onRemoteReady, for test') + this.proxy = proxy + this.proxy.on("asyncReceiverRegister", syncRegisterCallback1); + this.proxy.on("asyncReceiverRegister", (proxy1) => { + console.info("on invoke for test, type is asyncReceiverRegister") + }) + }) + }, (item: string) => item) + } + .width('100%') + } + .scrollable(ScrollDirection.Vertical) // 滚动方向纵向 + .scrollBar(BarState.On) // 滚动条常驻显示 + .scrollBarColor(Color.Gray) // 滚动条颜色 + .scrollBarWidth(10) // 滚动条宽度 + .friction(0.6) + .edgeEffect(EdgeEffect.None) + .onWillScroll((xOffset: number, yOffset: number, scrollState: ScrollState) => { + console.info(xOffset + ' ' + yOffset) + }) + .onScrollEdge((side: Edge) => { + console.info('To the edge') + }) + .onScrollStop(() => { + console.info('Scroll Stop') + }) + } + .height('100%') + .width('100%') + .padding({ left: 12, right: 12 }) + } + .backgroundColor('#f1f2f3') + .title($r('app.string.UI_Extension_Component_title')) + } +} + +function syncRegisterCallback1(proxy: UIExtensionProxy) { + console.info("on invoke for test, syncRegisterCallback1, type is syncReceiverRegister") +} + +function syncRegisterCallback2(proxy: UIExtensionProxy) { + console.info("on invoke for test, syncRegisterCallback2, type is syncReceiverRegister") +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityGroup.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityGroup.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3a3de5c9f2e6ebc66882f9940faf49c30821d70 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityGroup.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. + */ + +@Component +export struct AccessibilityGroup { + build() { + NavDestination() { + Column({ space: 10 }) { + Text('123456') + .focusable(true) + .borderRadius(5) + .accessibilityText("有accessibility有text优先读accessibility") + .accessibilityLevel("yes") + Button().accessibilityLevel("yes").accessibilityText("accessibility无text 读accessibility") + Button("无accessibility有text 读text").accessibilityLevel("yes") + Button() + Button('btnl23').accessibilityText("有accessibility有text btn123").accessibilityLevel("yes") + Button('btn123').accessibilityLevel("yes") + } + .accessibilityGroup(true, { accessibilityPreferred: true }) + //.accessibilityGroup(true) + .borderWidth(5) + .width('100%') + .height('100%') + } + .backgroundColor('#f1f2f3') + .title($r('app.string.UniversalAttributesAccessibility_title2')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityText.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityText.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd0841a74c921e9d38f319ed7c5eb65bd3130f09 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/AccessibilityText.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. + */ + +@Component +export struct AccessibilityText { + + @Builder customAccessibilityNode() { + Column() { + Text(`virtual node`) + } + .width(10) + .height(10) + } + + build() { + NavDestination() { + Row() { + Column() { + Text("文本1") + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text("文本2") + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .accessibilityGroup(true) + .accessibilityLevel("yes") + .accessibilityText("分组") // 无障碍文本的内容,若组件既拥有文本属性又拥有无障碍文本属性,则组件被选中时,仅播报无障碍文本内容。 + .accessibilityDescription("Column组件可以被选中,播报的内容是“分组”") + .accessibilityVirtualNode(this.customAccessibilityNode) + .accessibilityChecked(true) + .accessibilitySelected(undefined) + } + .height('100%') + } + .backgroundColor('#f1f2f3') + .title($r('app.string.UniversalAttributesAccessibility_title1')) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..25f8be66d55769db3dd5026ff9bc5a63583df64c --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/pages/UniversalAttributesAccessibility/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 { CompletedRoutableCard } from '../../common/Card' +import { Route } from '../../common/Route' +import { AccessibilityText } from './AccessibilityText' +import { AccessibilityGroup } from './AccessibilityGroup' +import resource from '../../common/resource' + +export const ACCESSIBILITY_ROUTE_PREFIX: string = "UniversalAttributesAccessibility"; + +const routes: Route[] = [ + { + name: `${ACCESSIBILITY_ROUTE_PREFIX}/AccessibilityText`, + title: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_title1')), + description: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_description1')), + }, + { + name: `${ACCESSIBILITY_ROUTE_PREFIX}/AccessibilityGroup`, + title: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_title2')), + description: resource.resourceToString($r('app.string.UniversalAttributesAccessibility_description2')), + } +]; + +@Builder +export function AccessibilityDestination(name: string) { + if (name == ACCESSIBILITY_ROUTE_PREFIX) { + AccessibilityExample(); + } else if (name == routes[0].name) { + AccessibilityText(); + } else if (name == routes[1].name) { + AccessibilityGroup(); + } +} + +@Entry +@Component +struct AccessibilityExample { + @Consume pathStack: NavPathStack; + + build() { + NavDestination() { + List({ space: 12 }) { + ForEach(routes, (route: Route) => { + ListItem() { + CompletedRoutableCard({ title: route.title, description: route.description }) + } + .width('100%') + .onClick(() => { + this.pathStack.pushPath({ name: route.name }); + }) + }) + } + .contentStartOffset(56) + .padding({ left: 16, right: 16 }) + } + .backgroundColor('#f1f3f5') + .title(resource.resourceToString($r('app.string.pageIndex_UniversalAttributesAccessibility')), { + backgroundBlurStyle: BlurStyle.COMPONENT_THICK, + barStyle: BarStyle.STACK + }) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/uiextensionability/UIExtensionProvider.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/uiextensionability/UIExtensionProvider.ets new file mode 100644 index 0000000000000000000000000000000000000000..c598ff5b049c83cacb782daabb7e3596b8d060a0 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/uiextensionability/UIExtensionProvider.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 { UIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'; + +const TAG: string = '[UIExtAbility]' +export default class UIExtAbility extends UIExtensionAbility { + + onCreate() { + console.log(TAG, `UIExtAbility onCreate`) + } + + onForeground() { + console.log(TAG, `UIExtAbility onForeground`) + } + + onBackground() { + console.log(TAG, `UIExtAbility onBackground`) + } + + onDestroy() { + console.log(TAG, `UIExtAbility onDestroy`) + } + + onSessionCreate(want: Want, session: UIExtensionContentSession) { + console.log(TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`) + let param: Record = { + 'session': session + }; + let storage: LocalStorage = new LocalStorage(param); + session.loadContent('pages/UIExtensionComponent/Extension', storage); + } + + onSessionDestroy(session: UIExtensionContentSession) { + console.log(TAG, `UIExtAbility onSessionDestroy`) + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/workers/OhCardWorker.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/workers/OhCardWorker.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7ee86db8e5443c896cd70a484c94c065352cc9e --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/ets/workers/OhCardWorker.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. + */ + +import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; + +const workerPort: ThreadWorkerGlobalScope = worker.workerPort; + +/** + * Defines the event handler to be called when the worker thread receives a message sent by the host thread. + * The event handler is executed in the worker thread. + * + * @param event message data + */ +workerPort.onmessage = (event: MessageEvents) => { +}; + +/** + * Defines the event handler to be called when the worker receives a message that cannot be deserialized. + * The event handler is executed in the worker thread. + * + * @param event message data + */ +workerPort.onmessageerror = (event: MessageEvents) => { +}; + +/** + * Defines the event handler to be called when an exception occurs during worker execution. + * The event handler is executed in the worker thread. + * + * @param event error message + */ +workerPort.onerror = (event: ErrorEvent) => { +}; \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/module.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..561601659c069529207d9d680b1bba82c5dd1539 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/module.json5 @@ -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. + */ + +{ + "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" + } + ] + }, + { + "name": "ExampleEmbeddedAbility", + "srcEntry": "./ets/extensionability/ExampleEmbeddedAbility.ets", + "type": "embeddedUI" + }, + { + "name": "UIExtensionProvider", + "srcEntry": "./ets/uiextensionability/UIExtensionProvider.ets", + "description": "1", + "label": "$string:EntryAbility_label", + "type": "sys/commonUI", + "exported": true, + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.RUN_DYN_CODE", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "inuse" + } + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/color.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/float.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..a0a93dd91fd48f08f3a9532c76e9b26e68d4c034 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/string.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e978681d7004a6221b4076dd32cdbe67bd9d9305 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/element/string.json @@ -0,0 +1,92 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "UIExtensionProvider_desc", + "value": "description" + }, + { + "name": "UIExtensionProvider_label", + "value": "label" + }, + { + "name": "pageIndex_UIExtensionComponent", + "value": "UIExtensionComponent 组件" + }, + { + "name": "pageIndex_EmbeddedComponent", + "value": "EmbeddedComponent 组件" + }, + { + "name": "pageIndex_FullScreenComponent", + "value": "FullScreenComponent 组件" + }, + { + "name": "pageIndex_IsolatedComponent", + "value": "IsolatedComponent 组件" + }, + { + "name": "pageIndex_UniversalAttributesAccessibility", + "value": "ArkUI 无障碍能力" + }, + { + "name": "Embedded_Component_title", + "value": "使用 EmbeddedComponent 组件" + }, + { + "name": "Full_Screen_Launch_Component_title", + "value": "使用 FullScreenLaunch 组件" + }, + { + "name": "UI_Extension_Component_title", + "value": "使用 UIExtensionComponent 组件" + }, + { + "name": "Isolated_Component_title", + "value": "使用 IsolatedComponent 组件" + }, + { + "name": "UniversalAttributesAccessibility_title1", + "value": "使用无障碍属性 1" + }, + { + "name": "UniversalAttributesAccessibility_title2", + "value": "使用无障碍属性 2" + }, + { + "name": "Embedded_Component_description", + "value": "展示 EmbeddedComponent 组件的基础使用方式" + }, + { + "name": "Full_Screen_Launch_Component_description", + "value": "展示 FullScreenLaunch 组件的基础使用方式" + }, + { + "name": "UI_Extension_Component_description", + "value": "展示 UIExtensionComponent 组件的基础使用方式" + }, + { + "name": "Isolated_Component_description", + "value": "展示 IsolatedComponent 组件的基础使用方式" + }, + { + "name": "UniversalAttributesAccessibility_description1", + "value": "设置无障碍文本和无障碍说明" + }, + { + "name": "UniversalAttributesAccessibility_description2", + "value": "设置无障碍组" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/background.png b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/UIExtensionComponent/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/UIExtensionComponent/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..34a24e6a3043b8afbeff2db47d334fbf4c51e7f4 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/Index", + "uiextensionprovider/pages/UIExtensionProviderPage" + ] +} \ No newline at end of file diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/dark/element/color.json b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/UIExtensionComponent/entry/src/mock/mock-config.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/ohosTest/ets/test/Ability.test.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. + */ + +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/UIExtensionComponent/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1eac52fcebe8958e19a7b8fed2e8f39c520a3e42 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/ohosTest/module.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/test/List.test.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/entry/src/test/LocalUnit.test.ets b/code/DocsSample/ArkUISample/UIExtensionComponent/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/ArkUISample/UIExtensionComponent/hvigor/hvigor-config.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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.1", + "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/UIExtensionComponent/hvigorfile.ts b/code/DocsSample/ArkUISample/UIExtensionComponent/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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/DocsSample/ArkUISample/UIExtensionComponent/oh-package.json5 b/code/DocsSample/ArkUISample/UIExtensionComponent/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b --- /dev/null +++ b/code/DocsSample/ArkUISample/UIExtensionComponent/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.1", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image1.jpg b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..34d2fd7bea78cd0811f2e91307423c1e4b33a54f Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image1.jpg differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image2.jpg b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..93997d2dd5f18ceeb1ac711adf6837d36f88c695 Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image2.jpg differ diff --git a/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image3.jpg b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d2295a7d6d843418c375e8898697325c5ece4a52 Binary files /dev/null and b/code/DocsSample/ArkUISample/UIExtensionComponent/screenshots/device/image3.jpg differ