diff --git a/AppPrivacyProtection/README.en.md b/AppPrivacyProtection/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..0bd75f2f043e9d46dae48c8796726d90c3e6d54b --- /dev/null +++ b/AppPrivacyProtection/README.en.md @@ -0,0 +1,54 @@ +# Application Privacy Protection + +### Overview + +This sample implements functions such as requesting approximate application location, selecting gallery files, and requesting sensitive permissions. + +### Preview + +| Requesting the Approximate Location Permission | Using Picker to Obtain Photos | Requesting the Camera Permission | +|------------------------------------------------|----------------------------------------------|----------------------------------------------| +| ![pic1.png](screenshots/devices/pic1.en.png) | ![pic2.png](screenshots/devices/pic3.en.png) | ![pic3.png](screenshots/devices/pic4.en.png) | + + +### Project Directory + +``` +├──entry/src/main/ets/ +│ ├──entryability +│ │ └──EntryAbility.ets // Entry ability lifecycle callbacks +│ ├──pages +│ │ ├──ApproximatelyLocationDemo.ets // Approximate location demo +│ │ ├──Index.ets // Application entry +│ │ ├──LocationButtonDemo.ets // LocationButton demo +│ │ └──PickerDemo.ets // PhotoViewPicker demo +│ └──utils +│ └──Logger.ets // Log utility +└──entry/src/main/resources // Static resources +``` + +### How to Implement + +* Call [getCurrentLocation](https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-geolocationmanager-V5#geolocationmanagergetcurrentlocation-2) in the **geoLocationManager** module to obtain the location information. For details, see [Obtaining Device Location Information](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/location-guidelines-V5). +* Use **PhotoViewPicker** to obtain the user photo. For details, see [Selecting User Files](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/select-user-file-V5). + +### Required Permissions + +**ohos.permission.APPROXIMATELY_LOCATION**: allows an application to obtain the approximate location information of a device. + +**ohos.permission.CAMERA**: allows an application to use the camera. + + +### Dependencies + +N/A + +### Constraints + +1. This sample is supported only on Huawei phones running the standard system. + +2. The HarmonyOS version must be HarmonyOS NEXT Beta 1 or later. + +3. The DevEco Studio version must be DevEco Studio NEXT Beta1 or later. + +4. The HarmonyOS SDK version must be HarmonyOS NEXT Beta1 SDK or later. diff --git a/AppPrivacyProtection/README.md b/AppPrivacyProtection/README.md index 852e3ae45b64834476fecbd1ab7b406b07142c83..ba35a0084b59bae181329bcbcceadbf3309dd842 100644 --- a/AppPrivacyProtection/README.md +++ b/AppPrivacyProtection/README.md @@ -6,9 +6,9 @@ ### 效果预览 -| 模糊定位权限申请 | LocationButton | 使用Picker获取图片 | 相机权限申请 | -|-------------------------------------------|-----------------------------------------|-------------------------------------------|-------------------------------------------| -| ![pic1.png](screenshots/devices/pic1.png) | ![pic2.png](screenshots/devices/pic2.png) | ![pic1.png](screenshots/devices/pic3.png) | ![pic3.png](screenshots/devices/pic4.png) | +| 模糊定位权限申请 | 使用Picker获取图片 | 相机权限申请 | +|-------------------------------------------|-------------------------------------------|-------------------------------------------| +| ![pic1.png](screenshots/devices/pic1.png) | ![pic2.png](screenshots/devices/pic3.png) | ![pic3.png](screenshots/devices/pic4.png) | ### 目录结构 @@ -19,7 +19,6 @@ │ ├──pages │ │ ├──ApproximatelyLocationDemo.ets // 模糊定位示例 │ │ ├──Index.ets // 应用入口页 -│ │ ├──LocationButtonDemo.ets // 位置控件示例 │ │ └──PickerDemo.ets // 文件选择器示例 │ └──utils │ └──Logger.ets // 日志工具类 @@ -29,7 +28,6 @@ ### 具体实现 * 使用geoLocationManager模块的[getCurrentLocation](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-geolocationmanager-V5#geolocationmanagergetcurrentlocation-2)方法获取位置信息,参考:[获取设备的位置信息开发指导](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/location-guidelines-V5)。 -* 使用安全控件LocationButton获取位置信息,参考:[使用位置控件](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/locationbutton-V5)。 * 获取用户图片通过PhotoViewPicker来实现,参考:[选择用户文件](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/select-user-file-V5)。 ### 相关权限 diff --git a/AppPrivacyProtection/entry/src/main/ets/pages/Index.ets b/AppPrivacyProtection/entry/src/main/ets/pages/Index.ets index 6d204101d1e0356a8c1829add0315083217ed7e4..5955de18fec54c943b1c4457b022abfdff7de58f 100644 --- a/AppPrivacyProtection/entry/src/main/ets/pages/Index.ets +++ b/AppPrivacyProtection/entry/src/main/ets/pages/Index.ets @@ -57,12 +57,6 @@ struct Index { .onClick(() => { router.pushUrl({ url: 'pages/ApproximatelyLocationDemo' }); }) - Button($r('app.string.use_location_button')) - .height(40) - .width('100%') - .onClick(() => { - router.pushUrl({ url: 'pages/LocationButtonDemo' }); - }) Button($r('app.string.use_picker')) .height(40) .width('100%') diff --git a/AppPrivacyProtection/entry/src/main/ets/pages/LocationButtonDemo.ets b/AppPrivacyProtection/entry/src/main/ets/pages/LocationButtonDemo.ets deleted file mode 100644 index 3f6a7ffc96b557cf335bb0f15f43ecc40d396b34..0000000000000000000000000000000000000000 --- a/AppPrivacyProtection/entry/src/main/ets/pages/LocationButtonDemo.ets +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024 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 { geoLocationManager } from '@kit.LocationKit'; -import { BusinessError } from '@kit.BasicServicesKit'; -import Logger from '../utils/Logger'; - -@Entry -@Component -struct LocationButtonDemo { - @State message: ResourceStr = ''; - requestInfo: geoLocationManager.LocationRequest = { - 'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, - 'scenario': geoLocationManager.LocationRequestScenario.UNSET, - 'timeInterval': 1, - 'distanceInterval': 0, - 'maxAccuracy': 0 - }; - locationChange = (err: BusinessError, location: geoLocationManager.Location) => { - if (err) { - Logger.error(`locationChante: err: ${JSON.stringify(err)}`) - return; - } - if (location) { - this.message = $r('app.string.punch_successfully'); - } - } - - build() { - Column() { - Text(this.message) - .fontSize(20) - .margin({ bottom: 12 }) - - LocationButton({ - icon: LocationIconStyle.LINES, - text: LocationDescription.PUNCH_IN, - buttonType: ButtonType.Circle - }) - .onClick((event, result) => { - if (result === LocationButtonOnClickResult.SUCCESS) { - geoLocationManager.getCurrentLocation(this.requestInfo, this.locationChange); - } - }) - } - .width('100%') - .height('100%') - .justifyContent(FlexAlign.Center) - } -} \ No newline at end of file diff --git a/AppPrivacyProtection/entry/src/main/resources/base/element/string.json b/AppPrivacyProtection/entry/src/main/resources/base/element/string.json index 8437d99d169280c22a77277685bdd713b047085b..77add0bd440aff19ab203f2fa32971aa790ffb3e 100644 --- a/AppPrivacyProtection/entry/src/main/resources/base/element/string.json +++ b/AppPrivacyProtection/entry/src/main/resources/base/element/string.json @@ -24,10 +24,6 @@ "name": "get_approximately_location", "value": "Get approximately location" }, - { - "name": "use_location_button", - "value": "Use location button" - }, { "name": "use_picker", "value": "Accessing files using picker" @@ -40,10 +36,6 @@ "name": "use_approximately_location", "value": "Use approximately location" }, - { - "name": "punch_successfully", - "value": "Punch successfully" - }, { "name": "select_picture", "value": "Select picture" diff --git a/AppPrivacyProtection/entry/src/main/resources/base/profile/main_pages.json b/AppPrivacyProtection/entry/src/main/resources/base/profile/main_pages.json index 035c346e5176141b3a5b0cbe8235af35bc395361..988a875544dc38aad82c3fc697b838cd01179e8e 100644 --- a/AppPrivacyProtection/entry/src/main/resources/base/profile/main_pages.json +++ b/AppPrivacyProtection/entry/src/main/resources/base/profile/main_pages.json @@ -2,7 +2,6 @@ "src": [ "pages/Index", "pages/ApproximatelyLocationDemo", - "pages/LocationButtonDemo", "pages/PickerDemo" ] } \ No newline at end of file diff --git a/AppPrivacyProtection/entry/src/main/resources/en_US/element/string.json b/AppPrivacyProtection/entry/src/main/resources/en_US/element/string.json index 8437d99d169280c22a77277685bdd713b047085b..77add0bd440aff19ab203f2fa32971aa790ffb3e 100644 --- a/AppPrivacyProtection/entry/src/main/resources/en_US/element/string.json +++ b/AppPrivacyProtection/entry/src/main/resources/en_US/element/string.json @@ -24,10 +24,6 @@ "name": "get_approximately_location", "value": "Get approximately location" }, - { - "name": "use_location_button", - "value": "Use location button" - }, { "name": "use_picker", "value": "Accessing files using picker" @@ -40,10 +36,6 @@ "name": "use_approximately_location", "value": "Use approximately location" }, - { - "name": "punch_successfully", - "value": "Punch successfully" - }, { "name": "select_picture", "value": "Select picture" diff --git a/AppPrivacyProtection/entry/src/main/resources/zh_CN/element/string.json b/AppPrivacyProtection/entry/src/main/resources/zh_CN/element/string.json index 71ef19bcc4967138596153ffef53244821824a6a..eca2cde8d26bd7929907750b716c65ee4208c21c 100644 --- a/AppPrivacyProtection/entry/src/main/resources/zh_CN/element/string.json +++ b/AppPrivacyProtection/entry/src/main/resources/zh_CN/element/string.json @@ -24,10 +24,6 @@ "name": "get_approximately_location", "value": "使用模糊定位获取位置信息" }, - { - "name": "use_location_button", - "value": "使用LocationButton获取位置信息" - }, { "name": "use_picker", "value": "使用Picker访问文件" @@ -40,10 +36,6 @@ "name": "use_approximately_location", "value": "使用模糊定位" }, - { - "name": "punch_successfully", - "value": "打开成功" - }, { "name": "select_picture", "value": "选择图片" diff --git a/AppPrivacyProtection/screenshots/devices/pic1.en.png b/AppPrivacyProtection/screenshots/devices/pic1.en.png new file mode 100644 index 0000000000000000000000000000000000000000..6327274b6039c018bd36718c734992b192df4e74 Binary files /dev/null and b/AppPrivacyProtection/screenshots/devices/pic1.en.png differ diff --git a/AppPrivacyProtection/screenshots/devices/pic2.png b/AppPrivacyProtection/screenshots/devices/pic2.png deleted file mode 100644 index bcbb4f9e95483b097a7495731625249b37d86d82..0000000000000000000000000000000000000000 Binary files a/AppPrivacyProtection/screenshots/devices/pic2.png and /dev/null differ diff --git a/AppPrivacyProtection/screenshots/devices/pic3.en.png b/AppPrivacyProtection/screenshots/devices/pic3.en.png new file mode 100644 index 0000000000000000000000000000000000000000..327d817e12bd7fb5ce5bf5635c679942201a6d0d Binary files /dev/null and b/AppPrivacyProtection/screenshots/devices/pic3.en.png differ diff --git a/AppPrivacyProtection/screenshots/devices/pic4.en.png b/AppPrivacyProtection/screenshots/devices/pic4.en.png new file mode 100644 index 0000000000000000000000000000000000000000..58c2e5db68ca475ad06e9a65f5697bdccf42f909 Binary files /dev/null and b/AppPrivacyProtection/screenshots/devices/pic4.en.png differ diff --git a/AppPrivacyProtection/screenshots/devices/pic4.png b/AppPrivacyProtection/screenshots/devices/pic4.png index 195fd089a756b41f3605970578fe52e80f50954f..03585d3bef0dd88fd32bfae992dd622c62c5cdc3 100644 Binary files a/AppPrivacyProtection/screenshots/devices/pic4.png and b/AppPrivacyProtection/screenshots/devices/pic4.png differ