diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index d8032b8b0e6d0ea5c285cc026791ed4ca676259f..ea884490a2d1f583c9c23477879d13989b88d20c 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. @@ -99,8 +95,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 +129,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] diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 2a5123051cc6ad979419133d9b19f7927a6a8034..43b79a5c26ff184bcbd9ec766447e23a75d8f627 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -16,7 +16,6 @@ import { display, window } from '@kit.ArkUI'; import { camera } from '@kit.CameraKit'; import { abilityAccessCtrl, Permissions } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; import { ChooseMusic, SettingButton, ShotArea, ShotAreaHalfFolded, ShotAreaSm } from '../views/CommonView'; import { CameraUtil } from '../utils/CameraUtil'; import { WindowUtil } from '../utils/WindowUtil'; @@ -44,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) { @@ -51,25 +51,30 @@ 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] aboutToAppear(): void { display.on('foldStatusChange', this.onFoldStatusChange); diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 190d4fae9255a9dc0203d063640879d05280d625..a1e61442532d94ba750ee64c5c37ac2a678648f3 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": [