| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 35 | 33 | ||
| entry/ | 06-May-2025 | - | 1,763 | 1,572 | ||
| hvigor/ | 06-May-2025 | - | 23 | 8 | ||
| screenshots/devices/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 98 | 9 | 9 | |
| README_zh.md | D | 06-May-2025 | 5.5 KiB | 94 | 67 | |
| build-profile.json5 | D | 06-May-2025 | 1.1 KiB | 42 | 42 | |
| hvigorfile.ts | D | 06-May-2025 | 765 | 17 | 1 | |
| hvigorw | D | 06-May-2025 | 2 KiB | 64 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 73 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 859 | 28 | 26 | |
| ohosTest.md | D | 06-May-2025 | 1.5 KiB | 12 | 9 |
README_zh.md
1# 安全控件类型的UI控件(仅对系统应用开放) 2 3### 介绍 4 5本示例提供了安全控件类型的UI控件,支撑应用开发者集成安全控件做临时授权场景,当用户实际点击了某种类型的安全控件时,会对应用进行相应的临时授权,减少权限弹窗对用户的干扰,同时提供更小的授权范围。 6 7### 效果预览 8 9| 主页 | Location | Paste | **Save** | 10|:--------------------------------------:|:----------------------------------------------:|:----------------------------------------:|:--------------------------------------:| 11|  |  |  |  | 12 13使用说明 141. 在主界面,点击“LocationButton安全控件”按钮,进入“LocationButton安全控件”界面,点击“当前位置”按钮,成功获取当前定位信息,并显示在方框中。 15 162. 在主界面,点击“PasteButton安全控件”按钮,进入“PasteButton安全控件”界面,点击”复制“按钮,复制下方“天天开心”文本,点击“粘贴”按钮,获取剪贴板内容并显示在其下方框中。 17 183. 在主界面,点击“SaveButton安全控件”按钮,进入“SaveButton安全控件”界面,点击“下载”按钮,将当前页面中的图片保存到本地图库中。 19 20### 工程目录 21 22``` 23entry/src/main/ets/ 24|---securitycomponent 25| |---pages 26| | |---Location.ets // 位置服务安全控件界面 27| | |---Paste.ets // 剪贴板安全控件界面 28| | |---Save.ets // 媒体库安全控件界面 29|---pages 30| |---Index.ets // 首页 31|---common 32| |---Component 33| | |---AuthorizedButton.ets // 安全控件样式 34| | |---CopyButton.ets // 剪贴板复制控件 35| | |---LocationButton.ets // 位置服务安全控件 36| | |---PasteButton.ets // 剪贴板粘贴控件 37| | |---SaveButton.ets // 媒体库写入文件控件 38| | |---TitleBar.ets // 标题栏 39|---utils 40| |---Logger.ts // 日志工具 41``` 42 43### 具体实现 44 45* 本示例分为Location安全控件模块,剪贴板安全控件模块,媒体库安全控件模块 46 47 * Location安全控件模块 48 49 * 使用SecLocationButton组件开发获取定位信息功能,在其点击回调onclick事件中调用geoLocationManager.getCurrentLocation()得到当前定位信息经纬度 50 * 源码链接:[LocationButton.ets](entry/src/main/ets/common/Component/LocationButton.ets) 51 * 接口参考:[@ohos.geoLocationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-location-kit/js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation) 52 53 * 剪贴板安全控件模块 54 55 * 使用SecPasteButton组件开发获取剪贴板信息功能,在其点击回调onclick事件中调用ystemPasteboard.setData()将文本复制到剪贴板中,systemPasteboard.getData()得到剪贴板内容 56 * 源码链接:[PasteButton.ets](entry/src/main/ets/common/Component/PasteButton.ets) 57 * 接口参考:[@ohos.pasteboard](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-pasteboard.md#getdata9) 58 59 * 媒体库安全控件模块 60 61 * 使用SecSaveButton组件开发保存图片到媒体库功能,在其点击回调onclick事件中调用photoAccessHelper.getPhotoAccessHelper()得到媒体库图片管理器helper, 62 helper.createAsset()得到保存到媒体库图片的uri, 63 resourceManager.getMediaContent()得到存放在Resources/base/media文件下的banner.png图片内容, 64 fs.open()和fs.write()将图片内容通过得到的uri写到媒体库中,最后fs.close()关闭文件 65 * 源码链接:[SaveButton.ets](entry/src/main/ets/common/Component/SaveButton.ets) 66 * 接口参考:[@ohos.file.photoAccessHelper](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) 67 68### 相关权限 69 70不涉及。 71 72### 依赖 73 74不涉及。 75 76### 约束与限制 77 781. 本示例仅支持标准系统上运行,支持设备:GPS定位功能仅支持部分机型。 792. 本示例仅支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)。 803. 本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。 814. 本示例需要使用系统权限的系统接口,需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)。 82 83### 下载 84 85如需单独下载本工程,执行如下命令: 86 87``` 88git init 89git config core.sparsecheckout true 90echo code/SystemFeature/Security/AuthorizedButton/ > .git/info/sparse-checkout 91git remote add origin https://gitee.com/openharmony/applications_app_samples.git 92git pull origin master 93``` 94