!4928 【Sample】SafeArea模块扩展安全区展示优化

Merge pull request !4928 from YangXin/master-CC
This commit is contained in:
openharmony_ci 2024-11-12 07:04:31 +00:00 committed by Gitee
commit 93eddc6569
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 9 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
@ -17,11 +17,12 @@ import UIAbility from '@ohos.app.ability.UIAbility'
import Logger from '../util/Logger' import Logger from '../util/Logger'
import window from '@ohos.window'; import window from '@ohos.window';
import { KeyboardAvoidMode } from '@ohos.arkui.UIContext'; import { KeyboardAvoidMode } from '@ohos.arkui.UIContext';
import { AbilityConstant } from '@kit.AbilityKit';
const TAG: string = 'MainAbility' const TAG: string = 'MainAbility'
export default class MainAbility extends UIAbility { export default class MainAbility extends UIAbility {
onCreate(want, launchParam) { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
Logger.info(TAG, 'onCreate'); Logger.info(TAG, 'onCreate');
AppStorage.setOrCreate('context', this.context); AppStorage.setOrCreate('context', this.context);
} }
@ -30,11 +31,11 @@ export default class MainAbility extends UIAbility {
Logger.info(TAG, 'onDestroy') Logger.info(TAG, 'onDestroy')
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
Logger.info(TAG, 'onWindowStageCreate') Logger.info(TAG, 'onWindowStageCreate')
try { try {
let windowClass = null; let windowClass: window.Window | undefined = undefined;
window.getLastWindow(this.context, (err, data) => { window.getLastWindow(this.context, (err, data) => {
if (err.code) { if (err.code) {
Logger.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); Logger.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
@ -42,9 +43,7 @@ export default class MainAbility extends UIAbility {
} }
Logger.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); Logger.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
windowClass = data; windowClass = data;
let systemBarProperties = { let systemBarProperties: window.SystemBarProperties = {};
statusBarColor: "#f1f3f5"
};
windowClass.setWindowSystemBarProperties(systemBarProperties, (err) => { windowClass.setWindowSystemBarProperties(systemBarProperties, (err) => {
if (err.code) { if (err.code) {
Logger.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); Logger.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. * Copyright (c) 2023-2024 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
@ -46,7 +46,6 @@ struct SafeAreaSample {
Column() { Column() {
TitleBar({ title: $r('app.string.safe_area') }) TitleBar({ title: $r('app.string.safe_area') })
.backgroundColor($r('app.color.background_shallow_grey'))
Column() { Column() {
IntroductionTitle({ introduction: $r('app.string.safe_area_type_and_safe_area_edge') }) IntroductionTitle({ introduction: $r('app.string.safe_area_type_and_safe_area_edge') })
ChangePanel({ ChangePanel({

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022 Huawei Device Co., Ltd. * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
@ -36,7 +36,7 @@
"abilities": [ "abilities": [
{ {
"name": "MainAbility", "name": "MainAbility",
"srcEntry": "./ets/MainAbility/MainAbility.ts", "srcEntry": "./ets/MainAbility/MainAbility.ets",
"description": "$string:MainAbility_desc", "description": "$string:MainAbility_desc",
"icon": "$media:icon", "icon": "$media:icon",
"label": "$string:entry_desc", "label": "$string:entry_desc",