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