From 90f8ef6759dab7a67f9ef19b675201c6f2887e1b Mon Sep 17 00:00:00 2001 From: asklie <760956257@qq.com> Date: Mon, 20 Jan 2025 17:19:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E4=BF=AE=E5=BE=A9pc=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: asklie <760956257@qq.com> --- .../flutter/src/main/ets/view/FlutterView.ets | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 f402b642b7..df70f08c83 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 @@ -579,18 +579,20 @@ export class FlutterView { boundCount = boundCount + displayFeatures[i].getBounds().length; } let displayFeatureBound: number[] = new Array(boundCount * 4); - let displayFeatureType: number[] = new Array(displayFeatures.length); - let displayFeatureStatus: number[] = new Array(displayFeatures.length); - for (let i = 0; i < displayFeatures.length; i++) { - let singleFeatureBound = displayFeatures[i].getBounds(); - for (let j = 0; j < singleFeatureBound.length; j++) { - displayFeatureBound[4*i + 4*j] = singleFeatureBound[j].left; - displayFeatureBound[4*i + 4*j + 1] = singleFeatureBound[j].top - displayFeatureBound[4*i + 4*j + 2] = singleFeatureBound[j].width; - displayFeatureBound[4*i + 4*j + 3] = singleFeatureBound[j].height; + let displayFeatureType: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + let displayFeatureStatus: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + if (boundCount) { + for (let i = 0; i < displayFeatures.length; i++) { + let singleFeatureBound = displayFeatures[i].getBounds(); + for (let j = 0; j < singleFeatureBound.length; j++) { + displayFeatureBound[4 * i + 4 * j] = singleFeatureBound[j].left; + displayFeatureBound[4 * i + 4 * j + 1] = singleFeatureBound[j].top + displayFeatureBound[4 * i + 4 * j + 2] = singleFeatureBound[j].width; + displayFeatureBound[4 * i + 4 * j + 3] = singleFeatureBound[j].height; + } + displayFeatureType[i] = displayFeatures[i].getType(); + displayFeatureStatus[i] = displayFeatures[i].getState(); } - displayFeatureType[i] = displayFeatures[i].getType(); - displayFeatureStatus[i] = displayFeatures[i].getState(); } this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, -- Gitee From 465ddddced9b67a3ad34b0077b71cef21891a969 Mon Sep 17 00:00:00 2001 From: asklie <760956257@qq.com> Date: Tue, 21 Jan 2025 17:05:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E5=B5=8C=E5=A5=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: asklie <760956257@qq.com> --- .../flutter/src/main/ets/view/FlutterView.ets | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 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 df70f08c83..58a0d28da8 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 @@ -570,53 +570,53 @@ export class FlutterView { } private updateViewportMetrics(): boolean { - if (this.isAttachedToFlutterEngine()) { - Log.i(TAG, 'updateViewportMetrics devicePixelRatio:' + this.viewportMetrics.devicePixelRatio); + if (!this.isAttachedToFlutterEngine()) { + return false; + } + Log.i(TAG, 'updateViewportMetrics devicePixelRatio:' + this.viewportMetrics.devicePixelRatio); - const displayFeatures = this.viewportMetrics.displayFeatures; - let boundCount = 0; - for (let i = 0; i < displayFeatures.length; i++) { - boundCount = boundCount + displayFeatures[i].getBounds().length; + const displayFeatures = this.viewportMetrics.displayFeatures; + let boundCount = 0; + for (let i = 0; i < displayFeatures.length; i++) { + boundCount = boundCount + displayFeatures[i].getBounds().length; + } + let displayFeatureBound: number[] = new Array(boundCount * 4); + let displayFeatureType: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + let displayFeatureStatus: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + for (let i = 0; i < displayFeatures.length; i++) { + let singleFeatureBound = displayFeatures[i].getBounds(); + if (singleFeatureBound.length === 0) { + continue; } - let displayFeatureBound: number[] = new Array(boundCount * 4); - let displayFeatureType: number[] = new Array(boundCount ? displayFeatures.length : boundCount); - let displayFeatureStatus: number[] = new Array(boundCount ? displayFeatures.length : boundCount); - if (boundCount) { - for (let i = 0; i < displayFeatures.length; i++) { - let singleFeatureBound = displayFeatures[i].getBounds(); - for (let j = 0; j < singleFeatureBound.length; j++) { - displayFeatureBound[4 * i + 4 * j] = singleFeatureBound[j].left; - displayFeatureBound[4 * i + 4 * j + 1] = singleFeatureBound[j].top - displayFeatureBound[4 * i + 4 * j + 2] = singleFeatureBound[j].width; - displayFeatureBound[4 * i + 4 * j + 3] = singleFeatureBound[j].height; - } - displayFeatureType[i] = displayFeatures[i].getType(); - displayFeatureStatus[i] = displayFeatures[i].getState(); - } + for (let j = 0; j < singleFeatureBound.length; j++) { + displayFeatureBound[4 * i + 4 * j] = singleFeatureBound[j].left; + displayFeatureBound[4 * i + 4 * j + 1] = singleFeatureBound[j].top; + displayFeatureBound[4 * i + 4 * j + 2] = singleFeatureBound[j].width; + displayFeatureBound[4 * i + 4 * j + 3] = singleFeatureBound[j].height; } - - this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, - this.viewportMetrics.physicalWidth, - this.viewportMetrics.physicalHeight, - this.viewportMetrics.physicalViewPaddingTop, - this.viewportMetrics.physicalViewPaddingRight, - this.viewportMetrics.physicalViewPaddingBottom, - this.viewportMetrics.physicalViewPaddingLeft, - this.viewportMetrics.physicalViewInsetTop, - this.viewportMetrics.physicalViewInsetRight, - this.viewportMetrics.physicalViewInsetBottom, - this.viewportMetrics.physicalViewInsetLeft, - this.viewportMetrics.systemGestureInsetTop, - this.viewportMetrics.systemGestureInsetRight, - this.viewportMetrics.systemGestureInsetBottom, - this.viewportMetrics.systemGestureInsetLeft, - this.viewportMetrics.physicalTouchSlop, - displayFeatureBound, - displayFeatureType, - displayFeatureStatus) - return true; + displayFeatureType[i] = displayFeatures[i].getType(); + displayFeatureStatus[i] = displayFeatures[i].getState(); } - return false; + this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, + this.viewportMetrics.physicalWidth, + this.viewportMetrics.physicalHeight, + this.viewportMetrics.physicalViewPaddingTop, + this.viewportMetrics.physicalViewPaddingRight, + this.viewportMetrics.physicalViewPaddingBottom, + this.viewportMetrics.physicalViewPaddingLeft, + this.viewportMetrics.physicalViewInsetTop, + this.viewportMetrics.physicalViewInsetRight, + this.viewportMetrics.physicalViewInsetBottom, + this.viewportMetrics.physicalViewInsetLeft, + this.viewportMetrics.systemGestureInsetTop, + this.viewportMetrics.systemGestureInsetRight, + this.viewportMetrics.systemGestureInsetBottom, + this.viewportMetrics.systemGestureInsetLeft, + this.viewportMetrics.physicalTouchSlop, + displayFeatureBound, + displayFeatureType, + displayFeatureStatus) + return true; } onKeyPreIme(event: KeyEvent) : boolean { -- Gitee