diff --git a/AbilityKit/StartAbility/.gitignore b/AbilityKit/StartAbility/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..08d606210b3993e8f1f4535767bb3459b7b1d208 --- /dev/null +++ b/AbilityKit/StartAbility/.gitignore @@ -0,0 +1,13 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer +/oh-package-lock.json5 \ No newline at end of file diff --git a/AbilityKit/StartAbility/AppScope/app.json5 b/AbilityKit/StartAbility/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..57490f95c76507a5642de47edc63adea0f790ad4 --- /dev/null +++ b/AbilityKit/StartAbility/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.startability", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AbilityKit/StartAbility/AppScope/resources/base/element/string.json b/AbilityKit/StartAbility/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..418259d4646a45db1b73e7a33513c6658ebd2886 --- /dev/null +++ b/AbilityKit/StartAbility/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartAbility" + } + ] +} diff --git a/AbilityKit/StartAbility/AppScope/resources/base/media/background.png b/AbilityKit/StartAbility/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AbilityKit/StartAbility/AppScope/resources/base/media/background.png differ diff --git a/AbilityKit/StartAbility/AppScope/resources/base/media/foreground.png b/AbilityKit/StartAbility/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/AbilityKit/StartAbility/AppScope/resources/base/media/foreground.png differ diff --git a/AbilityKit/StartAbility/AppScope/resources/base/media/layered_image.json b/AbilityKit/StartAbility/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AbilityKit/StartAbility/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/README_zh.md b/AbilityKit/StartAbility/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..4b9e971ab3d6c2fc3daa3ea3c0a6434e8ab4a554 --- /dev/null +++ b/AbilityKit/StartAbility/README_zh.md @@ -0,0 +1,197 @@ +# 拉起指定类型的应用概述 + +- 通过startAbilityByType接口拉起垂类面板:调用startAbilityByType接口拉起对应的垂域面板(目前支持拉起导航、金融、邮件、航班、快递类应用面板),该面板将展示目标方接入的垂域应用,由用户选择打开指定应用以实现相应的垂类意图。 +- 通过mailto方式跳转电子邮件应用:通过mailto电子邮件协议,可以创建指向电子邮件地址的超链接,方便用户通过网页或应用中的超链接直接跳转电子邮件应用。 +- 通过startAbility接口打开文件:开发者可以通过调用startAbility接口,由系统从已安装的应用中寻找符合要求的应用,打开特定类型的文件。 + +### 通过startAbilityByType接口拉起垂类面板 +开发者可通过特定的业务类型如导航、金融、邮件等,调用startAbilityByType接口拉起对应的垂域面板,该面板将展示目标方接入的垂域应用,由用户选择打开指定应用以实现相应的垂类意图。 + +### 匹配规则 +UIAbilityContext.startAbilityByType和UIExtensionContentSession.startAbilityByType接口支持基于业务类型拉起垂域面板。调用方通过指定业务类型即可拉起对应的垂域面板,在垂域面板上将展示目标方接入的垂域应用。 + + +系统会根据调用方在startAbilityByType接口传入的type与wantParams.sceneType取值,按照如下映射关系,匹配到在module.json5配置文件中声明了对应的目标应用。 + +| 支持的功能 | 调用方(startAbilityByType接口入参) | 目标方(配置文件linkFeature取值) | +| ------------ | ------------ | ------------ | +| 路线规划功能 |- type:navigation
- wantParams.sceneType:1 | RoutePlan | +|导航功能 |- type:navigation
- wantParams.sceneType:2 | Navigation| +|位置搜索功能 |- type:navigation
- wantParams.sceneType:3 | PlaceSearch| +|转账汇款功能 |- type:finance
- wantParams.sceneType:1 |Transfer| +|信用卡还款功能 |- type:finance
- wantParams.sceneType:2 |CreditCardRepayment| +|撰写邮件功能|- type:mail
- wantParams.sceneType:1|ComposeMail| +|按航班号查询航班功能|- type:flight
- wantParams.sceneType:1|QueryByFlightNo| +|按起降地查询航班功能|- type:flight
- wantParams.sceneType:2|QueryByLocation| +|快递查询功能|- type:express
- wantParams.sceneType:1|QueryExpress| + + +### 效果预览 + + +|主页| +|--------------------------------| +|![image](screenshots/welcome.png)| + +使用说明 + +1. 在主界面,点击Navigation按钮,会弹出一个hideAbility界面,点击"hideAbility"文本,会弹出导航类应用的面板。 +2. 在主界面,点击按钮Email,会弹出一个hideAbility界面,点击"hideAbility"文本,会弹出邮件类应用的面板。 +3. 在主界面,点击Finance按钮,会弹出一个hideAbility界面,点击"hideAbility"文本,会弹出金融类应用的面板。 +4. 在主界面,点击Express按钮,会弹出一个hideAbility界面,点击"hideAbility"文本,会弹出快递类应用的面板。 +5. 在主界面,点击Emailto按钮,会弹出一个hideAbility界面,点击"feedback"按钮,会弹出邮件发送类应用的面板。 +6. 在主界面,点击Flight按钮,会弹出一个hideAbility界面,点击"hideAbility"文本,会弹出航班类应用的面板。 +7. 在主界面,点击File按钮,会弹出一个文件预览(如果手机只有一个对应的应用),点击"hideAbility"文本,会弹出打开文件类应用的面板。 +8. 在主界面,点击PhotoEdit按钮,会弹出一个selectImg界面,点击相应的按钮会弹出选择图片或者第三方应用面板。 + +### 工程目录 +``` +entry/src/main/ +│ module.json5 +│ +├─ets +│ ├─entryability +│ │ ExpressAbility.ets // 快递 Ability +│ │ FileCallerAbility.ets // 文件发起方 Ability +│ │ FileHandlerAbility.ets // 文件调用方 Ability +│ │ FinanceAbility.ets // 金融 Ability +│ │ FlightAbility.ets // 航班 Ability +│ │ MailAbility.ets // 邮件 Ability +│ │ MailtoAbility.ets // 邮件to Ability +│ │ NavigationAbility.ets // 导航 Ability +│ │ PhotoEditorAbility.ets // 图像编辑 Ability +│ │ StartAbilityEntry.ets // Main Ability +│ │ +│ ├─entrybackupability +│ │ EntryBackupAbility.ets +│ │ +│ └─pages +│ ComposeMailPage.ets //Compose操作页面 +│ CreditCardRepaymentPage.ets //金融还款页面 +│ ExpressIndex.ets //快递操作页面 +│ FileIndex.ets //文件操作页面 +│ FinanceIndex.ets //金融入口页面 +│ FlightIndex.ets //航班入口页面 +│ Index.ets //路由选择 +│ MailIndex.ets //邮件页面 +│ MailtoIndex.ets +│ NavigationIndex.ets //导航页面 +│ PhotoEditorIndex.ets //图片编辑 +│ PhotoIndex.ets //图片编辑入口 +│ PlaceSearchPage.ets +│ QueryByFlightNoPage.ets +│ QueryByLocationPage.ets +│ QueryExpressPage.ets +│ RoutePlanPage.ets +│ TransferPage.ets +│ +└─resources + ├─base + │ ├─element + │ │ color.json + │ │ float.json + │ │ string.json + │ │ + │ ├─media + │ │ background.png + │ │ foreground.png + │ │ layered_image.json + │ │ startIcon.png + │ │ + │ └─profile + │ backup_config.json + │ main_pages.json + │ + └─dark + └─element + color.json +``` + +### 具体实现 + +#### 1. 导航功能 +**核心Ability**:NavigationAbility.ets +**功能页面**: +- 导航入口:NavigationIndex.ets → +- 路径规划:RoutePlanPage.ets +- 地点搜索:PlaceSearchPage.ets + **实现原理**:通过Want动作启动导航应用,支持目的地坐标和路径规划参数传递 + +#### 2. 快递功能 +**核心Ability**:ExpressAbility.ets +**功能页面**: +- 快递入口:ExpressIndex.ets → +- 快递查询:QueryExpressPage.ets +- 物流中转:TransferPage.ets + **实现原理**:通过快递查询协议启动快递应用,支持运单号查询和物流跟踪 + +#### 3. 航班功能 +**核心Ability**:FlightAbility.ets +**功能页面**: +- 航班入口:FlightIndex.ets → +- 航班号查询:QueryByFlightNoPage.ets +- 地点查询:QueryByLocationPage.ets + **实现原理**:支持按航班号或起降地两种方式查询航班信息 + +#### 4. 邮件功能 +**核心Ability**: +- 标准邮件:MailAbility.ets +- 协议邮件:MailtoAbility.ets + **功能页面**: +- 邮件入口:MailIndex.ets → +- 邮件撰写:ComposeMailPage.ets +- 协议入口:MailtoIndex.ets + **实现原理**:分别通过邮件意图和mailto协议两种方式启动邮件应用 + +#### 5. 金融功能 +**核心Ability**:FinanceAbility.ets +**功能页面**: +- 金融入口:FinanceIndex.ets → +- 信用卡还款:CreditCardRepaymentPage.ets + **实现原理**:通过金融支付协议调用支付应用,支持安全的支付和还款流程 + +#### 6. 文件功能 +**核心Ability**: +- 文件发起:FileCallerAbility.ets +- 文件处理:FileHandlerAbility.ets + **功能页面**:文件操作入口:FileIndex.ets + **实现原理**:通过文件操作Want实现文件的选择、分享和处理功能 + +#### 7. 图像编辑功能 +**核心Ability**:PhotoEditorAbility.ets +**功能页面**: +- 图片入口:PhotoIndex.ets → +- 图片编辑:PhotoEditorIndex.ets + **实现原理**:通过图片编辑意图启动编辑应用,支持图片处理和编辑功能 + +#### 8. 主入口管理 +**核心Ability**:StartAbilityEntry.ets +**路由页面**:Index.ets +**功能描述**:作为应用主入口,管理各功能模块的路由跳转和Ability生命周期 + + +### 相关权限 + +不涉及。 + +### 依赖 + +不涉及。 + +### 约束与限制 + + 1.本示例仅支持标准系统上运行,不支持设备:RK3568。 + 2.本示例为Stage模型,支持API20版本SDK,版本号:6.0.0.40,镜像版本号:OpenHarmony_6.0.0.40。 + 2.本示例需要使用(Build Version: 6.0.0.858, built on September 24, 2025)及以上版本才可编译。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/Ability/StartAbility > .git/info/sparse-checkout +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/AbilityKit/StartAbility/build-profile.json5 b/AbilityKit/StartAbility/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7d4b392336508d98757b8c930ef03b411af2e010 --- /dev/null +++ b/AbilityKit/StartAbility/build-profile.json5 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "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/AbilityKit/StartAbility/code-linter.json5 b/AbilityKit/StartAbility/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f5d7b39372750b6812e1544d7a4becb035dc8a0f --- /dev/null +++ b/AbilityKit/StartAbility/code-linter.json5 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/.gitignore b/AbilityKit/StartAbility/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0e1e360839f3008332c8e6e9cb72e49dcc6ffb07 --- /dev/null +++ b/AbilityKit/StartAbility/entry/.gitignore @@ -0,0 +1,8 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/oh-package-lock.json5 +/.idea +/.test \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/build-profile.json5 b/AbilityKit/StartAbility/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d6444a4da4d0e25793ad0daeb9e2762febbd9d5d --- /dev/null +++ b/AbilityKit/StartAbility/entry/build-profile.json5 @@ -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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } + }, + "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/AbilityKit/StartAbility/entry/hvigorfile.ts b/AbilityKit/StartAbility/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8b117a17af3b2d7cb87a7680e29e2bb8ccd5b46 --- /dev/null +++ b/AbilityKit/StartAbility/entry/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/obfuscation-rules.txt b/AbilityKit/StartAbility/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/oh-package.json5 b/AbilityKit/StartAbility/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/main/ets/entryability/ExpressAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/ExpressAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc41464abfb43fd1f0d043b7345a3520d1e79026 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/ExpressAbility.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start express_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'ExpressAbility'; +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + private windowStage: window.WindowStage | null = null; + + private uri?: string; + private expressNo?: string; + // [Start express_ability_on_create] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onCreate, want=${JSON.stringify(want)}`); + super.onCreate(want, launchParam); + this.parseWant(want); + } + // [End express_ability_on_create] + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onNewWant, want=${JSON.stringify(want)}`); + super.onNewWant(want, launchParam); + this.parseWant(want); + if (!this.windowStage) { + hilog.error(DOMAIN, TAG, 'windowStage is null'); + this.context.terminateSelf(); + return; + } + this.loadPage(this.windowStage); + } + + private parseWant(want: Want): void { + this.uri = want.uri as string | undefined; + this.expressNo = want.parameters?.expressNo as string | undefined; + } + + private loadPage(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `loadPage, uri=${this.uri}`); + if (this.uri === 'express://queryExpress') { + // 构建快递查询参数 + const storage: LocalStorage = new LocalStorage({ + 'expressNo': this.expressNo + } as Record); + // 拉起快递查询页面 + windowStage.loadContent('pages/QueryExpressPage', storage) + } else { + // 默认拉起首页 + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', + JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `onWindowStageCreate`); + this.windowStage = windowStage; + this.loadPage(this.windowStage); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} +// [End express_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileCallerAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileCallerAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..370a122203c7ec3bfb696e549eb0903a0742ae1a --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileCallerAbility.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start file_caller_ability_import] +import { fileUri } from '@kit.CoreFileKit'; +import { UIAbility, Want, wantConstant } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { window } from '@kit.ArkUI'; +// [End file_caller_ability_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'ExpressAbility'; +const DOMAIN = 0x0000; + +// [Start file_caller_ability_start] +// [Start file_caller_ability_create_request] +// [Start file_caller_ability_get_url] +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage) { + // 获取文件沙箱路径 + let filePath = this.context.filesDir + '/test.txt'; + // 将沙箱路径转换为uri + let uri = fileUri.getUriFromPath(filePath); + // 获取的uri为"file://com.example.demo/data/storage/el2/base/files/test.txt" + // [StartExclude file_caller_ability_get_url] + // 构造请求数据 + let want: Want = { + action: 'ohos.want.action.viewData', // 表示查看数据的操作,文件打开场景固定为此值 + uri: uri, + type: 'general.plain-text', // 表示待打开文件的类型 + // 配置被分享文件的读写权限,例如对文件打开应用进行读写授权 + flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION + }; + // [StartExclude file_caller_ability_create_request] + // 调用接口启动 + this.context.startAbility(want) + .then(() => { + hilog.info(DOMAIN, TAG, 'Succeed to invoke startAbility.'); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to invoke startAbility, code: ${err.code}, message: ${err.message}`); + }); + // [EndExclude file_caller_ability_create_request] + // [EndExclude file_caller_ability_get_url] + } +} +// [End file_caller_ability_get_url] +// [End file_caller_ability_create_request] +// [End file_caller_ability_start] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileHandlerAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileHandlerAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b34d6c62ae847c3c0bc186b756a26f4696f321b --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FileHandlerAbility.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start file_ability] +import fs from '@ohos.file.fs'; +import { Want, AbilityConstant, UIAbility } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'ExpressAbility'; +const DOMAIN = 0x0000; + +export default class FileHandlerAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + // 从want信息中获取uri字段 + let uri = want.uri; + if (uri == null || uri == undefined) { + hilog.info(DOMAIN, TAG, 'uri is invalid'); + return; + } + try { + // 根据待打开文件的URI进行相应操作。例如同步读写的方式打开URI获取file对象 + let file = fs.openSync(uri, fs.OpenMode.READ_WRITE); + hilog.info(DOMAIN, TAG, 'Succeed to open file.'); + } catch (err) { + let error: BusinessError = err as BusinessError; + hilog.error(DOMAIN, TAG, `Failed to open file openSync, code: ${error.code}, message: ${error.message}`); + } + } +} +// [End file_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/FinanceAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FinanceAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e2ce02bf0056e3c1cc34bd1d2024eada99b29a3 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FinanceAbility.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start finance_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'FinanceAbility'; +const DOMAIN = 0x0000; +export default class EntryAbility extends UIAbility { + private windowStage: window.WindowStage | null = null; + + private uri?: string; + private bankCardNo?: string; + // [Start finance_ability_on_create] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onCreate, want=${JSON.stringify(want)}`); + super.onCreate(want, launchParam); + this.parseWant(want); + } + // [End finance_ability_on_create] + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onNewWant, want=${JSON.stringify(want)}`); + super.onNewWant(want, launchParam); + this.parseWant(want); + if (!this.windowStage) { + hilog.error(DOMAIN, TAG, 'windowStage is null'); + this.context.terminateSelf(); + return; + } + this.loadPage(this.windowStage); + } + + private parseWant(want: Want): void { + this.uri = want.uri as string | undefined; + this.bankCardNo = want.parameters?.bankCardNo as string | undefined; + } + + private loadPage(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `loadPage, uri=${this.uri}`); + if (this.uri === 'finance://transfer') { + // 构建转账场景参数 + const storage: LocalStorage = new LocalStorage({ + 'bankCardNo': this.bankCardNo + } as Record); + // 拉起转账页面 + windowStage.loadContent('pages/TransferPage', storage) + } else if (this.uri === 'finance://credit_card_repayment') { + // 构建信用卡还款场景参数 + const storage: LocalStorage = new LocalStorage({ + 'bankCardNo': this.bankCardNo + } as Record); + // 拉起信用卡还款页面 + windowStage.loadContent('pages/CreditCardRepaymentPage', storage) + } else { + // 默认拉起首页 + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', + JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `onWindowStageCreate`); + this.windowStage = windowStage; + this.loadPage(this.windowStage); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} +// [End finance_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/FlightAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FlightAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..447328dc3051dd081a6b0281d5bdc2cb38427053 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/FlightAbility.ets @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start flight_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'FlightAbility'; +const DOMAIN = 0x0000; +export default class EntryAbility extends UIAbility { + private windowStage: window.WindowStage | null = null; + + private uri?: string; + private flightNo?: string; + private departureDate?: string; + private originLocation?: string; + private destinationLocation?: string; + + // [Start flight_ability_on_create] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onCreate, want=${JSON.stringify(want)}`); + super.onCreate(want, launchParam); + this.parseWant(want); + } + // [End flight_ability_on_create] + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onNewWant, want=${JSON.stringify(want)}`); + super.onNewWant(want, launchParam); + this.parseWant(want); + if (!this.windowStage) { + hilog.error(DOMAIN, TAG, 'windowStage is null'); + this.context.terminateSelf(); + return; + } + this.loadPage(this.windowStage); + } + + private parseWant(want: Want): void { + this.uri = want.uri as string | undefined; + this.flightNo = want.parameters?.flightNo as string | undefined; + this.departureDate = want.parameters?.departureDate as string | undefined; + this.originLocation = want.parameters?.originLocation as string | undefined; + this.destinationLocation = want.parameters?.destinationLocation as string | undefined; + } + + private loadPage(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `loadPage, uri=${this.uri}`); + if (this.uri === 'flight://queryByFlightNo') { + // 构建按航班号查询场景参数 + const storage: LocalStorage = new LocalStorage({ + 'flightNo': this.flightNo, + 'departureDate': this.departureDate + } as Record); + // 拉起按航班号查询页面 + windowStage.loadContent('pages/QueryByFlightNoPage', storage) + } else if (this.uri === 'flight://queryByLocation') { + // 构建按起降地查询场景参数 + const storage: LocalStorage = new LocalStorage({ + 'originLocation': this.originLocation, + 'destinationLocation': this.destinationLocation, + 'departureDate': this.departureDate + } as Record); + // 拉起按起降地查询页面 + windowStage.loadContent('pages/QueryByLocationPage', storage) + } else { + // 默认拉起首页 + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', + JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `onWindowStageCreate`); + this.windowStage = windowStage; + this.loadPage(this.windowStage); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} +// [End flight_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..66f86c8f532c29c8742251086be9a8bf9933c009 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailAbility.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start mail_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'MailAbility'; +const DOMAIN = 0x0000; +export default class EntryAbility extends UIAbility { + private windowStage: window.WindowStage | null = null; + + private email: string[] | undefined; + private cc: string[] | undefined; + private bcc: string[] | undefined; + private subject: string | undefined; + private body: string | undefined; + private stream: string[] | undefined; + // [Start mail_ability_on_create] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onCreate, want=${JSON.stringify(want)}`); + super.onCreate(want, launchParam); + this.parseWant(want); + } + // [End mail_ability_on_create] + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onNewWant, want=${JSON.stringify(want)}`); + super.onNewWant(want, launchParam); + this.parseWant(want); + if (!this.windowStage) { + hilog.error(DOMAIN, TAG, 'windowStage is null'); + this.context.terminateSelf(); + return; + } + this.loadPage(this.windowStage); + } + + private parseWant(want: Want): void { + this.email = this.decodeStringArr(want.parameters?.email as string[]); + this.cc = this.decodeStringArr(want.parameters?.cc as string[]); + this.bcc = this.decodeStringArr(want.parameters?.bcc as string[]); + this.subject = decodeURI(want.parameters?.subject as string);// 使用decodeURI()方法对邮件主题进行url解码,其他字段处理方法相同 + this.body = decodeURI(want.parameters?.body as string);// 使用decodeURI()方法对邮件内容进行url解码,其他字段处理方法相同 + this.stream = this.decodeStringArr(want.parameters?.stream as string[]); + } + + // 使用decodeURI()方法对string数组内容进行解码 + private decodeStringArr(source: string[] | undefined): string[] { + let target: string[] = []; + source?.forEach(e => { + target.push(decodeURI(e)); + }) + return target; + } + + private loadPage(windowStage: window.WindowStage): void { + const storage: LocalStorage = new LocalStorage({ + 'email': this.email, + 'cc': this.cc, + 'bcc': this.bcc, + 'subject': this.subject, + 'body': this.body, + 'stream': this.stream + } as Record); + + windowStage.loadContent('pages/ComposeMailPage', storage); + + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `onWindowStageCreate`); + this.windowStage = windowStage; + this.loadPage(this.windowStage); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, `onWindowStageDestroy`); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, `onForeground`); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, `onBackground`); + } +} +// [End mail_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailtoAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailtoAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8e9cc26ff599d90d898991bbfa330e643ce6018 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/MailtoAbility.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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'MailtoAbility'; +const DOMAIN = 0x0000; +// [Start mailto_ability] +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 应用冷启动生命周期回调,其他业务处理... + this.parseMailto(want); + } + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 应用热启动生命周期回调,其他业务处理 + this.parseMailto(want); + } + + public parseMailto(want: Want) { + const uri = want?.uri; + if (!uri || uri.length <= 0) { + return; + } + } + // [End mailto_ability] + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/MailtoIndex', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/NavigationAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/NavigationAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc6796262384af00848fb056e9a93a6db0ad4a06 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/NavigationAbility.ets @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start navigation_ability] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'NavigationAbility'; +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + private windowStage: window.WindowStage | null = null; + + private uri?: string; + private destinationLatitude?: number; + private destinationLongitude?: number; + private destinationName?: string; + private originName?: string; + private originLatitude?: number; + private originLongitude?: number; + private vehicleType?: number; + private destinationPoiId?: string; + private originPoiId?: string; + // [Start navigation_ability_on_create] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // [End navigation_ability_on_create] + hilog.info(DOMAIN, TAG, `onCreate, want=${JSON.stringify(want)}`); + super.onCreate(want, launchParam); + this.parseWant(want); + } + + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, TAG, `onNewWant, want=${JSON.stringify(want)}`); + super.onNewWant(want, launchParam); + this.parseWant(want); + if (!this.windowStage) { + hilog.error(DOMAIN, TAG, 'windowStage is null'); + this.context.terminateSelf(); + return; + } + this.loadPage(this.windowStage); + } + + private parseWant(want: Want): void { + this.uri = want.uri as string | undefined; + this.destinationLatitude = want.parameters?.destinationLatitude as number | undefined; + this.destinationLongitude = want.parameters?.destinationLongitude as number | undefined; + this.destinationName = want.parameters?.destinationName as string | undefined; + this.originName = want.parameters?.originName as string | undefined; + this.originLatitude = want.parameters?.originLatitude as number | undefined; + this.originLongitude = want.parameters?.originLongitude as number | undefined; + this.vehicleType = want.parameters?.vehicleType as number | undefined; + this.destinationPoiId = want.parameters?.destinationPoiId as string | undefined; + this.originPoiId = want.parameters?.originPoiId as string | undefined; + } + + private loadPage(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `loadPage, uri=${this.uri}`); + if (this.uri === 'maps://navigation') { + // 构建导航场景参数 + const storage: LocalStorage = new LocalStorage({ + 'destinationLatitude': this.destinationLatitude, + 'destinationLongitude': this.destinationLongitude, + 'destinationPoiId': this.destinationPoiId + } as Record); + // 拉起导航页面 + windowStage.loadContent('pages/NavigationPage', storage) + } else if (this.uri === 'maps://routePlan') { + // 构建路径规划场景参数 + const storage: LocalStorage = new LocalStorage({ + 'destinationLatitude': this.destinationLatitude, + 'destinationLongitude': this.destinationLongitude, + 'destinationName': this.destinationName, + 'originName': this.originName, + 'originLatitude': this.originLatitude, + 'originLongitude': this.originLongitude, + 'vehicleType': this.vehicleType, + 'destinationPoiId': this.destinationPoiId, + 'originPoiId': this.originPoiId + } as Record); + // 拉起路径规划页面 + windowStage.loadContent('pages/RoutePlanPage', storage) + } else if (this.uri === 'maps://search') { + // 构建位置搜索场景参数 + const storage: LocalStorage = new LocalStorage({ + 'destinationName': this.destinationName + } as Record); + // 拉起位置搜索页面 + windowStage.loadContent('pages/PlaceSearchPage', storage) + } else { + // 默认拉起首页 + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', + JSON.stringify(err) ?? ''); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, `onDestroy`); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(DOMAIN, TAG, `onWindowStageCreate`); + this.windowStage = windowStage; + this.loadPage(this.windowStage); + } + + onWindowStageDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} +// [End navigation_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/PhotoEditorAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/PhotoEditorAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..125accac6ea6311a0c9db82c27cc9f84d520c177 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/PhotoEditorAbility.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. + */ + +// [Start photo_edit_ability] +import { PhotoEditorExtensionAbility,UIExtensionContentSession,Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = '[ExamplePhotoEditorAbility]'; +export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility { + onCreate() { + hilog.info(0x0000, TAG, 'onCreate'); + } + + // 获取图片,加载页面并将需要的参数传递给页面 + onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession): void { + hilog.info(0x0000, TAG, `onStartContentEditing want: ${JSON.stringify(want)}, uri: ${uri}`); + + const storage: LocalStorage = new LocalStorage({ + 'session': session, + 'uri': uri + } as Record); + + session.loadContent('pages/PhotoEditorIndex', storage); + } + + onForeground() { + hilog.info(0x0000, TAG, 'onForeground'); + } + + onBackground() { + hilog.info(0x0000, TAG, 'onBackground'); + } + + onDestroy() { + hilog.info(0x0000, TAG, 'onDestroy'); + } +} +// [End photo_edit_ability] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entryability/StartAbilityEntry.ets b/AbilityKit/StartAbility/entry/src/main/ets/entryability/StartAbilityEntry.ets new file mode 100644 index 0000000000000000000000000000000000000000..258b640f262f9404b62f680cb0eb0dc66ff77589 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/entryability/StartAbilityEntry.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const TAG = 'StartAbilityEntry'; +const DOMAIN = 0x0000; + +export default class StartAbilityEntry extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, TAG, 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/AbilityKit/StartAbility/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/main/ets/pages/ComposeMailPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/ComposeMailPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..335222316fcc8b0aa0103601badcde462dcf0194 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/ComposeMailPage.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct ComposeMailPage { + build() { + Column() { + Text('RoutePlanning') + .fontSize(20) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/CreditCardRepaymentPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/CreditCardRepaymentPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..3effeabcca246da5d47fea102276e37cdb013b98 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/CreditCardRepaymentPage.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 CreditCardRepaymentPage { + @LocalStorageLink('BankCardNo') bankCardNo: string = ''; + + build() { + Column() { + Text('CreditCardRepayment') + .fontSize(30) + .fontWeight(FontWeight.Bold) + + Text(`CardNo: ${this.bankCardNo}`) + .fontSize(18) + .margin(10) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/ExpressIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/ExpressIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..61dffd66e38d090243f8d624cdb76cf897cb3d31 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/ExpressIndex.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start express_index_import] +import { common } from '@kit.AbilityKit'; +// [End express_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'ExpressIndex'; +const DOMAIN = 0x0000; +// [Start express_index_component] +@Entry +@Component +struct Index { + @State hideAbility: string = 'hideAbility'; + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let wantParam: Record = { + 'sceneType': 1, + 'expressNo': 'SF123456' + }; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(DOMAIN, TAG, `onError code ${code} name: ${name} message: ${message}`); + }, + onResult: (result) => { + hilog.info(DOMAIN, TAG, `onResult result: ${JSON.stringify(result)}`); + } + } + + context.startAbilityByType('express', wantParam, abilityStartCallback, + (err) => { + if (err) { + hilog.error(DOMAIN, TAG, `startAbilityByType fail, err: ${JSON.stringify(err)}`); + } else { + hilog.info(DOMAIN, TAG, `success`); + } + }); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End express_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/FileIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/FileIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..11a1379439883a51b05bd3f388fc3afcd6715e2e --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/FileIndex.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { router } from '@kit.ArkUI'; +import { fileUri } from '@kit.CoreFileKit'; +import { Want, wantConstant } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import fs from '@ohos.file.fs'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'ExpressIndex'; +const DOMAIN = 0x0000; + +@Entry +@Component +struct FileIndex { + @State hideAbility: string = 'hideAbility'; + @State message: string = ''; + private context = getContext(this) as common.UIAbilityContext; + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.openFile(); + }) + } + .width('100%') + } + .height('100%') + } + +private openFile() { + try { + // 获取文件沙箱路径 + let filePath = this.context.filesDir + '/test.txt'; + this.createTestFile(filePath); + // 将沙箱路径转换为uri + let uri = fileUri.getUriFromPath(filePath); + hilog.info(DOMAIN, TAG, 'Generated file URI: ' + uri); + + // 构造请求数据 - 完全使用示例代码 + let want: Want = { + action: 'ohos.want.action.viewData', // 表示查看数据的操作,文件打开场景固定为此值 + uri: uri, + type: 'general.plain-text', // 表示待打开文件的类型 + // 配置被分享文件的读写权限,例如对文件打开应用进行读写授权 + flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, + parameters: {'ohos.ability.params.showDefaultPicker' : true} + }; + + this.context.startAbility(want) + .then(() => { + hilog.info(DOMAIN, TAG, 'Succeed to invoke startAbility.'); + }) + .catch((err: BusinessError) => { + hilog.error(DOMAIN, TAG, `Failed to invoke startAbility, code: ${err.code}, message: ${err.message}`); + }); + } catch (err) { + hilog.error(DOMAIN, TAG, 'Failed to open file: ' + JSON.stringify(err)); + this.message = 'An error occurred while opening the file.'; + } +} + + private createTestFile(filePath: string) { + try { + let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); + fs.writeSync(file.fd, 'This is the content of test file!\nCreate Time: ' + new Date().toLocaleString()); + fs.closeSync(file); + this.message = 'create file success!Click [Open file]'; + hilog.info(DOMAIN, TAG, 'Test file created successfully'); + } catch (err) { + hilog.error(DOMAIN, TAG, 'Failed to create test file: ' + JSON.stringify(err)); + this.message = 'Failed to create the test file'; + } + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/FinanceIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/FinanceIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..290ecd101492999da3ef75f00412dc453d0265cd --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/FinanceIndex.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +// [Start finance_index_import] +import { common } from '@kit.AbilityKit'; +// [End finance_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'FinanceIndex'; +const DOMAIN = 0x0000; +// [Start finance_index_component] +@Entry +@Component +struct Index { + @State hideAbility: string = 'hideAbility'; + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let wantParam: Record = { + 'sceneType': 1, + 'bankCardNo': '123456789' + }; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(DOMAIN, TAG, `onError code ${code} name: ${name} message: ${message}`); + }, + onResult: (result) => { + hilog.info(DOMAIN, TAG, `onResult result: ${JSON.stringify(result)}`); + } + } + + context.startAbilityByType('finance', wantParam, abilityStartCallback, + (err) => { + if (err) { + hilog.error(DOMAIN, TAG, `startAbilityByType fail, err: ${JSON.stringify(err)}`); + } else { + hilog.info(DOMAIN, TAG, `success`); + } + }); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End finance_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/FlightIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/FlightIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..42f7ab0c12e9647bb0bb5614f2948bde6478958e --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/FlightIndex.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. + */ + +// [Start flight_index_import] +import { common } from '@kit.AbilityKit'; +// [End flight_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'FlightIndex'; +const DOMAIN = 0x0000; +// [Start flight_index_component] +@Entry +@Component +struct Index { + @State hideAbility: string = 'hideAbility' + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let wantParam: Record = { + 'sceneType': 1, + 'flightNo': 'ZH1509', + 'departureDate': '2024-10-01', + 'uri': 'flight://queryByFlightNo' + }; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(DOMAIN, TAG, `onError code ${code} name: ${name} message: ${message}`); + }, + onResult: (result) => { + hilog.info(DOMAIN, TAG, `onResult result: ${JSON.stringify(result)}`); + } + } + + context.startAbilityByType('flight', wantParam, abilityStartCallback, + (err) => { + if (err) { + hilog.error(DOMAIN, TAG, `startAbilityByType fail, err: ${JSON.stringify(err)}`); + } else { + hilog.info(DOMAIN, TAG, `success`); + } + }); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End flight_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/Index.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..4760fe57b10ae1bd59c2349c4b33bb92d339a2e8 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct MainPage { + + build() { + Row() { + Column() { + Button('Navigation') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/NavigationIndex' }); + }) + + Button('Email') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/MailIndex' }); + }) + + Button('Finance') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/FinanceIndex' }); + }) + + Button('Emailto') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/MailtoIndex' }); + }) + + Button('Flight') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/FlightIndex' }); + }) + + Button('Express') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/ExpressIndex' }); + }) + + Button('File') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/FileIndex' }); + }) + + Button('PhotoEdit') + .fontSize(20) + .width('80%') + .height(50) + .margin(10) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/PhotoIndex' }); + }) + } + .width('100%') + .justifyContent(FlexAlign.Center) + } + .height('100%') + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/MailIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/MailIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..685b4e8c8b11850f8ce7ba455d6c9e8df0c7af2d --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/MailIndex.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start mail_index_import] +import { common, wantConstant } from '@kit.AbilityKit'; +// [End mail_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'MailIndex'; +const DOMAIN = 0x0000; +// [Start mail_index_component] + +@Entry +@Component +struct Index { + @State hideAbility: string = 'hideAbility' + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let wantParam: Record = { + 'sceneType': 1, + 'email': [encodeURI('xxx@example.com'), encodeURI('xxx@example.com')], // 收件人邮箱地址,多值以逗号分隔,对数组内容使用encodeURI()方法进行url编码 + 'cc': [encodeURI('xxx@example.com'), encodeURI('xxx@example.com')], // 抄收人邮箱地址,多值以逗号分隔,对数组内容使用encodeURI()方法进行url编码 + 'bcc': [encodeURI('xxx@example.com'), encodeURI('xxx@example.com')], // 密送人邮箱地址,多值以逗号分隔,对数组内容使用encodeURI()方法进行url编码 + 'subject': encodeURI('邮件主题'), // 邮件主题,对内容使用encodeURI()方法进行url编码 + 'body': encodeURI('邮件正文'), // 邮件正文,对内容使用encodeURI()方法进行url编码 + 'ability.params.stream': [encodeURI('附件uri1'), encodeURI('附件uri2')], // 附件uri,多值以逗号分隔,对数组内容使用encodeURI()方法进行url编码 + 'ability.want.params.uriPermissionFlag': wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION + }; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(DOMAIN, TAG, `onError code ${code} name: ${name} message: ${message}`); + }, + onResult: (result) => { + hilog.info(DOMAIN, TAG, `onResult result: ${JSON.stringify(result)}`); + } + } + + context.startAbilityByType('mail', wantParam, abilityStartCallback, + (err) => { + if (err) { + hilog.error(DOMAIN, TAG, `startAbilityByType fail, err: ${JSON.stringify(err)}`); + } else { + hilog.info(DOMAIN, TAG, `success`); + } + }); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End mail_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/MailtoIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/MailtoIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d264fdac60b57b6489600ab6baccb709a5007c9 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/MailtoIndex.ets @@ -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. + */ + +// [Start mailto_index] +import { common } from '@kit.AbilityKit'; + +@Entry +@Component +struct Index { + build() { + Column() { + Button('feedback') + .onClick(() => { + let ctx = this.getUIContext().getHostContext() as common.UIAbilityContext; + ctx.startAbility({ + action: 'ohos.want.action.sendToData', + uri: 'mailto:feedback@example.com?subject=App Feedback&body=Please describe your feedback here...' + }).catch(() => { + // TODO: Implement error handling. + }) + }) + } + } +} +// [End mailto_index] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/NavigationIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/NavigationIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a98f6b215c3334ad743ec7ea37e708a8a36a64f3 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/NavigationIndex.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start navigation_index_import] +import { common } from '@kit.AbilityKit'; +// [End navigation_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'NavigationIndex'; +const DOMAIN = 0x0000; +// [Start navigation_index_component] +@Entry +@Component +struct Index { + @State hideAbility: string = 'hideAbility' + + build() { + Row() { + Column() { + Text(this.hideAbility) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let wantParam: Record = { + 'sceneType': 1, + 'destinationLatitude': 32.060844, + 'destinationLongitude': 118.78315, + 'destinationName': 'xx市xx路xx号', + 'destinationPoiIds': { + 1: '1001', // key为1代表花瓣地图,value需为花瓣地图POI + 2: '2002', // key为2代表高德地图,value需为高德地图POI + 3: '3003' // key为3代表百度地图,value需为百度地图POI + } as Record, + 'originName': 'xx City xx Park', + 'originLatitude': 31.060844, + 'originLongitude': 120.78315, + 'originPoiIds': { + 1: '1101', // key为1代表花瓣地图,value需为花瓣地图POI + 2: '2202', // key为2代表高德地图,value需为高德地图POI + 3: '3303' // key为3代表百度地图,value需为百度地图POI + } as Record, + 'vehicleType': 0 + }; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code: number, name: string, message: string) => { + hilog.error(DOMAIN, TAG, `onError code ${code} name: ${name} message: ${message}`); + }, + onResult: (result) => { + hilog.info(DOMAIN, TAG, `onResult result: ${JSON.stringify(result)}`); + } + } + + context.startAbilityByType('navigation', wantParam, abilityStartCallback, + (err) => { + if (err) { + hilog.error(DOMAIN, TAG, `startAbilityByType fail, err: ${JSON.stringify(err)}`); + } else { + hilog.info(DOMAIN, TAG, `success`); + } + }); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End navigation_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoEditorIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoEditorIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..66a1a4fa76f1a9e565c192097938a22a69c9c35c --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoEditorIndex.ets @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start photo_edit_index] +import { common } from '@kit.AbilityKit'; +import { UIExtensionContentSession, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { fileIo } from '@kit.CoreFileKit'; +import { image } from '@kit.ImageKit'; + +const TAG = '[ExamplePhotoEditorAbility]'; + +@Entry +@Component +struct Index { + @State message: string = 'editImg'; + @State originalImage: PixelMap | null = null; + @State editedImage: PixelMap | null = null; + private newWant ?: Want; + private storage = this.getUIContext().getSharedLocalStorage(); + + aboutToAppear(): void { + let originalImageUri = this.storage?.get('uri') ?? ''; + hilog.info(0x0000, TAG, `OriginalImageUri: ${originalImageUri}.`); + + this.readImageByUri(originalImageUri).then(imagePixMap => { + this.originalImage = imagePixMap; + }) + } + + // 根据uri读取图片内容 + async readImageByUri(uri: string): Promise < PixelMap | null > { + hilog.info(0x0000, TAG, `uri: ${uri}`); + let file: fileIo.File | undefined; + try { + file = await fileIo.open(uri, fileIo.OpenMode.READ_ONLY); + hilog.info(0x0000, TAG, `Original image file id: ${file.fd}`); + + let imageSourceApi: image.ImageSource = image.createImageSource(file.fd); + if(!imageSourceApi) { + hilog.info(0x0000, TAG, `ImageSourceApi failed.`); + return null; + } + let pixmap: image.PixelMap = await imageSourceApi.createPixelMap(); + if(!pixmap) { + hilog.info(0x0000, TAG, `createPixelMap failed.`); + return null; + } + this.originalImage = pixmap; + return pixmap; + } catch(e) { + hilog.error(0x0000, TAG, `ReadImage failed:${e}`); + } finally { + fileIo.close(file); + } + return null; + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + + Button('RotateAndSaveImg').onClick(event => { + hilog.info(0x0000, TAG, 'Start to edit image and save.'); + // 编辑图片功能实现 + this.originalImage?.rotate(90).then(() => { + let packOpts: image.PackingOption = { format: 'image/jpeg', quality: 98 }; + try { + // 调用saveEditedContentWithImage保存图片 + (this.getUIContext().getHostContext() as common.PhotoEditorExtensionContext).saveEditedContentWithImage( + this.originalImage as image.PixelMap, + packOpts).then(data => { + if (data.resultCode == 0) { + hilog.info(0x0000, TAG, 'Save succeed.'); + } + hilog.info(0x0000, TAG, + `saveContentEditingWithImage result: ${JSON.stringify(data)}`); + this.newWant = data.want; + // data.want.uri存有编辑过图片的uri + this.readImageByUri(this.newWant?.uri ?? '').then(imagePixMap => { + this.editedImage = imagePixMap; + }) + }) + } catch (e) { + hilog.error(0x0000, TAG, `saveContentEditingWithImage failed:${e}`); + return; + } + }) + }).margin({ top: 10 }) + + Button('terminateSelfWithResult').onClick((event => { + hilog.info(0x0000, TAG, 'Finish the current editing.'); + + let session = this.storage?.get('session') as UIExtensionContentSession; + // 关闭并回传修改结果给调用方 + session?.terminateSelfWithResult({ resultCode: 0, want: this.newWant }); + })).margin({ top: 10 }) + + Image(this.originalImage).width('100%').height(200).margin({ top: 10 }).objectFit(ImageFit.Contain) + + Image(this.editedImage).width('100%').height(200).margin({ top: 10 }).objectFit(ImageFit.Contain) + } + .width('100%') + } + .height('100%') + .backgroundColor(Color.Pink) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) + } +} +// [End photo_edit_index] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoIndex.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe8849e4179ba82ec0730b843debf4a5af61fab7 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/PhotoIndex.ets @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// [Start photo_index_component] +// [Start photo_index_import] +import { common, wantConstant } from '@kit.AbilityKit'; +import { fileUri, picker } from '@kit.CoreFileKit'; +// [End photo_index_import] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { fileIo } from '@kit.CoreFileKit'; +import { image } from '@kit.ImageKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { JSON } from '@kit.ArkTS'; +import { photoAccessHelper } from '@kit.MediaLibraryKit'; + +const TAG = 'PhotoEditorCaller'; + +@Entry +@Component +struct Index { + @State message: string = 'selectImg'; + @State originalImage: ResourceStr = ''; + @State editedImage: PixelMap | null = null; + private filePath: string = ''; + + // 根据uri读取图片内容 + async readImage(uri: string): Promise < PixelMap | null > { + hilog.info(0x0000, TAG, `image uri: ${uri}`); + let file: fileIo.File | undefined; + try { + file = await fileIo.open(uri, fileIo.OpenMode.READ_ONLY); + hilog.info(0x0000, TAG, `file: ${file.fd}`); + + let imageSourceApi: image.ImageSource = image.createImageSource(file.fd); + if(!imageSourceApi) { + hilog.info(0x0000, TAG, 'imageSourceApi failed'); + return null; + } + let pixmap: image.PixelMap = await imageSourceApi.createPixelMap(); + if(!pixmap) { + hilog.info(0x0000, TAG, 'createPixelMap failed'); + return null; + } + this.editedImage = pixmap; + return pixmap; + } catch(e) { + hilog.error(0x0000, TAG, `readImage failed:${e}`); + } finally { + fileIo.close(file); + } + return null; + } + + // 图库中选取图片 + // [Start photo_index_picker] + async photoPickerGetUri(): Promise { + try { + let textInfo: photoAccessHelper.TextContextInfo = { + text: 'photo' + } + let recommendOptions: photoAccessHelper.RecommendationOptions = { + textContextInfo: textInfo + } + let options: photoAccessHelper.PhotoSelectOptions = { + MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE, + maxSelectNumber: 1, + recommendationOptions: recommendOptions + } + let photoPicker = new photoAccessHelper.PhotoViewPicker(); + let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoPicker.select(options); + return photoSelectResult.photoUris[0]; + } catch (error) { + let err: BusinessError = error as BusinessError; + hilog.error(0x0000, TAG, 'PhotoViewPicker failed with err: ' + JSON.stringify(err)); + } + return ''; + } + // [End photo_index_picker] + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + + Button('selectImg').onClick(event => { + // 图库中选取图片 + this.photoPickerGetUri().then(uri => { + hilog.info(0x0000, TAG, `uri: ${uri}`); + // [Start photo_index_photo_select] + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let file: fileIo.File | undefined; + try { + file = fileIo.openSync(uri, fileIo.OpenMode.READ_ONLY); + hilog.info(0x0000, TAG, `file: ${file.fd}`); + + let timeStamp = Date.now(); + // 将用户图片拷贝到应用沙箱路径 + fileIo.copyFileSync(file.fd, context.filesDir + `/original-${timeStamp}.jpg`); + + this.filePath = context.filesDir + `/original-${timeStamp}.jpg`; + this.originalImage = fileUri.getUriFromPath(this.filePath); + } catch (e) { + hilog.info(0x0000, TAG, `readImage failed:${e}`); + } finally { + fileIo.close(file); + } + // [End photo_index_photo_select] + }) + + }).width('200').margin({ top: 20 }) + + Button('editImg').onClick(event => { + // [Start photo_index_ability_callback] + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let abilityStartCallback: common.AbilityStartCallback = { + onError: (code, name, message) => { + const tip: string = `code:` + code + ` name:` + name + ` message:` + message; + hilog.error(0x0000, TAG, `startAbilityByType: fail, err: ${tip}`); + }, + onResult: (result) => { + // 获取到回调结果中编辑后的图片uri并做对应的处理 + let uri = result.want?.uri ?? ''; + hilog.info(0x0000, TAG, `PhotoEditorCaller result: ${JSON.stringify(result)}`); + this.readImage(uri).then(imagePixMap => { + this.editedImage = imagePixMap; + }); + } + } + // [End photo_index_ability_callback] + // 将图片转换为图片uri,并调用startAbilityByType拉起图片编辑应用面板 + // [Start photo_index_ability_start] + let uri = fileUri.getUriFromPath(this.filePath); + context.startAbilityByType('photoEditor', { + 'ability.params.stream': [uri], // 原始图片的uri,只支持传入一个uri + 'ability.want.params.uriPermissionFlag': wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION // 至少需要分享读权限给到图片编辑面板 + } as Record, abilityStartCallback, (err) => { + let tip: string; + if (err) { + tip = `Start error: ${JSON.stringify(err)}`; + hilog.error(0x0000, TAG, `startAbilityByType: fail, err: ${JSON.stringify(err)}`); + } else { + tip = `Start success`; + hilog.info(0x0000, TAG, `startAbilityByType: ${tip}`); + } + }); + // [End photo_index_ability_start] + }).width('200').margin({ top: 20 }) + + Image(this.originalImage).width('100%').height(200).margin({ top: 20 }).objectFit(ImageFit.Contain) + + Image(this.editedImage).width('100%').height(200).margin({ top: 20 }).objectFit(ImageFit.Contain) + } + .width('100%') + } + .height('100%') + .backgroundColor(Color.Orange) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) + } +} +// [End photo_index_component] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/PlaceSearchPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/PlaceSearchPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..87666ef00e13bd6268ce546dc4ad3594c248ad03 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/PlaceSearchPage.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct PlaceSearchPage { + build() { + Column() { + Text('LocationSearch') + .fontSize(20) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByFlightNoPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByFlightNoPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..66e65f0c52b4dce699535d1d98125a6d4fe5012d --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByFlightNoPage.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 QueryByFlightNoPage { + @LocalStorageLink('flightNo') flightNo: string = ''; + @LocalStorageLink('departureDate') departureDate: string = ''; + + build() { + Column() { + Text('SearchFlightNoByNo') + .fontSize(30) + .fontWeight(FontWeight.Bold) + + Text(`FlightNo: ${this.flightNo}`) + .fontSize(18) + .margin(10) + + Text(`DepartureDate: ${this.departureDate}`) + .fontSize(18) + .margin(10) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByLocationPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByLocationPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..f800b3afeabee2b99c919ec30a9cfe4f2fa409bc --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryByLocationPage.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct QueryByLocationPage { + @LocalStorageLink('originLocation') originLocation: string = ''; + @LocalStorageLink('destinationLocation') destinationLocation: string = ''; + @LocalStorageLink('departureDate') departureDate: string = ''; + + build() { + Column() { + Text('Search page by departure') + .fontSize(30) + .fontWeight(FontWeight.Bold) + + Text(`departure location: ${this.originLocation}`) + .fontSize(18) + .margin(10) + + Text(`destination: ${this.destinationLocation}`) + .fontSize(18) + .margin(10) + + Text(`departure date: ${this.departureDate}`) + .fontSize(18) + .margin(10) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryExpressPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryExpressPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..0449ad0f4deb5228105681a14690bfb22df14536 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/QueryExpressPage.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 QueryExpressPage { + @LocalStorageLink('ExpressNo') expressNo: string = ''; + + build() { + Column() { + Text('ExpressSearch') + .fontSize(30) + .fontWeight(FontWeight.Bold) + + Text(`ExpressNo: ${this.expressNo}`) + .fontSize(18) + .margin(10) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/RoutePlanPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/RoutePlanPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e05d030386fb3f055284f866ab95ef0e4ac5a33 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/RoutePlanPage.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct RoutePlanPage { + build() { + Column() { + Text('RoutePlanning') + .fontSize(20) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/ets/pages/TransferPage.ets b/AbilityKit/StartAbility/entry/src/main/ets/pages/TransferPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac93fda04cea84e10c5a753663a44a3e40fe8b4c --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/ets/pages/TransferPage.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 TransferPage { + @LocalStorageLink('BankCardNo') bankCardNo: string = ''; + + build() { + Column() { + Text('Transfer') + .fontSize(30) + .fontWeight(FontWeight.Bold) + + Text(`CreditNo: ${this.bankCardNo}`) + .fontSize(18) + .margin(10) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center) + } +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/module.json5 b/AbilityKit/StartAbility/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8a4fd7752b6400a1270218a5e5782a30a88a91e6 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/module.json5 @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// [Start file_config] +// [Start photo_config] +// [Start mailto_config] +// [Start express_config] +// [Start finance_config] +// [Start flight_config] +// [Start mail_config] +// [Start navitation_config] +{ + "module": { + // [StartExclude file_config] + // [StartExclude photo_config] + // [StartExclude mailto_config] + // [StartExclude express_config] + // [StartExclude finance_config] + // [StartExclude flight_config] + // [StartExclude mail_config] + // [StartExclude navitation_config] + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "StartAbilityEntry", + "deviceTypes": [ + "default", + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + // [EndExclude file_config] + // [EndExclude mailto_config] + // [EndExclude express_config] + // [EndExclude finance_config] + // [EndExclude flight_config] + // [EndExclude mail_config] + // [EndExclude navitation_config] + "abilities": [ + // [StartExclude file_config] + // [StartExclude mailto_config] + // [StartExclude express_config] + // [StartExclude finance_config] + // [StartExclude flight_config] + // [StartExclude mail_config] + // [StartExclude navitation_config] + { + "name": "StartAbilityEntry", + "srcEntry": "./ets/entryability/StartAbilityEntry.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": [ + "ohos.want.action.home" + ] + } + ] + }, + // [EndExclude navitation_config] + { + // [StartExclude navitation_config] + "name": "NavigationAbility", + "srcEntry": "./ets/entryability/NavigationAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:Navigation_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + // [EndExclude navitation_config] + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ], + "uris": [ + { + "scheme": "maps", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "navigation", + "path": "", + "linkFeature": "Navigation" // 声明应用支持导航功能 + }, + { + "scheme": "maps", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "routePlan", + "path": "", + "linkFeature": "RoutePlan" // 声明应用支持路线规划功能 + }, + { + "scheme": "maps", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "search", + "path": "", + "linkFeature": "PlaceSearch" // 声明应用支持位置搜索功能 + } + ] + } + ] + }, + // [EndExclude mail_config] + // [StartExclude navitation_config] + { + // [StartExclude mail_config] + "name": "MailAbility", + "srcEntry": "./ets/entryability/MailAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:Mail_label", + "exported": true, + // [EndExclude mail_config] + "skills": [ + { + "uris": [ + { + "scheme": "mailto", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "", + "path": "", + "linkFeature": "ComposeMail" // 声明应用支持撰写邮件功能 + } + ] + } + ], + // [StartExclude mail_config] + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + // [EndExclude mail_config] + }, + // [EndExclude mailto_config] + // [StartExclude mail_config] + { + // [StartExclude mailto_config] + "name": "MailtoAbility", + "srcEntry": "./ets/entryability/MailtoAbility.ets", + "description": "$string:MailtoAbility_label", + "icon": "$media:layered_image", + "label": "$string:MailtoAbility_label", + "exported": true, + // [EndExclude mailto_config] + "skills": [ + { + "actions": [ + 'ohos.want.action.sendToData' + ], + "uris": [ + { + "scheme": "mailto", + // linkFeature 用于适配垂类面板拉起 + "linkFeature": 'ComposeMail' + } + ] + } + ], + // [StartExclude mailto_config] + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + // [EndExclude mailto_config] + }, + // [StartExclude mailto_config] + // [EndExclude finance_config] + { + // [StartExclude finance_config] + "name": "FinanceAbility", + "srcEntry": "./ets/entryability/FinanceAbility.ets", + "description": "$string:FinanceAbility_desc", + "icon": "$media:layered_image", + "label": "$string:FinanceAbility_label", + "exported": true, + // [EndExclude finance_config] + "skills": [ + { + "actions": ["ohos.want.action.viewData"], + "uris": [ + { + "scheme": "finance", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "transfer", + "path": "", + "linkFeature": "Transfer" // 声明应用支持转账汇款功能 + }, + { + "scheme": "finance", // 这里仅示意,应用需确保这里声明的uri能被外部正常拉起 + "host": "credit_card_repayment", + "path": "", + "linkFeature": "CreditCardRepayment" // 声明应用支持信用卡还款功能 + } + ] + } + ], + // [StartExclude finance_config] + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + // [EndExclude finance_config] + }, + // [StartExclude finance_config] + // [EndExclude flight_config] + { + // [StartExclude flight_config] + "name": "FlightAbility", + "srcEntry": "./ets/entryability/FlightAbility.ets", + "description": "$string:FlightAbility_desc", + "icon": "$media:layered_image", + "label": "$string:FlightAbility_label", + "exported": true, + // [EndExclude flight_config] + "skills": [ + { + "actions": ["ohos.want.action.viewData"], + "uris": [ + { + "scheme": "flight", + "host": "queryByFlightNo", + "path": "", + "linkFeature": "QueryByFlightNo" + }, + { + "scheme": "flight", + "host": "queryByLocation", + "path": "", + "linkFeature": "QueryByLocation" + } + ] + } + ], + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + // [EndExclude express_config] + // [StartExclude flight_config] + { + // [StartExclude express_config] + "name": "ExpressAbility", + "srcEntry": "./ets/entryability/ExpressAbility.ets", + "description": "$string:ExpressAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ExpressAbility_label", + "exported": true, + // [EndExclude express_config] + "skills": [ + { + "actions": ["ohos.want.action.viewData"], + "uris": [ + { + "scheme": "express", + "host": "queryExpress", + "path": "", + "linkFeature": "QueryExpress" + } + ] + } + ], + // [StartExclude express_config] + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + // [EndExclude express_config] + }, + // [StartExclude express_config] + { + "name": "FileCallerAbility", + "srcEntry": "./ets/entryability/FileCallerAbility.ets", + "description": "$string:FileAbility_desc", + "icon": "$media:layered_image", + "label": "$string:FileAbility_label", + "exported": true, + "skills": [ + { + "entities": ["entity.system.home"], + "actions": ["ohos.want.action.home"] + } + ], + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + // [EndExclude file_config] + { + // [StartExclude file_config] + "name": "FileHandlerAbility", + "srcEntry": "./ets/entryability/FileHandlerAbility.ets", + "description": "$string:FileAbility_desc", + "icon": "$media:layered_image", + "label": "$string:FileAbility_label", + "exported": true, + // [EndExclude file_config] + "skills": [ + // [StartExclude file_config] + { + "entities": ["entity.system.home"], + "actions": ["ohos.want.action.home"] + }, + // [EndExclude file_config] + { + "actions": [ + "ohos.want.action.viewData" // 必填,声明数据处理能力 + ], + "uris": [ + { + // 允许打开uri中以file://协议开头标识的本地文件 + "scheme": "file", // 必填,声明协议类型为文件 + "type": "general.plain-text", // 必填,表示支持打开的文件类型 + "linkFeature": "FileOpen" // 必填且大小写敏感, 表示此URI的功能为文件打开 + } + ], + } + ], + // [StartExclude file_config] + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + // [EndExclude file_config] + } + // [EndExclude mailto_config] + // [EndExclude express_config] + // [EndExclude finance_config] + // [EndExclude flight_config] + // [EndExclude mail_config] + // [EndExclude navitation_config] + ], + // [StartExclude file_config] + // [EndExclude photo_config] + // [StartExclude mailto_config] + // [StartExclude express_config] + // [StartExclude finance_config] + // [StartExclude flight_config] + // [StartExclude mail_config] + // [StartExclude navitation_config] + "extensionAbilities": [ + { + "name": "ExamplePhotoEditorAbility", + "icon": "$media:layered_image", + "description": "ExamplePhotoEditorAbility", + "type": "photoEditor", + "exported": true, + "srcEntry": "./ets/entryability/PhotoEditorAbility.ets", + "label": "$string:photo_label", + "extensionProcessMode": "bundle" + } + ], + // [EndExclude file_config] + // [EndExclude mailto_config] + // [EndExclude express_config] + // [EndExclude finance_config] + // [EndExclude flight_config] + // [EndExclude mail_config] + // [EndExclude navitation_config] + } +} +// [End file_config] +// [End photo_config] +// [End mailto_config] +// [End express_config] +// [End finance_config] +// [End flight_config] +// [End mail_config] +// [End navitation_config] \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/element/color.json b/AbilityKit/StartAbility/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/main/resources/base/element/float.json b/AbilityKit/StartAbility/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/element/string.json b/AbilityKit/StartAbility/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..37fd173fb91e76b03e8a145d5150a59c8cbabf61 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/resources/base/element/string.json @@ -0,0 +1,104 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartAbility" + }, + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "StartAbility" + }, + { + "name": "Navigation_label", + "value": "导航功能" + }, + { + "name": "Mail_label", + "value": "邮件功能" + }, + { + "name": "MailtoAbility_desc", + "value": "Mailto功能" + }, + { + "name": "MailtoAbility_label", + "value": "Mailto邮件功能" + }, + { + "name": "FinanceAbility_desc", + "value": "金融功能" + }, + { + "name": "FinanceAbility_label", + "value": "金融功能" + }, + { + "name": "FlightAbility_desc", + "value": "航班功能" + }, + { + "name": "FlightAbility_label", + "value": "航班功能" + }, + { + "name": "ExpressAbility_desc", + "value": "快递功能" + }, + { + "name": "ExpressAbility_label", + "value": "快递功能" + }, + { + "name": "FileAbility_desc", + "value": "文件功能" + }, + { + "name": "FileAbility_label", + "value": "文件功能" + }, + { + "name": "photo_label", + "value": "图像编辑" + }, + { + "name": "FileOpenAbility_desc", + "value": "FileOpenAbility" + }, + { + "name": "FileOpenAbility_label", + "value": "FileOpenAbility_label" + }, + { + "name": "OpenType_label", + "value": "打开方式" + }, + { + "name": "Choice_label", + "value": "选择应用" + }, + { + "name": "other_apps", + "value": "其他应用" + }, + { + "name": "feedback", + "value": "反馈" + }, + { + "name": "select_img", + "value": "selectImg" + }, + { + "name": "edit_img", + "value": "editImg" + } + ] +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/media/background.png b/AbilityKit/StartAbility/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AbilityKit/StartAbility/entry/src/main/resources/base/media/background.png differ diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/media/foreground.png b/AbilityKit/StartAbility/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AbilityKit/StartAbility/entry/src/main/resources/base/media/foreground.png differ diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/media/layered_image.json b/AbilityKit/StartAbility/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/main/resources/base/media/startIcon.png b/AbilityKit/StartAbility/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/AbilityKit/StartAbility/entry/src/main/resources/base/media/startIcon.png differ diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/profile/backup_config.json b/AbilityKit/StartAbility/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/main/resources/base/profile/main_pages.json b/AbilityKit/StartAbility/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..f60de712be246c8bb5fd8dc3e649f2dce3e68761 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,22 @@ +{ + "src": [ + "pages/Index", + "pages/NavigationIndex", + "pages/MailIndex", + "pages/RoutePlanPage", + "pages/PlaceSearchPage", + "pages/ComposeMailPage", + "pages/FinanceIndex", + "pages/MailtoIndex", + "pages/CreditCardRepaymentPage", + "pages/TransferPage", + "pages/QueryByFlightNoPage", + "pages/QueryByLocationPage", + "pages/QueryExpressPage", + "pages/FlightIndex", + "pages/ExpressIndex", + "pages/FileIndex", + "pages/PhotoIndex", + "pages/PhotoEditorIndex" + ] +} diff --git a/AbilityKit/StartAbility/entry/src/main/resources/dark/element/color.json b/AbilityKit/StartAbility/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/mock/mock-config.json5 b/AbilityKit/StartAbility/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a99e1d70a555e9935e93519642bb8d05bcb5a149 --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/Ability.test.ets b/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f56eefdf4489d9ef42fc47f945e3ff6e2ca55d9 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,506 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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, it, expect, beforeAll, afterAll, TestType, Size, Level } from '@ohos/hypium'; +import { Driver, ON, Component, MatchPattern } from '@ohos.UiTest'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import Want from '@ohos.app.ability.Want'; +import hilog from '@ohos.hilog'; + +class Logger { + private domain: number = 0xFF00; + private prefix: string = '[Sample_StartAbility]'; + private format: string = '%{public}s'; + + debug(tag: string, message: string): void { + hilog.debug(this.domain, this.prefix, this.format, `${tag}: ${message}`); + } + + info(tag: string, message: string): void { + hilog.info(this.domain, this.prefix, this.format, `${tag}: ${message}`); + } + + warn(tag: string, message: string): void { + hilog.warn(this.domain, this.prefix, this.format, `${tag}: ${message}`); + } + + error(tag: string, message: string): void { + hilog.error(this.domain, this.prefix, this.format, `${tag}: ${message}`); + } +} + +const logger = new Logger(); + +const BUNDLE_NAME: string = 'com.samples.startability'; +const ABILITY_NAME: string = 'StartAbilityEntry'; + +// define delay time interface +interface DelayTimes { + SHORT: number; + MEDIUM: number; + LONG: number; + PAGE_LOAD: number; + PANEL_WAIT: number; + INIT: number; +} + +// define delay time constants (unit: milliseconds) +const DELAY: DelayTimes = { + SHORT: 500, // short delay + MEDIUM: 1000, // medium delay + LONG: 2000, // long delay + PAGE_LOAD: 3000, // page load delay + PANEL_WAIT: 3000, // panel wait delay + INIT: 1000, // initialization delay +}; + +async function findComponentByContains(driver: Driver, text: string): Promise { + try { + return await driver.findComponent(ON.text(text, MatchPattern.CONTAINS)); + } catch (error) { + return null; + } +} + +// Helper function to get string from resource +async function getStringFromResource(resource: Resource): Promise { + try { + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const manager = abilityDelegator.getAppContext().resourceManager; + return await manager.getStringValue(resource); + } catch (error) { + logger.error('getStringFromResource', `Failed to get string from resource: ${JSON.stringify(error)}`); + return ''; + } +} + +export default function abilityTest() { + describe('abilityTest', () => { + let driver: Driver; + + beforeAll(async () => { + driver = Driver.create(); + await driver.delayMs(DELAY.INIT); + + logger.info('TestSetup', 'start APP...'); + try { + const abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + const want: Want = { + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME + }; + await abilityDelegator.startAbility(want); + logger.info('TestSetup', 'start app success'); + } catch (error) { + logger.warn('TestSetup', 'app is running'); + } + + await driver.delayMs(DELAY.PAGE_LOAD); + }); + + afterAll(async () => { + await driver.delayMs(DELAY.MEDIUM); + logger.info('TestCleanup', 'Test is over'); + }); + + /** + * @tc.number : test_application_launch + * @tc.name : test_application_launch + * @tc.desc : test app launch + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_application_launch', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_application_launch', 'Verify application startup'); + + const mainButton = await driver.findComponent(ON.text('Navigation')); + expect(mainButton != null).assertTrue(); + logger.info('test_application_launch', 'Application startup verification passed.'); + + done(); + }); + + /** + * @tc.number : test_all_buttons_exist + * @tc.name : test_all_buttons_exist + * @tc.desc : Test whether all buttons exist. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_all_buttons_exist', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_all_buttons_exist', 'Check all buttons'); + + const buttonTexts: string[] = [ + 'Navigation', 'Email', 'Finance', 'Emailto', + 'Flight', 'Express', 'File', 'PhotoEdit' + ]; + + for (const buttonText of buttonTexts) { + const button = await driver.findComponent(ON.text(buttonText)); + expect(button != null).assertTrue(); + logger.info('ButtonsCheck', `Locate the button: ${buttonText}`); + } + + logger.info('test_all_buttons_exist', 'All buttons have been checked.'); + done(); + }); + + /** + * @tc.number : test_navigation_function + * @tc.name : test_all_buttons_exist + * @tc.desc : Test whether all buttons exist. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_navigation_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_navigation_function', 'Test the navigation function'); + + const navButton = await driver.findComponent(ON.text('Navigation')); + expect(navButton != null).assertTrue(); + await navButton.click(); + await driver.delayMs(DELAY.LONG); + + // check hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // check application selection panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const navigationText = await getStringFromResource($r('app.string.Navigation_label')); + + const panel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, 'Just once') || + await findComponentByContains(driver, navigationText); + expect(panel != null).assertTrue(); + logger.info('test_navigation_function', 'Application selection panel called successfully.'); + + // return back to main page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_navigation_function', 'Navigation function test completed.'); + done(); + }); + + /** + * @tc.number : test_mail_function + * @tc.name : test_mail_function + * @tc.desc : Test whether the mail function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_mail_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_mail_function', 'Test the mail function.'); + + const mailButton = await driver.findComponent(ON.text('Email')); + expect(mailButton != null).assertTrue(); + await mailButton.click(); + await driver.delayMs(DELAY.LONG); + + // check hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // check application selection panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const mailText = await getStringFromResource($r('app.string.Mail_label')); + const otherAppsText = await getStringFromResource($r('app.string.other_apps')); + + const hasPanel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, mailText) || + await findComponentByContains(driver, otherAppsText); + expect(hasPanel != null).assertTrue(); + logger.info('test_mail_function', 'Mail function panel called successfully.'); + + // return + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_mail_function', 'Mail function test completed.'); + done(); + }); + + /** + * @tc.number : test_finance_function + * @tc.name : test_finance_function + * @tc.desc : Test whether the finance function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_finance_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_finance_function', 'Test the finance function.'); + + const financeButton = await driver.findComponent(ON.text('Finance')); + expect(financeButton != null).assertTrue(); + await financeButton.click(); + await driver.delayMs(DELAY.LONG); + + // check hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // check application selection panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const financeText = await getStringFromResource($r('app.string.FinanceAbility_label')); + const otherAppsText = await getStringFromResource($r('app.string.other_apps')); + + const hasPanel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, financeText) || + await findComponentByContains(driver, otherAppsText); + expect(hasPanel != null).assertTrue(); + logger.info('test_finance_function', 'Finance function panel called successfully.'); + + // return + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_finance_function', 'Finance function test completed.'); + done(); + }); + + /** + * @tc.number : test_mailto_function + * @tc.name : test_mailto_function + * @tc.desc : Test whether the mailto function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_mailto_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_mailto_function', 'Test the mailto function.'); + + const mailtoButton = await driver.findComponent(ON.text('Emailto')); + expect(mailtoButton != null).assertTrue(); + await mailtoButton.click(); + await driver.delayMs(DELAY.LONG); + + const feedbackButton = await driver.findComponent(ON.text('feedback')); + expect(feedbackButton != null).assertTrue(); + if (feedbackButton != null) { + logger.info('test_mailto_function', 'Feedback button found, directly return to the home page.'); + // return to the home page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + } else { + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + if (hideAbilityText != null) { + logger.warn('test_mailto_function', 'Mailto function is not the expected behavior.'); + await hideAbilityText.click(); + await driver.delayMs(DELAY.LONG); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + } + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + } + + logger.info('test_mailto_function', 'Mailto function test completed.'); + done(); + }); + + /** + * @tc.number : test_flight_function + * @tc.name : test_flight_function + * @tc.desc : Test whether the flight function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_flight_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_flight_function', 'Test the flight function.'); + + const flightButton = await driver.findComponent(ON.text('Flight')); + expect(flightButton != null).assertTrue(); + await flightButton.click(); + await driver.delayMs(DELAY.LONG); + + // locate hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // locate flight function panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const flightText = await getStringFromResource($r('app.string.FlightAbility_label')); + const otherAppsText = await getStringFromResource($r('app.string.other_apps')); + + const hasPanel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, flightText) || + await findComponentByContains(driver, otherAppsText); + expect(hasPanel != null).assertTrue(); + logger.info('test_flight_function', 'Flight function panel call success.'); + + // return to the main page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_flight_function', 'Flight function test completed.'); + done(); + }); + + /** + * @tc.number : test_express_function + * @tc.name : test_express_function + * @tc.desc : Test whether the express function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_express_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_express_function', 'Test the express function.'); + + const expressButton = await driver.findComponent(ON.text('Express')); + expect(expressButton != null).assertTrue(); + await expressButton.click(); + await driver.delayMs(DELAY.LONG); + + // locate hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // locate express function panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const expressText = await getStringFromResource($r('app.string.ExpressAbility_label')); + const otherAppsText = await getStringFromResource($r('app.string.other_apps')); + + const hasPanel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, expressText) || + await findComponentByContains(driver, otherAppsText); + expect(hasPanel != null).assertTrue(); + logger.info('test_express_function', 'Express function panel call success.'); + + // return to the main page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_express_function', 'Express function test completed.'); + done(); + }); + + /** + * @tc.number : test_file_function + * @tc.name : test_file_function + * @tc.desc : Test whether the file function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_file_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_file_function', 'Test the file function.'); + + const fileButton = await driver.findComponent(ON.text('File')); + expect(fileButton != null).assertTrue(); + await fileButton.click(); + await driver.delayMs(DELAY.LONG); + + // locate hideAbility text + const hideAbilityText = await driver.findComponent(ON.text('hideAbility')); + expect(hideAbilityText != null).assertTrue(); + await hideAbilityText.click(); + await driver.delayMs(DELAY.PANEL_WAIT); + + // locate file function panel + const openWithText = await getStringFromResource($r('app.string.OpenType_label')); + const choiceText = await getStringFromResource($r('app.string.Choice_label')); + const fileText = await getStringFromResource($r('app.string.FileAbility_label')); + const otherAppsText = await getStringFromResource($r('app.string.other_apps')); + + const hasPanel = await findComponentByContains(driver, openWithText) || + await findComponentByContains(driver, choiceText) || + await findComponentByContains(driver, fileText) || + await findComponentByContains(driver, otherAppsText); + expect(hasPanel != null).assertTrue(); + logger.info('test_file_function', 'File function panel call success.'); + + // return to the main page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_file_function', 'File function test completed.'); + done(); + }); + + /** + * @tc.number : test_photo_editor_function + * @tc.name : test_photo_editor_function + * @tc.desc : Test whether the photo editor function works. + * @tc.level : Level0 + * @tc.size : SmallTest + * @tc.type : Function + */ + it('test_photo_editor_function', TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, async (done: Function) => { + logger.info('test_photo_editor_function', 'Test the photo editor function'); + + const photoButton = await driver.findComponent(ON.text('PhotoEdit')); + expect(photoButton != null).assertTrue(); + await photoButton.click(); + await driver.delayMs(DELAY.LONG); + + // locate selectimg and editimg button + const selectImgText = await getStringFromResource($r('app.string.select_img')); + const editImgText = await getStringFromResource($r('app.string.edit_img')); + + const selectImgButton = await driver.findComponent(ON.text(selectImgText)); + const editImgButton = await driver.findComponent(ON.text(editImgText)); + + expect(selectImgButton != null).assertTrue(); + expect(editImgButton != null).assertTrue(); + logger.info('PhotoEditorTest', 'locate selectimg and editimg button successfully'); + + // return to the main page + await driver.pressBack(); + await driver.delayMs(DELAY.MEDIUM); + + logger.info('test_photo_editor_function', 'Photo editor function test completed.'); + done(); + }); + }); +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/List.test.ets b/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc447d595a7f1e27328cb4787eb5bdf071c3e580 --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/entry/src/ohosTest/module.json5 b/AbilityKit/StartAbility/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0c0beea0acae551d38f8531d5ef830c9038997bd --- /dev/null +++ b/AbilityKit/StartAbility/entry/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + ], + "deliveryWithInstall": true, + "installationFree": false, + } +} diff --git a/AbilityKit/StartAbility/entry/src/test/List.test.ets b/AbilityKit/StartAbility/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/entry/src/test/LocalUnit.test.ets b/AbilityKit/StartAbility/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/AbilityKit/StartAbility/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/AbilityKit/StartAbility/hvigor/hvigor-config.json5 b/AbilityKit/StartAbility/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b8fea3f097bd68b0bc4d87de986d2cb7732c1d9b --- /dev/null +++ b/AbilityKit/StartAbility/hvigor/hvigor-config.json5 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | 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 */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "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/AbilityKit/StartAbility/hvigorfile.ts b/AbilityKit/StartAbility/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f64721585467916e1c062ee76e85fd4f74ff6cfb --- /dev/null +++ b/AbilityKit/StartAbility/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. */ +} \ No newline at end of file diff --git a/AbilityKit/StartAbility/oh-package.json5 b/AbilityKit/StartAbility/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..296ae7efeb12adf30dcbe27bfb80a9d264bd67ff --- /dev/null +++ b/AbilityKit/StartAbility/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": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.24", + "@ohos/hamock": "1.0.0" + } +} diff --git a/AbilityKit/StartAbility/screenshots/email.png b/AbilityKit/StartAbility/screenshots/email.png new file mode 100644 index 0000000000000000000000000000000000000000..28da53e3f25da1818c7b00bf688883b141892321 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/email.png differ diff --git a/AbilityKit/StartAbility/screenshots/emailto.png b/AbilityKit/StartAbility/screenshots/emailto.png new file mode 100644 index 0000000000000000000000000000000000000000..d57d5972fbdd365040618d22d7c67d27b7a85968 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/emailto.png differ diff --git a/AbilityKit/StartAbility/screenshots/express.png b/AbilityKit/StartAbility/screenshots/express.png new file mode 100644 index 0000000000000000000000000000000000000000..eeb6aec358bc5768c3ad28f70f58a48f9f025d14 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/express.png differ diff --git a/AbilityKit/StartAbility/screenshots/file.png b/AbilityKit/StartAbility/screenshots/file.png new file mode 100644 index 0000000000000000000000000000000000000000..b731c2c0c647cbfe47ebea931e2bccc14cb909a3 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/file.png differ diff --git a/AbilityKit/StartAbility/screenshots/finance.png b/AbilityKit/StartAbility/screenshots/finance.png new file mode 100644 index 0000000000000000000000000000000000000000..fbee3fd9358ac4a3b3be580c4f789a1418f1e19a Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/finance.png differ diff --git a/AbilityKit/StartAbility/screenshots/flight.png b/AbilityKit/StartAbility/screenshots/flight.png new file mode 100644 index 0000000000000000000000000000000000000000..b97fc73a01bfc33f13fa81abfd7cef2d6f716e0c Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/flight.png differ diff --git a/AbilityKit/StartAbility/screenshots/navigation.png b/AbilityKit/StartAbility/screenshots/navigation.png new file mode 100644 index 0000000000000000000000000000000000000000..f8788273c53bf1822d8e654b5833f6a137aa04c4 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/navigation.png differ diff --git a/AbilityKit/StartAbility/screenshots/photoEdit.png b/AbilityKit/StartAbility/screenshots/photoEdit.png new file mode 100644 index 0000000000000000000000000000000000000000..a193cfe05b308445320701ee6ac695d79c71ad07 Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/photoEdit.png differ diff --git a/AbilityKit/StartAbility/screenshots/welcome.png b/AbilityKit/StartAbility/screenshots/welcome.png new file mode 100644 index 0000000000000000000000000000000000000000..13508f93006eae3777a56156ef743d8a2a58a7cb Binary files /dev/null and b/AbilityKit/StartAbility/screenshots/welcome.png differ