diff --git a/OAT.xml b/OAT.xml index 2b4d5172eb49860fad4b14adbb8191d232159f7c..00823cbb19069888bca94342a2f5cb785651c7a6 100644 --- a/OAT.xml +++ b/OAT.xml @@ -190,6 +190,25 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + + + + + + + + + + @@ -2195,6 +2214,16 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + + + + diff --git a/code/ArkTS1.2/CustomanimationtabSample/.gitignore b/code/ArkTS1.2/CustomanimationtabSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/AppScope/app.json5 b/code/ArkTS1.2/CustomanimationtabSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad6d2270c3a00cb572e22e212a26a2c53c27eb7a --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/AppScope/app.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "bundleName": "com.samples.CustomanimationtabSample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/element/string.json b/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e3dcb530174a0ba98b973cf2157e77d4344bd2be --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CustomanimationtabSample" + } + ] +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/media/app_icon.png b/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/ArkTS1.2/CustomanimationtabSample/AppScope/resources/base/media/app_icon.png differ diff --git a/code/ArkTS1.2/CustomanimationtabSample/README.md b/code/ArkTS1.2/CustomanimationtabSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7c4477ab088f47fc714a364f6d8faea705f6c718 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/README.md @@ -0,0 +1,65 @@ +# 自定义动效tab实现案例 + +### 介绍 + +本示例介绍使用List、Text等组件,以及animateTo等接口实现自定义Tab效果。 + +### 效果预览 + +效果如下所示: + +| 主界面 | +|-------------------------------------------------------------| +| ![Alt text](entry/src/main/resources/base/media/tbas.png) | + +使用说明 + +1. 在主界面,左右滑动页签条。 + * 向左右滑动,背景条随之滚动。 +2. 在主界面,左右滑动内容区域。 + * 向左右滑动,背景条随之滚动。 +3. 在主界面,点击蓝色按钮"修改背景条颜色"。 + * 背景条颜色进行切换。 + + +### 工程目录 + +``` +entry/src/main/ets/ +|---pages +| |---SkeletonLayout.ets // 内容区域组件定义 +| |---index.ets // 首页 +``` + +### 具体实现 + +* 选中页签,字体放大加粗且后面有背景条,起到强调作用。 +* 手势触摸tab内容滑动,背景条跟随手势一起滑动。 +* 点击页签,可以进行页签切换。 +* 滑动页签条,背景条也会随之一起滑动,然后滑动tab内容,页签条会滑动到原处,使背景条处于可视范围内,之后背景条开始跟随手势滑动。 + +### 相关权限 + +无 + +### 依赖 + +无 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:Phone; +2. 本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0.0.31)。 +3. 本示例需要使用DevEco Studio 版本号(6.0.0.6)版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/ArkTS1.2/CustomanimationtabSample/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull +``` \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/build-profile.json5 b/code/ArkTS1.2/CustomanimationtabSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c83260a8d4a7c41693901753e0c0ea562824569c --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/build-profile.json5 @@ -0,0 +1,68 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "arkTSVersion": "1.2", + "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/code/ArkTS1.2/CustomanimationtabSample/code-linter.json5 b/code/ArkTS1.2/CustomanimationtabSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..87b3919d419c09728067f1b545b7e2d5116adc07 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/code-linter.json5 @@ -0,0 +1,58 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/.gitignore b/code/ArkTS1.2/CustomanimationtabSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/build-profile.json5 b/code/ArkTS1.2/CustomanimationtabSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36f9e65afb2abbbbdda625e86543807eee16240c --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/hvigorfile.ts b/code/ArkTS1.2/CustomanimationtabSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f830cdfd5bfdd8bde92ebfc27fc0562423dca3d --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/obfuscation-rules.txt b/code/ArkTS1.2/CustomanimationtabSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/oh-package.json5 b/code/ArkTS1.2/CustomanimationtabSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..39ab3f901494a87d5ab258dfaa9e6882de1f5166 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/oh-package.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d205c00999b495e390eb8582f3dec20cc547d5fc --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base' +import hilog from '@ohos.hilog' + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onWindowStageCreate'); + try { + windowStage.loadContent('pages/Index', (err: BusinessError): void => { + hilog.info(0x0000, 'testTag', 'loadContent entering'); + if (err.code) { + hilog.info(0x0000, 'testTag', 'loadContent error'); + return; + } + hilog.info(0x0000, 'testTag', 'loadContent ok'); + }); + } catch (e: Error) { + hilog.info(0x0000, 'testTag', 'loadContent catch error:-----------' + e.message); + } + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/Index.ets b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a89d248edf30337a6431950fa2cbd108f8e55883 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,187 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { + Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Builder, + SwiperController, Swiper, TextAlign, ForEach, Color, Margin, Scroll, Scroller, ScrollDirection, EdgeEffect, List, + ListItem, FontWeight, ImageFit, ListItemAlign, Axis, BarState, Stack, Alignment, Row, Image, $r, VerticalAlign, Resource, + ResourceColor, FlexAlign, SizeOptions, Area, Curve, PlayMode, SwiperAnimationEvent, ScrollState, ScrollOptions, ScrollSource, + ScrollOnWillScrollCallback, OffsetResult, ScrollOnScrollCallback +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy } from '@ohos.arkui.stateManagement'; +import { UIContext } from '@ohos.arkui.UIContext'; +import { SkeletonLayout } from './SkeletonLayout'; +import common from '@ohos.app.ability.common'; +import hilog from '@ohos.hilog'; + +@Component +struct MyStateSample { + @State indicatorBarColor: ResourceColor = '#C0C0C0'; + @State tabIndex: number = 0; + @State backgroundBarDisplacement: number = 0; + @State barMargin: number = 0; + @State tabs: Array = new Array(); + private swiperController: SwiperController = new SwiperController(); + private scroller: Scroller = new Scroller(); + private data: Array = new Array(); + + aboutToAppear(): void { + for (let i = 0; i < 8; i++) { + this.data.push(`${i}`); + } + this.tabs = ['全部', 'UI布局', '动效', '三方库', '其他']; + } + + build() { + Column() { + Column(){ + Stack({ alignContent: Alignment.Start }) { + Row() { + Column() { + Column() + .height('100%') + .width('100%') + .backgroundColor(this.indicatorBarColor) + .borderRadius(20) + } + .height(60) + .width(90) + .margin({ left: this.backgroundBarDisplacement } as Margin) + .animation({ + duration: 130, + curve: Curve.Linear + }) + } + .alignItems(VerticalAlign.Center) + .clip(true) + .height('100%') + .width('100%') + + // 页签条 + Scroll(this.scroller) { + Row(){ + ForEach(this.tabs, (item: string, index: number) => { + Column() { + Image($r('app.media.return_home_fill')) + .height(20) + .width(20) + .objectFit(ImageFit.Contain) + Text(item) + .fontSize(index === this.tabIndex ? $r('app.float.custom_animation_tab_list_select_font_size') : $r('app.float.custom_animation_tab_list_unselect_font_size')) + .fontColor('#000000') + .fontWeight(index === this.tabIndex ? FontWeight.Bold : FontWeight.Medium) + .textAlign(TextAlign.Center) + } + .id(String(index)) + .height('100%') + .width(95) + .onClick(():void=>{ + this.backgroundBarDisplacement = this.backgroundBarDisplacement + (index - this.tabIndex) * 95; + this.tabIndex = index; + if(this.tabIndex === 3){ + this.scroller.scrollTo({xOffset: 90, yOffset: 0}); + } else if(this.tabIndex === 1) { + this.scroller.scrollTo({xOffset: -90, yOffset: 0}); + } + }) + }) + } + } + .margin({top: 10} as Margin) + .scrollable(ScrollDirection.Horizontal) + .scrollBar(BarState.Off) + .onDidScroll((xOffset: number, yOffset: number, scrollState: ScrollState): void => { + this.backgroundBarDisplacement += -xOffset; + } as ScrollOnScrollCallback) + }.height(60) + Swiper() { + ForEach(this.tabs, (item: string, index: number) => { + Column(){ + Text(item).fontSize(20) + List() { + ForEach(this.data, (data: string, index: number) => { + ListItem() { + SkeletonLayout({ isMine: false }) + } + }) + } + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .height($r('app.string.custom_animation_tab_one_hundred_percent')) + }.width($r('app.string.custom_animation_tab_one_hundred_percent')) + .height($r('app.string.custom_animation_tab_one_hundred_percent')) + }) + } + .id('tabContent') + .loop(false) + .indicator(false) + .index(this.tabIndex) + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .height($r('app.string.custom_animation_tab_one_hundred_percent')) + .onChange((index: number):void => { + this.backgroundBarDisplacement = this.backgroundBarDisplacement + (index - this.tabIndex) * 95; + this.tabIndex = index; + if(this.tabIndex === 3){ + this.scroller.scrollTo({xOffset: 90, yOffset: 0}); + } else if(this.tabIndex === 1) { + this.scroller.scrollTo({xOffset: -90, yOffset: 0}); + } + }) + }.height('85%') + + // 更新自定义动效变量——背景条颜色 + Column() { + Button($r('app.string.custom_animation_tab_button_text')) + .height('40%') + .onClick(():void => { + if(this.indicatorBarColor == '#C0C0C0') { + this.indicatorBarColor = Color.Yellow; + } else { + this.indicatorBarColor = '#C0C0C0'; + } + }) + } + .justifyContent(FlexAlign.End) + .height('15%') + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + } + .width('100%') + .height('100%') + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @ + memo() => + { + hilog.info(0x0000, 'testTag', 'MyStateSample'); + MyStateSample(undefined) + } + return wrapper + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/SkeletonLayout.ets b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/SkeletonLayout.ets new file mode 100644 index 0000000000000000000000000000000000000000..25bd712b2497a4b1f53830d1920339b2b74da29d --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/ets/pages/SkeletonLayout.ets @@ -0,0 +1,121 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, + VerticalAlign, HorizontalAlign,FlexAlign, Color, Padding, Margin, Builder, Row, $r, Length +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy } from '@ohos.arkui.stateManagement'; + +@Component +export struct SkeletonLayout { + isMine: boolean = false; + + build() { + Row() { + Column() { + Column() { + // 标题 + textArea($r('app.float.custom_animation_tab_ske_card_title_height')) + + Text('').height(4) + + // 内容 + textArea($r('app.float.custom_animation_tab_ske_card_text_height')) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + // 判断是否自己作品来适配不同骨架布局 + if (!this.isMine) { + Row() { + // 浏览量 + actionArea() + // 点赞数 + actionArea() + // 收藏量 + actionArea() + } + .padding({ top: $r('app.float.custom_animation_tab_ske_md_padding_margin') } as Padding) + .height($r('app.float.custom_animation_tab_ske_row_height')) + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .justifyContent(FlexAlign.SpaceBetween) + } else { + Row() { + // 摄影作品标签 + Row() + .width($r('app.float.custom_animation_tab_ske_lg_topic_width')) + .height($r('app.float.custom_animation_tab_ske_topic_height')) + .backgroundColor($r('app.color.custom_animation_tab_skeleton_color_medium')) + .borderRadius($r('app.float.custom_animation_tab_ske_xs_border_radius')) + .margin({ bottom: 12 } as Margin) + // 自然风光标签 + Row() + .width($r('app.float.custom_animation_tab_ske_lg_topic_width')) + .height($r('app.float.custom_animation_tab_ske_topic_height')) + .backgroundColor($r('app.color.custom_animation_tab_skeleton_color_medium')) + .borderRadius($r('app.float.custom_animation_tab_ske_xs_border_radius')) + } + .padding({ top: $r('app.float.custom_animation_tab_ske_md_padding_margin') } as Padding) + .height($r('app.float.custom_animation_tab_ske_row_height')) + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .justifyContent(FlexAlign.Start) + } + } + .layoutWeight(1) + .height($r('app.string.custom_animation_tab_one_hundred_percent')) + Row() + .backgroundColor($r('app.color.custom_animation_tab_skeleton_color_light')) + .borderRadius($r('app.float.custom_animation_tab_ske_small_border_radius')) + .width($r('app.float.custom_animation_tab_ske_image_width')) + .height($r('app.float.custom_animation_tab_ske_image_height')) + .margin({ left: $r('app.float.custom_animation_tab_ske_md_padding_margin') } as Margin) + } + .padding($r('app.float.custom_animation_tab_ske_md_padding_margin')) + .borderRadius($r('app.float.custom_animation_tab_ske_large_border_radius')) + .backgroundColor(Color.White) + .alignItems(VerticalAlign.Top) + .justifyContent(FlexAlign.SpaceAround) + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .height($r('app.float.custom_animation_tab_ske_card_height')) + } +} + +@Builder +function actionArea() { + Row() + .width($r('app.float.custom_animation_tab_ske_action_area_width')) + .height($r('app.float.custom_animation_tab_ske_action_area_height')) + .backgroundColor($r('app.color.custom_animation_tab_skeleton_color_medium')) +} + +@Builder +function textArea(height: Length) { + Row() + .width($r('app.string.custom_animation_tab_one_hundred_percent')) + .height(height) + .backgroundColor($r('app.color.custom_animation_tab_skeleton_color_medium')) +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/module.json5 b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cca7656f5308dac3ecbf78c69f40fb1c89c8ec6a --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/module.json5 @@ -0,0 +1,69 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + }, + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/color.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3d3c3ec9596f348ac4907c46479e3e5d507f4e77 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,44 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "custom_animation_tab_indicator_color", + "value": "#C0C0C0" + }, + { + "name": "custom_animation_tab_menu_button_color", + "value": "#DCDCDC" + }, + { + "name": "custom_animation_tab_menu_button_inner_color", + "value": "#C0C0C0" + }, + { + "name": "custom_animation_tab_background_color", + "value": "#F5F5F5" + }, + { + "name": "custom_animation_tab_list_font_color", + "value": "#000000" + }, + { + "name": "custom_animation_tab_skeleton_color_medium", + "value": "#FFF2F3F4" + }, + { + "name": "custom_animation_tab_skeleton_color_light", + "value": "#FFECECEC" + }, + { + "name": "custom_animation_tab_title_background_color", + "value": "#FF4500" + }, + { + "name": "custom_animation_tab_search_background_color", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/float.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..57930e35e24d4e62c61300cd12a954ae543d4265 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,183 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + }, + { + "name": "custom_animation_tab_list_item_width", + "value": "100" + }, + { + "name": "custom_animation_tab_indicator_height", + "value": "40" + }, + { + "name": "custom_animation_tab_indicator_border_radius", + "value": "20" + }, + { + "name": "custom_animation_tab_inner_tabBar_height", + "value": "40" + }, + { + "name": "custom_animation_tab_menu_button_size", + "value": "40" + }, + { + "name": "custom_animation_tab_menu_button_inner_size", + "value": "30" + }, + { + "name": "custom_animation_tab_list_select_font_size", + "value": "18" + }, + { + "name": "custom_animation_tab_list_unselect_font_size", + "value": "17" + }, + { + "name": "custom_animation_tab_inner_tab_divider_width", + "value": "2px" + }, + { "name": "custom_animation_tab_ske_xs_font_size", + "value": "10fp" + }, + { + "name": "custom_animation_tab_ske_small_text_size", + "value": "12fp" + }, + { + "name": "custom_animation_tab_ske_normal_text_size", + "value": "14fp" + }, + { + "name": "custom_animation_tab_ske_failure_img_size", + "value": "120vp" + }, + { + "name": "custom_animation_tab_ske_reload_btn_height", + "value": "32vp" + }, + { + "name": "custom_animation_tab_ske_reload_btn_width", + "value": "80vp" + }, + { + "name": "custom_animation_tab_ske_large_border_radius", + "value": "8vp" + }, + { + "name": "custom_animation_tab_ske_small_border_radius", + "value": "8vp" + }, + { + "name": "custom_animation_tab_ske_xs_border_radius", + "value": "4vp" + }, + { + "name": "custom_animation_tab_ske_lg_topic_width", + "value": "58vp" + }, + { + "name": "custom_animation_tab_ske_topic_height", + "value": "16vp" + }, + { + "name": "custom_animation_tab_ske_action_area_width", + "value": "58vp" + }, + { + "name": "custom_animation_tab_ske_action_area_height", + "value": "20vp" + }, + { + "name": "custom_animation_tab_ske_card_height", + "value": "102vp" + }, + { + "name": "custom_animation_tab_ske_card_title_height", + "value": "20vp" + }, + { + "name": "custom_animation_tab_ske_card_text_height", + "value": "20vp" + }, + { + "name": "custom_animation_tab_ske_image_height", + "value": "80vp" + }, + { + "name": "custom_animation_tab_ske_image_width", + "value": "128vp" + }, + { + "name": "custom_animation_tab_ske_type_width", + "value": "28vp" + }, + { + "name": "custom_animation_tab_ske_type_height", + "value": "16vp" + }, + { + "name": "custom_animation_tab_ske_sm_margin", + "value": "5vp" + }, + { + "name": "custom_animation_tab_ske_topic_width", + "value": "132vp" + }, + { + "name": "custom_animation_tab_ske_xxl_padding_margin", + "value": "24vp" + }, + { + "name": "custom_animation_tab_ske_xl_padding_margin", + "value": "20vp" + }, + { + "name": "custom_animation_tab_ske_md_padding_margin", + "value": "12vp" + }, + { + "name": "custom_animation_tab_ske_sm_padding_margin", + "value": "8vp" + }, + { + "name": "custom_animation_tab_ske_xs_padding_margin", + "value": "4vp" + }, + { + "name": "custom_animation_tab_ske_xxs_padding_margin", + "value": "2vp" + }, + { + "name": "custom_animation_tab_ske_icon_size", + "value": "18vp" + }, + { + "name": "custom_animation_tab_ske_navigation_height", + "value": "56vp" + }, + { + "name": "custom_animation_tab_ske_none_view_image_size", + "value": "120vp" + }, + { + "name": "custom_animation_tab_ske_view_count_icon_width", + "value": "36vp" + }, + { + "name": "custom_animation_tab_ske_row_height", + "value": "40vp" + }, + { + "name": "custom_animation_tab_search_height", + "value": "120px" + }, + { + "name": "custom_animation_tab_ic_public_more", + "value": "18" + } + ] +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/integer.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..3b1936d6a96a00d707f9a14b4086f09e4b381961 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/integer.json @@ -0,0 +1,104 @@ +{ + "integer": [ + { + "name": "multiple_files_download_image_size_fifty", + "value": 50 + }, + { + "name": "multiple_files_download_image_size_twenty_five", + "value": 25 + }, + { + "name": "multiple_files_download_text_font_size_fourteen", + "value": 14 + }, + { + "name": "multiple_files_download_text_font_size_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_text_font_size_twenty_five", + "value": 25 + }, + { + "name": "multiple_files_download_text_font_size_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_padding_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_padding_fifteen", + "value": 15 + }, + { + "name": "multiple_files_download_margin_bottom_eighteen", + "value": 18 + }, + { + "name": "multiple_files_download_margin_bottom_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_margin_top_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_margin_top_seven", + "value": 7 + }, + { + "name": "multiple_files_download_margin_top_five", + "value": 5 + }, + { + "name": "multiple_files_download_progress_height", + "value": 5 + }, + { + "name": "multiple_files_download_border_width", + "value": 5 + }, + { + "name": "multiple_files_download_border_radius", + "value": 10 + }, + { + "name": "multiple_files_download_margin_top_thirty", + "value": 30 + }, + { + "name": "multiple_files_download_margin_left_four", + "value": 4 + }, + { + "name": "multiple_files_download_padding_zero", + "value": 0 + }, + { + "name": "multiple_files_download_padding_five", + "value": 5 + }, + { + "name": "multiple_files_download_height_twenty_six", + "value": 26 + }, + { + "name": "multiple_files_download_borderRadius_eight", + "value": 8 + }, + { + "name": "multiple_files_download_borderRadius_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_history_percentage_fifty", + "value": 50 + }, + { + "name": "multiple_files_download_margin_left_sixty", + "value": 60 + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/string.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6a12811250102026531021a76aa9302f1b8b38ff --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "CustomanimationtabSample" + }, + { + "name": "custom_animation_tab_one_hundred_percent", + "value": "100%" + }, + { + "name": "custom_animation_tab_ninety_percent", + "value": "90%" + }, + { + "name": "custom_animation_tab_ten_percent", + "value": "10%" + }, + { + "name": "custom_animation_tab_sixty_percent", + "value": "60%" + }, + { + "name": "custom_animation_tab_button_text", + "value": "修改背景条颜色" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/background.png b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/foreground.png b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/layered_image.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/return_home_fill.svg b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/return_home_fill.svg new file mode 100644 index 0000000000000000000000000000000000000000..529375de763bca415f5b7a536bb1e3c2b1ccef46 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/return_home_fill.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/startIcon.png b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/tbas.png b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/tbas.png new file mode 100644 index 0000000000000000000000000000000000000000..e5a4ee6572ef0c40711e6060cd8096b1fd9e651e Binary files /dev/null and b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/media/tbas.png differ diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/backup_config.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/main_pages.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/dark/element/color.json b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/CustomanimationtabSample/hvigor/hvigor-config.json5 b/code/ArkTS1.2/CustomanimationtabSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..57c58e3641a0b085f39f7f137b9a938ecb20f2fd --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/hvigor/hvigor-config.json5 @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "dependencies": { + "@ohos/hvigor-ohos-online-sign-plugin": "4.0.2" + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/hvigorfile.ts b/code/ArkTS1.2/CustomanimationtabSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f435606b5766719f7203539113d84a2b281b0353 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/oh-package.json5 b/code/ArkTS1.2/CustomanimationtabSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b6f7090658c0e69d5582af5d236fde4eab954ed6 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/oh-package.json5 @@ -0,0 +1,34 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/code/ArkTS1.2/CustomanimationtabSample/ohosTest.md b/code/ArkTS1.2/CustomanimationtabSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..8f2559e9817c726ea63f393d72afc1222f537522 --- /dev/null +++ b/code/ArkTS1.2/CustomanimationtabSample/ohosTest.md @@ -0,0 +1,10 @@ +# 主页Tabs嵌套场景测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|-----------------------------------|-------------------------------------|----------------------|------------------------------------|------|------| +| tab页签切换 | 1. 需在真机测试
2. 构建并安装测试hap
3.启动测试hap| 1、点击切换tab
2、点击修改背景条颜色 | 1、页面切换,tab字体放大加粗且后面有背景条,默认灰色
2、tab背景颜色变成黄色 | 否 | Pass | +| 页面滑动切换 | 1. 需在真机测试
2. 构建并安装测试hap
3.启动测试hap| 1、触摸tab内容滑动,距离不足一半
2、tab内容滑动距离大于一半 | 1、背景条自动回弹
2、背景条会移动到下一个页签,页面切换成功 | 否 | Pass | +| 页面滑动是否正常显示 | 1. 需在真机测试
2. 构建并安装测试hap
3.启动测试hap| 1、进入页面,滑动页面到底部
2、在页面底部时,滑动页面到顶部 | 1、可以滑动到底,无明显卡顿
2、可以滑动到顶,无明显卡顿| 否 | Pass | +| 发布或回复评论 | 1. 需在真机测试
2. 构建并安装测试hap
3.启动测试hap| 1、输入内容,点击发布按钮
2、点击"回复",评论内容,点击发布按钮 | 1、新增评论在评论顶最新一条出现
2、评论的文字成功显示 | 否 | Pass | \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/.gitignore b/code/ArkTS1.2/OperaterdbintaskpoolSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/app.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a9bfedd58f08f7fcea81b93effc1ba164c6766e6 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/app.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "bundleName": "com.samples.OperaterdbintaskpoolSample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/element/string.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ef65a53970986f55aba407105241b7b58a57d44d --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "OperaterdbintaskpoolSample" + } + ] +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/media/app_icon.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/AppScope/resources/base/media/app_icon.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/README.md b/code/ArkTS1.2/OperaterdbintaskpoolSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a8291df02d306e3daccb97a5821949d03d63dc0d --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/README.md @@ -0,0 +1,78 @@ +# TaskPool线程中操作关系型数据库实现案例 + +### 介绍 + +本示例通过通讯录场景实例进行讲解,介绍了在 TaskPool 线程中操作关系型数据库的方法。 + +### 效果预览 + +效果如下所示: + +| 主界面 |详情页|编辑新增页| +|--------------------------------------------------------------|--------------------------------|--------------------------------| +| ![Alt text](entry/src/main/resources/base/media/index.png) |![Alt text](entry/src/main/resources/base/media/index2.png)|![Alt text](entry/src/main/resources/base/media/index3.png) + + + +使用说明 + +1. 在主界面,点击列表数据。 + * 跳转详情页。 +2. 在详情页,点击编辑和删除按钮。 + * 点击编辑按钮跳转编辑页 + * 点击删除按钮跳转主界面,删除数据 +3. 在编辑页,修改数据后点击确定。 + * 跳转主界面,修改数据 +4. 在主界面,点击加号图标按钮跳转新增页。 + * 修改数据后点击确定跳转主界面,新增数据 + + +### 工程目录 + +``` +entry/src/main/ets/ +|---pages +| |---constant +| | |---CommonConstant.ets // 使用数据定义 +| | |---RdbConstant.ets // 数据库代码定义 +| |---model +| | |---Contact.ets // 数据类型定义 +| |---view +| | |---AddressBookDetail.ets // 详情页 +| | |---AddressBookEdit.ets // 编辑页 +| | |---AddressBookList.ets // 主界面列表组件 +| | |---DatabaseConnection.ets // 数据库接口定义 +| | |---OperateRDBInTaskPool.ets // 主界面 +| | |---TaskPool.ets // 多线程接口定义 +``` + +### 具体实现 + +* (TaskPool线程中操作关系型数据库) + * 创建任务池(taskpool)为数据库操作提供一个多线程的运行环境,将创建好的任务(新增、删除、修改、查询操作)放入taskpool内部任务队列,在子线程中实现数据库增删改查的任务,以此防止阻塞主线程。执行完成后,将结果回调至主线程,从而在主线程中更新数据源和用户界面。这样做不仅提升了应用的响应速度,还确保了用户交互的流畅性。 + +### 相关权限 + +无 + +### 依赖 + +无 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:Phone; +2. 本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0.0.31)。 +3. 本示例需要使用DevEco Studio 版本号(6.0.0.6)版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/ArkTS1.2/OperaterdbintaskpoolSample/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull +``` \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/build-profile.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c83260a8d4a7c41693901753e0c0ea562824569c --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/build-profile.json5 @@ -0,0 +1,68 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "arkTSVersion": "1.2", + "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/code/ArkTS1.2/OperaterdbintaskpoolSample/code-linter.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..87b3919d419c09728067f1b545b7e2d5116adc07 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/code-linter.json5 @@ -0,0 +1,58 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/.gitignore b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/build-profile.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36f9e65afb2abbbbdda625e86543807eee16240c --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/hvigorfile.ts b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f830cdfd5bfdd8bde92ebfc27fc0562423dca3d --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/obfuscation-rules.txt b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/oh-package.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..39ab3f901494a87d5ab258dfaa9e6882de1f5166 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/oh-package.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d205c00999b495e390eb8582f3dec20cc547d5fc --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base' +import hilog from '@ohos.hilog' + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onWindowStageCreate'); + try { + windowStage.loadContent('pages/Index', (err: BusinessError): void => { + hilog.info(0x0000, 'testTag', 'loadContent entering'); + if (err.code) { + hilog.info(0x0000, 'testTag', 'loadContent error'); + return; + } + hilog.info(0x0000, 'testTag', 'loadContent ok'); + }); + } catch (e: Error) { + hilog.info(0x0000, 'testTag', 'loadContent catch error:-----------' + e.message); + } + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/Index.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..31e8d47eecae60d352d05d21f7dc676c42908e34 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,69 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { + Entry, + Text, + TextAttribute, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView, + List, Image, $r, AlphabetIndexer, Margin, ForEach, Color, TextAlign, ImageFit +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy } from '@ohos.arkui.stateManagement'; +import hilog from '@ohos.hilog'; +import { BusinessError } from '@ohos.base'; +import { UIContext } from '@ohos.arkui.UIContext'; + +@Entry +@Component +struct MyStateSample { + build() { + Column() { + Button('126-TaskPool线程中操作关系型数据库实现案例') + .margin(20) + .onClick((): void => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/view/OperateRDBInTaskPool' }); + }) + }.width('100%') + .height('100%') + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo() =>{ + hilog.info(0x0000, 'testTag', 'MyStateSample'); + MyStateSample(undefined) + } + return wrapper + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/CommonConstant.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/CommonConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc0b5bd4090801a664713a95e36d0a315b185782 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/CommonConstant.ets @@ -0,0 +1,86 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Common constants for common component. + */ +export class CommonConstants { + // custom dialog + public static readonly CUSTOM_DIALOG_ICON_SIZE = 40; + // percent + public static readonly FULL_PERCENT: string = '100%'; + public static readonly HALF_PERCENT: string = '50%'; + // border radius + public static readonly BORDER_RADIUS_SLIGHT: number = 2; + public static readonly BORDER_RADIUS_SOFT: number = 14; + public static readonly BORDER_RADIUS_MODERATE: number = 15; + public static readonly BORDER_RADIUS_PROMINENT: number = 20; + public static readonly BORDER_RADIUS_FULLY: number = 50; + // border width + public static readonly BORDER_WIDTH_FINE: number = 1; + public static readonly BORDER_WIDTH_BOLD: number = 5; + // divider + public static readonly STROKE_WIDTH_LIST: number = 1; + public static readonly STROKE_WIDTH: number = 2; + public static readonly START_MARGIN: number = 12; + public static readonly END_MARGIN: number = 26; + // initial index + public static readonly INITIAL_INDEX: number = 0; + // navigation title width + public static readonly FOLD_NAVIGATION_TITLE_WIDTH: number = 204; + public static readonly UNFOLD_NAVIGATION_TITLE_WIDTH: number = 220; + // space + public static readonly COLUMN_SPACE: number = 10; + public static readonly LIST_SPACE: number = 12; + public static readonly SYNC_COLUMN_SPACE: number = 50; + // max length + public static readonly MAX_LENGTH_SHORT: number = 7; + public static readonly MAX_LENGTH_MODERATE: number = 12; + public static readonly MAX_LENGTH_LONG: number = 25; + public static readonly MAX_LENGTH_VERY_LONG: number = 100; + // list + public static readonly CACHE_COUNT: number = 5; + public static readonly LAYOUT_WEIGHT: number = 1; + // alphabetIndexer + public static readonly POPUP_X: number = 40; + public static readonly POPUP_Y: number = 250; + public static readonly POPUP_SELECTED_FONT_SIZE: number = 16; + public static readonly POPUP_FONT_SIZE: number = 30; + public static readonly POPUP_ITEM_SIZE: number = 20; + // add image + public static readonly Z_INDEX: number = 1; + public static readonly ADD_IMAGE_BOTTOM: number = 110; + public static readonly ADD_IMAGE_RIGHT: number = 40; + // prompt duration + public static readonly PROMPT_DURATION_TIME: number = 2000; + // search + public static readonly SEARCH_TEXT: string = '搜索'; + public static readonly SEARCH_TEXT_SIZE: number = 14; + public static readonly SEARCH_TEXT_WEIGHT: number = 400; + // progress + public static readonly PROGRESS_ORIGIN_VALUE: number = 0; + public static readonly PROGRESS_HEIGHT: number = 4; +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/RdbConstant.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/RdbConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0d510f9aa5e40dafacaa3182d76d28e1680f647 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/constant/RdbConstant.ets @@ -0,0 +1,41 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +import rdb from '@ohos.data.relationalStore'; + +export const TABLE_NAME = 'contact'; + +export const SQL_CREATE_TABLE = + 'CREATE TABLE IF NOT EXISTS contact(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, phone TEXT NOT NULL, email TEXT NOT NULL, address TEXT NOT NULL, avatar TEXT NOT NULL, category TEXT NOT NULL)'; + +export const COLUMNS = ['id', 'name', 'phone', 'email', 'address', 'avatar', 'category']; + +export const STORE_CONFIG: rdb.StoreConfig = { name: 'contact.db', securityLevel: rdb.SecurityLevel.S2 }; + +export const BUNDLE = 'com.north.cases'; + +export const ABILITY = 'EntryAbility'; \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/model/Contact.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/model/Contact.ets new file mode 100644 index 0000000000000000000000000000000000000000..a320367da6ebdf8062d968083a4346cb1946d349 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/model/Contact.ets @@ -0,0 +1,56 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * 单个通讯录所有字段信息 + */ +export class Contact { + public name: string; // 名字 + public phone: string; // 电话号码 + public email: string; // 邮箱 + public address: string; // 地址 + public avatar: string; // 头像 + public category: string; // 分类 + constructor(name: string = '', phone: string = '', email: string = '', address: string = '', + avatar: string = '', category: string = '') { + this.name = name; + this.phone = phone; + this.email = email; + this.address = address; + this.avatar = avatar; + this.category = category; + } +} + +export class RouterParams { + public text: string; + public data: Contact; + + constructor(str: string, data: Contact){ + this.text = str; + this.data = data; + } +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookDetail.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookDetail.ets new file mode 100644 index 0000000000000000000000000000000000000000..da40facd980a518f661b46ced5db65b2cf6e69d4 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookDetail.ets @@ -0,0 +1,287 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { Entry, Text, TextAttribute, Column, Component, Button, ClickEvent, UserView, Row, TextAlign, SafeAreaEdge, + List, ListItem, ForEach, TextOverflow, Image, HorizontalAlign, Progress, Flex ,FlexAlign, SafeAreaType, + Stack, Radio, Slider, $r, Builder, Blank, Color, ImageFit, + TextInput, InputType, Placement, ItemAlign, Divider, Margin, Padding, FontWeight +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement'; +import hilog from '@ohos.hilog'; +import common from '@ohos.app.ability.common'; +import { BusinessError } from '@ohos.base'; +import { UIContext } from '@ohos.arkui.UIContext'; +import { CommonConstants } from '../constant/CommonConstant'; +import { Contact, RouterParams } from '../model/Contact'; +import router from '@ohos.router'; + +@Entry +@Component +struct AddressBookDetail { + @State isChange: boolean = false; + @State sourceData: Contact = new Contact('艾德里安', '13333333333', 'aidelian@example.com', '江苏省南京市鼓楼区', + 'operate_rdb_in_taskpool_photo1.jpg', 'A'); + + aboutToAppear(): void { + setTimeout(()=>{ + if(this.getUIContext().getRouter().getParams()){ + this.sourceData = (this.getUIContext().getRouter().getParams() as RouterParams).data; + } + },1); + } + + @Builder + navDestinationTitle(name: string | undefined) { + Row() { + Column() { + Image($r('app.media.operate_rdb_in_taskpool_arrow_left')) + .width(28) + .height(28) + } + .justifyContent(FlexAlign.Center) + .width(40) + .height(40) + .borderRadius(CommonConstants.BORDER_RADIUS_PROMINENT) + .backgroundColor('#E5E7E9') + .onClick(():void => { + this.getUIContext().getRouter().back(); + }) + + Text(name) + .fontWeight(FontWeight.Bold) + .fontSize(20) + .width(100) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .margin({ left: 20 } as Margin) + } + .width(CommonConstants.FULL_PERCENT) + .height(56) + .backgroundColor(Color.White) + .margin({ bottom: 16 } as Margin) + } + + @Builder + phoneBuilder() { + Row() { + Column() { + Text(this.sourceData.phone) + .fontSize(19) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .width(CommonConstants.HALF_PERCENT) + .height(25) + + Text($r('app.string.operate_rdb_in_taskpool_detail_phone')) + .fontSize(15) + .fontColor('#A9A9A9') + .width(CommonConstants.HALF_PERCENT) + .height(25) + } + + Row(){ + Image($r('app.media.operate_rdb_in_taskpool_phone')) + .width(25) + .height(25) + + }.width(45) + .height(45) + .backgroundColor('#009e76') + .borderRadius(CommonConstants.BORDER_RADIUS_SOFT) + .justifyContent(FlexAlign.Center) + + Row(){ + Image($r('app.media.operate_rdb_in_taskpool_message')) + .width(25) + .height(25) + }.width(45) + .height(45) + .backgroundColor('#1b7af8') + .borderRadius(CommonConstants.BORDER_RADIUS_SOFT) + .justifyContent(FlexAlign.Center) + } + .height(40) + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .margin({ top:40 } as Margin) + } + + @Builder + videoBuilder() { + Row() { + Text($r('app.string.operate_rdb_in_taskpool_detail_video')) + .fontSize(19) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .width(CommonConstants.HALF_PERCENT) + .height(50) + + Row(){ + Image($r('app.media.operate_rdb_in_taskpool_video')) + .width(25) + .height(25) + + }.width(45) + .height(45) + .backgroundColor('#ff5d5b') + .borderRadius(CommonConstants.BORDER_RADIUS_SOFT) + .justifyContent(FlexAlign.Center) + } + .height(60) + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .margin({ top: 30 } as Margin) + } + + @Builder + emailBuilder() { + Column() { + Text(this.sourceData.email) + .fontSize(19) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .width(CommonConstants.FULL_PERCENT) + .height(25) + Text($r('app.string.operate_rdb_in_taskpool_detail_email')) + .fontSize( 15) + .fontColor('#A9A9A9') + .width(CommonConstants.FULL_PERCENT) + .height(25) + } + .height(60) + .width(CommonConstants.FULL_PERCENT) + .margin({ top: 30 } as Margin) + } + + @Builder + addressBuilder() { + Column() { + Text(this.sourceData.address) + .fontSize(19) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .width(CommonConstants.FULL_PERCENT) + .height(25) + + Text($r('app.string.operate_rdb_in_taskpool_detail_address')) + .fontSize(15) + .fontColor('#A9A9A9') + .width(CommonConstants.FULL_PERCENT) + .height(25) + } + .height(60) + .width(CommonConstants.FULL_PERCENT) + .margin({ top: 30 } as Margin) + } + + build() { + Column() { + // 导航栏 + this.navDestinationTitle(this.sourceData.name); + // 头像 + Image($r('app.media.operate_rdb_in_taskpool_portrait')) + .width(100) + .height(100) + .backgroundColor('#d9d9d9') + .border({ + width: CommonConstants.BORDER_WIDTH_BOLD, + color: Color.White, + radius: CommonConstants.BORDER_RADIUS_FULLY + }) + + // 姓名 + Text(this.sourceData.name) + .fontSize(40) + .fontColor('#222222') + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Center) + .width(CommonConstants.FULL_PERCENT) + .height(50) + .margin({ top: 10 } as Margin) + + this.phoneBuilder(); + this.videoBuilder(); + this.emailBuilder(); + this.addressBuilder(); + + Blank(); + + Row(){ + Button($r('app.string.operate_rdb_in_taskpool_dialog_edit_button_text')) + .fontSize(17) + .width('40%') + .fontColor(Color.White) + .height(45) + .backgroundColor('#1b7af8') + .onClick(():void=>{ + let params:RouterParams = new RouterParams('编辑联系人', this.sourceData); + let options: router.RouterOptions = { + url: 'pages/view/AddressBookEdit', + params: params as RouterParams + } as router.RouterOptions; + this.getUIContext().getRouter().pushUrl(options); + }) + + Button($r('app.string.operate_rdb_in_taskpool_dialog_delete_button_text')) + .fontSize(17) + .width('40%') + .fontColor(Color.White) + .height(45) + .backgroundColor('#ff5d5b') + .onClick(():void=>{ + let params:RouterParams = new RouterParams('删除联系人', this.sourceData); + let options: router.RouterOptions = { + url: 'pages/view/OperateRDBInTaskPool', + params: params as RouterParams + } as router.RouterOptions; + this.getUIContext().getRouter().pushUrl(options); + }) + + }.width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .margin({top: 24, bottom: 24} as Margin) + } + .padding({ + left: 24, + right: 24 + } as Padding) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .backgroundColor(Color.White) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo() =>{ + hilog.info(0x0000, 'testTag', 'MyStateSample'); + AddressBookDetail(undefined) + } + return wrapper + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookEdit.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookEdit.ets new file mode 100644 index 0000000000000000000000000000000000000000..121c722aa89d800d20d4d33a9fc0254c0ddf9956 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookEdit.ets @@ -0,0 +1,310 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Row, + TextAlign, SafeAreaEdge, TextOverflow, Image ,FlexAlign, SafeAreaType, $r, Builder, Color, + TextInput, Divider, JSON, Margin, Navigation, FontWeight, ResourceStr +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement'; +import hilog from '@ohos.hilog'; +import common from '@ohos.app.ability.common'; +import { BusinessError } from '@ohos.base'; +import { UIContext } from '@ohos.arkui.UIContext'; +import { Contact, RouterParams } from '../model/Contact'; +import router from '@ohos.router'; +import { CommonConstants } from '../constant/CommonConstant'; +import json from '@ohos.util.json'; +import { taskPoolExecuteQuery } from './TaskPool'; + +@Entry +@Component +struct AddressBookEdit { + @State data: Contact = new Contact(); + @State textData: string = ''; + @State dataArray: Array = [ + new Contact('艾德里安', '13333333333', 'aidelian@example.com', '江苏省南京市鼓楼区', 'operate_rdb_in_taskpool_photo1.jpg', 'A'), + new Contact('阿诺德', '16666666666', 'arnold@example.com', '上海市浦东新区', '', 'A'), + new Contact('贝拉', '11111111111', 'bella@example.com', '湖北省武汉市江汉区', '', 'B'), + new Contact('本', '12222222222', 'ben@example.com', '四川省成都市锦江区', 'operate_rdb_in_taskpool_photo22.jpg', 'B'), + new Contact('本杰明', '16666666666', 'benjieiming@example.com', '上海市浦东新区', 'operate_rdb_in_taskpool_photo5.jpg', 'B'), + new Contact('卡梅隆', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'C'), + new Contact('康纳', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'C'), + new Contact('卡特琳娜', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'C'), + new Contact('丹尼尔', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'D'), + new Contact('戴维维', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'D'), + new Contact('艾登', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'E'), + new Contact('艾拉', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'E'), + new Contact('艾里', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'E'), + new Contact('法比而', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'F'), + new Contact('法里', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'F'), + ]; + @State isName: boolean = false; + aboutToAppear(): void { + setTimeout( ()=>{ + this.data = (this.getUIContext().getRouter().getParams() as RouterParams).data; + this.textData = (this.getUIContext().getRouter().getParams() as RouterParams).text; + // 数据查看操作 + taskPoolExecuteQuery(context).then((arr: Array) => { + // 数据库查看成功 + hilog.info(0x0000, 'testTag', 'taskPoolExecuteQuery, arr: ' + JSON.stringify(arr)) + this.dataArray = [...arr] + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'taskPoolExecuteQuery, err: ' + err) + }) + }, 1) + } + + @Builder + navDestinationTitle(name: ResourceStr | string | undefined) { + Row() { + Column() { + Image($r('app.media.operate_rdb_in_taskpool_arrow_left')) + .width(28) + .height(28) + } + .onClick(():void => { + this.getUIContext().getRouter().back() + }) + .justifyContent(FlexAlign.Center) + .width(40) + .height(40) + .borderRadius(CommonConstants.BORDER_RADIUS_PROMINENT) + .backgroundColor('#E5E7E9') + + Text(name) + .fontWeight(FontWeight.Bold) + .fontSize(20) + .width(230) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + + Column() { + Image($r('app.media.operate_rdb_in_taskpool_ok')) + .width(25) + .height(25) + .id('taskpool_button_ok') + } + .onClick(():void => { + let params = new RouterParams(this.textData, this.data); + let options: router.RouterOptions = { + url: 'pages/view/OperateRDBInTaskPool', + params: params + } as router.RouterOptions; + if(!this.isName){ + this.getUIContext().getRouter().pushUrl(options); + }; + }) + .justifyContent(FlexAlign.Center) + .width(40) + .height(40) + .borderRadius(CommonConstants.BORDER_RADIUS_PROMINENT) + .backgroundColor('#E5E7E9') + } + .expandSafeArea([SafeAreaType.KEYBOARD]) + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor(Color.White) + .margin({ bottom: 8 } as Margin) + .width(CommonConstants.FULL_PERCENT) + .height(56) + } + + build() { + Column() { + Column(){ + this.navDestinationTitle(this.textData); + + Image($r('app.media.operate_rdb_in_taskpool_portrait')) + .height(100) + .width(100) + .margin({ top: 30 } as Margin) + .backgroundColor('#d9d9d9') + .border({ + width: CommonConstants.BORDER_WIDTH_BOLD, + color: Color.White, + radius: CommonConstants.BORDER_RADIUS_FULLY + }) + if(this.textData !== '新增联系人'){ + Text(this.data.name) + .id('taskpool_textinput_name') + .fontSize(22) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .height(60) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + .margin({ + left: 24, + right: 24, + bottom: 30 + } as Margin) + }else { + Row(){ + Text($r('app.string.operate_rdb_in_taskpool_text_input_name')) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .width('15%') + + TextInput({ placeholder: $r('app.string.operate_rdb_in_taskpool_name_prompt_text'), text: this.data.name }) + .placeholderColor('#999999') + .placeholderFont({ + size: 17, + weight: FontWeight.Bold + }) + .id('taskpool_textinput_phone') + .fontSize(17) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .height(60) + .width('85%') + .maxLength(CommonConstants.MAX_LENGTH_MODERATE) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + .backgroundColor('#e6e6e6') + .onChange((value: string):void => { + this.data.name = value; + this.isName = this.dataArray.some((item:Contact)=> item.name === this.data.name); + }) + }.margin({ + top: 30 + } as Margin) + } + + Column() { + Row(){ + Text($r('app.string.operate_rdb_in_taskpool_text_input_phone')) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .width('15%') + TextInput({ placeholder: $r('app.string.operate_rdb_in_taskpool_phone_prompt_text'), text: this.data.phone }) + .placeholderColor('#999999') + .placeholderFont({ + size: 17, + weight: FontWeight.Bold + }) + .id('taskpool_textinput_phone') + .fontSize(17) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .height(60) + .width('85%') + .maxLength(CommonConstants.MAX_LENGTH_MODERATE) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + .backgroundColor('#e6e6e6') + .onChange((value: string):void => { + this.data.phone = value; + }) + } + + Divider() + .strokeWidth(CommonConstants.STROKE_WIDTH) + .color('#ffffff') + .margin({top: 10} as Margin) + + Row(){ + Text($r('app.string.operate_rdb_in_taskpool_detail_email')) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .width('15%') + + TextInput({ + placeholder: $r('app.string.operate_rdb_in_taskpool_email_prompt_text'), + text: this.data.email + }) + .placeholderColor('#999999') + .placeholderFont({ + size: 17, + weight: FontWeight.Bold + }) + .id('taskpool_textinput_email') + .fontSize(17) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .height(60) + .width('85%') + .maxLength(CommonConstants.MAX_LENGTH_LONG) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + .backgroundColor('#e6e6e6') + .margin({top: 10} as Margin) + .onChange((value: string):void => { + this.data.email = value; + }) + } + Divider() + .strokeWidth(CommonConstants.STROKE_WIDTH) + .color('#ffffff') + .margin({top: 10} as Margin) + + Row(){ + Text($r('app.string.operate_rdb_in_taskpool_detail_address')) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .width('15%') + + TextInput({ + placeholder: $r('app.string.operate_rdb_in_taskpool_address_prompt_text'), + text: this.data.address + }) + .placeholderColor('#999999') + .placeholderFont({ + size: 17, + weight: FontWeight.Bold + }) + .id('taskpool_textinput_address') + .fontSize(17) + .fontWeight(FontWeight.Bold) + .fontColor('#222222') + .height(60) + .width('85%') + .maxLength(CommonConstants.MAX_LENGTH_VERY_LONG) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + .backgroundColor('#e6e6e6') + .margin({top: 10} as Margin) + .onChange((value: string):void => { + this.data.address = value; + }) + } + } + .margin({ + top: 10 + } as Margin) + .borderRadius(CommonConstants.BORDER_RADIUS_MODERATE) + }.width('90%') + }.width('100%') + .height('100%') + .backgroundColor(Color.White) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} + + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo() =>{ + hilog.info(0x0000, 'testTag', 'MyStateSample'); + AddressBookEdit(undefined) + } + return wrapper + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookList.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookList.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9492c4264f56b1b20c4827cbfb0dc2ee58dd3bc --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/AddressBookList.ets @@ -0,0 +1,109 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Row, TextAlign, + SafeAreaEdge,Visibility, List, ListItem, ForEach, TextOverflow, Image, HorizontalAlign, Progress, ProgressType, Flex, + FlexAlign, FlexDirection, SafeAreaType,Stack, Radio, Slider, SliderStyle, SaveButton ,SaveDescription, ButtonType, + Scroll ,Scroller, BarState, $r, Builder, Blank, Color, ImageFit, TextInput, InputType, Placement, ItemAlign, Divider, + JSON, DialogAlignment, SearchController, Margin, NavPathStack, Navigation, Alignment +} from '@ohos.arkui.component'; // TextAttribute should be insert by ui-plugins +import { State, Link, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement'; +import hilog from '@ohos.hilog'; +import common from '@ohos.app.ability.common'; +import { BusinessError } from '@ohos.base'; +import { UIContext } from '@ohos.arkui.UIContext'; +import router from '@ohos.router'; +import { Contact, RouterParams } from '../model/Contact'; +import { CommonConstants } from '../constant/CommonConstant'; + +@Component +export struct AddressBookList { + private scroller: Scroller = new Scroller(); + // 数据源 + @Link dataArray: Contact[]; + @State selectIndex: number = 0; + + build() { + Stack({ alignContent: Alignment.End }) { + List({ + initialIndex: CommonConstants.INITIAL_INDEX, + scroller: this.scroller + }) { + Column(){ + ForEach(this.dataArray, (contact: Contact) => { + ListItem() { + ItemComponent({ name: contact.name }) + }.margin({left: 15, right: 15} as Margin) + .onClick((): void => { + let options: router.RouterOptions = { + url: 'pages/view/AddressBookDetail', + params: new RouterParams('编辑联系人', contact) + } as router.RouterOptions; + this.getUIContext().getRouter().pushUrl(options); + }) + Divider().strokeWidth('100%').height(1).color('#d9d9d9').margin({left: 15, right: 15} as Margin) + }) + }.width('100%') + } + .id('address_book_list') + .width(CommonConstants.FULL_PERCENT) + .scrollBar(BarState.Off) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT) + .margin({ bottom: 100 } as Margin) + + Image($r('app.media.operate_rdb_in_taskpool_add')) + .width(50) + .height(50) + .id('taskpool_add_button') + .zIndex(CommonConstants.Z_INDEX) + .margin({ + top: 400, + right: CommonConstants.ADD_IMAGE_RIGHT + } as Margin) + .onClick(():void => { + let options: router.RouterOptions = { + url: 'pages/view/AddressBookEdit', + params: new RouterParams('新增联系人', new Contact()) + }as router.RouterOptions; + this.getUIContext().getRouter().pushUrl(options); + }); + } + .backgroundColor(Color.White) + } +} + +@Component +struct ItemComponent { + @State name: string = ''; + + build() { + Text(this.name) + .width(CommonConstants.FULL_PERCENT) + .height(50) + .fontSize(16) + } +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/DatabaseConnection.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/DatabaseConnection.ets new file mode 100644 index 0000000000000000000000000000000000000000..a7eb640fa6418bdd8af8b9d679538526c991459c --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/DatabaseConnection.ets @@ -0,0 +1,353 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { + Entry, + Text, + TextAttribute, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView, + List, Image, $r, AlphabetIndexer, Margin, ForEach, Color, TextAlign, ImageFit, JSON +} from '@ohos.arkui.component'; +import relationalStore from '@ohos.data.relationalStore'; +import type common from '@ohos.app.ability.common'; +import { Contact } from '../model/Contact'; +import { ValuesBucket } from '@ohos.data.ValuesBucket'; +import { STORE_CONFIG, SQL_CREATE_TABLE, TABLE_NAME } from '../constant/RdbConstant'; +import { BusinessError } from '@ohos.base'; +import { CommonConstants } from '../constant/CommonConstant'; +import hilog from '@ohos.hilog'; + +class DatabaseConnection { + private static instance: DatabaseConnection | undefined = undefined; + public rdbStore: relationalStore.RdbStore | undefined = undefined; + + /** + * 静态方法,用于获取数据库连接实例 + * + * @returns 数据库实例 + */ + public static getInstance(): DatabaseConnection { + if (!DatabaseConnection.instance) { + DatabaseConnection.instance = new DatabaseConnection(); + } + return DatabaseConnection.instance as DatabaseConnection; + } + + /** + * 初始化数据库 + * + * @param context 上下文 + */ + public async initRdbStore(context: common.Context): Promise { + hilog.info(0x0000, 'testTag', 'init rdbStore begin'); + if (!context) { + hilog.info(0x0000, 'testTag', 'initRdbStore context is invalid'); + return; + } + + if (this.rdbStore) { + hilog.info(0x0000, 'testTag', 'rdbStore is exist'); + return; + } + + try { + this.rdbStore = await relationalStore.getRdbStore(context, STORE_CONFIG); + hilog.info(0x0000, 'testTag', 'getRdbStore succeed'); + await this.createTable(); + } catch (err: Error) { + hilog.info(0x0000, 'testTag', `getRdbStore failed, err: ${err}`); + return; + } + } + + /** + * 创建数据库表 + */ + private async createTable(): Promise { + hilog.info(0x0000, 'testTag', 'create table begin'); + try { + // 执行sql语句,联系人个各个属性设定 + if (this.rdbStore != undefined) { + await (this.rdbStore as relationalStore.RdbStore).executeSql(SQL_CREATE_TABLE) + hilog.info(0x0000, 'testTag', 'create table succeed'); + return; + } + } catch (err: Error) { + hilog.info(0x0000, 'testTag', `create table failed, err: ${err}`); + return; + } + } + + /** + * 查询数据库 + * + * @param context 上下文 + * @param predicates predicates + * @return ret | resultSet 结果 + */ + public async query(context: common.Context): Promise> { + hilog.info(0x0000, 'testTag', 'query begin'); + + if (!context) { + hilog.info(0x0000, 'testTag', 'context is null or undefined'); + return [] as Contact[]; + } + + let predicates = new relationalStore.RdbPredicates(TABLE_NAME); + predicates.orderByAsc('category'); + if (predicates === null || predicates === undefined) { + hilog.info(0x0000, 'testTag', 'predicates is null or undefined'); + return [] as Contact[]; + } + + try { + this.rdbStore = await relationalStore.getRdbStore(context, STORE_CONFIG); + const resultSet: relationalStore.ResultSet = + await (this.rdbStore as relationalStore.RdbStore).query(predicates); + hilog.info(0x0000, 'testTag', 'result is ' + JSON.stringify(resultSet.rowCount)); + // 处理查询到的结果数组 + return this.getListFromResultSet(resultSet); + } catch (err: Error) { + hilog.info(0x0000, 'testTag', 'query result error:' + JSON.stringify(err)); + return [] as Contact[]; + } + } + + /** + * 批量插入数据库 + */ + public async batchInsertData(context: common.Context, array: Array): Promise { + hilog.info(0x0000, 'testTag', 'batch insert begin'); + if (!context) { + hilog.info(0x0000, 'testTag', 'context is null or undefined'); + } + + const predicates = new relationalStore.RdbPredicates(TABLE_NAME); + if (predicates === null || predicates === undefined) { + hilog.info(0x0000, 'testTag', 'predicates is null or undefined'); + } + + if (!this.rdbStore) { + hilog.info(0x0000, 'testTag', 'batch insert rdbStore is null'); + await this.initRdbStore(context); + } + + let valueBuckets: relationalStore.ValuesBucket[] = [] as relationalStore.ValuesBucket[]; + + for (let index = 0; index < array.length; index++) { + let contactItem = array[index] as Contact; + let value1 = contactItem.name; + let value2 = contactItem.phone; + let value3 = contactItem.email; + let value4 = contactItem.address; + let value5 = contactItem.avatar; + let value6 = contactItem.category; + + const valueBucket: relationalStore.ValuesBucket = { + 'name': value1, + 'phone': value2, + 'email': value3, + 'address': value4, + 'avatar': value5, + 'category': value6 + } + valueBuckets = [...valueBuckets, valueBucket]; + hilog.info(0x0000, 'testTag', 'valueBuckets:' + JSON.stringify(valueBuckets)); + } + + if (valueBuckets.length == 20) { + return (this.rdbStore as relationalStore.RdbStore).batchInsert(TABLE_NAME, valueBuckets).then((row: long)=>{ + hilog.info(0x0000, 'testTag', `batchInsert:${row}`); + return row as number; + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'batchInsert, err: ' + err); + return 0 as number; + }) + } + return 0 as number; + } + + /** + * 插入数据库 + */ + public async insertData(context: common.Context, contact: Contact): Promise { + hilog.info(0x0000, 'testTag', 'insert begin'); + if (!context) { + hilog.info(0x0000, 'testTag', 'context is null or undefined'); + } + + const predicates = new relationalStore.RdbPredicates(TABLE_NAME); + if (predicates === null || predicates === undefined) { + hilog.info(0x0000, 'testTag', 'predicates is null or undefined'); + } + + this.rdbStore = await relationalStore.getRdbStore(context, STORE_CONFIG); + + let value1 = contact.name; + let value2 = contact.phone; + let value3 = contact.email; + let value4 = contact.address; + let value5 = contact.avatar; + let value6 = contact.category; + + const valueBucket: relationalStore.ValuesBucket = { + 'name': value1, + 'phone': value2, + 'email': value3, + 'address': value4, + 'avatar': value5, + 'category': value6 + } + + if (this.rdbStore != undefined) { + (this.rdbStore as relationalStore.RdbStore) + .insert(TABLE_NAME, valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((row: long)=>{ + hilog.info(0x0000, 'testTag', `insert done:${row}`); + return undefined; + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'Insert failed, err: ' + err); + return undefined; + }) + } + } + + /** + * 删除操作 + */ + public async deleteData(context: common.Context, contact: Contact): Promise { + hilog.info(0x0000, 'testTag', 'delete begin'); + if (!context) { + hilog.info(0x0000, 'testTag', 'context is null or undefined'); + } + + const predicates = new relationalStore.RdbPredicates(TABLE_NAME); + if (predicates === null || predicates === undefined) { + hilog.info(0x0000, 'testTag', 'predicates is null or undefined'); + } + + this.rdbStore = await relationalStore.getRdbStore(context, STORE_CONFIG); + + predicates.equalTo('name', contact.name); + (this.rdbStore as relationalStore.RdbStore).delete(predicates).then((row: long)=>{ + hilog.info(0x0000, 'testTag', `delete contact success:${row}`); + return undefined; + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'delete failed, err: ' + err); + return undefined; + }) + } + + /** + * 更新数据库 + */ + public async updateData(context: common.Context, contact: Contact): Promise { + hilog.info(0x0000, 'testTag', 'update begin'); + if (!context) { + hilog.info(0x0000, 'testTag', 'context is null or undefined'); + } + + const predicates = new relationalStore.RdbPredicates(TABLE_NAME); + if (predicates === null || predicates === undefined) { + hilog.info(0x0000, 'testTag', 'predicates is null or undefined'); + } + + if (!this.rdbStore) { + hilog.info(0x0000, 'testTag', 'update rdbStore is null'); + await this.initRdbStore(context); + } + let value1 = contact.name; + let value2 = contact.phone; + let value3 = contact.email; + let value4 = contact.address; + let value5 = contact.avatar; + let value6 = contact.category; + + const valueBucket: relationalStore.ValuesBucket = { + 'name': value1, + 'phone': value2, + 'email': value3, + 'address': value4, + 'avatar': value5, + 'category': value6 + } + + predicates.equalTo('name', contact.name); + if (this.rdbStore != undefined) { + (this.rdbStore as relationalStore.RdbStore) + .update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((row: long)=>{ + hilog.info(0x0000, 'testTag', `update done:${row}`); + return undefined; + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'updated failed, err: ' + err); + return undefined; + }) + } + } + + /** + * 处理数据格式 + */ + getListFromResultSet(resultSet: relationalStore.ResultSet): Array { + // 声明结果变量 + let contacts: Contact[] = [] as Contact[]; + // 进入结果集的第一行 + resultSet.goToFirstRow(); + // 如果没有结束就继续遍历 + while (!resultSet.isEnded) { + // 读取各个属性,初始化临时变量contact + let contact: Contact = new Contact( + resultSet.getString(resultSet.getColumnIndex('name')), + resultSet.getString(resultSet.getColumnIndex('phone')), + resultSet.getString(resultSet.getColumnIndex('email')), + resultSet.getString(resultSet.getColumnIndex('address')), + resultSet.getString(resultSet.getColumnIndex('avatar')), + resultSet.getString(resultSet.getColumnIndex('category')) + ) + + const isDuplicate: boolean = contacts.some( + (c: Contact) => c.name === contact.name && c.phone === contact.phone + ); + + if (!isDuplicate) { + // 如果数据集合中没有这条数据就添加进去 + contacts.push(contact) + } + // 进入下一行 + resultSet.goToNextRow(); + } + // 数据整合完毕就释放资源 + resultSet.close(); + hilog.info(0x0000, 'testTag', 'contacts number is ' + contacts.length); + return contacts; + } +} + +export default DatabaseConnection; diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/OperateRDBInTaskPool.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/OperateRDBInTaskPool.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ba95cad0e74f32eb7c53d1998dc3f5aecc47b14 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/OperateRDBInTaskPool.ets @@ -0,0 +1,160 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Row, + SafeAreaEdge, Image, SafeAreaType,Stack, $r, Builder, Color, Search, SearchController, Margin +} from '@ohos.arkui.component' +import { State, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement' +import hilog from '@ohos.hilog' +import common from '@ohos.app.ability.common'; +import resourceManager from '@ohos.resourceManager' +import { BusinessError } from '@ohos.base' +import { UIContext } from '@ohos.arkui.UIContext' +import { Contact, RouterParams } from '../model/Contact'; +import { CommonConstants } from '../constant/CommonConstant'; +import { AddressBookList } from './AddressBookList'; +import { taskPoolExecuteQuery, taskPoolExecuteInsert, taskPoolExecuteDelete, + taskPoolExecuteUpdate, taskPoolExecuteBatchInsert } from './TaskPool'; + +@Entry +@Component +struct OperateRDBInTaskPool { + // 搜索值 + @State changeValue: string = ''; + // 搜索控制器 + private controller: SearchController = new SearchController(); + // 数据库初始化数据 + @State dataArray: Array = [ + new Contact('艾德里安', '13333333333', 'aidelian@example.com', '江苏省南京市鼓楼区', 'operate_rdb_in_taskpool_photo1.jpg', 'A'), + new Contact('阿诺德', '16666666666', 'arnold@example.com', '上海市浦东新区', '', 'A'), + new Contact('贝拉', '11111111111', 'bella@example.com', '湖北省武汉市江汉区', '', 'B'), + new Contact('本', '12222222222', 'ben@example.com', '四川省成都市锦江区', 'operate_rdb_in_taskpool_photo22.jpg', 'B'), + new Contact('本杰明', '16666666666', 'benjieiming@example.com', '上海市浦东新区', 'operate_rdb_in_taskpool_photo5.jpg', 'B'), + new Contact('卡梅隆', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'C'), + new Contact('康纳', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'C'), + new Contact('卡特琳娜', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'C'), + new Contact('丹尼尔', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'D'), + new Contact('戴维维', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'D'), + new Contact('艾登', '17777777777', 'cameron@example.com', '陕西省西安市雁塔区', 'operate_rdb_in_taskpool_photo11.jpg', 'E'), + new Contact('艾拉', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'E'), + new Contact('艾里', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'E'), + new Contact('法比而', '10000000000', 'connor@example.com', '辽宁省沈阳市沈河区', 'operate_rdb_in_taskpool_photo7.jpg', 'F'), + new Contact('法里', '11111111111', 'katrina@example.com', '吉林省长春市朝阳区', '', 'F'), + ]; + // 路由传递数据 + @State routerData: Contact = new Contact(); + + aboutToAppear(): void { + setTimeout(()=>{ + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + this.routerData = (this.getUIContext().getRouter().getParams() as RouterParams).data; + // 数据插入操作 + if((this.getUIContext().getRouter().getParams() as RouterParams).text === '新增联系人'){ + taskPoolExecuteInsert(context, this.routerData).then(() => { + // 数据库插入成功 + this.dataArray = [...this.dataArray, this.routerData]; + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'taskPoolExecuteInsert, err: ' + err) + }) + } + // 数据删除操作 + if((this.getUIContext().getRouter().getParams() as RouterParams).text === '删除联系人'){ + taskPoolExecuteDelete(context, this.routerData).then(() => { + // 数据库删除成功 + this.dataArray = this.dataArray.filter((item: Contact)=> { + return item.name !== this.routerData.name + }); + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'taskPoolExecuteDelete, err: ' + err) + }) + } + // 数据更新操作 + if((this.getUIContext().getRouter().getParams() as RouterParams).text === '编辑联系人'){ + taskPoolExecuteUpdate(context, this.routerData).then(() => { + // 数据库更新成功 + for(let i = 0; i < this.dataArray.length; i++){ + if(this.dataArray[i].name === this.routerData.name){ + this.dataArray[i] = this.routerData + this.dataArray = [...this.dataArray] + return; + } + } + }).catch((err: Error)=>{ + hilog.info(0x0000, 'testTag', 'taskPoolExecuteUpdate, err: ' + err) + }) + } + },1) + } + + build() { + Stack() { + Column() { + Text('← 返回') + .fontSize(20) + .width('90%') + .margin({left: 8.5, bottom: 10} as Margin) + .onClick(():void=>{ + this.getUIContext().getRouter().back(); + }) + // 搜索框 + Search({ + value: this.changeValue, + placeholder: '搜索', + controller: this.controller + }) + .searchButton(CommonConstants.SEARCH_TEXT, + { fontColor: '#0091FF' }) + .height(40) + .margin({ + left: 12, + right: 12, + bottom: 15 + } as Margin) + .backgroundColor('#d9d9d9') + .placeholderColor(Color.Grey) + .placeholderFont({ size: CommonConstants.SEARCH_TEXT_SIZE, weight: CommonConstants.SEARCH_TEXT_WEIGHT }) + .textFont({ size: CommonConstants.SEARCH_TEXT_SIZE, weight: CommonConstants.SEARCH_TEXT_WEIGHT }) + + // 通讯录列表 + AddressBookList({ dataArray: this.dataArray }) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + } + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo() =>{ + hilog.info(0x0000, 'testTag', 'MyStateSample'); + OperateRDBInTaskPool(undefined) + } + return wrapper + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/TaskPool.ets b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/TaskPool.ets new file mode 100644 index 0000000000000000000000000000000000000000..763043a1bf9ff7b8db966a227b26bbe60d21cb3d --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/ets/pages/view/TaskPool.ets @@ -0,0 +1,117 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { + Entry, + Text, + TextAttribute, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView, + List, Image, $r, AlphabetIndexer, Margin, ForEach, Color, TextAlign, ImageFit, JSON +} from '@ohos.arkui.component'; +import { State, MutableState, stateOf, observableProxy } from '@ohos.arkui.stateManagement'; +import relationalStore from '@ohos.data.relationalStore'; +import type common from '@ohos.app.ability.common'; +import { Contact } from '../model/Contact'; +import { ValuesBucket } from '@ohos.data.ValuesBucket'; +import { STORE_CONFIG, SQL_CREATE_TABLE, TABLE_NAME } from '../constant/RdbConstant'; +import { BusinessError } from '@ohos.base'; +import DatabaseConnection from './DatabaseConnection'; +import hilog from '@ohos.hilog'; + +async function queryItem(context: common.Context): Promise> { + return await DatabaseConnection.getInstance().query(context); +} + +async function insertItem(context: common.Context, contact: Contact) { + return await DatabaseConnection.getInstance().insertData(context, contact); +} + +async function deleteItem(context: common.Context, contact: Contact) { + return await DatabaseConnection.getInstance().deleteData(context, contact); +} + +async function updateItem(context: common.Context, contact: Contact) { + return await DatabaseConnection.getInstance().updateData(context, contact); +} + +async function batchInsert(context: common.Context, array: Array): Promise { + return await DatabaseConnection.getInstance().batchInsertData(context, array); +} + +export async function taskPoolExecuteQuery(context: common.Context): Promise> { + try { + let task = new taskpool.Task(queryItem, context); + let result: Contact[]= await taskpool.execute(task) as Contact[]; + hilog.info(0x0000, 'testTag', 'query_result: ' + JSON.stringify(result)); + return result; + } catch (err:Error) { + hilog.info(0x0000, 'testTag', 'query error:' + JSON.stringify(err)); + return [] as Contact[]; + } +} + +export async function taskPoolExecuteInsert(context: common.Context, contact: Contact): Promise { + try { + let task = new taskpool.Task(insertItem, context, contact); + await taskpool.execute(task); + } catch (err:Error) { + hilog.info(0x0000, 'testTag', 'insert error:' + JSON.stringify(err)); + } +} + +export async function taskPoolExecuteDelete(context: common.Context, contact: Contact): Promise { + try { + let task = new taskpool.Task(deleteItem, context, contact); + await taskpool.execute(task); + } catch (err:Error) { + hilog.info(0x0000, 'testTag', 'delete error:' + JSON.stringify(err)); + } +} + +export async function taskPoolExecuteUpdate(context: common.Context, contact: Contact): Promise { + try { + let task = new taskpool.Task(updateItem, context, contact); + await taskpool.execute(task); + } catch (err:Error) { + hilog.info(0x0000, 'testTag', 'update error:' + JSON.stringify(err)); + } +} + +export async function taskPoolExecuteBatchInsert(context: common.Context, array: Array): Promise { + try { + let task = new taskpool.Task(batchInsert, context, array); + let insertNum: number = await taskpool.execute(task) as number; + return insertNum; + } catch (err:Error) { + hilog.info(0x0000, 'testTag', 'batch insert error:' + JSON.stringify(err)); + return 0 as number; + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/module.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f95f9a6e69c03b1b6da379b36fc7aa9ee2c41ac4 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/module.json5 @@ -0,0 +1,64 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/color.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..980fcc8f4956e0d436971bd49ebb61924a8ed0bf --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,112 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "operate_rdb_in_taskpool_divider_color", + "value": "#aaaaaa" + }, + { + "name": "operate_rdb_in_taskpool_head_background_color", + "value": "#aabbcc" + }, + { + "name": "operate_rdb_in_taskpool_navigation_button_background_color", + "value": "#E5E7E9" + }, + { + "name": "operate_rdb_in_taskpool_navigation_background_color", + "value": "#F1F1F1" + }, + { + "name": "operate_rdb_in_taskpool_detail_content_text_color", + "value": "#222222" + }, + { + "name": "operate_rdb_in_taskpool_detail_title_text_color", + "value": "#A9A9A9" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_green", + "value": "#009e76" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_blue", + "value": "#1b7af8" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_red", + "value": "#ff5d5b" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_gray", + "value": "#A9A9A9" + }, + { + "name": "operate_rdb_in_taskpool_dialog_divider_line_color", + "value": "#F1F3F5" + }, + { + "name": "operate_rdb_in_taskpool_avatar_background_color", + "value": "#d9d9d9" + }, + { + "name": "operate_rdb_in_taskpool_text_input_placeholder_color", + "value": "#999999" + }, + { + "name": "operate_rdb_in_taskpool_text_input_font_color", + "value": "#222222" + }, + { + "name": "operate_rdb_in_taskpool_text_input_background_color", + "value": "#e6e6e6" + }, + { + "name": "operate_rdb_in_taskpool_text_input_devider_color", + "value": "#dddddd" + }, + { + "name": "operate_rdb_in_taskpool_list_head_background_color", + "value": "#d9d9d9" + }, + { + "name": "operate_rdb_in_taskpool_list_divider_background_color", + "value": "#d9d9d9" + }, + { + "name": "operate_rdb_in_taskpool_alphabet_selected_color", + "value": "#FFFFFF" + }, + { + "name": "operate_rdb_in_taskpool_alphabet_selected_bacground_color", + "value": "#5dabff" + }, + { + "name": "operate_rdb_in_taskpool_alphabet_popup_color", + "value": "#A9A9A9" + }, + { + "name": "operate_rdb_in_taskpool_alphabet_popup_background_color", + "value": "#F1F3F5" + }, + { + "name": "operate_rdb_in_taskpool_search_button_color", + "value": "#0091FF" + }, + { + "name": "operate_rdb_in_taskpool_search_background_color", + "value": "#d9d9d9" + }, + { + "name": "operate_rdb_in_taskpool_sync_button_color", + "value": "#5dabff" + }, + { + "name": "operate_rdb_in_taskpool_progress_background_color", + "value": "#d9d9d9" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/float.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/integer.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..831b0d94a6b3c36700b41bd68f4be8651ac7f207 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/integer.json @@ -0,0 +1,332 @@ +{ + "integer": [ + { + "name": "operate_rdb_in_taskpool_head_font_size", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_head_padding", + "value": 10 + }, + { + "name": "operate_rdb_in_taskpool_button_border_radius", + "value": 8 + }, + { + "name": "operate_rdb_in_taskpool_button_width", + "value": 110 + }, + { + "name": "operate_rdb_in_taskpool_button_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_flex_padding", + "value": 10 + }, + { + "name": "operate_rdb_in_taskpool_flex_margin", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_list_flex_padding", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_list_item_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_list_start_margin", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_list_end_margin", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_list_margin_top", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_list_margin_bottom", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_arrow_left_width", + "value": 28 + }, + { + "name": "operate_rdb_in_taskpool_arrow_left_height", + "value": 28 + }, + { + "name": "operate_rdb_in_taskpool_arrow_left_background_width", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_arrow_left_background_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_navigation_title_font_size", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_navigation_title_margin_left", + "value": 9 + }, + { + "name": "operate_rdb_in_taskpool_button_right_width", + "value": 30 + }, + { + "name": "operate_rdb_in_taskpool_button_right_height", + "value": 30 + }, + { + "name": "operate_rdb_in_taskpool_button_right_back_ground_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_bind_sheet_height", + "value": 180 + }, + { + "name": "operate_rdb_in_taskpool_button_ok_width", + "value": 28 + }, + { + "name": "operate_rdb_in_taskpool_button_ok_height", + "value": 28 + }, + { + "name": "operate_rdb_in_taskpool_navigation_height", + "value": 56 + }, + { + "name": "operate_rdb_in_taskpool_navigation_padding_left", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_navigation_padding_right", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_navigation_margin_bottom", + "value": 8 + }, + { + "name": "operate_rdb_in_taskpool_detail_content_font_size", + "value": 19 + }, + { + "name": "operate_rdb_in_taskpool_detail_content_height", + "value": 25 + }, + { + "name": "operate_rdb_in_taskpool_detail_title_font_size", + "value": 15 + }, + { + "name": "operate_rdb_in_taskpool_detail_title_height", + "value": 25 + }, + { + "name": "operate_rdb_in_taskpool_detail_icon_width", + "value": 25 + }, + { + "name": "operate_rdb_in_taskpool_detail_icon_height", + "value": 25 + }, + { + "name": "operate_rdb_in_taskpool_detail_icon_button_width", + "value": 45 + }, + { + "name": "operate_rdb_in_taskpool_detail_item_button_height", + "value": 45 + }, + { + "name": "operate_rdb_in_taskpool_detail_item_height", + "value": 60 + }, + { + "name": "operate_rdb_in_taskpool_phone_margin_top", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_video_button_height", + "value": 50 + }, + { + "name": "operate_rdb_in_taskpool_detail_item_margin_top", + "value": 30 + }, + { + "name": "operate_rdb_in_taskpool_dialog_button_font_size", + "value": 17 + }, + { + "name": "operate_rdb_in_taskpool_dialog_button_height", + "value": 45 + }, + { + "name": "operate_rdb_in_taskpool_dialog_divider_line_height", + "value": 2 + }, + { + "name": "operate_rdb_in_taskpool_operate_builder_padding_top", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_avatar_width", + "value": 100 + }, + { + "name": "operate_rdb_in_taskpool_avatar_height", + "value": 100 + }, + { + "name": "operate_rdb_in_taskpool_avatar_font_size", + "value": 60 + }, + { + "name": "operate_rdb_in_taskpool_name_font_size", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_name_height", + "value": 50 + }, + { + "name": "operate_rdb_in_taskpool_name_margin_top", + "value": 10 + }, + { + "name": "operate_rdb_in_taskpool_detail_padding_left", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_detail_padding_right", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_confirm_buttom_background_width", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_confirm_buttom_background_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_avatar_edit_view_margin_top", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_text_input_font_size", + "value": 17 + }, + { + "name": "operate_rdb_in_taskpool_text_input_height", + "value": 60 + }, + { + "name": "operate_rdb_in_taskpool_text_input_margin_left", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_text_input_margin_right", + "value": 24 + }, + { + "name": "operate_rdb_in_taskpool_text_input_margin_top", + "value": 20 + }, + { + "name": "operate_rdb_in_taskpool_text_input_devider_padding_left", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_text_input_devider_padding_right", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_text_input_padding_top", + "value": 5 + }, + { + "name": "operate_rdb_in_taskpool_text_input_padding_bottom", + "value": 5 + }, + { + "name": "operate_rdb_in_taskpool_list_head_font_size", + "value": 16 + }, + { + "name": "operate_rdb_in_taskpool_list_head_height", + "value": 25 + }, + { + "name": "operate_rdb_in_taskpool_list_head_padding_left", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_list_font_size", + "value": 16 + }, + { + "name": "operate_rdb_in_taskpool_list_padding_left", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_alphabet_margin_right", + "value": -8 + }, + { + "name": "operate_rdb_in_taskpool_alphabet_padding_right", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_add_image_width", + "value": 50 + }, + { + "name": "operate_rdb_in_taskpool_add_image_height", + "value": 50 + }, + { + "name": "operate_rdb_in_taskpool_search_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_search_margin_left", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_search_margin_right", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_progress_margin_left", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_progress_margin_right", + "value": 12 + }, + { + "name": "operate_rdb_in_taskpool_sync_button_width", + "value": 180 + }, + { + "name": "operate_rdb_in_taskpool_sync_button_height", + "value": 40 + }, + { + "name": "operate_rdb_in_taskpool_sync_height", + "value": 200 + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/string.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..64a562f1149f1cbef424961bfab7353a0b91efa0 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,171 @@ +{ + "string": [ + { + "name": "router_back", + "value": "← 返回" + }, + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "OperaterdbintaskpoolSample" + },{ + "name": "page_show", + "value": "page from package" + }, + { + "name": "operate_rdb_in_taskpool_list_name", + "value": "列表" + }, + { + "name": "operate_rdb_in_taskpool_prompt_text", + "value": "仅演示,可自行实现业务功能" + }, + { + "name": "operate_rdb_in_taskpool_delete_dialog_title", + "value": "确定删除%s通讯录好友吗?" + }, + { + "name": "operate_rdb_in_taskpool_edit_dialog_title", + "value": "确定修改%s信息吗?" + }, + { + "name": "operate_rdb_in_taskpool_add_dialog_title", + "value": "确定新增%s通讯录好友吗?" + }, + { + "name": "operate_rdb_in_taskpool_delete_dialog_content", + "value": "确定从通讯录中删除不可恢复" + }, + { + "name": "operate_rdb_in_taskpool_edit_dialog_content", + "value": "确定从修改不可撤回" + }, + { + "name": "operate_rdb_in_taskpool_add_dialog_content", + "value": "确定新增好友" + }, + { + "name": "operate_rdb_in_taskpool_dialog_confirm_button_text", + "value": "确定" + }, + { + "name": "operate_rdb_in_taskpool_dialog_edit_button_text", + "value": "编辑" + }, + { + "name": "operate_rdb_in_taskpool_dialog_delete_button_text", + "value": "删除" + }, + { + "name": "operate_rdb_in_taskpool_dialog_cancel_button_text", + "value": "取消" + }, + { + "name": "operate_rdb_in_taskpool_detail_phone", + "value": "号码" + }, + { + "name": "operate_rdb_in_taskpool_detail_video", + "value": "视频通话" + }, + { + "name": "operate_rdb_in_taskpool_detail_email", + "value": "邮箱" + }, + { + "name": "operate_rdb_in_taskpool_detail_address", + "value": "地址" + }, + { + "name": "operate_rdb_in_taskpool_name_prompt_text", + "value": "请输入姓名" + }, + { + "name": "operate_rdb_in_taskpool_phone_prompt_text", + "value": "请输入电话" + }, + { + "name": "operate_rdb_in_taskpool_email_prompt_text", + "value": "请输入邮箱" + }, + { + "name": "operate_rdb_in_taskpool_address_prompt_text", + "value": "请输入地址" + }, + { + "name": "operate_rdb_in_taskpool_no_modify_prompt_text", + "value": "暂无修改" + }, + { + "name": "operate_rdb_in_taskpool_navigation_edit_text", + "value": "编辑联系人" + }, + { + "name": "operate_rdb_in_taskpool_navigation_add_text", + "value": "新增联系人" + }, + { + "name": "operate_rdb_in_taskpool_text_input_name", + "value": "姓名" + }, + { + "name": "operate_rdb_in_taskpool_text_input_phone", + "value": "电话" + }, + { + "name": "operate_rdb_in_taskpool_text_input_email", + "value": "邮箱" + }, + { + "name": "operate_rdb_in_taskpool_text_input_address", + "value": "地址" + }, + { + "name": "operate_rdb_in_taskpool_add_prompt_text", + "value": "好友%s添加成功" + }, + { + "name": "operate_rdb_in_taskpool_delete_prompt_text", + "value": "好友%s已删除" + }, + { + "name": "operate_rdb_in_taskpool_update_prompt_text", + "value": "好友%s已更新" + }, + { + "name": "operate_rdb_in_taskpool_query_prompt_text", + "value": "查询通讯录数据共%s条" + }, + { + "name": "operate_rdb_in_taskpool_sync_book", + "value": "点击同步通讯录数据" + }, + { + "name": "operate_rdb_in_taskpool_sync_book_fail", + "value": "通讯录同步失败" + }, + { + "name": "operate_rdb_in_taskpool_sync_book_done", + "value": "通讯录同步完成" + }, + { + "name": "operate_rdb_in_taskpool_sync_book_loading", + "value": "正在同步通讯录数据" + }, + { + "name": "operate_rdb_in_taskpool_search_text", + "value": "搜索" + }, + { + "name": "operate_rdb_in_taskpool_one_hundred_percent", + "value": "100%" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/background.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/foreground.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd7289c4485589c30ee9c9384fa69c0b296a3b1 Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index2.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index2.png new file mode 100644 index 0000000000000000000000000000000000000000..33b03b8dddb3aea6b429b720c42b7236d8f977d3 Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index2.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index3.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index3.png new file mode 100644 index 0000000000000000000000000000000000000000..565fef717aad0957c7c2ae465875b57f08e8ed42 Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/index3.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/layered_image.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_add.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_add.svg new file mode 100644 index 0000000000000000000000000000000000000000..06467d625f7c778e5d8e4a8401f96f546a5f4190 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_add.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_add_norm_filled + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_arrow_left.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_arrow_left.svg new file mode 100644 index 0000000000000000000000000000000000000000..1e9405ce617d5dca35385a994b5ce7e384f78dd1 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_arrow_left.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_arrow_left + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_message.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_message.svg new file mode 100644 index 0000000000000000000000000000000000000000..9d13ba7ba94a5f2ed2605c6ac6ec2c3e80c018eb --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_message.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_message_filled + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_ok.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_ok.svg new file mode 100644 index 0000000000000000000000000000000000000000..d3f2bd7564eb79dd9315599759a68ca285d4c8b9 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_ok.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_ok + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_phone.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_phone.svg new file mode 100644 index 0000000000000000000000000000000000000000..674fc6087ee69b80bf4358586442dde3d3e4b7de --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_phone.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_phone_filled + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_portrait.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_portrait.svg new file mode 100644 index 0000000000000000000000000000000000000000..6fc8ea96e6c12b08b88fadad6ed19bdf58c21fb6 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_portrait.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_save.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_save.svg new file mode 100644 index 0000000000000000000000000000000000000000..dc46cfcf338182945ebddd90890083fbf37010db --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_save.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_todo_filled + + + + + + + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_video.svg b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_video.svg new file mode 100644 index 0000000000000000000000000000000000000000..0f5aeed6b1ee7d78ca74ccb8aa787666590576d3 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/operate_rdb_in_taskpool_video.svg @@ -0,0 +1,9 @@ + + + + Public/ic_public_video_fille + Created with Sketch. + + + + \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/startIcon.png b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/backup_config.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/main_pages.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..47a0c52a8c9ef4ace9669c458b8b2846e756c1d2 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,8 @@ +{ + "src": [ + "pages/Index", + "pages/view/OperateRDBInTaskPool", + "pages/view/AddressBookDetail", + "pages/view/AddressBookEdit" + ] +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/dark/element/color.json b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigor/hvigor-config.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..57c58e3641a0b085f39f7f137b9a938ecb20f2fd --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigor/hvigor-config.json5 @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "dependencies": { + "@ohos/hvigor-ohos-online-sign-plugin": "4.0.2" + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigorfile.ts b/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f435606b5766719f7203539113d84a2b281b0353 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/oh-package.json5 b/code/ArkTS1.2/OperaterdbintaskpoolSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b6f7090658c0e69d5582af5d236fde4eab954ed6 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/oh-package.json5 @@ -0,0 +1,34 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/code/ArkTS1.2/OperaterdbintaskpoolSample/ohosTest.md b/code/ArkTS1.2/OperaterdbintaskpoolSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..d04636a0b3d592de8e98580151f61ec5b9432741 --- /dev/null +++ b/code/ArkTS1.2/OperaterdbintaskpoolSample/ohosTest.md @@ -0,0 +1,9 @@ +# 文件并行化处理场景测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|-----------------------------------|-------------------------------------|----------------------|------------------------------------|------|------| +| 新增联系人 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【在TaskPool线程中操作关系型数据库实现案例】| 1、点击右下角蓝色加号按钮
2、输入姓名:艾森宝,电话:18855558888,邮箱:aisengbao@example.com,地址:安徽省合肥市,点击“√”保存 | 1、跳转至新增联系人页
2、好友添加成功并返回通讯录列表页刷新列表数据 | 否 | Pass | +| 编辑联系人 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【在TaskPool线程中操作关系型数据库实现案例】| 1、点击通讯录好友【艾伦】
2、选中编辑项
3、修改电话、邮箱、地址后,点击“√”保存按钮 | 1、进入【艾伦】联系人详情页
2、跳转至编辑联系人页面
3、好友信息修改成功并返回联系人详情页且刷新数据 | 否 | Pass | +| 删除联系人 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【在TaskPool线程中操作关系型数据库实现案例】| 1、点击通讯录好友【艾伦】
2、点击删除按钮 | 1、进入【艾伦】联系人详情页
2、好友信息删除成功并返回通讯录列表页刷新列表数据 | 否 | Pass |