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 { CurActiveAbility } from '../common/CurActiveAbility'; 17@Entry 18@Component 19struct Index { 20 storage = LocalStorage.GetShared(); 21 @State launchParam: string = ''; 22 @State wantParam: string = ''; 23 fromEntryAbility: boolean = false; 24 25 aboutToAppear() { 26 this.launchParam = this.storage.get<string>('launchParam') ?? 'UnknownLaunchParam'; 27 this.wantParam = this.storage.get<string>('wantParam') ?? 'UnknownWantParam'; 28 let abilityName = AppStorage.Get<string>('RecoverAbility'); 29 if (abilityName === 'EntryAbility') { 30 this.fromEntryAbility = true; 31 } 32 } 33 34 build() { 35 Column() { 36 Text('RecoveryPage') 37 .fontSize('30fp') 38 .fontWeight(FontWeight.Bold) 39 .padding({ left: '24vp', right: '24vp', top: '4vp', bottom: '4vp' }) 40 .margin({ top: '14vp' }) 41 .textAlign(TextAlign.Start) 42 .height('56vp') 43 .width('100%') 44 .fontColor($r('app.color.text_grey')); 45 46 if (this.fromEntryAbility === false) { 47 List() { 48 ListItem() { 49 Column() { 50 Row() { 51 Text('SecondAbility').fontSize('16fp').width('76.3%'); 52 Button($r('app.string.recover')) 53 .fontSize('12fp') 54 .width('23.7%') 55 .fontColor($r('app.color.text_blue_opacity')) 56 .onClick(() => { 57 if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { 58 return; 59 } 60 let want: Record<string, Object> = { 61 'bundleName': 'com.samples.recovery', 62 'abilityName': 'SecondAbility' 63 }; 64 CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); 65 }) 66 .height('28vp') 67 .backgroundColor($r('sys.color.ohos_id_color_sub_background')) 68 }.height('48vp').align(Alignment.Center).width('100%'); 69 } 70 }.width('100%') 71 } 72 .margin({ left: '12vp', right: '12vp', top: '12vp' }) 73 .width('93.3%') 74 .borderRadius('24vp') 75 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) 76 .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) 77 } 78 79 List() { 80 ListItem() { 81 Column() { 82 Row() { 83 Text('EntryAbility').fontSize('16fp').width('76.3%'); 84 Button($r('app.string.recover')) 85 .fontSize('12fp') 86 .width('23.7%') 87 .fontColor($r('app.color.text_blue_opacity')) 88 .onClick(() => { 89 if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) { 90 return; 91 } 92 let want: Record<string, Object> = { 93 'bundleName': 'com.samples.recovery', 94 'abilityName': 'EntryAbility' 95 }; 96 CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want); 97 }) 98 .height('28vp') 99 .backgroundColor($r('sys.color.ohos_id_color_sub_background')) 100 }.height('48vp').align(Alignment.Center).width('100%'); 101 } 102 }.width('100%') 103 } 104 .margin({ left: '12vp', right: '12vp', top: '12vp' }) 105 .width('93.3%') 106 .borderRadius('24vp') 107 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) 108 .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' }) 109 }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%') 110 .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); 111 } 112} 113