From 6af8b1e08d70c9d5c3a6475ab0a76e43315c5073 Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Wed, 30 Apr 2025 17:01:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=9A=E8=AE=BE=E5=A4=87=E7=9B=B8?= =?UTF-8?q?=E6=9C=BASample=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/utils/CameraUtil.ets | 1 - 1 file changed, 1 deletion(-) diff --git a/entry/src/main/ets/utils/CameraUtil.ets b/entry/src/main/ets/utils/CameraUtil.ets index 63a0408..64f9aba 100644 --- a/entry/src/main/ets/utils/CameraUtil.ets +++ b/entry/src/main/ets/utils/CameraUtil.ets @@ -20,7 +20,6 @@ import { BusinessError, deviceInfo } from "@kit.BasicServicesKit"; import { photoAccessHelper } from "@kit.MediaLibraryKit"; import { colorSpaceManager } from "@kit.ArkGraphics2D"; import { sensor } from "@kit.SensorServiceKit"; -import { display } from "@kit.ArkUI"; export class CameraUtil { previewOutput?: camera.PreviewOutput; -- Gitee From 62d9c922b74ed8e2444a659b6bcba4cd8b23b824 Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Wed, 30 Apr 2025 18:08:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=9A=E8=AE=BE=E5=A4=87=E7=9B=B8?= =?UTF-8?q?=E6=9C=BASample=E4=BF=AE=E6=94=B9=E5=BA=9F=E5=BC=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/utils/WindowUtil.ets | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5c45da1..534da74 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -57,7 +57,7 @@ struct Index { }; aboutToAppear(): void { - this.windowUtil!.getFoldCreaseRegion(); + this.windowUtil!.getFoldCreaseRegion(this.getUIContext()); display.on('foldStatusChange', this.onFoldStatusChange); abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.context, this.permissions).then(() => { setTimeout(async () => { diff --git a/entry/src/main/ets/utils/WindowUtil.ets b/entry/src/main/ets/utils/WindowUtil.ets index 5999289..09b5488 100644 --- a/entry/src/main/ets/utils/WindowUtil.ets +++ b/entry/src/main/ets/utils/WindowUtil.ets @@ -21,6 +21,7 @@ export class WindowUtil { windowStage?: window.WindowStage; mainWindow?: window.Window; + static getInstance(): WindowUtil | undefined { if (!AppStorage.get('windowUtil')) { AppStorage.setOrCreate('windowUtil', new WindowUtil()); @@ -56,12 +57,12 @@ export class WindowUtil { this.mainWindow!.off('windowSizeChange'); } - getFoldCreaseRegion(): void { + getFoldCreaseRegion(context: UIContext): void { if (display.isFoldable()) { let foldRegion: display.FoldCreaseRegion = display.getCurrentFoldCreaseRegion(); let rect: display.Rect = foldRegion.creaseRects[0]; // Height of the avoidance area in the upper half screen and height of the avoidance area. - let creaseRegion: number[] = [px2vp(rect.top), px2vp(rect.height), px2vp(rect.width)]; + let creaseRegion: number[] = [context.px2vp(rect.top), context.px2vp(rect.height), context.px2vp(rect.width)]; AppStorage.setOrCreate('creaseRegion', creaseRegion); } } -- Gitee