diff --git a/build-profile.json5 b/build-profile.json5 index 4d15135e88b26f4465203a25be541d1664be25f4..c22fe515a0cca759389cb2f85ea84048b4e8880a 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -6,7 +6,7 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.4(16)", "runtimeOS": "HarmonyOS", "buildOption": { "strictMode": { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index dd18aedd94d45f4d9113a0a75e043e73308a9c1b..f2b9a711f6fddde64e392fb335cdf11a1db9b1ec 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -17,7 +17,7 @@ import { common, Want } from '@kit.AbilityKit'; @Entry @Component struct Index { - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { diff --git a/features/longList/src/main/ets/pages/Index.ets b/features/longList/src/main/ets/pages/Index.ets index 846b59451851aedb7f27293884c154355eb1599f..723336ff3b0f9bdd9cd15d074d83aac56ae53093 100644 --- a/features/longList/src/main/ets/pages/Index.ets +++ b/features/longList/src/main/ets/pages/Index.ets @@ -29,7 +29,7 @@ struct Index { @StorageLink(CommonConstants.LANGUAGE) language: string = CommonConstants.CHINESE_LANGUAGE; @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State windowsHeight: number = CommonConstants.NUMBER_DEFAULT_VALUE; - private breakpointSystem: BreakpointSystem = new BreakpointSystem(); + private breakpointSystem: BreakpointSystem = new BreakpointSystem(this.getUIContext()); private indexPage: string = CommonConstants.CHINESE_LANGUAGE; onBackPress() { diff --git a/features/longList/src/main/ets/utils/BreakpointSystem.ets b/features/longList/src/main/ets/utils/BreakpointSystem.ets index f0ede609789bdd86c37617a7955bbd17378044c7..310e44405a30c374f8479564b76190c031043e75 100644 --- a/features/longList/src/main/ets/utils/BreakpointSystem.ets +++ b/features/longList/src/main/ets/utils/BreakpointSystem.ets @@ -52,9 +52,15 @@ export class BreakpointType { export class BreakpointSystem { private readonly listenerKey = 'change'; private currentBreakpoint: string = BreakpointConstants.BREAKPOINT_SM; - private smListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_SM); - private mdListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_MD); - private lgListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_LG); + private smListener: mediaQuery.MediaQueryListener; + private mdListener: mediaQuery.MediaQueryListener; + private lgListener: mediaQuery.MediaQueryListener; + + constructor(context: UIContext) { + this.smListener = context.getMediaQuery().matchMediaSync(BreakpointConstants.RANGE_SM); + this.mdListener = context.getMediaQuery().matchMediaSync(BreakpointConstants.RANGE_MD); + this.lgListener = context.getMediaQuery().matchMediaSync(BreakpointConstants.RANGE_LG); + } private updateCurrentBreakpoint(breakpoint: string): void { if (this.currentBreakpoint !== breakpoint) { diff --git a/features/longList/src/main/ets/view/HomeContent.ets b/features/longList/src/main/ets/view/HomeContent.ets index 35d1df19003a4a743f7e864bddda7478eb103a3a..688b3efc788a9bbc70c1d60098c2b25ae1e16832 100644 --- a/features/longList/src/main/ets/view/HomeContent.ets +++ b/features/longList/src/main/ets/view/HomeContent.ets @@ -41,7 +41,7 @@ export struct HomeContent { @State netConnectState: NetConnectionState = NetConnectionState.UNKNOWN_STATE; public scroller: Scroller = new Scroller(); public waterFlowScroller: Scroller = new Scroller(); - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; watchCurrentOffset(){ if(this.setCurrentOffset){ @@ -66,7 +66,7 @@ export struct HomeContent { }, 3000); } else { try { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.net_connection_description'), bottom: 120, duration: 3000 diff --git a/features/longList/src/main/ets/view/WaterFlowView.ets b/features/longList/src/main/ets/view/WaterFlowView.ets index 4dd302eb776fb1a53048e47a67b82f4a42762aa6..bc88a7e7fc5c7a770c1cf7c840717b5260432002 100644 --- a/features/longList/src/main/ets/view/WaterFlowView.ets +++ b/features/longList/src/main/ets/view/WaterFlowView.ets @@ -66,7 +66,7 @@ export struct WaterFlowView { this.isShowFoot = false; } try { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.net_connection_description'), bottom: CommonConstants.TOAST_SHOW_MARGIN_BOTTOM, duration: CommonConstants.TOAST_SHOW_TIME @@ -102,7 +102,7 @@ export struct WaterFlowView { } getTitleHeight(title: string) { - let textWidth: number = MeasureText.measureText({ + let textWidth: number = this.getUIContext().getMeasureUtils().measureText({ textContent: title, fontSize: $r('app.float.font_size_14') }); diff --git a/features/video/src/main/ets/components/ExitVideo.ets b/features/video/src/main/ets/components/ExitVideo.ets index 8ea99b3d98838dcf9d51292a10f57a089cbc182e..c77d19f747da88dc2c4439d8fa4547e050e4cbfb 100644 --- a/features/video/src/main/ets/components/ExitVideo.ets +++ b/features/video/src/main/ets/components/ExitVideo.ets @@ -25,7 +25,7 @@ export struct ExitVideo { @StorageLink('show') show: boolean = false; @StorageLink('videoSelect') videoSelect: number = 0; @Link avPlayManage: avPlayManage; - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; private videoList: Resource[] = [$r('app.string.video_res_1'), $r('app.string.video_res_2')]; async isInternet(): Promise { @@ -37,7 +37,7 @@ export struct ExitVideo { } async toast() { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.video_warn'), duration: 2000, }); diff --git a/features/video/src/main/ets/pages/Index.ets b/features/video/src/main/ets/pages/Index.ets index 5882d51de77778e482c6a522b6c5048ebe4d8689..dd4683868b032d9c27190a323e6474ab8361211e 100644 --- a/features/video/src/main/ets/pages/Index.ets +++ b/features/video/src/main/ets/pages/Index.ets @@ -165,7 +165,7 @@ struct Index { } async toast() { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.video_warn'), duration: 2000, }); diff --git a/features/web/src/main/ets/pages/IndexPage.ets b/features/web/src/main/ets/pages/IndexPage.ets index 6f4404f338128693bb83559ad12bcad8d688f741..bbf5be0b7c59125fdf1d10d17bd106e9e3f03eaa 100644 --- a/features/web/src/main/ets/pages/IndexPage.ets +++ b/features/web/src/main/ets/pages/IndexPage.ets @@ -38,7 +38,7 @@ struct IndexPage { @State controller: webview.WebviewController = new webview.WebviewController(); @State statusBarHeight: number = 0; @State sliderBarHeight: number = 56; - private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; arkTSObj: ArkTSFunModel = { jumpOrderConfirm: (detailStr: string) => this.jumpOrderConfirm(detailStr) }; @@ -52,7 +52,7 @@ struct IndexPage { aboutToAppear() { webview.WebviewController.setWebDebuggingAccess(true); - window.getLastWindow(getContext(this), (err: BusinessError, windowClass: window.Window) => { + window.getLastWindow(this.getUIContext().getHostContext(), (err: BusinessError, windowClass: window.Window) => { if (err.code) { Logger.error(TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); return;