diff --git a/OAT.xml b/OAT.xml index 5d8a8bd5c8e86805323a9003b823bb53ea96c367..2ac30d44370f217483038c2dd959f822f6e178a0 100644 --- a/OAT.xml +++ b/OAT.xml @@ -176,6 +176,13 @@ Note:If the text contains special characters, please escape them according to th + + + + + + + @@ -2187,6 +2194,11 @@ Note:If the text contains special characters, please escape them according to th + + + + + diff --git a/code/ArkTS1.2/DownLoadSample/.gitignore b/code/ArkTS1.2/DownLoadSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/.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/DownLoadSample/AppScope/app.json5 b/code/ArkTS1.2/DownLoadSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..76254eb8f296c74bfe2edae322971ef1a0bc4ccb --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.samples.DownloadSample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/element/string.json b/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a9f86e0b9da71179cb298b2048a23e88aac4c5f5 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DownloadSample" + } + ] +} diff --git a/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/media/app_icon.png b/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/AppScope/resources/base/media/app_icon.png differ diff --git a/code/ArkTS1.2/DownLoadSample/build-profile.json5 b/code/ArkTS1.2/DownLoadSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7178fe08b386249b64b2c1afbd1e9844aa959548 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "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/DownLoadSample/code-linter.json5 b/code/ArkTS1.2/DownLoadSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/.gitignore b/code/ArkTS1.2/DownLoadSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/build-profile.json5 b/code/ArkTS1.2/DownLoadSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "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/DownLoadSample/entry/hvigorfile.ts b/code/ArkTS1.2/DownLoadSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/DownLoadSample/entry/obfuscation-rules.txt b/code/ArkTS1.2/DownLoadSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/oh-package.json5 b/code/ArkTS1.2/DownLoadSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d205c00999b495e390eb8582f3dec20cc547d5fc --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/src/main/ets/pages/Index.ets b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..51954c9bc64fd630c420847e57fd222a76c5f3b3 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,57 @@ +/** + * + * 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"; // should be insert by ui-plugins +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Entry, JSON } from "@ohos.arkui.component"; // TextAttribute should be insert by ui-plugins +import { State, StateDecoratedVariable, MutableState, stateOf, observableProxy } from "@ohos.arkui.stateManagement"; // should be insert by ui-plugins +import hilog from '@ohos.hilog'; +import camera from '@ohos.multimedia.camera'; +import request from '@ohos.request'; +import {BusinessError} from '@ohos.base'; +import common from '@ohos.app.ability.common'; // 导入依赖资源context模块 +import { UIContext, Router } from "@ohos.arkui.UIContext"; +import { MultipleFilesDownloadComponent } from './view/MultipleFilesDownload'; + +@Entry +@Component +struct MyStateSample { + + build() { + Column(undefined) { + MultipleFilesDownloadComponent(); + } + } +} + +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/DownLoadSample/entry/src/main/ets/pages/model/dataType.ets b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/model/dataType.ets new file mode 100644 index 0000000000000000000000000000000000000000..18dd4a7ea6f7404b88b2eab6386d3cc2fbd1a147 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/model/dataType.ets @@ -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. + */ + +let NextID: number = 1; + +export class downloadFilesData { + // 唯一标识 + id: string; + // 下载地址 + url: string; + // 文件下载状态: 0未下载, 1下载成功, 2下载失败, 3已删除 + fileStatus: number; + // 下载完成的时间戳 + downloadTime: number; + + constructor( + url: string = '', + fileStatus: number = 0, + downloadTime: number = 0, + ) { + this.id = String(NextID++); + this.url = url; + this.fileStatus = fileStatus; + this.downloadTime = downloadTime; + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/HistoryItem.ets b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/HistoryItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..15cdf2ae48142cf1e58b9ddffa7910f47c86e2ea --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/HistoryItem.ets @@ -0,0 +1,103 @@ +/** + * + * 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'; // should be insert by ui-plugins +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Row, TextAlign, + Visibility, List, ListItem, ForEach, TextOverflow, Image, HorizontalAlign, Progress, ProgressType, FlexAlign, SafeAreaType, + RelativeContainer, TextDecorationType, ButtonType, $r, Margin +} from '@ohos.arkui.component'; // TextAttribute should be insert by ui-plugins +import { State, Link, StateDecoratedVariable, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins +import { downloadFilesData } from '../model/dataType'; +import fs from '@ohos.file.fs'; +import hilog from '@ohos.hilog'; +import { BusinessError } from '@ohos.base'; +import common from '@ohos.app.ability.common'; + +const TAG: string = 'HistoryFiles'; + +@Component +export struct HistoryItem { + // 文件名称 + @State fileName: string = '文件名'; + // 待下载任务数量 + @Link downloadCount: number; + // 下载历史列表 + @Link historyArray: downloadFilesData[] = new Array(); + // 下载列表 + @Link downloadFileArray: downloadFilesData[] = new Array(); + // 文件下载状态 + @State fileStatus: number = -1; + + aboutToAppear(): void { + } + build() { + Row(){ + Row(){ + Image($r('app.media.multiple_files_download_file')) + .height(50) + .width(50) + .borderRadius(8) + .id('fileImage') + }.width('17%') + + Column(){ + Row(){ + Column(){ + Text(this.fileName) + .height(22) + .width('100%') + .fontSize(14) + .fontColor('#000000') + .textAlign(TextAlign.Start) + .maxLines(1) // 限制为单行 + .id('fileName') + + Row(){ + Text($r('app.string.text_download')) + .fontSize(12) + .fontColor('#66182431') + .id('downloadVal') + }.width('100%') + .height(23) + } + .width('75%') + + // 完成按钮 + Button($r('app.string.button_finish')) + .fontSize(12) + .height(30) + .width('25%') + .borderRadius(8) + .backgroundColor($r('app.color.operate_rdb_in_taskpool_button_background_color_green')) + } + } + .width("83%") + .height(50) + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .height(80) + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets new file mode 100644 index 0000000000000000000000000000000000000000..da589c0260a76b7c0c96b3ecce438147a7fb9d26 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets @@ -0,0 +1,458 @@ +/** + * + * 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'; // should be insert by ui-plugins +import { + Entry, + Text, + TextAttribute, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView, + Row, + TextAlign, + Visibility, + List, + ListItem, + ForEach, + TextOverflow, + Image, + HorizontalAlign, + Progress, + ProgressType, + FlexAlign, + SafeAreaType, + JSON, + $r, + Margin +} from '@ohos.arkui.component'; // TextAttribute should be insert by ui-plugins +import { + State, + Link, + StateDecoratedVariable, + MutableState, + stateOf, + observableProxy, + Prop, + Watch +} from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins\ +import hilog from '@ohos.hilog'; +import zlib from '@ohos.zlib'; +import common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import { BusinessError } from '@ohos.base'; +import { HistoryItem } from './HistoryItem'; +import request from '@ohos.request'; // 导入上传下载模块。需要配置ohos.permission.INTERNET权限 +import { downloadFilesData } from '../model/dataType'; +import util from '@ohos.util'; + +const NO_TASK: number = 0; // 0个下载任务 +const INIT_PROGRESS: number = 0; // 进度条初始值 +const BYTE_CONVERSION: number = 1024; // 字节转换 + +/** + * 功能描述: 多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。 + * 每个应用最多支持创建10个未完成的任务,相关规格说明请参考request.agent.create。 + * + * 推荐场景: 多文件下载 + * + * 核心组件: + * 1. FileDownloadItem + * + * 实现步骤: + * 1.配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务 + * 中请按实际情况按需配置。 + * 2.创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听, + * 需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从 + * 而实现多文件下载监听。 + * 3.创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注 + * 册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。 + * 4.启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。 + * 5.本例中下载任务用到的其他操作:使用request.agent.show,根据任务id可查询任务的详细信息。使用task.pause可以暂停正在等待WAITING/正在运行 + * RUNNING/正在重试RETRYING的后台下载任务。使用task.resume可以重新启动任务,可恢复暂停的后台任务。 + */ + +@Entry +@Component +export struct MultipleFilesDownloadComponent { + @State message: string = '待下载'; + // 是否全部开始下载 + @State isStartAllDownload: boolean = false; + // 待下载任务数量 + @State downloadCount: number = 0; + // 下载失败任务数量。当所有任务下载失败时,'全部暂停'状态重置为'全部开始'。 + @State downloadFailCount: number = 0; + // 下载列表内容透明度。用于控制是否显示下载列表相应内容 + @State downloadPageOpacity: number = 1; + // 下载列表内容使能控制。避免隐藏后还能点击 + @State isDownloadPageEnabled: boolean = true; + // 历史列表的显隐控制。 + @State historyPageVisibility: Visibility = Visibility.None; + // 历史列表内容使其能控制。避免隐藏后还能点击 + @State isHistoryPageEnabled: boolean = false; + // 点击历史列表tab时,控制下载列表相应的内容的显隐 + @State downloadPageVisibility: Visibility = Visibility.Visible; + // 下载列表数据 + @State downloadFileArray: downloadFilesData[] = new Array(); + // 下载历史列表数据 + @State historyList: downloadFilesData[] = new Array(); + // 下载文件名 + @State fileName: string = '文件名'; + // 下载任务状态 + @State state: string = ''; + // 下载状态图标显隐控制。下载中显示图标,下载完成或者下载失败隐藏图标 + @State isShow: boolean = false; + // 是否正在下载标志位 + @State downloading: boolean = false; + // 下载文件大小。类型字符串 + @State sFileSize: string = '-'; + // 下载文件大小。类型数值 + @State nFileSize: number = 0; + // 当前已下载数据量。类型字符串 + @State sCurrentDownloadSize: string = '-'; + // 当前已下载数据量。类型数值 + @State nCurrentDownloadSize: number = 0; + // 下载任务对象初始化。用于下载失败和下载过程中暂停和重新启动下载。 + private downloadTask: request.agent.Task | undefined; + + // 下载信息初始化 + aboutToAppear(): void { + this.downloadFileArray = [ + { + 'id': '1', + 'url': 'https://gitee.com/openharmony/applications_app_samples/raw/master/code/Solutions/Shopping/OrangeShopping/feature/navigationHome/src/main/resources/base/media/favor_list_tea.png', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '2', + 'url': 'https://gitee.com/harmonyos-cases/cases/blob/master/CommonAppDevelopment/product/entry/src/main/resources/base/media/after_cache.png', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '3', + 'url': 'https://gitee.com/harmonyos-cases/cases/blob/master/CommonAppDevelopment/product/entry/src/main/resources/base/media/icon_main_color.png', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '4', + 'url': 'https://gitee.com/harmonyos-cases/cases/blob/master/CommonAppDevelopment/product/entry/src/main/resources/base/media/image_resizable.png', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '5', + 'url': 'https://gitee.com/harmonyos-cases/cases/blob/master/CommonAppDevelopment/product/entry/src/main/resources/base/media/text_overflow_detail.png', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + } + ] + // 下载数量,用于显示页面上下载队列数量 + this.downloadCount = this.downloadFileArray.length; + } + + // 监听是否开始下载/暂停下载 + onDownLoadUpdated(): void { + if (this.isStartAllDownload) { + this.startAllDownloads(); + } + } + + startAllDownloads() { + this.downloadFileArray.forEach((item: downloadFilesData) => { + this.startDownload(item.url); + }) + } + + // 启动下载任务 + startDownload(url: string) { + // 首次下载,创建任务 + hilog.info(0x0000, 'TAGhttp', `点击`); + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + hilog.info(0x0000, 'TAGhttp', `context创建`); + (request.agent.create(context, { + action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务 + url: url, // 配置下载任务url + overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件 + method: 'GET', // HTTP标准方法。下载时,使用GET或POST。 + saveas: './', // 这里'./'表示下载至应用当前缓存路径下。 + mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。 + gauge: true, // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。 + retry: false, // 默认为true,如果没有网络或者网络不满足时,会自动暂停waiting,等网络满足时进行一次重试。设置为false时,没网直接走失败回调 + } as request.agent.Config) as Promise) + .then((task: request.agent.Task) => { + hilog.info(0x0000, 'TAGhttp', `create成功`); + + // 注册下载任务相关回调 + task.on('completed', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `下载完成`); + }); // 下载任务完成回调 + task.on('progress', this.progressCallback); // 下载进度更新回调 + task.on('failed', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `下载失败`); + }); // 下载任务失败回调 + + task.on('resume', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `重新启动`); + }); // 重新启动任务回调 + + task.on('pause', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `暂停`); + }); // 暂停任务回调 + + // TODO 知识点:启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。 + task.start((err: BusinessError) => { + if (err) { + hilog.info(0x0000, 'TAGhttp', + `Failed to task start with error message: ${err.message}, error code: ${err.code}`); + return; + } + this.downloadTask = task as request.agent.Task; + }) + }) + } + + // 下载进度更新回调 + private progressCallback: (progress: request.agent.Progress) => void = (progress: request.agent.Progress) => { + // 性能知识点: 如果注册了progress下载进度更新监听,不建议在progress下载进度更新回调中加日志打印,减少不必要的性能损耗。 + hilog.info(0x0000, 'TAGhttp', JSON.stringify(progress)); + this.state = '下载中'; + this.downloading = true; + // 显示下载状态图标 + this.isShow = true; + // 第一次开始下载 + if (this.sFileSize === '-') { + // 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。传过来的值为-1,则在页面上显示'未知大小' + if (progress.sizes[0] === -1) { + this.sFileSize = '未知大小'; + // 文件大小无法获取的情况下,进度条的值设置为0,总进度设置为1 + this.nCurrentDownloadSize = 0; + this.nFileSize = 1; + } else { + // 能获取文件大小时,按实际下载数据量更新进度 + this.nFileSize = progress.sizes[0]; + hilog.info(0x0000, 'TAGhttp', `nFileSize: ` + String(this.nFileSize)); + this.sFileSize = (progress.sizes[0] / BYTE_CONVERSION) + 'kb'; + hilog.info(0x0000, 'TAGhttp', `sFileSize: ` + String(this.sFileSize)); + this.nCurrentDownloadSize = progress.processed; + hilog.info(0x0000, 'TAGhttp', `nCurrentDownloadSize: ` + String(this.nCurrentDownloadSize)); + } + } else if (this.sFileSize === '未知大小') { + // 非首次下载(暂停过下载任务后重新启动下载时),文件大小未知情况时,下载时进度不做更新 + hilog.info(0x0000, 'TAGhttp', `When the file size is unknown, the download progress will not be updated`); + } else { + // 非首次下载(暂停过下载任务后重新启动下载时),文件大小能获取到的情况,更新下载进度 + this.nCurrentDownloadSize = progress.processed; + } + // 用于显示已下载文件数据大小 + this.sCurrentDownloadSize = (progress.processed / BYTE_CONVERSION) + 'kb'; + } + + build() { + Column() { + Text($r('app.string.router_back')) + .fontSize(20) + .width('100%') + .onClick((): void => { + this.getUIContext().getRouter().back(); + }) + + Text($r('app.string.multiple_files_download_transfer_list')) + .fontSize(25) + .textAlign(TextAlign.Center) + Row() { + Text($r('app.string.multiple_files_download_list')) + .fontSize(16) + .fontColor(this.downloadPageOpacity === 1 ? '#FFFFFF' : '#808080') + .textAlign(TextAlign.Center) + .backgroundColor(this.downloadPageOpacity === 1 ? '#007DFF' : '#E8E8E8') + .width('49%') + .height(35) + .borderRadius(50) + .margin(3) + .onClick((e: ClickEvent) => { + this.downloadPageOpacity = 1; + this.isDownloadPageEnabled = true; + this.downloadPageVisibility = Visibility.Visible; + this.historyPageVisibility = Visibility.None; + this.isHistoryPageEnabled = false; + }) + + Text($r('app.string.multiple_files_download_album_backup')) + .fontSize(16) + .fontColor(this.downloadPageOpacity === 1 ? '#808080' : '#FFFFFF') + .textAlign(TextAlign.Center) + .backgroundColor(this.downloadPageOpacity === 1 ? '#E8E8E8' : '#007DFF') + .width('49%') + .height(35) + .borderRadius(50) + .margin(3) + .onClick((e: ClickEvent) => { + this.downloadPageOpacity = 0; + this.isDownloadPageEnabled = false; + this.downloadPageVisibility = Visibility.None; + this.historyPageVisibility = Visibility.Visible; + this.isHistoryPageEnabled = true; + }) + } + .width('100%') + .backgroundColor('#E8E8E8') + .borderRadius(50) + .margin(20) + + Row() { + Row() { + Text($r('app.string.multiple_files_download_queue')).fontSize(20) + Text(this.downloadCount + '').fontSize(20) + }.width('50%') + + Row() { + Text(this.isStartAllDownload && this.downloadCount > NO_TASK ? '全部暂停' : '全部开始') + .fontSize(20) + .fontColor('#418AF3') + .textAlign(TextAlign.End) + .width('100%') + .id('download') + .onClick((): void => { + if (this.downloadCount === NO_TASK) { + return; + } + this.isStartAllDownload = !this.isStartAllDownload; + this.onDownLoadUpdated() + }) + }.width('50%') + } + .opacity(this.downloadPageOpacity) + .visibility(this.downloadPageVisibility) + .enabled(this.isDownloadPageEnabled) + .width('100%') + + List() { + /** + * 本例只展示下载列表。由于每个应用request.agent.create最多支持创建10个未完成的任务,数量较小,所以这里使用ForEach展示下载列表。 + * 如果需要显示大量历史下载完成任务信息,建议使用LazyForEach提升性能。create相关限制说明请参考https://developer.huawei.com/ + * consumer/cn/doc/harmonyos-references/js-apis-request-0000001774281338#ZH-CN_TOPIC_0000001774281338__request + * agentcreate10。 + */ + ForEach(this.downloadFileArray, (item: downloadFilesData) => { + ListItem() { + // TODO 知识点:创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听,需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从而实现多文件下载监听。 + Row() { + Row() { + Image($r('app.media.multiple_files_download_file')) + .height(50) + .width(50) + .borderRadius(8) + .id('fileImage') + }.width('17%') + + Column() { + Row() { + Column() { + Text(this.fileName) + .height(22) + .width('100%') + .fontSize(14) + .fontColor('#000000') + .textAlign(TextAlign.Start) + .maxLines(1)// 限制为单行 + .id('fileName') + + Row() { + Text(this.sCurrentDownloadSize + '/' + this.sFileSize + 'MB ') + .fontSize(12) + .fontColor('#66182431') + .id('downloadVal') + + Text(this.state) + .fontSize(12) + .fontColor('#66182431') + .id(this.fileName + 'state') + }.width('100%') + .height(23) + } + .width('90%') + + Image($r('app.media.multiple_files_download_start')) + .height(25) + .width('10%') + .id('downloadImage') + } + + // 下载进度条,用于显示从下载进度更新回调中获取到的已下载数据大小 + Progress({ value: INIT_PROGRESS, total: this.nFileSize, type: ProgressType.Capsule }) + .value(1) + .height(5) + .id('progress') + + } + .width('83%') + .height(50) + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .height(50) + .margin({ top: 15, bottom: 15 } as Margin) + } + }, (item: downloadFilesData) => item.id) + } + .opacity(this.downloadPageOpacity) + .visibility(this.downloadPageVisibility) + .enabled(this.isDownloadPageEnabled) + .width('100%') + .height('80%') + + // 下载历史列表 + List() { + ForEach(this.downloadFileArray, (item: downloadFilesData) => { + ListItem() { + HistoryItem({ + downloadCount: this.downloadCount, // 待下载任务数量 + historyArray: this.historyList, + downloadFileArray: this.downloadFileArray // 下载文件数据源 + }) + }.onClick((): void => { + hilog.info(0x0000, 'testTag', '点击单个文件'); + }) + }) + }.visibility(this.historyPageVisibility) + .enabled(this.isHistoryPageEnabled) + .width('100%') + .height('80%') + + }.padding(15) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/module.json5 b/code/ArkTS1.2/DownLoadSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..de78b5cae3b2ba99788048311e5d0cd34d075039 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/module.json5 @@ -0,0 +1,38 @@ +{ + "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/DownLoadSample/entry/src/main/resources/base/element/color.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..4d7d6016598d738996ff7ea3be42ad8df7516edf --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,37 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "multiple_files_download_text_font_color", + "value": "#66182431" + }, + { + "name": "multiple_files_download_column_border_color", + "value": "#6fafee" + }, + { + "name": "multiple_files_download_selected_background_color", + "value": "#FF007DFF" + }, + { + "name": "multiple_files_download_background_color", + "value": "#FFFEFEFE" + }, + { + "name": "multiple_files_download_text_color", + "value": "#418AF3" + }, + { + "name": "multiple_files_download_del_bgc", + "value": "#F55A42" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_green", + "value": "#FF2F9117" + } + + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/float.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/src/main/resources/base/element/integer.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..3b1936d6a96a00d707f9a14b4086f09e4b381961 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/src/main/resources/base/element/string.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1f87b0cf1c3f1b2b503ad882d9936d66b42f7f3d --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,116 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "router_back", + "value": "←" + }, + { + "name": "EntryAbility_label", + "value": "DownloadSample" + }, + { + "name": "multiple_files_download_text_width", + "value": "40%" + }, + { + "name": "button_finish", + "value": "已完成" + }, + { + "name": "text_download", + "value": "已下载" + }, + { + "name": "multiple_files_download_relative_container_width", + "value": "100%" + }, + { + "name": "multiple_files_download_relative_container_height", + "value": "15%" + }, + { + "name": "multiple_files_download_row_width", + "value": "50%" + }, + { + "name": "multiple_files_download_row_text_width", + "value": "100%" + }, + { + "name": "multiple_files_download_outer_row_width", + "value": "100%" + }, + { + "name": "multiple_files_download_transfer_list", + "value": "传输列表" + }, + { + "name": "multiple_files_download_queue", + "value": "下载队列 " + }, + { + "name": "multiple_files_download_completed", + "value": "下载已完成" + }, + { + "name": "multiple_files_download_function_only_display_purposes", + "value": "功能仅做展示" + }, + { + "name": "multiple_files_download_list", + "value": "下载列表" + }, + { + "name": "multiple_files_download_file_upload", + "value": "文件上传" + }, + { + "name": "multiple_files_download_album_backup", + "value": "下载历史" + }, + { + "name": "multiple_files_download_row_height", + "value": "30%" + }, + { + "name": "multiple_files_download_list_width", + "value": "100%" + }, + { + "name": "multiple_files_download_list_height", + "value": "80%" + }, + { + "name": "multiple_files_download_history_button_del", + "value": "删除" + }, + { + "name": "multiple_files_download_history_toast_text_del", + "value": "文件已删除" + }, + { + "name": "multiple_files_download_history_text_downloaded", + "value": "已下载" + }, + { + "name": "multiple_files_download_history_button_text_cancel", + "value": "取消" + }, + { + "name": "multiple_files_download_history_button_text_confirm", + "value": "确定" + }, + { + "name": "multiple_files_download_history_toast_text_exist", + "value": "文件已存在" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/background.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/foreground.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/layered_image.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_file.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_file.png new file mode 100644 index 0000000000000000000000000000000000000000..a323e4d76acc869e00672162e540167576b93c71 Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_file.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_start.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_start.png new file mode 100644 index 0000000000000000000000000000000000000000..78100dcba58fcc7cc98d979fe5f025653d823ecb Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_start.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png new file mode 100644 index 0000000000000000000000000000000000000000..5ba740178443c784ba961aec5dca4375b30f7f38 Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/startIcon.png b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/profile/backup_config.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/entry/src/main/resources/base/profile/main_pages.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/dark/element/color.json b/code/ArkTS1.2/DownLoadSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/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/DownLoadSample/hvigor/hvigor-config.json5 b/code/ArkTS1.2/DownLoadSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a9b16a8a74bd1e7b243bf7da0307d931f6574975 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "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/DownLoadSample/hvigorfile.ts b/code/ArkTS1.2/DownLoadSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/ArkTS1.2/DownLoadSample/oh-package.json5 b/code/ArkTS1.2/DownLoadSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9c36c086ae807ea710acd9e480cb6cc1d18bd011 --- /dev/null +++ b/code/ArkTS1.2/DownLoadSample/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +}