diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index a6992d80430f600088242a54bbf16b4c9ef2562d..949a08ecb6d07978bb6ed21a290a6d8630dfdb84 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -29,16 +29,11 @@ export default class EntryAbility extends UIAbility { uiContext?: UIContext; cameraUtil?: CameraUtil; windowUtil?: WindowUtil; - isFirstCreated: boolean = true; - isFirstTime: boolean = true; // [EndExclude WindowSizeChange] + isFirstTime: boolean = true; // [Start Bp2] - // [Start SelectCamera2] - // [Start SelectCamera4] onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - // [StartExclude SelectCamera4] // [StartExclude WindowSizeChange] - // [StartExclude SelectCamera2] this.setOrientation(this.uiContext!.px2vp(windowSize.width), this.uiContext!.px2vp(windowSize.height)); // [StartExclude Bp2] AppStorage.setOrCreate('windowSize', windowSize); @@ -49,18 +44,14 @@ export default class EntryAbility extends UIAbility { let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); // [EndExclude WindowSizeChange] - // [EndExclude SelectCamera2] if (!this.isFirstTime) { this.cameraUtil!.setXComponentRect(this.windowUtil!.getWindowSize()); } else { this.isFirstTime = false; } - // [EndExclude SelectCamera4] // [EndExclude Bp2] } - // [End SelectCamera2] // [StartExclude WindowSizeChange] - // [End SelectCamera4] 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. @@ -127,12 +118,12 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate('heightBp', heightBp); let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); + AppStorage.setOrCreate('isBackground', false); + // [EndExclude Bp2] // [EndExclude WindowSizeChange] // Monitor window size changes and update breakpoints. - windowStage.getMainWindowSync().on('windowSizeChange', this.onWindowSizeChange); + data.on('windowSizeChange', this.onWindowSizeChange); // [StartExclude WindowSizeChange] - AppStorage.setOrCreate('isBackground', false); - // [EndExclude Bp2] let rect: window.Rect = data.getWindowProperties().windowRect; this.setOrientation(this.uiContext.px2vp(rect.width), this.uiContext.px2vp(rect.height)); // [EndExclude WindowSizeChange] diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5eee6ad4cb6b287523d2401060c6238aa89a3667..9867354cbf3a6602a8d80f6aa094b62e170e6e78 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -46,6 +46,7 @@ struct Index { ]; // [Start Preview2] // [Start FoldStatusChange] + // [Start SelectCamera2] onFoldStatusChange: (foldStatus: display.FoldStatus) => void = (foldStatus: display.FoldStatus) => { if (foldStatus === display.FoldStatus.FOLD_STATUS_HALF_FOLDED) { let orientation: display.Orientation = display.getDefaultDisplaySync().orientation; @@ -69,10 +70,12 @@ struct Index { return; } // [StartExclude Preview2] + // [StartExclude SelectCamera2] if (this.widthBp !== WidthBreakpoint.WIDTH_SM) { this.windowUtil.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); } // [EndExclude Preview2] + // [EndExclude SelectCamera2] // Exit the half folded status page. if (this.isHalfFolded) { this.cameraUtil.setXComponentRect(this.windowUtil.getWindowSize()); @@ -89,8 +92,10 @@ struct Index { } } } + // [StartExclude SelectCamera2] this.isHalfFolded = false; this.oldFoldStatus = foldStatus; + // [EndExclude SelectCamera2] } // [End FoldStatusChange] // [End Preview2] @@ -98,6 +103,7 @@ struct Index { aboutToAppear(): void { display.on('foldStatusChange', this.onFoldStatusChange); } + // [End SelectCamera2] // [Start SelectCamera1] onPageShow(): void {