1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 17import router from '@ohos.router'; 18import common from '@ohos.app.ability.common'; 19import { staffItem } from '../common/encryptionComponents/staff'; 20import Constants from '../common/constant'; 21import ability from '@ohos.ability.ability'; 22import { 23 AuthAccount, 24 PermissionType, 25 calculate, 26 toggleShow, 27 directionStatus, 28 getTime, 29} from '../common/utils'; 30import GlobalContext from '../common/GlobalContext'; 31import HomeFeature from '../feature/HomeFeature'; 32import { HiLog } from '../common/HiLog'; 33 34const TAG = 'EncSucc'; 35let abilityResult: ability.AbilityResult = { 36 'resultCode': 0, 37 'want': {} 38}; 39 40@Extend(Text) 41function customizeText() { 42 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 43 .fontSize($r('sys.float.ohos_id_text_size_button2')) 44 .fontWeight(FontWeight.Medium) 45} 46 47let storage: LocalStorage = LocalStorage.getShared(); 48@Entry(storage) 49@Component 50struct encryptionSuccess { 51 @State session: UIExtensionContentSession | undefined = storage === undefined ? undefined : storage.get<UIExtensionContentSession>('session'); 52 private routerParams: Record<string, AuthAccount[] | PermissionType> = 53 router.getParams() as Record<string, AuthAccount[] | PermissionType>; 54 @State directionStatus: number = 0; 55 @State flag: boolean = false; 56 @State editFlag: boolean = false; 57 @State readOnlyFlag: boolean = false; 58 @State handlePopupReadOnly: boolean = false; 59 @State handlePopupEdit: boolean = false; 60 @State rowNamesLenEdit: number = 0; 61 @State rowNamesLenReadOnly: number = 0; 62 @State hideNamesNumEdit: string = '0'; 63 @State hideNamesNumReadOnly: string = '0'; 64 @State showNamesArrEdit: AuthAccount[] = []; 65 @State showNamesArrReadOnly: AuthAccount[] = []; 66 @State staffDataArrayReadOnly: AuthAccount[] = this.routerParams.staffDataArrayReadOnly as AuthAccount[]; 67 @State staffDataArrayEdit: AuthAccount[] = this.routerParams.staffDataArrayEdit as AuthAccount[]; 68 69 @Builder popupBuilderReadOnly() { 70 Row() { 71 Text($r('app.string.header_title_readonly_tips')) 72 .fontFamily('HarmonyHeiTi') 73 .fontSize($r('sys.float.ohos_id_text_size_body2')) 74 .fontColor($r('sys.color.ohos_id_color_text_primary')) 75 } 76 .width(Constants.HEADER_COLUMN_MESSAGE_TIPS) 77 .padding({ 78 left: Constants.ROW_FONT_SIZE, 79 right: Constants.ROW_FONT_SIZE, 80 top: Constants.DA_MARGIN_TOP, 81 bottom: Constants.DA_MARGIN_TOP 82 }) 83 } 84 85 @Builder popupBuilderEdit() { 86 Row() { 87 Text($r('app.string.header_title_edit_tips')) 88 .fontSize($r('sys.float.ohos_id_text_size_body2')) 89 .fontColor($r('sys.color.ohos_id_color_text_primary')) 90 } 91 .width(Constants.HEADER_COLUMN_MESSAGE_TIPS) 92 .padding({ 93 left: Constants.ROW_FONT_SIZE, 94 right: Constants.ROW_FONT_SIZE, 95 top: Constants.DA_MARGIN_TOP, 96 bottom: Constants.DA_MARGIN_TOP 97 }) 98 } 99 100 onFlagChange() { 101 animateTo({ 102 duration: 650, 103 curve: Curve.Smooth 104 }, () => { 105 this.flag = !this.flag; 106 }) 107 } 108 109 aboutToAppear() { 110 HiLog.info(TAG, `aboutToAppear, encrypt success`); 111 this.directionStatus = (getContext(this) as common.UIAbilityContext).config.direction ?? -1; 112 directionStatus((counter) => { 113 this.directionStatus = counter; 114 }) 115 } 116 117 build() { 118 GridRow({ 119 columns: { 120 xs: Constants.XS_COLUMNS, 121 sm: Constants.SM_COLUMNS, 122 md: Constants.MD_COLUMNS, 123 lg: Constants.LG_COLUMNS 124 }, 125 gutter: Constants.DIALOG_GUTTER 126 }) { 127 GridCol({ 128 span: { 129 xs: Constants.XS_SPAN, 130 sm: Constants.SM_SPAN, 131 md: Constants.DIALOG_MD_SPAN, 132 lg: Constants.DIALOG_LG_SPAN 133 }, 134 offset: { 135 xs: Constants.XS_OFFSET, 136 sm: Constants.SM_OFFSET, 137 md: Constants.DIALOG_MD_OFFSET, 138 lg: Constants.DIALOG_LG_OFFSET 139 } 140 }) { 141 Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, 142 direction: FlexDirection.Column }) { 143 Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 144 Column() { 145 Row() { 146 Text($r('app.string.header_title')) 147 .fontWeight(FontWeight.Bold) 148 .fontFamily($r('app.string.typeface')) 149 .fontColor($r('sys.color.ohos_id_color_text_primary')) 150 .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) 151 .lineHeight(Constants.HEADER_TEXT_LINE_HEIGHT) 152 .width(Constants.HEADER_TEXT_WIDTH) 153 .align(Alignment.Start) 154 } 155 .width(Constants.HEADER_COLUMN_WIDTH) 156 .height(Constants.HEADER_COLUMN_HEIGHT) 157 .padding({ 158 left: Constants.HEADER_COLUMN_PADDING_LEFT, 159 right: Constants.HEADER_COLUMN_PADDING_RIGHT 160 }) 161 .margin({ bottom: Constants.HEADER_COLUMN_MARGIN_BOTTOM }); 162 163 Scroll() { 164 Column() { 165 Stack() { 166 Circle({ width: Constants.ENCRYPTION_SUCCESS_CIRCLE, height: Constants.ENCRYPTION_SUCCESS_CIRCLE }) 167 .fill($r('sys.color.multi_color_04')); 168 Image($r('app.media.ic_public_ok')) 169 .draggable(false) 170 .fillColor($r('sys.color.icon_on_primary')) 171 .width(Constants.ENCRYPTION_SUCCESS_ICON) 172 .height(Constants.ENCRYPTION_SUCCESS_ICON) 173 } 174 .margin({ top: Constants.ENCRYPTION_SUCCESS_IMAGE_MARGIN_TOP }); 175 Column() { 176 Row() { 177 Text($r('app.string.file_encrypted')) 178 .fontSize($r('sys.float.ohos_id_text_size_body1')) 179 .fontColor($r('sys.color.ohos_id_color_text_primary')) 180 .width(Constants.HEADER_COLUMN_WIDTH) 181 .textAlign(TextAlign.Center) 182 .fontWeight(FontWeight.Medium) 183 } 184 .width(Constants.HEADER_COLUMN_WIDTH) 185 186 Row() { 187 Text(`${GlobalContext.load('dlpFileName') as string}`) 188 .fontSize($r('sys.float.ohos_id_text_size_body2')) 189 .fontColor($r('sys.color.ohos_id_color_secondary')) 190 .fontWeight(FontWeight.Regular) 191 .width(Constants.HEADER_COLUMN_WIDTH) 192 .textAlign(TextAlign.Center) 193 } 194 .width(Constants.HEADER_COLUMN_WIDTH) 195 } 196 .width(Constants.HEADER_COLUMN_WIDTH) 197 .padding({ 198 top: Constants.HEADER_COLUMN_PADDING_LEFT, 199 bottom: Constants.HEADER_COLUMN_PADDING_RIGHT 200 }) 201 202 Row() { 203 Text(!this.flag ? $r('app.string.viewing_encryption_details') : $r('app.string.stow_away')) 204 .fontSize($r('sys.float.ohos_id_text_size_body2')) 205 .fontColor($r('sys.color.ohos_id_color_secondary')) 206 .fontWeight(FontWeight.Regular) 207 .textAlign(TextAlign.Center) 208 Image($r('app.media.icon_change')) 209 .draggable(false) 210 .fillColor($r('sys.color.ohos_id_color_tertiary')) 211 .width(Constants.PP_IMAGE_HEIGHT) 212 .height(Constants.PP_TEXT_FONT_SIZE2) 213 .objectFit(ImageFit.Contain) 214 .rotate({ 215 angle: !this.flag ? Constants.PP_BUTTON_PAD : Constants.ENCRYPTION_SUCCESS_TRANSLATE 216 }) 217 .transition({ type: TransitionType.All, opacity: Constants.PP_BUTTON_PAD }) 218 } 219 .onClick(() => this.onFlagChange()) 220 .width(Constants.ENCRYPTION_SUCCESS_TRANSLATE_WIDTH) 221 .height(Constants.ENCRYPTION_READ_ONLY_EDIT_HEIGHT) 222 .justifyContent(FlexAlign.Center) 223 .margin({ bottom: Constants.ENCRYPTION_SUCCESS_ROTATE_MARGIN_BOTTOM }) 224 225 Column() { 226 if (this.flag) { 227 if ((this.routerParams.selectedPermissionTypeReadOnly as PermissionType).data === 'all') { 228 Row() { 229 Text($r('app.string.header_title_readonly')) 230 .fontWeight(FontWeight.Medium) 231 .fontColor($r('sys.color.ohos_id_color_text_primary')) 232 .fontSize($r('sys.float.ohos_id_text_size_body2')) 233 Text(' : ') 234 .fontFamily($r('app.string.typeface')) 235 .fontWeight(FontWeight.Regular) 236 .fontColor($r('sys.color.ohos_id_color_text_primary')) 237 .fontSize($r('sys.float.ohos_id_text_size_body2')) 238 Text($r('app.string.PERMISSION_TYPE_SELECT_ALL')) 239 .fontFamily($r('app.string.typeface')) 240 .fontWeight(FontWeight.Regular) 241 .fontColor($r('sys.color.ohos_id_color_text_primary')) 242 .fontSize($r('sys.float.ohos_id_text_size_body2')) 243 Image($r('app.media.ic_public_detail')) 244 .width(Constants.FOOTER_ROW_PAD_RIGHT) 245 .height(Constants.FOOTER_ROW_PAD_RIGHT) 246 .margin({ left: Constants.AP_TEXT_PAD_RIGHT }) 247 .fillColor($r('sys.color.icon_secondary')) 248 .onClick(() => { 249 this.handlePopupReadOnly = !this.handlePopupReadOnly 250 }) 251 .draggable(false) 252 .bindPopup(this.handlePopupReadOnly, { 253 builder: this.popupBuilderReadOnly, 254 placement: Placement.BottomLeft, 255 offset: { x: Constants.POPUP_OFFSET_X }, 256 enableArrow: true, 257 showInSubWindow: false, 258 onStateChange: (e) => { 259 if (!e.isVisible) { 260 this.handlePopupReadOnly = false 261 } 262 } 263 }) 264 } 265 .width(Constants.FOOTER_ROW_WIDTH) 266 .height(Constants.ENCRYPTION_READ_ONLY_EDIT_HEIGHT) 267 .margin({ 268 top: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_TOP, 269 bottom: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_BOTTOM 270 }) 271 } else { 272 if (this.staffDataArrayReadOnly['length']) { 273 Row() { 274 Text($r('app.string.header_title_readonly')) 275 .fontWeight(FontWeight.Medium) 276 .fontColor($r('sys.color.ohos_id_color_text_primary')) 277 .fontSize($r('sys.float.ohos_id_text_size_body2')) 278 Text(` (${this.staffDataArrayReadOnly['length']}):`) 279 .fontFamily($r('app.string.typeface')) 280 .fontWeight(FontWeight.Regular) 281 .fontColor($r('sys.color.ohos_id_color_text_primary')) 282 .fontSize($r('sys.float.ohos_id_text_size_body2')) 283 Image($r('app.media.ic_public_detail')) 284 .width(Constants.FOOTER_ROW_PAD_RIGHT) 285 .height(Constants.FOOTER_ROW_PAD_RIGHT) 286 .margin({ left: Constants.AP_TEXT_PAD_RIGHT }) 287 .fillColor($r('sys.color.icon_secondary')) 288 .onClick(() => { 289 this.handlePopupReadOnly = !this.handlePopupReadOnly 290 }) 291 .draggable(false) 292 .bindPopup(this.handlePopupReadOnly, { 293 builder: this.popupBuilderReadOnly, 294 placement: Placement.BottomLeft, 295 offset: { x: Constants.POPUP_OFFSET_X }, 296 enableArrow: true, 297 showInSubWindow: false, 298 onStateChange: (e) => { 299 if (!e.isVisible) { 300 this.handlePopupReadOnly = false 301 } 302 } 303 }) 304 } 305 .width(Constants.FOOTER_ROW_WIDTH) 306 .height(Constants.ENCRYPTION_READ_ONLY_EDIT_HEIGHT) 307 308 Flex({ 309 direction: FlexDirection.Row, 310 wrap: FlexWrap.Wrap, 311 }) { 312 if (this.staffDataArrayReadOnly['length'] > 0) { 313 ForEach( 314 this.showNamesArrReadOnly, 315 (item: AuthAccount, index?: number) => { 316 staffItem({ 317 authAccount: item.authAccount, 318 textContent: item.textContent, 319 isActive: false, 320 changeIndex: Number(index), 321 }) 322 }, 323 (item: AuthAccount) => item.authAccount 324 ) 325 if (Number(this.hideNamesNumReadOnly) > 0) { 326 Row() { 327 if (this.showNamesArrReadOnly.length !== this.staffDataArrayReadOnly.length) { 328 Text() { 329 Span('+') 330 Span(this.hideNamesNumReadOnly) 331 } 332 .customizeText() 333 } 334 Image($r('app.media.icon_change')) 335 .draggable(false) 336 .width(Constants.PP_IMAGE_HEIGHT) 337 .height(Constants.PP_TEXT_FONT_SIZE2) 338 .objectFit(ImageFit.Contain) 339 .fillColor($r('sys.color.ohos_id_color_secondary')) 340 .rotate({ 341 angle: !this.readOnlyFlag ? 342 Constants.PP_BUTTON_PAD : Constants.ENCRYPTION_SUCCESS_TRANSLATE 343 }) 344 .transition({ type: TransitionType.All, opacity: Constants.PP_BUTTON_PAD }) 345 } 346 .height(Constants.ENCRYPTION_SUCCESS_TOGGLE_HEIGHT) 347 .onClick(() => { 348 let tmp: Record<string, AuthAccount[] | boolean> = toggleShow( 349 this.routerParams.staffDataArrayReadOnly as AuthAccount[], 350 this.showNamesArrReadOnly, 351 this.readOnlyFlag, 352 this.rowNamesLenReadOnly 353 ); 354 this.showNamesArrReadOnly = tmp.showNamesArr as AuthAccount[]; 355 this.readOnlyFlag = tmp.showFlag as boolean; 356 }) 357 } 358 } 359 } 360 .onAreaChange((oldValue: Area, newValue: Area) => { 361 if (oldValue.width === Constants.ENCRYPTION_ON_AREA_CHANGE_WIDTH || 362 newValue.width !== oldValue.width) { 363 let tmp: Record<string, number | AuthAccount[] | string> = 364 calculate(newValue, this.routerParams.staffDataArrayReadOnly as AuthAccount[]); 365 this.rowNamesLenReadOnly = tmp.rowNamesLen as number; 366 this.showNamesArrReadOnly = tmp.showNamesArr as AuthAccount[]; 367 this.hideNamesNumReadOnly = tmp.hideNamesNum as string; 368 this.readOnlyFlag = false; 369 } 370 }) 371 .margin({ 372 top: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_TOP, 373 bottom: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_BOTTOM 374 }) 375 } 376 } 377 378 if (['all', 'self'].includes((this.routerParams.selectedPermissionTypeEdit as PermissionType).data)) { 379 Row() { 380 Text($r('app.string.header_title_edit')) 381 .fontWeight(FontWeight.Medium) 382 .fontColor($r('sys.color.ohos_id_color_text_primary')) 383 .fontSize($r('sys.float.ohos_id_text_size_body2')) 384 Text(' : ') 385 .fontFamily($r('app.string.typeface')) 386 .fontWeight(FontWeight.Regular) 387 .fontColor($r('sys.color.ohos_id_color_text_primary')) 388 .fontSize($r('sys.float.ohos_id_text_size_body2')) 389 Text((this.routerParams.selectedPermissionTypeEdit as PermissionType).data === 'all' ? $r('app.string.PERMISSION_TYPE_SELECT_ALL') : $r('app.string.PERMISSION_TYPE_SELECT_SELF')) 390 .fontFamily($r('app.string.typeface')) 391 .fontWeight(FontWeight.Regular) 392 .fontColor($r('sys.color.ohos_id_color_text_primary')) 393 .fontSize($r('sys.float.ohos_id_text_size_body2')) 394 Image($r('app.media.ic_public_detail')) 395 .width(Constants.FOOTER_ROW_PAD_RIGHT) 396 .height(Constants.FOOTER_ROW_PAD_RIGHT) 397 .margin({ left: Constants.AP_TEXT_PAD_RIGHT }) 398 .fillColor($r('sys.color.icon_secondary')) 399 .onClick(() => { 400 this.handlePopupEdit = !this.handlePopupEdit 401 }) 402 .draggable(false) 403 .bindPopup(this.handlePopupEdit, { 404 builder: this.popupBuilderEdit, 405 placement: Placement.BottomLeft, 406 offset: { x: Constants.POPUP_OFFSET_X }, 407 enableArrow: true, 408 showInSubWindow: false, 409 onStateChange: (e) => { 410 if (!e.isVisible) { 411 this.handlePopupEdit = false 412 } 413 } 414 }) 415 } 416 .justifyContent(FlexAlign.Start) 417 .width(Constants.FOOTER_ROW_WIDTH) 418 .height(Constants.ENCRYPTION_READ_ONLY_EDIT_HEIGHT) 419 .margin({ 420 top: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_TOP, 421 bottom: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_BOTTOM 422 }) 423 } else { 424 if (this.staffDataArrayEdit['length']) { 425 Row() { 426 Text($r('app.string.header_title_edit')) 427 .fontWeight(FontWeight.Medium) 428 .fontColor($r('sys.color.ohos_id_color_text_primary')) 429 .fontSize($r('sys.float.ohos_id_text_size_body2')) 430 Text(` (${this.staffDataArrayEdit['length']}):`) 431 .fontFamily($r('app.string.typeface')) 432 .fontWeight(FontWeight.Regular) 433 .fontColor($r('sys.color.ohos_id_color_text_primary')) 434 .fontSize($r('sys.float.ohos_id_text_size_body2')) 435 Image($r('app.media.ic_public_detail')) 436 .width(Constants.FOOTER_ROW_PAD_RIGHT) 437 .height(Constants.FOOTER_ROW_PAD_RIGHT) 438 .margin({ left: Constants.AP_TEXT_PAD_RIGHT }) 439 .fillColor($r('sys.color.icon_secondary')) 440 .onClick(() => { 441 this.handlePopupEdit = !this.handlePopupEdit 442 }) 443 .draggable(false) 444 .bindPopup(this.handlePopupEdit, { 445 builder: this.popupBuilderEdit, 446 placement: Placement.BottomLeft, 447 offset: { x: Constants.POPUP_OFFSET_X }, 448 enableArrow: true, 449 showInSubWindow: false, 450 onStateChange: (e) => { 451 if (!e.isVisible) { 452 this.handlePopupEdit = false 453 } 454 } 455 }) 456 } 457 .justifyContent(FlexAlign.Start) 458 .width(Constants.FOOTER_ROW_WIDTH) 459 .height(Constants.ENCRYPTION_READ_ONLY_EDIT_HEIGHT) 460 461 Flex({ 462 direction: FlexDirection.Row, 463 wrap: FlexWrap.Wrap, 464 }) { 465 if (this.staffDataArrayEdit['length'] > 0) { 466 ForEach( 467 this.showNamesArrEdit, 468 (item: AuthAccount, index?: number) => { 469 staffItem({ 470 authAccount: item.authAccount, 471 textContent: item.textContent, 472 isActive: false, 473 changeIndex: Number(index), 474 }) 475 }, 476 (item: AuthAccount) => item.authAccount 477 ) 478 if (Number(this.hideNamesNumEdit) > 0) { 479 Row() { 480 if (this.showNamesArrEdit.length !== this.staffDataArrayEdit.length) { 481 Text() { 482 Span('+') 483 Span(this.hideNamesNumEdit) 484 } 485 .customizeText() 486 } 487 Image($r('app.media.icon_change')) 488 .draggable(false) 489 .width(Constants.PP_IMAGE_HEIGHT) 490 .height(Constants.PP_TEXT_FONT_SIZE2) 491 .objectFit(ImageFit.Contain) 492 .fillColor($r('sys.color.ohos_id_color_secondary')) 493 .rotate({ 494 angle: !this.editFlag ? 495 Constants.PP_BUTTON_PAD : Constants.ENCRYPTION_SUCCESS_TRANSLATE 496 }) 497 .transition({ type: TransitionType.All, opacity: Constants.PP_BUTTON_PAD }) 498 } 499 .height(Constants.ENCRYPTION_SUCCESS_TOGGLE_HEIGHT) 500 .onClick(() => { 501 let tmp: Record<string, AuthAccount[] | boolean> = toggleShow( 502 this.routerParams.staffDataArrayEdit as AuthAccount[], 503 this.showNamesArrEdit, 504 this.editFlag, 505 this.rowNamesLenEdit 506 ); 507 this.showNamesArrEdit = tmp.showNamesArr as AuthAccount[]; 508 this.editFlag = tmp.showFlag as boolean; 509 }) 510 } 511 } 512 } 513 .onAreaChange((oldValue: Area, newValue: Area) => { 514 if (oldValue.width === Constants.ENCRYPTION_ON_AREA_CHANGE_WIDTH || 515 newValue.width !== oldValue.width) { 516 let tmp: Record<string, number | AuthAccount[] | string> = 517 calculate(newValue, this.routerParams.staffDataArrayEdit as AuthAccount[]); 518 this.rowNamesLenEdit = tmp.rowNamesLen as number; 519 this.showNamesArrEdit = tmp.showNamesArr as AuthAccount[]; 520 this.hideNamesNumEdit = tmp.hideNamesNum as string; 521 this.editFlag = false; 522 } 523 }) 524 .margin({ 525 top: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_TOP, 526 bottom: Constants.ENCRYPTION_SUCCESS_ADD_STAFF_MARGIN_BOTTOM 527 }) 528 } 529 } 530 531 Column({ space: Constants.HEADER_ROW_FONT_SIZE }) { 532 Row() { 533 Text($r('app.string.Document_valid_until')) 534 .fontSize($r('sys.float.ohos_id_text_size_body2')) 535 .fontColor($r('sys.color.ohos_id_color_text_primary')) 536 .fontWeight(FontWeight.Medium) 537 .textAlign(TextAlign.Start) 538 Text(' : ') 539 .fontFamily($r('app.string.typeface')) 540 .fontWeight(FontWeight.Regular) 541 .fontColor($r('sys.color.ohos_id_color_text_primary')) 542 .fontSize($r('sys.float.ohos_id_text_size_body2')) 543 Text(getTime()) 544 .fontSize($r('sys.float.ohos_id_text_size_body2')) 545 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 546 .fontWeight(FontWeight.Regular) 547 .width(Constants.HEADER_COLUMN_WIDTH) 548 .textAlign(TextAlign.Start) 549 .margin({ left: Constants.AP_TEXT_PAD_RIGHT }) 550 } 551 .width(Constants.HEADER_COLUMN_WIDTH) 552 553 Row() { 554 Text($r('app.string.change_encryption')) 555 .fontSize($r('sys.float.ohos_id_text_size_body2')) 556 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 557 .fontWeight(FontWeight.Medium) 558 .width(Constants.HEADER_COLUMN_WIDTH) 559 .textAlign(TextAlign.Start) 560 .onClick(() => { 561 router.replaceUrl({ 562 url: 'pages/changeEncryption', 563 params: this.routerParams 564 }) 565 }) 566 } 567 .width(Constants.HEADER_COLUMN_WIDTH) 568 } 569 .width(Constants.HEADER_COLUMN_WIDTH) 570 .margin({ bottom: Constants.ENCRYPTION_CHANGE_VALID_UNTIL_MARGIN_BOTTOM }) 571 } 572 } 573 } 574 }.constraintSize({ 575 maxHeight: this.directionStatus === 576 0 ? Constants.CHANGE_MAX_HEIGHT : Constants.ENCRYPTION_SUCCESS_MAX_HEIGHT 577 }) 578 .padding({ 579 left: Constants.HEADER_COLUMN_PADDING_LEFT, 580 right: Constants.HEADER_COLUMN_PADDING_RIGHT 581 }) 582 583 Row() { 584 Button($r('app.string.finished'), { type: ButtonType.Capsule, stateEffect: true }) 585 .backgroundColor($r('sys.color.ohos_id_color_text_primary_activated')) 586 .fontWeight(FontWeight.Medium) 587 .width(Constants.FOOTER_WIDTH_BUTTON) 588 .height(Constants.FOOTER_HEIGHT) 589 .onClick(async (event) => { 590 if (!(GlobalContext.load('requestIsFromSandBox') as boolean)) { 591 let dlpFileName: string = GlobalContext.load('dlpFileName') as string; 592 try { 593 HiLog.info(TAG, `closeDLPFile: ${dlpFileName}`); 594 let hF = GlobalContext.load('homeFeature') as HomeFeature; 595 await new Promise<void>((resolve, reject) => { 596 hF.closeDLPFileHome(GlobalContext.load('uri'), (err: number) => { 597 if (err !== 0) { 598 reject(); 599 } 600 resolve(); 601 }); 602 }) 603 } catch (err) { 604 HiLog.error(TAG, `closeDLPFile: ${dlpFileName}, failed: ${JSON.stringify(err)}`); 605 } 606 } 607 if (this.session !== undefined) { 608 this.session.terminateSelfWithResult({ 609 'resultCode': 0, 610 'want': { 611 'bundleName': Constants.DLP_MANAGER_BUNDLE_NAME, 612 }, 613 }); 614 } else { 615 if (GlobalContext.load('fileOpenHistoryFromMain')) { 616 (GlobalContext.load('fileOpenHistoryFromMain') as Map<string, Object>).delete(GlobalContext.load('uri') as string) 617 } 618 abilityResult.resultCode = 0; 619 (getContext(this) as common.UIAbilityContext).terminateSelfWithResult(abilityResult); 620 } 621 }) 622 } 623 .justifyContent(FlexAlign.Center) 624 .margin({ 625 top: Constants.ENCRYPTION_BUTTON_PADDING_TOP, 626 bottom: Constants.ENCRYPTION_BUTTON_MARGIN_BOTTOM 627 }) 628 .padding({ 629 left: Constants.FOOTER_ROW_PAD_LEFT, 630 right: Constants.FOOTER_ROW_PAD_RIGHT 631 }) 632 } 633 .width(Constants.ENCRYPTION_PC_FIXING_WIDTH) 634 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 635 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 636 .constraintSize({ 637 minWidth: Constants.ENCRYPTION_PC_FIXING_WIDTH, 638 minHeight: Constants.ENCRYPTION_LOADING_HEIGHT 639 }) 640 .backgroundBlurStyle(BlurStyle.COMPONENT_ULTRA_THICK); 641 } 642 } 643 } 644 } 645 .backgroundColor($r('sys.color.mask_fourth')) 646 } 647} 648