diff --git a/README.md b/README.md index 9ce1055db989f11ba8553d9ebb998cbd7127f283..b8e847ed23a85ddb315309146a01105fa656ecb3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,25 @@ ## 效果展示 +手机运行效果图: +![](screenshots/device/mate60.png) + +阔折叠运行效果图: + +![](screenshots/device/purax.png) + +大折叠运行效果图: + +![](screenshots/device/matex5.png) + +三折叠运行效果图: + +![](screenshots/device/matext.png) + +平板运行效果图: + +![](screenshots/device/matepadpro.png) ## 使用说明 @@ -24,7 +42,8 @@ │ │ └──Index.ets // 主页 │ ├──utils │ │ ├──BreakpointType.ets // 一多断点工具类 -│ │ └──CameraUtil.ets // 相机工具类 +│ │ ├──CameraUtil.ets // 相机工具类 +│ │ └──WindowUtil.ets // 窗口工具类 │ └──views │ └──CommonView.ets // 公共视图类 └──entry/src/main/resource // 应用静态资源目录 @@ -39,7 +58,8 @@ ## 相关权限 1. 相机权限:ohos.permission.CAMERA,用于相机开发场景。 -2. 媒体库权限: ohos.permission.READ_IMAGEVIDEO,用于读取图库文件;ohos.permission.WRITE_IMAGEVIDEO:用于保存文件至图库。 +2. 受限开放权限-媒体库权限:ohos.permission.READ_IMAGEVIDEO,用于读取图库文件。可申请此权限的特殊场景与功能: 应用需要克隆、备份或同步图片/视频类文件。 +3. 受限开放权限-媒体库权限:ohos.permission.WRITE_IMAGEVIDEO,用于保存文件至图库。可申请此权限的特殊场景与功能: 应用需要克隆、备份或同步图片/视频类文件。 ## 依赖 diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 7247c340f41573d6ad12428e703c8b317888f207..eda7630558c3dc53bea1b4e17d3ff88330cee397 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -17,8 +17,8 @@ import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.Ab import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; -import { CameraUtil } from '../utils/CameraUtil'; import { camera } from '@kit.CameraKit'; +import { CameraUtil } from '../utils/CameraUtil'; import { WindowUtil } from '../utils/WindowUtil'; const DOMAIN = 0x0000; @@ -30,13 +30,14 @@ export default class EntryAbility extends UIAbility { windowUtil?: WindowUtil = WindowUtil.getInstance(); isFirstCreated: boolean = true; onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { + this.setOrientation(this.uiContext!.px2vp(windowSize.width), this.uiContext!.px2vp(windowSize.height)); + AppStorage.setOrCreate('windowSize', windowSize); let widthBp: WidthBreakpoint = this.uiContext!.getWindowWidthBreakpoint(); AppStorage.setOrCreate('widthBp', widthBp); let heightBp: HeightBreakpoint = this.uiContext!.getWindowHeightBreakpoint(); AppStorage.setOrCreate('heightBp', heightBp); let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); - this.setOrientation(this.uiContext!.px2vp(windowSize.width), this.uiContext!.px2vp(windowSize.height)); let isFront: boolean | undefined = AppStorage.get('isFront'); let surfaceId: string | undefined = AppStorage.get('surfaceId'); if (widthBp === WidthBreakpoint.WIDTH_MD && heightBp === HeightBreakpoint.HEIGHT_MD && @@ -48,10 +49,6 @@ export default class EntryAbility extends UIAbility { // When switching to a wide folding external screen, onForeground() will be triggered. return; } - if (this.isFirstCreated) { - this.isFirstCreated = false; - return; - } if (isFront) { this.cameraUtil?.cameraShooting(surfaceId!, this.context!, camera.CameraPosition.CAMERA_POSITION_FRONT); } else { @@ -93,12 +90,16 @@ export default class EntryAbility extends UIAbility { data.setWindowLayoutFullScreen(true); data.setWindowSystemBarEnable([]); this.uiContext = data.getUIContext(); + // Obtain the crease area of the folding screen. + this.windowUtil!.getFoldCreaseRegion(this.uiContext); + // First time obtaining breakpoint and screen display orientation. let widthBp: WidthBreakpoint = this.uiContext.getWindowWidthBreakpoint(); let heightBp: HeightBreakpoint = this.uiContext.getWindowHeightBreakpoint(); AppStorage.setOrCreate('widthBp', widthBp); AppStorage.setOrCreate('heightBp', heightBp); let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; AppStorage.setOrCreate('displayOrientation', displayOrientation); + // Monitor window size changes and update breakpoints. data.on('windowSizeChange', this.onWindowSizeChange); let rect: window.Rect = data.getWindowProperties().windowRect; this.setOrientation(this.uiContext.px2vp(rect.width), this.uiContext.px2vp(rect.height)); @@ -117,6 +118,11 @@ export default class EntryAbility extends UIAbility { onForeground(): void { // Ability has brought to foreground hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + if (this.isFirstCreated) { + this.isFirstCreated = false; + return; + } + // When the front-end displays the camera application, regenerate the preview stream. if (AppStorage.get('isBackground')) { this.cameraUtil?.fromBack(); AppStorage.setOrCreate('isBackground', false); @@ -126,6 +132,7 @@ export default class EntryAbility extends UIAbility { onBackground(): void { // Ability has back to background hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + // Release camera session and streams when the application is hidden in the background. this.cameraUtil?.releaseCamera(); AppStorage.setOrCreate('isBackground', true); } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 534da741c9d476836732533f8f6e6f8a19419f27..418c208bb2ef61f29e3a4585fc7692336ef07121 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -26,7 +26,7 @@ import { WindowUtil } from '../utils/WindowUtil'; struct Index { @StorageLink('widthBp') widthBp: WidthBreakpoint = WidthBreakpoint.WIDTH_SM; @StorageLink('heightBp') heightBp: HeightBreakpoint = HeightBreakpoint.HEIGHT_SM; - @StorageLink('displayOrientation') displayOrientation: display.Orientation = display.Orientation.PORTRAIT; + @StorageLink('displayOrientation') displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; @StorageLink('photoUri') photoUri: string | Resource | PixelMap = ''; @StorageLink('surfaceId') surfaceId: string = ''; @StorageLink('rotation') rotation: number = 0; @@ -45,22 +45,35 @@ struct Index { onFoldStatusChange: (foldStatus: display.FoldStatus) => void = (foldStatus: display.FoldStatus) => { if (foldStatus === display.FoldStatus.FOLD_STATUS_HALF_FOLDED) { let orientation: display.Orientation = display.getDefaultDisplaySync().orientation; + // 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)) { this.isHalfFolded = true; + this.cameraUtil!.setXComponentRect(this.windowUtil!.getWindowSize()); this.windowUtil?.setMainWindowOrientation(window.Orientation.LANDSCAPE); } - } else { - this.isHalfFolded = false; - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); + } + // 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); + } } }; aboutToAppear(): void { - this.windowUtil!.getFoldCreaseRegion(this.getUIContext()); display.on('foldStatusChange', this.onFoldStatusChange); + // Apply to the user for permission to access the camera and gallery. abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.context, this.permissions).then(() => { setTimeout(async () => { + // After obtaining permission, load the camera preview stream and ensure it is consistent with the aspect ratio of the surface. + this.cameraUtil?.setSurfaceProfile(this.xComponentController, this.getUIContext()); this.cameraUtil?.cameraShooting(this.surfaceId, this.context!, camera.CameraPosition.CAMERA_POSITION_BACK); }, 200); }) @@ -82,22 +95,19 @@ struct Index { }) {} .onLoad(async () => { this.surfaceId = this.xComponentController.getXComponentSurfaceId(); + // Set surface to lock direction when screen rotates. this.xComponentController.setXComponentSurfaceRotation({ lock: true }); }) .onDestroy(() => { + // Release camera session and streams. this.cameraUtil?.releaseCamera(); }) - .width(this.widthBp === WidthBreakpoint.WIDTH_SM || (this.widthBp === WidthBreakpoint.WIDTH_MD && - this.heightBp === HeightBreakpoint.HEIGHT_LG)? '100%' : '') - .height(this.widthBp !== WidthBreakpoint.WIDTH_SM && (this.widthBp !== WidthBreakpoint.WIDTH_MD && - this.heightBp !== HeightBreakpoint.HEIGHT_LG)? '100%' : '') - .aspectRatio(this.getXComponentAspectRatio()) + .width('100%') + .height(this.isHalfFolded ? this.creaseRegion[0] : '100%') } .width('100%') .height(this.isHalfFolded ? this.creaseRegion[0] : '') .layoutWeight(this.isHalfFolded ? 0 : 1) - .alignItems(this.widthBp === WidthBreakpoint.WIDTH_MD && this.heightBp === HeightBreakpoint.HEIGHT_MD && - !this.isHalfFolded ? HorizontalAlign.Start : HorizontalAlign.Center) .margin({ bottom: deviceInfo.productSeries !== 'VDE' && this.widthBp === WidthBreakpoint.WIDTH_SM ? 156 : 0 }) // Shooting button view. @@ -214,8 +224,8 @@ struct Index { .alignContent(Alignment.BottomEnd) .visibility(this.isHalfFolded ? Visibility.None : Visibility.Visible) + // Half folded view. Stack() { - // Half folded view. Row() { SettingButton({ imageButton: $r('app.media.icon_lighting'), @@ -301,30 +311,4 @@ struct Index { .hideToolBar(true) .backgroundColor(Color.Black) } - - getXComponentAspectRatio(): number { - if (this.widthBp === WidthBreakpoint.WIDTH_SM) { - if (this.heightBp === HeightBreakpoint.HEIGHT_LG) { - return 0.75; - } - return 1; - } - if (this.widthBp === WidthBreakpoint.WIDTH_MD) { - if (this.heightBp === HeightBreakpoint.HEIGHT_MD && (this.displayOrientation === display.Orientation.LANDSCAPE || - this.displayOrientation === display.Orientation.LANDSCAPE_INVERTED)) { - return 1.33; - } else if (this.heightBp === HeightBreakpoint.HEIGHT_LG && deviceInfo.productSeries === 'GRL') { - return 1.33; - } else { - return 0.75; - } - } - if (this.widthBp === WidthBreakpoint.WIDTH_LG) { - if (deviceInfo.productSeries === 'GRL') { - return 0.75 - } - return 1.33; - } - return 1.33; - } } \ No newline at end of file diff --git a/entry/src/main/ets/utils/CameraUtil.ets b/entry/src/main/ets/utils/CameraUtil.ets index 64f9aba60657232dc52df6414ed72067c00f5528..75f05b37bbedeeec70f2f88ab291ae87a386f652 100644 --- a/entry/src/main/ets/utils/CameraUtil.ets +++ b/entry/src/main/ets/utils/CameraUtil.ets @@ -13,13 +13,15 @@ * limitations under the License. */ -import { camera } from "@kit.CameraKit" -import { common, Context } from "@kit.AbilityKit"; -import { hilog } from "@kit.PerformanceAnalysisKit"; -import { BusinessError, deviceInfo } from "@kit.BasicServicesKit"; -import { photoAccessHelper } from "@kit.MediaLibraryKit"; -import { colorSpaceManager } from "@kit.ArkGraphics2D"; -import { sensor } from "@kit.SensorServiceKit"; +import { camera } from '@kit.CameraKit'; +import { common, Context } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; +import { photoAccessHelper } from '@kit.MediaLibraryKit'; +import { colorSpaceManager } from '@kit.ArkGraphics2D'; +import { sensor } from '@kit.SensorServiceKit'; +import { display, window } from '@kit.ArkUI'; +import { WindowUtil } from './WindowUtil'; export class CameraUtil { previewOutput?: camera.PreviewOutput; @@ -29,6 +31,9 @@ export class CameraUtil { uri: string = ''; currentContext?: Context; surfaceId: string = ''; + xComponentController?: XComponentController; + uiContext?: UIContext; + windowUtil?: WindowUtil = WindowUtil.getInstance(); static getInstance(): CameraUtil | undefined { if (!AppStorage.get('cameraUtil')) { @@ -40,6 +45,7 @@ export class CameraUtil { async cameraShooting(surfaceId: string, context: Context, cameraPosition: camera.CameraPosition): Promise { this.surfaceId = surfaceId; this.currentContext = context; + // Release camera session and streams, to avoid conflicts in camera resource usage. this.releaseCamera(); let cameraManager: camera.CameraManager = camera.getCameraManager(context); if (!cameraManager) { @@ -50,10 +56,13 @@ export class CameraUtil { if (cameraArray.length <= 0) { return; } + // Select front and rear camera. let cameraIndex: number = this.getCamera(cameraArray, cameraPosition); + // Create a camera input stream based on the camera. this.cameraInput = cameraManager.createCameraInput(cameraArray[cameraIndex]); // Open the camera. await this.cameraInput.open(); + // Get the supported modes of the camera and select the photo mode. let sceneModes: camera.SceneMode[] = cameraManager.getSupportedSceneModes(cameraArray[cameraIndex]); let cameraOutputCap: camera.CameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraArray[cameraIndex], camera.SceneMode.NORMAL_PHOTO); @@ -65,6 +74,7 @@ export class CameraUtil { return; } + // Get camera preview and photo configuration. let previewProfileArray: camera.Profile[] = cameraOutputCap.previewProfiles; let previewProfile: camera.Profile = this.getProfile(previewProfileArray); let photoProfileArray: camera.Profile[] = cameraOutputCap.photoProfiles; @@ -78,9 +88,11 @@ export class CameraUtil { if (this.photoOutput === undefined) { return; } - // Save photo. + // Save photo. this.setPhotoOutputCb(); - + // Configure the camera preview stream to match the aspect ratio of the surface, otherwise the preview page will be compressed or stretched. + this.setXComponentRect(this.windowUtil!.getWindowSize()); + // Create the camera session and config. this.photoSession = cameraManager.createSession(camera.SceneMode.NORMAL_PHOTO); if (this.photoSession === undefined) { return; @@ -91,11 +103,6 @@ export class CameraUtil { this.photoSession.addOutput(this.photoOutput); this.photoSession.setColorSpace(colorSpaceManager.ColorSpace.DISPLAY_P3); await this.photoSession.commitConfig(); - try { - this.previewOutput.setPreviewRotation(camera.ImageRotation.ROTATION_270, true); - } catch (err) { - hilog.error(0x0000, 'testLog', `Fail to set rotation, err: ${JSON.stringify(err)}`); - } await this.photoSession.start(); return; } @@ -103,10 +110,12 @@ export class CameraUtil { getCamera(cameras: Array, cameraPosition: camera.CameraPosition): number { let widthBp: WidthBreakpoint | undefined = AppStorage.get('widthBp'); let heightBp: HeightBreakpoint | undefined = AppStorage.get('heightBp'); + // Three fold M-mode cannot use the front camera. if (widthBp === WidthBreakpoint.WIDTH_MD && heightBp === HeightBreakpoint.HEIGHT_MD && - deviceInfo.productSeries === 'GRL' ? Visibility.Hidden : Visibility.Visible) { + deviceInfo.productSeries === 'GRL') { cameraPosition = camera.CameraPosition.CAMERA_POSITION_BACK; } + // Choose front or rear camera. for (let i: number = 0; i < cameras.length; ++i) { if (cameras[i].cameraPosition === cameraPosition) { if (cameraPosition === camera.CameraPosition.CAMERA_POSITION_BACK) { @@ -129,11 +138,12 @@ export class CameraUtil { } getProfile(profileArray: camera.Profile[]): camera.Profile { - // 根据断点返回profile + // Return profile based on breakpoint. let widthBp: WidthBreakpoint | undefined = AppStorage.get('widthBp'); let heightBp: HeightBreakpoint | undefined = AppStorage.get('heightBp'); + // Choose a preview or camera configuration with an aspect ratio of 4:3, and select a 1:1 configuration on the Purax external screen. let aspectRatio: number = 4 / 3; - if (widthBp === WidthBreakpoint.WIDTH_SM && heightBp !== HeightBreakpoint.HEIGHT_LG) { + if (widthBp === WidthBreakpoint.WIDTH_SM && heightBp === HeightBreakpoint.HEIGHT_MD) { aspectRatio = 1; } let maxWidth: number = 0; @@ -167,6 +177,7 @@ export class CameraUtil { new photoAccessHelper.MediaAssetChangeRequest(photoAsset); assetChangeRequest.saveCameraPhoto(); await accessHelper.applyChanges(assetChangeRequest); + // Save the address of the latest photo. this.uri = photoAsset.uri; AppStorage.setOrCreate('photoUri', await photoAsset.getThumbnail()); }) @@ -178,25 +189,25 @@ export class CameraUtil { sensor.once(sensor.SensorId.GRAVITY, async (data: sensor.GravityResponse) => { let degree: number = this.getCalDegree(data.x, data.y, data.z); let isFront: boolean | undefined = AppStorage.get('isFront'); - if (degree >= 0 && (degree <= 30 || degree >= 330)) { + if (degree >= 0 && (degree <= 30 || degree >= 300)) { rotation = camera.ImageRotation.ROTATION_0; - } else if (degree >= 60 && degree <= 120) { + } else if (degree > 30 && degree <= 120) { if (isFront) { - // Use ROTATION_270 when degree range is [60, 120] for front camera. + // Use ROTATION_270 when degree range is (30, 120] for front camera. rotation = camera.ImageRotation.ROTATION_270; } else { - // Use ROTATION_90 when degree range is [60, 120] for back camera. + // Use ROTATION_90 when degree range is (30, 120] for back camera. rotation = camera.ImageRotation.ROTATION_90; } - } else if (degree >= 150 && degree <= 210) { - // Use ROTATION_180 when degree range is [150, 210]. + } else if (degree > 120 && degree <= 210) { + // Use ROTATION_180 when degree range is (120, 210]. rotation = camera.ImageRotation.ROTATION_180; - } else if (degree >= 240 && degree <= 300) { + } else if (degree > 210 && degree <= 300) { if (isFront) { - // Use ROTATION_90 when degree range is [240, 300] for front camera. + // Use ROTATION_90 when degree range is (210, 300] for front camera. rotation = camera.ImageRotation.ROTATION_90; } else { - // Use ROTATION_270 when degree range is [240, 300] for back camera. + // Use ROTATION_270 when degree range is (210, 300] for back camera. rotation = camera.ImageRotation.ROTATION_270; } }; @@ -239,7 +250,7 @@ export class CameraUtil { previewPhoto(): void { let photoContext: common.UIAbilityContext = this.currentContext as common.UIAbilityContext; - // Start the gallery application. + // Start the gallery application to preview photo. photoContext.startAbility({ parameters: { uri: this.uri }, action: 'ohos.want.action.viewData', @@ -261,4 +272,62 @@ export class CameraUtil { degree = 90 - (Number)(Math.round(Math.atan2(y, -x) / Math.PI * 180)); return degree >= 0 ? degree % 360 : degree % 360 + 360; } + + setSurfaceProfile(xComponentController: XComponentController, uiContext: UIContext): void { + this.xComponentController = xComponentController; + this.uiContext = uiContext; + } + + setXComponentRect(windowSize: window.Size): void { + let creaseRegion: number[] | undefined = AppStorage.get('creaseRegion'); + // Initialize the width and height of the surface to match the full screen of the window. + let rect: SurfaceRect = { + surfaceWidth: windowSize.width, + surfaceHeight: windowSize.height + }; + // Set the width and height of the half folded page surface. + if (AppStorage.get('isHalfFolded')) { + rect.surfaceHeight = this.uiContext!.vp2px(creaseRegion![0]); + rect.surfaceWidth = this.uiContext!.vp2px(creaseRegion![0]) / 3 * 4; + this.xComponentController!.setXComponentSurfaceRect(rect); + return; + } + let widthBp: WidthBreakpoint = this.uiContext!.getWindowWidthBreakpoint(); + let heightBp: HeightBreakpoint = this.uiContext!.getWindowHeightBreakpoint(); + let displayOrientation: display.Orientation = display.getDefaultDisplaySync().orientation; + // Landscape for Mate X5 fold status expand, or Mate XT M-mode. + if (widthBp === WidthBreakpoint.WIDTH_MD && heightBp === HeightBreakpoint.HEIGHT_MD && (displayOrientation === + display.Orientation.LANDSCAPE || displayOrientation === display.Orientation.LANDSCAPE_INVERTED)) { + rect.surfaceHeight = windowSize.width / 4 * 3; + } + // Portrait for Mate X5 fold status expand, or Mate XT M-mode. + else if(widthBp === WidthBreakpoint.WIDTH_MD && heightBp === HeightBreakpoint.HEIGHT_MD && (displayOrientation === + display.Orientation.PORTRAIT || displayOrientation === display.Orientation.PORTRAIT_INVERTED)) { + rect.offsetX = 0; + rect.offsetY = 0; + rect.surfaceWidth = windowSize.height / 4 * 3; + } + // Landscape for tablet. + else if (widthBp === WidthBreakpoint.WIDTH_LG && heightBp === HeightBreakpoint.HEIGHT_SM && + deviceInfo.productSeries !== 'GRL') { + rect.surfaceWidth = windowSize.height / 3 * 4; + } + // Portrait for Mate XT G-mode. + else if (widthBp === WidthBreakpoint.WIDTH_MD && heightBp === HeightBreakpoint.HEIGHT_LG && + deviceInfo.productSeries === 'GRL') { + rect.surfaceHeight = windowSize.width / 4 * 3; + } + // Landscape for Mate XT G-mode. + else if (widthBp === WidthBreakpoint.WIDTH_LG && heightBp === HeightBreakpoint.HEIGHT_SM && + deviceInfo.productSeries === 'GRL') { + rect.surfaceWidth = windowSize.height / 4 * 3; + } + // Pura X external screen. + else if (widthBp === WidthBreakpoint.WIDTH_SM && heightBp === HeightBreakpoint.HEIGHT_MD) {} + // Portrait for phone and tablet. + else { + rect.surfaceHeight = windowSize.width / 3 * 4; + } + this.xComponentController!.setXComponentSurfaceRect(rect); + } } \ No newline at end of file diff --git a/entry/src/main/ets/utils/WindowUtil.ets b/entry/src/main/ets/utils/WindowUtil.ets index 09b5488cc75bdae38bbd8de1b7461ff567077f7b..635df82a44628bb9e51c39fc335b1e5f22a88905 100644 --- a/entry/src/main/ets/utils/WindowUtil.ets +++ b/entry/src/main/ets/utils/WindowUtil.ets @@ -13,15 +13,14 @@ * limitations under the License. */ -import { display, window } from "@kit.ArkUI"; -import { hilog } from "@kit.PerformanceAnalysisKit"; -import { BusinessError } from "@kit.BasicServicesKit"; +import { display, window } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; export class WindowUtil { windowStage?: window.WindowStage; mainWindow?: window.Window; - static getInstance(): WindowUtil | undefined { if (!AppStorage.get('windowUtil')) { AppStorage.setOrCreate('windowUtil', new WindowUtil()); @@ -66,4 +65,13 @@ export class WindowUtil { AppStorage.setOrCreate('creaseRegion', creaseRegion); } } + + getWindowSize(): window.Size { + let rect: window.Rect = this.mainWindow!.getWindowProperties().windowRect; + let result: window.Size = { + width: rect.width, + height: rect.height + }; + return result; + } } \ No newline at end of file diff --git a/entry/src/main/ets/views/CommonView.ets b/entry/src/main/ets/views/CommonView.ets index 38ec506f5d1a8183b57dc9880068991aad5f8583..a6fc0a0752a0bed8894dd55eb6ca154ed568a178 100644 --- a/entry/src/main/ets/views/CommonView.ets +++ b/entry/src/main/ets/views/CommonView.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import { curves } from "@kit.ArkUI"; -import { camera } from "@kit.CameraKit"; -import { BreakpointType } from "../utils/BreakpointType"; -import { CameraUtil } from "../utils/CameraUtil"; +import { curves } from '@kit.ArkUI'; +import { camera } from '@kit.CameraKit'; +import { BreakpointType } from '../utils/BreakpointType'; +import { CameraUtil } from '../utils/CameraUtil'; @Component export struct ChooseMusic { diff --git a/screenshots/device/mate60.png b/screenshots/device/mate60.png new file mode 100644 index 0000000000000000000000000000000000000000..8b97cd0987d7fcc306d35dbb0eb8bfc99199e3aa Binary files /dev/null and b/screenshots/device/mate60.png differ diff --git a/screenshots/device/matepadpro.png b/screenshots/device/matepadpro.png new file mode 100644 index 0000000000000000000000000000000000000000..b11841b70e0d11aebf64f8098a6e506f30959ead Binary files /dev/null and b/screenshots/device/matepadpro.png differ diff --git a/screenshots/device/matex5.png b/screenshots/device/matex5.png new file mode 100644 index 0000000000000000000000000000000000000000..72800662fb76fe4c6c62b549bd8bd66405bce474 Binary files /dev/null and b/screenshots/device/matex5.png differ diff --git a/screenshots/device/matext.png b/screenshots/device/matext.png new file mode 100644 index 0000000000000000000000000000000000000000..108fd5eea0c81a33a27ae08363b7d9c74045d260 Binary files /dev/null and b/screenshots/device/matext.png differ diff --git a/screenshots/device/purax.png b/screenshots/device/purax.png new file mode 100644 index 0000000000000000000000000000000000000000..d45c0f8ea977e9002a0fb2af73b5312b8b9e00f5 Binary files /dev/null and b/screenshots/device/purax.png differ