From 305e6e486e0cbd830fcabcab4af9581875df4e8c Mon Sep 17 00:00:00 2001 From: shijie Date: Wed, 23 Oct 2024 18:32:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3getContext(this)=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E8=8E=B7=E5=8F=96=E7=9A=84window=E6=98=AFundefine?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shijie --- .../src/main/ets/embedding/ohos/FlutterAbility.ets | 2 +- .../src/main/ets/embedding/ohos/FlutterManager.ets | 11 ++++++----- .../flutter/src/main/ets/plugin/PlatformPlugin.ets | 6 +++--- 3 files changed, 10 insertions(+), 9 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 4013fed189..c011613e1d 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 @@ -179,7 +179,7 @@ export class FlutterAbility extends UIAbility implements Host { Log.i(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); - FlutterManager.getInstance().setUseFullScreen(true); + FlutterManager.getInstance().setUseFullScreen(true, this.context); } catch (exception) { Log.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets index e2ef4d772b..363878dd12 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets @@ -109,8 +109,8 @@ export default class FlutterManager { return this.mFullScreenListener; } - setUseFullScreen(use: boolean) { - this.mFullScreenListener.setUseFullScreen(use) + setUseFullScreen(use: boolean, context?: Context) { + this.mFullScreenListener.setUseFullScreen(use, context); } useFullScreen(): boolean { @@ -120,7 +120,7 @@ export default class FlutterManager { export interface FullScreenListener { useFullScreen(): boolean; - setUseFullScreen(useFullScreen: boolean): void; + setUseFullScreen(useFullScreen: boolean, context?: Context): void; onScreenStateChanged(data: window.WindowStatusType): void; } @@ -132,12 +132,13 @@ export class DefaultFullScreenListener implements FullScreenListener { return this.fullScreen; } - setUseFullScreen(useFullScreen: boolean): void { + setUseFullScreen(useFullScreen: boolean, context?: Context): void { this.fullScreen = useFullScreen; this.skipCheck = true; + context = context??getContext(this); let window = FlutterManager.getInstance() - .getWindowStage(FlutterManager.getInstance().getUIAbility(getContext(this))); + .getWindowStage(FlutterManager.getInstance().getUIAbility(context)); window.getMainWindowSync().setWindowLayoutFullScreen(useFullScreen); Log.i(TAG, "WindowLayoutFullScreen is on") } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets index 949480ec65..500390aeb9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets @@ -279,13 +279,13 @@ export class PlatformPluginCallback implements PlatformMessageHandler { let uiConfig: ('status' | 'navigation')[] = []; if (mode == SystemUiMode.LEAN_BACK) { //全屏显示,通过点击显示器上的任何位置都可以显示状态和导航栏 - FlutterManager.getInstance().setUseFullScreen(true); + FlutterManager.getInstance().setUseFullScreen(true, null); } else if (mode == SystemUiMode.IMMERSIVE) { //全屏显示,通过在显示器边缘的滑动手势可以显示状态和导航栏,应用程序不会接收到此手势 - FlutterManager.getInstance().setUseFullScreen(true); + FlutterManager.getInstance().setUseFullScreen(true, null); } else if (mode == SystemUiMode.IMMERSIVE_STICKY) { //全屏显示,通过在显示器边缘的滑动手势可以显示状态和导航栏,此手势由应用程序接收 - FlutterManager.getInstance().setUseFullScreen(true); + FlutterManager.getInstance().setUseFullScreen(true, null); } else if (mode == SystemUiMode.EDGE_TO_EDGE) { uiConfig = ['status', 'navigation']; } else { -- Gitee From 8877a568dabfff5855ef581fe1f6ef3faba25399 Mon Sep 17 00:00:00 2001 From: shijie Date: Wed, 23 Oct 2024 19:41:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=9AArgument=20of=20type=20'null'=20is?= =?UTF-8?q?=20not=20assignable=20to=20parameter=20of=20type=20'Context=20|?= =?UTF-8?q?=20undefined'=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shijie --- .../flutter/src/main/ets/embedding/ohos/FlutterManager.ets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets index 363878dd12..0f449572ed 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets @@ -109,7 +109,7 @@ export default class FlutterManager { return this.mFullScreenListener; } - setUseFullScreen(use: boolean, context?: Context) { + setUseFullScreen(use: boolean, context?: Context | null | undefined) { this.mFullScreenListener.setUseFullScreen(use, context); } @@ -120,7 +120,7 @@ export default class FlutterManager { export interface FullScreenListener { useFullScreen(): boolean; - setUseFullScreen(useFullScreen: boolean, context?: Context): void; + setUseFullScreen(useFullScreen: boolean, context?: Context | null | undefined): void; onScreenStateChanged(data: window.WindowStatusType): void; } @@ -132,7 +132,7 @@ export class DefaultFullScreenListener implements FullScreenListener { return this.fullScreen; } - setUseFullScreen(useFullScreen: boolean, context?: Context): void { + setUseFullScreen(useFullScreen: boolean, context?: Context | null | undefined): void { this.fullScreen = useFullScreen; this.skipCheck = true; -- Gitee From f1f6ab6836531ca0dc117c043b7f6fdf1ec05a75 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Thu, 24 Oct 2024 19:58:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9ets=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E7=A8=B3=E5=AE=9A=E6=80=A7=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 --- .../src/main/ets/embedding/ohos/FlutterPage.ets | 2 +- .../src/main/ets/plugin/editing/TextInputPlugin.ets | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index 1634db5f6f..de520a54ea 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets @@ -183,7 +183,7 @@ export struct FlutterPage { aboutToDisappear() { this.flutterView?.removeFirstFrameListener(this); - getContext().eventHub.off(OHOS_FLUTTER_PAGE_UPDATE) + getContext()?.eventHub.off(OHOS_FLUTTER_PAGE_UPDATE) } onFirstFrame() { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets index 2d5c4ac2a3..89f07262f5 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets @@ -293,12 +293,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { } cancelListenKeyBoardEvent(): void { - this.inputMethodController.off('insertText', this.insertTextCallback); - this.inputMethodController.off('deleteLeft', this.deleteLeftCallback); - this.inputMethodController.off('deleteRight', this.deleteRightCallback); - this.inputMethodController.off('sendFunctionKey', this.sendFunctionKeyCallback); - this.inputMethodController.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); - this.inputMethodController.off('selectByRange', this.selectByRangeCallback); + this.inputMethodController?.off('insertText', this.insertTextCallback); + this.inputMethodController?.off('deleteLeft', this.deleteLeftCallback); + this.inputMethodController?.off('deleteRight', this.deleteRightCallback); + this.inputMethodController?.off('sendFunctionKey', this.sendFunctionKeyCallback); + this.inputMethodController?.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); + this.inputMethodController?.off('selectByRange', this.selectByRangeCallback); this.imcFlag = false; } -- Gitee