diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..100825ec6c1dc08abfce33ddcb7ab49c0a0b89c2 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.filesmanger", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..90766e847210497c6f38ab00665c99c11dfaa0b2 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FilesManger" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0210352ae2ade0dd7b4c841cb6e8ba08b4780038 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 1047d3ddcb34aa7af71e8c485e45a7d3ee008e45..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# FilesManger - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 0f6a9daf4efe9799a36a32bf9e5c9ff474986011..946b6adfdde9e4a036d173f6ed3b8dd72012df59 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,35 @@ -# FilesManger +# 数据和文件-文件管理 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +## 简介 -#### 软件架构 -软件架构说明 +实现文件管理相关的操作,包括应用文件保存与读取,用户文件图片读取,txt文档读取保存操作。便于用户根据codelab学习如何操作文件管理。 +![](screenshots/device/file.gif) -#### 安装教程 +## 相关概念 -1. xxxx -2. xxxx -3. xxxx +- 文件管理能力:该模块为基础文件操作API,提供基础文件操作能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。(@ohos.file.fs) +- 选择器: 选择器(Picker)是一个封装PhotoViewPicker、DocumentViewPicker、AudioViewPicker等API模块,具有选择与保存的能力。(@ohos.file.picker) +- 相册管理模块:该模块提供相册管理模块能力,包括创建相册以及访问、修改相册中的媒体数据信息等。(@ohos.file.photoAccessHelper) +- PhotoViewPicker:图库选择器对象,用来支撑选择图片/视频和保存图片/视频等用户场景。 +- DocumentViewPicker:文件选择器对象,用来支撑选择和保存各种格式文档。 -#### 使用说明 +## 相关权限 -1. xxxx -2. xxxx -3. xxxx +不涉及 -#### 参与贡献 +## 使用说明 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +1. 在输入框输入内容后,点击保存至应用沙箱目录,可以创建沙箱文件并将信息存储在沙箱文件下。 +2. 点击读取保存的文件内容,即可获取沙箱文件保存的内容。 +3. 点击保存图片按钮,可以将图片保存至图库中。 +4. 点击添加文件的图片,可以拉取图库,并挑选一张图片展示在页面上。 +5. 在输入框输入内容后,点击保存 test.txt至用户目录,可以拉取文件管理页面,创建文件并保存内容。 +6. 点击读取test.txt文件内容。可以拉取文件目录,挑选文件读取内容。 +## 约束与限制 -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 +2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 +3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 +4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d209fee432db4515940449ca8f4516144ae32cf6 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,35 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..197e83c1b9504b12a3837e0189185479662cad4b --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + "arkOptions": { + // "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/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/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# 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://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# 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 \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..225946cb11a2c405c8dc81eea89c22f923556638 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "license": "", + "devDependencies": {}, + "author": "", + "name": "entry", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/entry/src/main/ets/common/utils/Logger.ets b/entry/src/main/ets/common/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..8682d2ab830588b6c042f964700940a8a5ad1109 --- /dev/null +++ b/entry/src/main/ets/common/utils/Logger.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const LOGGER_PREFIX: string = 'File_Management' +class Logger { + private domain: number; + private prefix: string; + // format Indicates the log format string. + private format: string = '%{public}s, %{public}s'; + + /** + * constructor. + * + * @param prefix Identifies the log tag. + * @param domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF + * @param args Indicates the log parameters. + */ + constructor(prefix: string = '', domain: number = 0xFF00) { + this.prefix = prefix; + this.domain = domain; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger(LOGGER_PREFIX, 0xFF02); \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/PictureSaving.ets b/entry/src/main/ets/common/utils/PictureSaving.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ba8b3fe9a354cda83b04e42860befaa6f33006f --- /dev/null +++ b/entry/src/main/ets/common/utils/PictureSaving.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { picker } from '@kit.CoreFileKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import Logger from './Logger'; + +// Defines a URI array, which is used to receive the URI returned by PhotoViewPicker for selecting images. +let uris: Array = []; + +/** + * photoPickerGetUri. + * Returns the URI of the selected file based on the select method of PhotoViewPicker. + * @return Promise. + */ +export async function photoPickerGetUri(): Promise { + try { + let PhotoSelectOptions = new picker.PhotoSelectOptions(); + PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; + PhotoSelectOptions.maxSelectNumber = 1; + let photoPicker = new picker.PhotoViewPicker(); + await photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: picker.PhotoSelectResult) => { + Logger.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult)); + uris = PhotoSelectResult.photoUris; + }).catch((err: BusinessError) => { + Logger.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err)); + }); + } catch (error) { + let err = error as BusinessError; + Logger.error('PhotoViewPicker failed with err: ' + err.message); + } + return uris[0].toString(); +} diff --git a/entry/src/main/ets/common/utils/ReadFile.ets b/entry/src/main/ets/common/utils/ReadFile.ets new file mode 100644 index 0000000000000000000000000000000000000000..7998b100a4c41aaf757cc7eaec1fcef8e32f963e --- /dev/null +++ b/entry/src/main/ets/common/utils/ReadFile.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { fileIo } from '@kit.CoreFileKit'; +import { common } from '@kit.AbilityKit'; +import { buffer } from '@kit.ArkTS'; + +// Obtaining the Application File Path +let context = getContext(this) as common.UIAbilityContext; +let filesDir = context.filesDir; +let res: string = ''; + +/** + * readFile. + * Reads the contents of a file and returns a string. + * @return string. + */ +export function readFile(): string { + let filePath = filesDir + '/test.txt'; + let stat = fileIo.statSync(filePath); + let size = stat.size; + let buf = new ArrayBuffer(size); + // Open a file stream based on the file path. + let fileStream = fileIo.createStreamSync(filePath, "r+"); + // File stream reading information + fileStream.readSync(buf); + // Converts the read information to the string type and returns the string type. + let con = buffer.from(buf, 0); + res = con.toString(); + fileStream.close(); + return res; +} diff --git a/entry/src/main/ets/common/utils/SavingAndSelectUserFile.ets b/entry/src/main/ets/common/utils/SavingAndSelectUserFile.ets new file mode 100644 index 0000000000000000000000000000000000000000..62b56916dbd2e3b4a45446ea3479cdb9e54d4840 --- /dev/null +++ b/entry/src/main/ets/common/utils/SavingAndSelectUserFile.ets @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { picker, fileIo } from '@kit.CoreFileKit'; +import { buffer } from '@kit.ArkTS'; +import Logger from './Logger'; + +let uri: string = ''; +// Obtaining the Application File Path + +let message: string = ''; + +/** + * saveToUser. + * Save content to user directory file + * @param content Contents saved to a user directory file + */ +export async function saveToUser(content: string) { + try { + let DocumentSaveOptions = new picker.DocumentSaveOptions(); + DocumentSaveOptions.newFileNames = ['test.txt']; + let documentPicker = new picker.DocumentViewPicker(); + documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult: Array) => { + Logger.info('DocumentViewPicker.save successfully, uri: ' + JSON.stringify(DocumentSaveResult)); + uri = DocumentSaveResult[0]; + let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); + // Open a file stream based on the file path. + fileIo.writeSync(file.fd, content); + }).catch((err: BusinessError) => { + Logger.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err)); + }); + } catch (error) { + let err: BusinessError = error as BusinessError; + Logger.error('DocumentViewPicker failed with err: ' + err.message); + } +} + +/** + * readUserFile. + * Reads the contents of a user directory file. + * @return Promise. + */ +export async function readUserFile(): Promise { + try { + let DocumentSelectOptions = new picker.DocumentSelectOptions(); + let documentPicker = new picker.DocumentViewPicker(); + await documentPicker.select(DocumentSelectOptions).then((DocumentSelectResult: Array) => { + Logger.info('DocumentViewPicker.select successfully, uri: ' + JSON.stringify(DocumentSelectResult)); + uri = DocumentSelectResult[0]; + let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); + let stat = fileIo.statSync(file.fd); + let size = stat.size; + let buf = new ArrayBuffer(size); + fileIo.readSync(file.fd, buf); + let con = buffer.from(buf, 0); + message = con.toString(); + Logger.info('DocumentViewPicker.select successfully, message: ' + message); + return message; + }).catch((err: BusinessError) => { + Logger.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err)); + }); + } catch (error) { + let err = error as BusinessError; + Logger.error('DocumentViewPicker.select failed with err: ' + err.message); + } + return message; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/WriteFile.ets b/entry/src/main/ets/common/utils/WriteFile.ets new file mode 100644 index 0000000000000000000000000000000000000000..59a958c20562e4460b102521c1800075d5456564 --- /dev/null +++ b/entry/src/main/ets/common/utils/WriteFile.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { fileIo } from '@kit.CoreFileKit'; +import { common } from '@kit.AbilityKit'; + +let context = getContext(this) as common.UIAbilityContext; +let filesDir = context.filesDir; + +/** + * writeFile. + * Write content to a file + * @param content Contents to be written to the file + */ +export function writeFile(content: string): void { + let filePath = filesDir + '/test.txt'; + // Open a file stream based on the file path. + let fileStream = fileIo.createStreamSync(filePath, "w+"); + fileStream.writeSync(content); + fileStream.close(); +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..43d55fab40beb98493dfd1a258c0264da3b107c7 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/HomePage', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/entry/src/main/ets/pages/HomePage.ets b/entry/src/main/ets/pages/HomePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..eafdd35a359b667362e333bf3dc2bc74adbdbb0c --- /dev/null +++ b/entry/src/main/ets/pages/HomePage.ets @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ApplicationFileTab } from '../view/ApplicationFileTab'; +import { publicFilesTab } from '../view/PublicFilesTab'; + +@Entry +@Component +struct HomePage { + build() { + Column() { + Column() { + Text($r('app.string.title')) + .width($r('app.float.default_312')) + .height($r('app.float.default_41')) + .textAlign(TextAlign.Start) + .fontSize($r('app.float.default_30')) + .fontFamily('HarmonyHeiTi-Bold') + .fontColor($r('app.color.text_color')) + .lineHeight($r('app.float.default_41')) + .fontWeight(700) + .margin({ + top: $r('app.float.default_7'), + bottom: $r('app.float.default_8'), + left: $r('app.float.default_24'), + right: $r('app.float.default_24') + }) + } + .width($r('app.float.default_360')) + .height($r('app.float.default_56')) + + Tabs() { + TabContent() { + ApplicationFileTab() + } + .tabBar(new SubTabBarStyle($r('app.string.bar1')) + .indicator({ marginTop: $r('app.float.default_8') }) + .labelStyle({ font: { size: $r('app.float.default_16') } }) + ) + + TabContent() { + Scroll() { + publicFilesTab() + } + .height($r('app.float.default_680')) + } + .height('100%') + .tabBar(new SubTabBarStyle($r('app.string.bar2')) + .indicator({marginTop : $r('app.float.default_8')}) + .labelStyle({font : {size : $r('app.float.default_16')}}) + ) + } + .barWidth($r('app.float.default_200')) + .barHeight($r('app.float.default_56')) + .width('100%') + } + .backgroundColor($r('app.color.picture_background')) + .justifyContent(FlexAlign.Center) + .width('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/ApplicationFileTab.ets b/entry/src/main/ets/view/ApplicationFileTab.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d6057d947143e9b571ee48fc9767446989c4a44 --- /dev/null +++ b/entry/src/main/ets/view/ApplicationFileTab.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { readFile } from '../common/utils/ReadFile'; +import { writeFile } from '../common/utils/WriteFile'; + +@Component +export struct ApplicationFileTab { + // Used to record the read content. + @State message: string = ''; + // Used to record the contents of a text box. + @State content: string = ''; + + build() { + Column() { + Text($r('app.string.textarea_default')) + .width($r('app.float.default_294')) + .height($r('app.float.default_22')) + .fontColor($r('app.color.text_color')) + .fontWeight(500) + .fontSize($r('app.float.default_16')) + .fontFamily('HarmonyHeiTi-Medium') + .lineHeight($r('app.float.default_22')) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.default_13'), + bottom: $r('app.float.default_13'), + right: $r('app.float.default_8') + }) + TextArea({ text: this.content }) + .width($r('app.float.default_336')) + .height($r('app.float.default_139')) + .borderRadius($r('app.float.default_24')) + .backgroundColor($r('app.color.start_window_background')) + .enableKeyboardOnFocus(false) + .onChange((value: string) => { + this.content = value + }) + Text($r('app.string.file_content')) + .width($r('app.float.default_294')) + .height($r('app.float.default_22')) + .fontSize($r('app.float.default_16')) + .lineHeight($r('app.float.default_22')) + .fontWeight(500) + .margin({ + top: $r('app.float.default_13'), + bottom: $r('app.float.default_13'), + right: $r('app.float.default_8') + }) + TextArea({ text: this.message }) + .enableKeyboardOnFocus(false) + .width($r('app.float.default_336')) + .height($r('app.float.default_139')) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius($r('app.float.default_24')) + + Column() { + Button($r('app.string.button1')) + .width($r('app.float.default_312')) + .height($r('app.float.default_40')) + // Write the information and clear the content so that the text box is cleared after you click Save. + .onClick(() => { + writeFile(this.content); + this.content = '' + }) + Button($r('app.string.button2')) + .width($r('app.float.default_312')) + .height($r('app.float.default_40')) + .margin({ top: $r('app.float.default_12'), bottom: $r('app.float.default_100') }) + .onClick(() => { + this.message = readFile(); + }) + } + .width('100%') + .margin({ top: $r('app.float.default_100') }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/PublicFilesTab.ets b/entry/src/main/ets/view/PublicFilesTab.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff9e90d96146b7f4816d73c5b48f60671a135c46 --- /dev/null +++ b/entry/src/main/ets/view/PublicFilesTab.ets @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { photoAccessHelper } from '@kit.MediaLibraryKit'; +import { fileIo } from '@kit.CoreFileKit'; +import Logger from '../common/utils/Logger'; +import { readUserFile, saveToUser } from '../common/utils/SavingAndSelectUserFile'; +import { photoPickerGetUri } from '../common/utils/PictureSaving'; + +@Component +export struct publicFilesTab { + @State picture: string = ''; + @State flag: Boolean = false; + @State message: string = ''; + @State content: string = ''; + @State isInput: Boolean = false; + // Setting the button properties of a security control + @State saveButtonOptions: SaveButtonOptions = { + icon: SaveIconStyle.FULL_FILLED, + text: SaveDescription.SAVE_IMAGE, + buttonType: ButtonType.Capsule + } + + build() { + Column() { + Column() { + Image($r('app.media.img')) + .borderRadius($r('app.float.default_24')) + .width($r('app.float.default_312')) + .height($r('app.float.default_147')) + // Create Security Control Button + SaveButton(this.saveButtonOptions) + .onClick(async (event, result: SaveButtonOnClickResult) => { + if (result == SaveButtonOnClickResult.SUCCESS) { + try { + Logger.info('createAsset successfully, event: ' + event); + let context = getContext(); + let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); + // Creating a Media File + let uri = await phAccessHelper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpg'); + Logger.info('createAsset successfully, uri: ' + uri); + // Open the created media file and read the local file and convert it to ArrayBuffer for easy filling. + let file = await fileIo.open(uri, fileIo.OpenMode.READ_WRITE); + let buffer = getContext(this).resourceManager.getMediaContentSync($r('app.media.img').id); + // Write the read ArrayBuffer to the new media file. + let writeLen = await fileIo.write(file.fd, buffer.buffer); + Logger.info('write success,len=' + writeLen); + await fileIo.close(file); + } catch (err) { + Logger.error('createAsset failed, message = ', err); + } + } else { + Logger.error('SaveButtonOnClickResult createAsset failed'); + } + }) + } + .margin({ bottom: $r('app.float.default_10') }) + .width($r('app.float.default_336')) + .height($r('app.float.default_223')) + .borderRadius($r('app.float.default_24')) + .justifyContent(FlexAlign.SpaceAround) + .backgroundColor($r('app.color.start_window_background')) + + Column() { + Text($r('app.string.select_photo')) + .width($r('app.float.default_302')) + .height($r('app.float.default_48')) + .lineHeight($r('app.float.default_22')) + .fontFamily('HarmonyHeiTi-Medium') + .fontSize($r('app.float.default_16')) + .fontWeight(500) + .textAlign(TextAlign.Start) + .fontColor($r('app.color.text_color')) + Column() { + if (!this.flag) { + Image($r('app.media.ic_folder_add2')) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .objectFit(ImageFit.Contain) + } else { + Image(this.picture) + .width('100%') + .height('100%') + .borderRadius($r('app.float.default_24')) + } + } + .width($r('app.float.default_312')) + .height($r('app.float.default_147')) + .borderRadius($r('app.float.default_16')) + .backgroundColor($r('app.color.picture_background')) + .onClick(async () => { + await photoPickerGetUri().then(value => { + this.flag = true; + this.picture = value; + }); + }) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + } + .margin({ bottom: $r('app.float.default_10') }) + .backgroundColor($r('app.color.start_window_background')) + .width($r('app.float.default_336')) + .height($r('app.float.default_213')) + .borderRadius($r('app.float.default_24')) + + Column() { + TextArea({ placeholder: $r('app.string.textarea_default2'), text: this.isInput ? this.content : this.message }) + .onChange((value: string) => { + this.content = value; + }) + .width($r('app.float.default_312')) + .height($r('app.float.default_120')) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + .enableKeyboardOnFocus(false) + Button($r('app.string.button3')) + .width($r('app.float.default_312')) + .height($r('app.float.default_40')) + .onClick(() => { + saveToUser(this.content) + this.content = ''; + this.isInput = true; + }) + .margin({ bottom: $r('app.float.default_10') }) + Button($r('app.string.button4')) + .width($r('app.float.default_312')) + .height($r('app.float.default_40')) + .onClick(async () => { + await readUserFile().then((value: string) => { + this.message = value; + this.isInput = false; + }) + }) + } + .backgroundColor($r('app.color.start_window_background')) + .width($r('app.float.default_336')) + .height('251') + .borderRadius($r('app.float.default_24')) + .margin({ bottom: $r('app.float.default_100') }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6c07d9d8839ac9716809c6e06c21805d52c138fe --- /dev/null +++ b/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:icon", + "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/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..6ee11fc52269f504193a75dd585ddb841384affb --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,17 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_color", + "value": "#182431" + }, + { + "name": "picture_background", + "value": "#0D182431" + } + + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/dimen.json b/entry/src/main/resources/base/element/dimen.json new file mode 100644 index 0000000000000000000000000000000000000000..b7935dfba76ebe37e91265582499eaceb0f6aad8 --- /dev/null +++ b/entry/src/main/resources/base/element/dimen.json @@ -0,0 +1,116 @@ +{ + "float": [ + { + "name": "default_22", + "value": "22vp" + }, + { + "name": "default_24", + "value": "24vp" + }, + { + "name": "default_294", + "value": "294vp" + }, + { + "name": "default_312", + "value": "312vp" + }, + { + "name": "default_40", + "value": "40vp" + }, + { + "name": "default_16", + "value": "16vp" + }, + { + "name": "default_13", + "value": "13vp" + }, + { + "name": "default_336", + "value": "336vp" + }, + { + "name": "default_8", + "value": "8vp" + }, + { + "name": "default_139", + "value": "139vp" + }, + { + "name": "default_20", + "value": "20vp" + }, + { + "name": "default_100", + "value": "100vp" + }, + { + "name": "default_48", + "value": "48vp" + }, + { + "name": "default_147", + "value": "147vp" + }, + { + "name": "default_10", + "value": "10vp" + }, + { + "name": "default_223", + "value": "223vp" + }, + { + "name": "default_302", + "value": "302vp" + }, + { + "name": "default_213", + "value": "213vp" + }, + { + "name": "default_120", + "value": "120vp" + }, + { + "name": "default_251", + "value": "251vp" + }, + { + "name": "default_41", + "value": "41vp" + }, + { + "name": "default_30", + "value": "30vp" + }, + { + "name": "default_7", + "value": "7vp" + }, + { + "name": "default_360", + "value": "360vp" + }, + { + "name": "default_56", + "value": "56vp" + }, + { + "name": "default_680", + "value": "680vp" + }, + { + "name": "default_200", + "value": "200vp" + }, + { + "name": "default_12", + "value": "12vp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..81213f2eb39e6bb47bcdbbdb8695b9ea6e5e8d74 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,60 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "文件管理" + }, + { + "name": "textarea_default", + "value": "Please enter the content to be saved to the file" + }, + { + "name": "file_content", + "value": "File Content" + }, + { + "name": "button1", + "value": "Save to the application sandbox directory" + }, + { + "name": "button2", + "value": "Reads the saved file content." + }, + { + "name": "title", + "value": "File Management" + }, + { + "name": "bar1", + "value": "Application File" + }, + { + "name": "bar2", + "value": "Public file" + }, + { + "name": "select_photo", + "value": "Select an image from the gallery to display." + }, + { + "name": "textarea_default2", + "value": "File Contents..." + }, + { + "name": "button3", + "value": "Save the test.txt file to the user directory." + }, + { + "name": "button4", + "value": "Reading the content of the test.txt file" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_folder_add.png b/entry/src/main/resources/base/media/ic_folder_add.png new file mode 100644 index 0000000000000000000000000000000000000000..b8c8411e371dc64a7c1e09f77d4c0e090eb7f502 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_folder_add.png differ diff --git a/entry/src/main/resources/base/media/ic_folder_add2.png b/entry/src/main/resources/base/media/ic_folder_add2.png new file mode 100644 index 0000000000000000000000000000000000000000..f1d689c2b9a4d67a79497e79ee5ab9375890879f Binary files /dev/null and b/entry/src/main/resources/base/media/ic_folder_add2.png differ diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cd45accb1dfd2fd0da16c732c72faa6e46b26521 Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ diff --git a/entry/src/main/resources/base/media/img.png b/entry/src/main/resources/base/media/img.png new file mode 100644 index 0000000000000000000000000000000000000000..2c20a838ec51cffad1012dbc24f602c317a41970 Binary files /dev/null and b/entry/src/main/resources/base/media/img.png differ diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..366f76459ffd4494ec40d0ddd5c59385b9c5da11 Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..8607be393726d65baba7d64deacc51ce1c8f143d --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/HomePage" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b0bdb2ce5423eada2c04a5fb0abab5db1d4505eb --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,60 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "fileManagement" + }, + { + "name": "textarea_default", + "value": "Please enter the content to be saved to the file" + }, + { + "name": "file_content", + "value": "File Content" + }, + { + "name": "button1", + "value": "Save to the application sandbox directory" + }, + { + "name": "button2", + "value": "Reads the saved file content." + }, + { + "name": "title", + "value": "File Management" + }, + { + "name": "bar1", + "value": "Application File" + }, + { + "name": "bar2", + "value": "Public file" + }, + { + "name": "select_photo", + "value": "Select an image from the gallery to display." + }, + { + "name": "textarea_default2", + "value": "File Contents..." + }, + { + "name": "button3", + "value": "Save the test.txt file to the user directory." + }, + { + "name": "button4", + "value": "Reading the content of the test.txt file" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b944945596679ef162eb0f7348c6187eeb53f972 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,60 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "文件管理" + }, + { + "name": "textarea_default", + "value": "请输入保存至文件的内容" + }, + { + "name": "file_content", + "value": "文件内容" + }, + { + "name": "button1", + "value": "保存至应用沙箱目录" + }, + { + "name": "button2", + "value": "读取保存的文件内容" + }, + { + "name": "title", + "value": "文件管理" + }, + { + "name": "bar1", + "value": "应用文件" + }, + { + "name": "bar2", + "value": "公共文件" + }, + { + "name": "select_photo", + "value": "从图库中选择一张图片展示" + }, + { + "name": "textarea_default2", + "value": "文件内容..." + }, + { + "name": "button3", + "value": "保存test.txt至用户目录" + }, + { + "name": "button4", + "value": "读取test.txt文件内容" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0ce8c1f598ef975b2d64a1079d46e78a22a75cab --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "daemon": true, /* Enable daemon compilation. Default: true */ + // "incremental": true, /* Enable incremental compilation. Default: true */ + // "parallel": true, /* Enable parallel compilation. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Default: false */ + } +} \ No newline at end of file diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/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/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6656cdcd51fec3813d76bab1d0f1b72c1ff18a6c --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "modelVersion": "5.0.0", + "license": "", + "devDependencies": { + }, + "author": "", + "name": "filesmanger", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/screenshots/device/file.gif b/screenshots/device/file.gif new file mode 100644 index 0000000000000000000000000000000000000000..4a30e15e3493d06271205f397be014a786f26211 Binary files /dev/null and b/screenshots/device/file.gif differ