yangsunyue_wd

Revert "desc:隐私设置"

This reverts commit 98e1fc3a.
1 -import { PrivacySettingComponents} from 'wdComponent'; 1 +import { AboutPageUI} from 'wdComponent';
2 2
3 @Entry 3 @Entry
4 @Component 4 @Component
5 struct PrivacySettingPage { 5 struct PrivacySettingPage {
6 build() { 6 build() {
7 Column(){ 7 Column(){
8 - PrivacySettingComponents() 8 + AboutPageUI()
9 } 9 }
10 } 10 }
11 } 11 }
@@ -32,58 +32,6 @@ @@ -32,58 +32,6 @@
32 } 32 }
33 ] 33 ]
34 } 34 }
35 - ],  
36 - "requestPermissions": [  
37 - {  
38 - "name": "ohos.permission.CAMERA",  
39 - "reason": "$string:EntryAbility_desc",  
40 - "usedScene": {  
41 - "abilities": [  
42 - "FormAbility"  
43 - ],  
44 - "when": "inuse"  
45 - }  
46 - },  
47 - {  
48 - "name": "ohos.permission.READ_MEDIA",  
49 - "reason": "$string:EntryAbility_desc",  
50 - "usedScene": {  
51 - "abilities": [  
52 - "FormAbility"  
53 - ],  
54 - "when": "inuse"  
55 - }  
56 - },  
57 - {  
58 - "name": "ohos.permission.WRITE_MEDIA",  
59 - "reason": "$string:EntryAbility_desc",  
60 - "usedScene": {  
61 - "abilities": [  
62 - "FormAbility"  
63 - ],  
64 - "when": "inuse"  
65 - }  
66 - },  
67 - {  
68 - "name": "ohos.permission.LOCATION",  
69 - "reason": "$string:EntryAbility_desc",  
70 - "usedScene": {  
71 - "abilities": [  
72 - "FormAbility"  
73 - ],  
74 - "when": "inuse"  
75 - }  
76 - },  
77 - {  
78 - "name": "ohos.permission.MICROPHONE",  
79 - "reason": "$string:EntryAbility_desc",  
80 - "usedScene": {  
81 - "abilities": [  
82 - "FormAbility"  
83 - ],  
84 - "when": "inuse"  
85 - }  
86 - }  
87 ] 35 ]
88 } 36 }
89 } 37 }
@@ -32,6 +32,4 @@ export { MineSettingComponent } from "./components/page/MineSettingComponent" @@ -32,6 +32,4 @@ export { MineSettingComponent } from "./components/page/MineSettingComponent"
32 32
33 export { AboutPageUI } from "./components/page/about/AboutPageUI" 33 export { AboutPageUI } from "./components/page/about/AboutPageUI"
34 34
35 -export { PrivacySettingComponents } from "./components/page/PrivacySettingComponents"  
36 -  
37 export { AppointmentListUI } from "./components/page/mine/AppointmentListUI" 35 export { AppointmentListUI } from "./components/page/mine/AppointmentListUI"
@@ -6,7 +6,6 @@ import { BottomNavDTO } from '../../repository/bean/BottomNavDTO'; @@ -6,7 +6,6 @@ import { BottomNavDTO } from '../../repository/bean/BottomNavDTO';
6 import { UIUtils } from '../../repository/UIUtils'; 6 import { UIUtils } from '../../repository/UIUtils';
7 import { MinePageComponent } from './MinePageComponent'; 7 import { MinePageComponent } from './MinePageComponent';
8 import PageViewModel from '../../viewmodel/PageViewModel'; 8 import PageViewModel from '../../viewmodel/PageViewModel';
9 -import RouteManager from '../../utils/RouteManager'  
10 9
11 import storageStatistics from "@ohos.file.storageStatistics"; 10 import storageStatistics from "@ohos.file.storageStatistics";
12 import { BusinessError } from '@ohos.base'; 11 import { BusinessError } from '@ohos.base';
@@ -66,9 +65,8 @@ export struct MineSettingComponent { @@ -66,9 +65,8 @@ export struct MineSettingComponent {
66 }.padding({ left: '27lpx' }) 65 }.padding({ left: '27lpx' })
67 .onClick(() => { 66 .onClick(() => {
68 console.log(subIndex + "") 67 console.log(subIndex + "")
69 - if (subIndex == 2) { 68 + if (subIndex == 4) {
70 // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面 69 // RouteManager.jumpNewPage("pages/SettingPage") // 调用跳转方法,跳转新页面
71 - RouteManager.jumpNewPage("pages/PrivacySettingPage")  
72 } 70 }
73 }) 71 })
74 .height('117lpx') 72 .height('117lpx')
1 -import dataPreferences from '@ohos.data.preferences';  
2 -import { PermissionUtil } from 'wdKit'  
3 -import { SPHelper } from 'wdKit'  
4 -import hilog from '@ohos.hilog';  
5 -import {PrivacySettingModel} from '../../viewmodel/PrivacySettingModel'  
6 -  
7 -const TAG = 'PrivacySettingComponents';  
8 -  
9 -@Component  
10 -export struct PrivacySettingComponents {  
11 - @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, null), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];  
12 - @State tips: string = '设置前可查阅'  
13 - @State privacyTips: string = '《隐私政策》'  
14 -  
15 - aboutToAppear() {  
16 - // 获取权限=  
17 - // SPHelper.default.save('sdf','sdf');  
18 - // this.initListData();  
19 - this.getPermissionStatus();  
20 - RefreshStatus;  
21 -  
22 - }  
23 -  
24 - // initListData(){  
25 - // let model1 = new PrivacySettingModel('开启个性推荐', false, null);  
26 - // let model2 = new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA');  
27 - // let model3 = new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA');  
28 - // let model4 = new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION');  
29 - // let model5 = new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE');  
30 - //  
31 - // this.listData.push(model1, model2, model3, model4, model5);  
32 - // }  
33 -  
34 - async getPermissionStatus(){  
35 - const permissionUtil = new PermissionUtil();  
36 - for (const element of this.listData) {  
37 - if (!element.permissionKey) {  
38 - continue;  
39 - }  
40 - const result = await permissionUtil.checkPermissions(element.permissionKey);  
41 - element.permission = result;  
42 - }  
43 - }  
44 -  
45 - build() {  
46 - Navigation() {  
47 - //滑动区域  
48 - this.PrivacySettingComponentsUI()  
49 -  
50 - }.titleMode(NavigationTitleMode.Mini)  
51 - .title('隐私设置')  
52 - .backgroundColor('#F8F8F8')  
53 - }  
54 -  
55 - @Builder PrivacySettingComponentsUI() {  
56 - Column() {  
57 -  
58 - List({space:'23lpx'}){  
59 - ForEach(this.listData, (item:PrivacySettingModel, index) =>{  
60 - ListItem() {  
61 - if (index == 0) {  
62 - getTuiJianCell({item, index});  
63 - }else{  
64 - getArrowCell({item, index});  
65 - }  
66 - }.onClick(()=>{  
67 - if (index != 0) {  
68 - if (!item.permission){  
69 - //跳转权限设置  
70 - const permissionUtil = new PermissionUtil();  
71 - PermissionUtil.reqPermissionsFromUser([item.permissionKey]);  
72 - }  
73 - }  
74 - })  
75 - }, item => item)  
76 - }  
77 - .padding({left:'29lpx', right:'29lpx'})  
78 - .margin({top:'38lpx'})  
79 -  
80 - Row(){  
81 - Text(this.tips)  
82 - .fontSize('25lpx')  
83 - .textAlign(TextAlign.Start)  
84 - .fontColor($r("app.color.color_666666"))  
85 - .margin({left:'29lpx', top:'46lpx'})  
86 - // .backgroundColor(Color.Orange)  
87 - Text(this.privacyTips)  
88 - .fontSize('25lpx')  
89 - .textAlign(TextAlign.Start)  
90 - .fontColor('#ED2800')  
91 - .margin({top:'46lpx'})  
92 - .onClick(()=>{  
93 - //跳转隐私政策  
94 - })  
95 - }  
96 -  
97 -  
98 - }  
99 - .width('100%')  
100 - .height('100%')  
101 - .backgroundColor('#F8F8F8')  
102 - .alignItems(HorizontalAlign.Start)  
103 - }  
104 -}  
105 -  
106 -  
107 -@Component  
108 -struct getArrowCell {  
109 - @ObjectLink item: PrivacySettingModel;  
110 - index;  
111 - // 右文字+箭头cell  
112 - // @Builder getArrowCell(item:PrivacySettingModel, index) {  
113 - build() {  
114 - Row() {  
115 - // 左侧标题  
116 - Text(this.item.privacyName)  
117 - .fontColor('#666666')  
118 - .fontSize('31lpx')  
119 -  
120 - Row() {  
121 - Text(this.item.permission ? '已开启' : '去设置')  
122 - .fontColor(this.item.permission ? '#666666' : '#CCCCCC')  
123 - .fontSize('31lpx')  
124 - .margin({ right: '8lpx' })  
125 -  
126 - Image($r('app.media.mine_user_arrow'))  
127 - .width('27lpx')  
128 - .height('27lpx')  
129 - .objectFit(ImageFit.Auto)  
130 - }  
131 -  
132 - }  
133 - .alignItems(VerticalAlign.Center)  
134 - .justifyContent(FlexAlign.SpaceBetween)  
135 - .height('97lpx')  
136 - .width('100%')  
137 - .padding({ left: '29lpx', right: '29lpx' })  
138 - .backgroundColor('#FFFFFF')  
139 - .borderRadius('8lpx')  
140 - }  
141 -}  
142 -  
143 -@Component  
144 -struct getTuiJianCell{  
145 - @ObjectLink item :PrivacySettingModel;  
146 - index;  
147 - build() {  
148 - //@Builder getTuiJianCell(item:PrivacySettingModel, index)  
149 - Column() {  
150 -  
151 - Row() {  
152 - // 左侧标题  
153 - Text(this.item.privacyName)  
154 - .fontColor('#666666')  
155 - .fontSize('31lpx')  
156 -  
157 - Row() {  
158 - Toggle({ type: ToggleType.Switch, isOn: this.item.permission })  
159 - .height('58lpx')  
160 - .width('96lpx')  
161 - // .selectedColor(Color.Pink)  
162 - .onChange((isOn: boolean) => {  
163 - // this.privacySwitch = isOn;  
164 - })  
165 - }  
166 -  
167 - }  
168 - .alignItems(VerticalAlign.Center)  
169 - .justifyContent(FlexAlign.SpaceBetween)  
170 - .height('97lpx')  
171 - .width('100%')  
172 -  
173 -  
174 - Blank()  
175 - .backgroundColor('#EDEDED')  
176 - .height('1lpx')  
177 -  
178 - Text('关闭后,将无法看到个性化推荐的服务')  
179 - .fontColor('#999999')  
180 - .fontSize('23lpx')  
181 - .margin({ right: '8lpx' })  
182 - .height('69lpx')  
183 -  
184 - }  
185 - .alignItems(HorizontalAlign.Start)  
186 - .backgroundColor('#FFFFFF')  
187 - .borderRadius('8lpx')  
188 - .padding({ left: '29lpx', right: '29lpx' })  
189 - }  
190 -}  
@@ -2,53 +2,28 @@ const TAG = 'AboutPageUI'; @@ -2,53 +2,28 @@ const TAG = 'AboutPageUI';
2 2
3 @Component 3 @Component
4 export struct AboutPageUI { 4 export struct AboutPageUI {
5 - @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];  
6 @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' 5 @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
7 @State version: string = '版本号:v8.0.1.1' 6 @State version: string = '版本号:v8.0.1.1'
8 7
9 8
10 build() { 9 build() {
11 - Navigation() {  
12 - //滑动区域  
13 - this.aboutUi()  
14 - }.titleMode(NavigationTitleMode.Mini)  
15 - .title('关于')  
16 - }  
17 -  
18 - @Builder aboutUi() {  
19 Column() { 10 Column() {
20 Image($r('app.media.setting_about_logo')) 11 Image($r('app.media.setting_about_logo'))
21 .width('278lpx') 12 .width('278lpx')
22 .height('154lpx') 13 .height('154lpx')
23 .margin({top:'173lpx',bottom:'154lpx'}) 14 .margin({top:'173lpx',bottom:'154lpx'})
24 15
25 - // Row(){  
26 - //  
27 - // }.backgroundColor(Color.Yellow)  
28 - // .width('100%')  
29 - // .height('97lpx')  
30 -  
31 - // Row(){  
32 - //  
33 - // }.backgroundColor(Color.Yellow)  
34 - // .width('100%')  
35 - // .height('97lpx')  
36 - 16 + Row(){
37 17
  18 + }.backgroundColor(Color.Yellow)
  19 + .width('100%')
  20 + .height('97lpx')
38 21
  22 + Row(){
39 23
40 - List(){  
41 - ForEach(this.listData, (item, index) =>{  
42 - ListItem() {  
43 - this.getArrowCell(item, index)  
44 - }  
45 - }, item => item)  
46 - }.divider({  
47 - strokeWidth: 1,  
48 - startMargin: '29lpx',  
49 - endMargin: '29lpx',  
50 - color: '#EDEDED'  
51 - }) 24 + }.backgroundColor(Color.Yellow)
  25 + .width('100%')
  26 + .height('97lpx')
52 27
53 Blank() 28 Blank()
54 29
@@ -71,31 +46,4 @@ export struct AboutPageUI { @@ -71,31 +46,4 @@ export struct AboutPageUI {
71 .width('100%') 46 .width('100%')
72 .height('100%') 47 .height('100%')
73 } 48 }
74 -  
75 -  
76 -  
77 - // 右文字+箭头cell  
78 - @Builder getArrowCell(item, index) {  
79 -  
80 - Row() {  
81 - // 左侧标题  
82 - Text(`${item}`)  
83 - .fontColor('#666666')  
84 - .fontSize('31lpx')  
85 -  
86 - Image($r('app.media.mine_user_arrow'))  
87 - .width('27lpx')  
88 - .height('27lpx')  
89 - .objectFit(ImageFit.Auto)  
90 - }  
91 - .alignItems(VerticalAlign.Center)  
92 - .justifyContent(FlexAlign.SpaceBetween)  
93 - .height('97lpx')  
94 - .width('100%')  
95 - .padding({left:'29lpx',right:'29lpx'})  
96 - }  
97 -  
98 -  
99 -}  
100 -  
101 - 49 +}
@@ -67,10 +67,7 @@ export default struct MinePageMoreFunctionUI{ @@ -67,10 +67,7 @@ export default struct MinePageMoreFunctionUI{
67 console.log(index+"") 67 console.log(index+"")
68 if (index == 3) { 68 if (index == 3) {
69 RouteManager.jumpNewPage("pages/SettingPage") 69 RouteManager.jumpNewPage("pages/SettingPage")
70 - } else if (index == 4) {  
71 - RouteManager.jumpNewPage("pages/SettingAboutPage")  
72 - }  
73 - else if (index == 2) { 70 + } else {
74 RouteManager.jumpNewPage("pages/PrivacySettingPage") 71 RouteManager.jumpNewPage("pages/PrivacySettingPage")
75 } 72 }
76 }) 73 })
1 -import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';  
2 -@Observed  
3 -export class PrivacySettingModel{  
4 - privacyName: string  
5 - permission: boolean  
6 - permissionKey: Permissions  
7 -  
8 - constructor(privacyName: string, permission: boolean, permissionKey: Permissions) {  
9 - this.privacyName = privacyName;  
10 - this.permission = permission;  
11 - this.permissionKey = permissionKey;  
12 - }  
13 -}  
@@ -14,6 +14,3 @@ export { DateTimeUtils } from './utils/DateTimeUtils' @@ -14,6 +14,3 @@ export { DateTimeUtils } from './utils/DateTimeUtils'
14 14
15 export { AppContext } from './utils/AppContext' 15 export { AppContext } from './utils/AppContext'
16 16
17 -export { PermissionUtil } from './utils/PermissionUtil'  
18 -  
19 -export { SPHelper } from './utils/SPHelper'  
1 -import bundleManager from '@ohos.bundle.bundleManager';  
2 -import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';  
3 -import common from '@ohos.app.ability.common';  
4 -import featureAbility from '@ohos.ability.featureAbility';  
5 -import wantConstant from '@ohos.ability.wantConstant';  
6 -  
7 -export class PermissionUtil {  
8 - async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {  
9 - let atManager = abilityAccessCtrl.createAtManager();  
10 - let grantStatus: abilityAccessCtrl.GrantStatus;  
11 -  
12 - // 获取应用程序的accessTokenID  
13 - let tokenId: number;  
14 - try {  
15 - let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);  
16 - let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;  
17 - tokenId = appInfo.accessTokenId;  
18 - } catch (err) {  
19 - console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`);  
20 - }  
21 -  
22 - // 校验应用是否被授予权限  
23 - try {  
24 - grantStatus = await atManager.checkAccessToken(tokenId, permission);  
25 - } catch (err) {  
26 - console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`);  
27 - }  
28 -  
29 - return grantStatus;  
30 - }  
31 -  
32 - async checkPermissions(permission: Permissions): Promise<boolean> {  
33 - let hasPermissions = false;  
34 - let grantStatus: abilityAccessCtrl.GrantStatus = await this.checkAccessToken(permission);  
35 -  
36 - if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {  
37 - // 已经授权,可以继续访问目标操作  
38 - hasPermissions = true;  
39 - } else {  
40 - hasPermissions = false;  
41 - // 申请日历权限  
42 - }  
43 - return hasPermissions;  
44 - }  
45 -  
46 - static reqPermissionsFromUser(permissions: Array<Permissions>): void {  
47 - let context = getContext(this) as common.UIAbilityContext;  
48 - let atManager = abilityAccessCtrl.createAtManager();  
49 - // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗  
50 - atManager.requestPermissionsFromUser(context, permissions).then((data) => {  
51 - let grantStatus: Array<number> = data.authResults;  
52 - let length: number = grantStatus.length;  
53 - for (let i = 0; i < length; i++) {  
54 - if (grantStatus[i] === 0) {  
55 - // 用户授权,可以继续访问目标操作  
56 -  
57 - } else {  
58 -  
59 - this.jumpSetting();  
60 - // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限  
61 - AlertDialog.show({  
62 - title: '权限设置',  
63 - message: '到系统设置中打开相应的权限',  
64 - confirm: {  
65 - value: "OK",  
66 - action: () => {  
67 -  
68 - },  
69 - }  
70 - })  
71 - return;  
72 - }  
73 - }  
74 - // 授权成功  
75 - }).catch((err) => {  
76 - console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);  
77 - })  
78 - }  
79 -  
80 -  
81 - static jumpSetting() {  
82 -  
83 - }  
84 -}