From b9ecba4525c2404c86094f13e0b239cd65ced92c Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Mon, 4 Aug 2025 17:12:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9windowSize=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/entryability/EntryAbility.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index d8032b8..c41635d 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -99,8 +99,6 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('windowUtil', new WindowUtil()); this.windowUtil = AppStorage.get('windowUtil'); this.windowUtil!.setWindowStage(windowStage); - // Monitor window size changes and update breakpoints. - windowStage.getMainWindowSync().on('windowSizeChange', this.onWindowSizeChange); // [EndExclude WindowSizeChange] // [EndExclude Bp2] windowStage.loadContent('pages/Index', (err) => { @@ -135,6 +133,8 @@ export default class EntryAbility extends UIAbility { let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); // [EndExclude WindowSizeChange] + // Monitor window size changes and update breakpoints. + windowStage.getMainWindowSync().on('windowSizeChange', this.onWindowSizeChange); // [StartExclude WindowSizeChange] AppStorage.setOrCreate('isBackground', false); // [EndExclude Bp2] -- Gitee From 018325757e013f5604d6cbcc5e83fcc33221982c Mon Sep 17 00:00:00 2001 From: lon9 <815882449@qq.com> Date: Fri, 22 Aug 2025 15:05:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=9B=B8=E6=9C=BA=E5=90=8C=E6=BA=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 4 -- entry/src/main/ets/pages/Index.ets | 43 ++++++++----------- entry/src/main/module.json5 | 2 +- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index c41635d..ea88449 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -36,12 +36,10 @@ export default class EntryAbility extends UIAbility { // [Start Bp2] // [Start SelectCamera2] // [Start SelectCamera4] - // [Start Preview2] onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { // [StartExclude SelectCamera4] // [StartExclude WindowSizeChange] // [StartExclude SelectCamera2] - // [StartExclude Preview2] this.setOrientation(this.uiContext!.px2vp(windowSize.width), this.uiContext!.px2vp(windowSize.height)); // [StartExclude Bp2] AppStorage.setOrCreate('windowSize', windowSize); @@ -53,7 +51,6 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('displayOrientation', displayOrientation); // [EndExclude WindowSizeChange] // [EndExclude SelectCamera2] - // [EndExclude Preview2] if (!this.isFirstTime) { this.cameraUtil!.setXComponentRect(this.windowUtil!.getWindowSize()); } else { @@ -65,7 +62,6 @@ export default class EntryAbility extends UIAbility { // [End SelectCamera2] // [StartExclude WindowSizeChange] // [End SelectCamera4] - // [End Preview2] setOrientation(width: number, height: number): void { // When the minimum value of window width and height is greater than the md breakpoint threshold, rotation is supported. diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index a21fa89..76aedc2 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -43,6 +43,7 @@ struct Index { 'ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO' ]; + // [Start Preview2] // [Start FoldStatusChange] onFoldStatusChange: (foldStatus: display.FoldStatus) => void = (foldStatus: display.FoldStatus) => { if (foldStatus === display.FoldStatus.FOLD_STATUS_HALF_FOLDED) { @@ -50,42 +51,36 @@ struct Index { // Determine the page layout that has entered half folded status and prohibit portrait orientation. if (this.widthBp === WidthBreakpoint.WIDTH_MD && (orientation === display.Orientation.LANDSCAPE || orientation === display.Orientation.LANDSCAPE_INVERTED)) { + // [StartExclude Preview2] this.isHalfFolded = true; - this.cameraUtil!.setXComponentRect(this.windowUtil.getWindowSize()); this.windowUtil.setMainWindowOrientation(window.Orientation.LANDSCAPE); + // [EndExclude Preview2] + this.cameraUtil!.setXComponentRect(this.windowUtil.getWindowSize()); } + return; } // Exit the half folded status page. - else { - if (this.isHalfFolded) { - this.isHalfFolded = false; - this.cameraUtil!.setXComponentRect(this.windowUtil.getWindowSize()); - } else { - this.isHalfFolded = false; - } - if (this.widthBp !== WidthBreakpoint.WIDTH_SM) { - this.windowUtil.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } + if (this.isHalfFolded) { + // The variable isHalfFolded will be used in the judgment of the next method. + this.isHalfFolded = false; + this.cameraUtil!.setXComponentRect(this.windowUtil.getWindowSize()); + } else { + this.isHalfFolded = false; } + // [StartExclude Preview2] + if (this.widthBp !== WidthBreakpoint.WIDTH_SM) { + this.windowUtil.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); + } + // [EndExclude Preview2] } // [End FoldStatusChange] + // [End Preview2] - // [Start SelectCamera1] aboutToAppear(): void { - // [StartExclude SelectCamera1] display.on('foldStatusChange', this.onFoldStatusChange); - // [EndExclude SelectCamera1] - // Apply to the user for permission to access the camera and gallery. - // abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.context, this.permissions).then(() => { - // setTimeout(() => { - // // After obtaining permission, load the camera preview stream and ensure it is consistent with the aspect ratio of the surface. - // // [StartExclude SelectCamera1] - // this.cameraUtil?.setSurfaceProfile(this.xComponentController, this.getUIContext()); - // // [EndExclude SelectCamera1] - // this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); - // }, 200); - // }) } + + // [Start SelectCamera1] onPageShow(): void { abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.context, this.permissions).then(() => { setTimeout(() => { diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 190d4fa..a1e6144 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -22,7 +22,7 @@ "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", "exported": true, - "supportWindowMode": ["fullscreen"], + "supportWindowMode": ["fullscreen", "floating"], "skills": [ { "entities": [ -- Gitee