From de93413fbc249346db84080c2ba0435739982ca6 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 14 Dec 2024 16:22:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9ohos.py=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- attachment/scripts/ohos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachment/scripts/ohos.py b/attachment/scripts/ohos.py index d60c405775..acf42ab53f 100644 --- a/attachment/scripts/ohos.py +++ b/attachment/scripts/ohos.py @@ -298,7 +298,7 @@ def zipFiles(buildInfo, useZip2=False, args=any): prefixInZip = os.path.join("src", "out", outputName) excludes = ["obj", "exe.unstripped", "so.unstripped"] if IS_WINDOWS: - excludes.extend([".*\.ilk", ".*\.pdb"]) + excludes.extend([r".*\.ilk", r".*\.pdb"]) zipFileDir(fileIn, fileName, prefixInZip, excludes=excludes, useZip2=useZip2) -- Gitee From 7fb6737b6339c464664e23ede83d8e855b6653c4 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 14 Dec 2024 16:25:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9FlutterView.ets,=E6=9C=89?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=B6=E5=8F=96=E5=80=BC=E4=B8=8D=E5=8F=98?= =?UTF-8?q?,=E9=81=BF=E5=85=8D=E7=8A=B6=E6=80=81=E6=A0=8F=E5=81=B6?= =?UTF-8?q?=E7=8E=B0=E9=AB=98=E5=BA=A6=E4=B8=BA0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../flutter/src/main/ets/view/FlutterView.ets | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index c8b2fd6742..5f5d50c849 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -388,16 +388,20 @@ export class FlutterView { // 根据是否全屏显示,设置标题栏高度(若全屏,则及时规避) if (this.checkFullScreen && (setFullScreen || this.mainWindow?.getWindowProperties().isLayoutFullScreen)) { // 全屏显示 - this.viewportMetrics.physicalViewPaddingTop = this.systemAvoidArea?.topRect.height ?? 0; - this.viewportMetrics.physicalViewPaddingBottom = this.navigationAvoidArea?.bottomRect.height ?? 0; + this.viewportMetrics.physicalViewPaddingTop = + this.systemAvoidArea?.topRect.height ?? this.viewportMetrics.physicalViewPaddingTop; + this.viewportMetrics.physicalViewPaddingBottom = + this.navigationAvoidArea?.bottomRect.height ?? this.viewportMetrics.physicalViewPaddingBottom; } else { // 非全屏显示(保持规避效果) // 顶部状态栏和底部导航栏规避为0,无平滑过渡效果 this.viewportMetrics.physicalViewPaddingTop = 0; this.viewportMetrics.physicalViewPaddingBottom = 0; } - this.viewportMetrics.physicalViewPaddingLeft = this.systemAvoidArea?.leftRect.width ?? 0; - this.viewportMetrics.physicalViewPaddingRight = this.systemAvoidArea?.rightRect.width ?? 0; + this.viewportMetrics.physicalViewPaddingLeft = + this.systemAvoidArea?.leftRect.width ?? this.viewportMetrics.physicalViewPaddingLeft; + this.viewportMetrics.physicalViewPaddingRight = + this.systemAvoidArea?.rightRect.width ?? this.viewportMetrics.physicalViewPaddingRight; this.onKeyboardAreaChange() this.onGestureAreaChange() @@ -410,10 +414,14 @@ export class FlutterView { private onKeyboardAreaChange() { if (this.checkKeyboard) { - this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.physicalViewInsetRight = this.keyboardAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.physicalViewInsetTop = + this.keyboardAvoidArea?.topRect.height ?? this.viewportMetrics.physicalViewInsetTop + this.viewportMetrics.physicalViewInsetLeft = + this.keyboardAvoidArea?.leftRect.width ?? this.viewportMetrics.physicalViewInsetLeft + this.viewportMetrics.physicalViewInsetBottom = + this.keyboardAvoidArea?.bottomRect.height ?? this.viewportMetrics.physicalViewInsetBottom + this.viewportMetrics.physicalViewInsetRight = + this.keyboardAvoidArea?.rightRect.width ?? this.viewportMetrics.physicalViewInsetRight } else { this.viewportMetrics.physicalViewInsetTop = 0 this.viewportMetrics.physicalViewInsetLeft = 0 @@ -424,10 +432,14 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { - this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.systemGestureInsetRight = this.gestureAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.systemGestureInsetTop = + this.gestureAvoidArea?.topRect.height ?? this.viewportMetrics.systemGestureInsetTop + this.viewportMetrics.systemGestureInsetLeft = + this.gestureAvoidArea?.leftRect.width ?? this.viewportMetrics.systemGestureInsetLeft + this.viewportMetrics.systemGestureInsetBottom = + this.gestureAvoidArea?.bottomRect.height ?? this.viewportMetrics.systemGestureInsetBottom + this.viewportMetrics.systemGestureInsetRight = + this.gestureAvoidArea?.rightRect.width ?? this.viewportMetrics.systemGestureInsetRight } else { this.viewportMetrics.systemGestureInsetTop = 0 this.viewportMetrics.systemGestureInsetLeft = 0 -- Gitee From 1b7f70a2d5ea1c89c2b9988bca186f4a06042618 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sat, 14 Dec 2024 16:27:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20UIAbility+FlutterEntry?= =?UTF-8?q?=20=E5=9C=BA=E6=99=AF,=E6=8F=92=E4=BB=B6=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20onAttachedToAbility=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../main/ets/embedding/ohos/FlutterAbility.ets | 2 +- .../main/ets/embedding/ohos/FlutterEntry.ets | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets index d13fd9859a..9eb08c3d5e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets @@ -319,7 +319,7 @@ export class FlutterAbility extends UIAbility implements Host { if (this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] != undefined) { return this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as boolean; } - if (this.getCachedEngineId() != null) { + if (this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) { // Prevent overwriting the existing state in a cached engine with restoration state. return false; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets index 38f0192ea0..de27aa398f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets @@ -152,15 +152,27 @@ export default class FlutterEntry implements Host { } shouldAttachEngineToAbility(): boolean { - return this.parameters![FlutterEntry.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY] as boolean + let param = this.parameters![FlutterEntry.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY]; + if (!param) { + return true; + } + return param as boolean } getCachedEngineId(): string { - return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as string + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID]; + if (!param) { + return ""; + } + return param as string } getCachedEngineGroupId(): string | null { - return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID] as string + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID]; + if (!param) { + return null; + } + return param as string } shouldDestroyEngineWithHost(): boolean { -- Gitee