Showing
2 changed files
with
33 additions
and
3 deletions
| @@ -82,4 +82,20 @@ export class DeviceUtil { | @@ -82,4 +82,20 @@ export class DeviceUtil { | ||
| 82 | static getRandomUUIDForTraceID(): string { | 82 | static getRandomUUIDForTraceID(): string { |
| 83 | return util.generateRandomUUID().toUpperCase().replace(/-/g, '') | 83 | return util.generateRandomUUID().toUpperCase().replace(/-/g, '') |
| 84 | } | 84 | } |
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 是否为phone设备(可折叠手机即便完全展开状态也返回true) | ||
| 88 | + * @returns | ||
| 89 | + */ | ||
| 90 | + static isPhone(): boolean { | ||
| 91 | + return deviceInfo.deviceType == 'phone' || deviceInfo.deviceType == 'default'; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + static isNotPhone(): boolean { | ||
| 95 | + return !DeviceUtil.isPhone(); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + static isTablet(): boolean { | ||
| 99 | + return deviceInfo.deviceType == 'tablet'; | ||
| 100 | + } | ||
| 85 | } | 101 | } |
| @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; | @@ -4,7 +4,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; | ||
| 4 | import Want from '@ohos.app.ability.Want'; | 4 | import Want from '@ohos.app.ability.Want'; |
| 5 | import window from '@ohos.window'; | 5 | import window from '@ohos.window'; |
| 6 | import { BusinessError } from '@ohos.base'; | 6 | import { BusinessError } from '@ohos.base'; |
| 7 | -import { EmitterEventId, EmitterUtils, WindowModel } from 'wdKit'; | 7 | +import { DeviceUtil, EmitterEventId, EmitterUtils, WindowModel } from 'wdKit'; |
| 8 | import { ConfigurationConstant } from '@kit.AbilityKit'; | 8 | import { ConfigurationConstant } from '@kit.AbilityKit'; |
| 9 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; | 9 | import { WDPushNotificationManager } from 'wdHwAbility/Index'; |
| 10 | import { StartupManager } from '../startupmanager/StartupManager'; | 10 | import { StartupManager } from '../startupmanager/StartupManager'; |
| @@ -52,8 +52,20 @@ export default class EntryAbility extends UIAbility { | @@ -52,8 +52,20 @@ export default class EntryAbility extends UIAbility { | ||
| 52 | console.info('floatWindowClass audioWidth' + audioWidth); | 52 | console.info('floatWindowClass audioWidth' + audioWidth); |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | - // let a = new WindowModel(); | ||
| 56 | - // 设置窗口的显示方向属性 | 55 | + // 在普通phone/折叠屏/tablet设备上以沉浸式(全屏)启动 |
| 56 | + if (DeviceUtil.isPhone() || DeviceUtil.isTablet()) { | ||
| 57 | + // 设置窗口的布局是否为沉浸式布局 | ||
| 58 | + // 沉浸式布局是指布局不避让状态栏与导航栏,组件可能产生与其重叠的情况。 | ||
| 59 | + // 非沉浸式布局是指布局避让状态栏与导航栏,组件不会与其重叠。 | ||
| 60 | + // windowClass.setWindowLayoutFullScreen(true) | ||
| 61 | + // 设置窗口全屏模式时窗口内导航栏、状态栏的属性 | ||
| 62 | + // windowClass.setWindowSystemBarProperties({ | ||
| 63 | + // statusBarContentColor: "#FFFFFF" | ||
| 64 | + // }) | ||
| 65 | + | ||
| 66 | + // 设置启动时窗口的显示方向属性, | ||
| 67 | + // 普通phone以PORTRAIT/竖屏显示模式启动 | ||
| 68 | + // 折叠屏和tablet是以AUTO_ROTATION_RESTRICTED/受开关控制的自动旋转模式启动 | ||
| 57 | WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT) | 69 | WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT) |
| 58 | .then(() => { | 70 | .then(() => { |
| 59 | hilog.info(0x0000, 'testTag', 'setPreferredOrientation Succeeded'); | 71 | hilog.info(0x0000, 'testTag', 'setPreferredOrientation Succeeded'); |
| @@ -62,6 +74,8 @@ export default class EntryAbility extends UIAbility { | @@ -62,6 +74,8 @@ export default class EntryAbility extends UIAbility { | ||
| 62 | hilog.error(0x0000, 'testTag', | 74 | hilog.error(0x0000, 'testTag', |
| 63 | `setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`); | 75 | `setPreferredOrientation catch, error error.name : ${err.name}, error.message:${err.message}`); |
| 64 | }) | 76 | }) |
| 77 | + } | ||
| 78 | + | ||
| 65 | //../../../../../../features/wdLogin/src/main/ets/pages/launchPage/LaunchPage | 79 | //../../../../../../features/wdLogin/src/main/ets/pages/launchPage/LaunchPage |
| 66 | windowStage.loadContent('pages/launchPage/LaunchPage', (err, data) => { | 80 | windowStage.loadContent('pages/launchPage/LaunchPage', (err, data) => { |
| 67 | if (err.code) { | 81 | if (err.code) { |
-
Please register or login to post a comment