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 4013fed1897c82c3aa82c1b8480ff80873f29af0..c011613e1dc47b5e6ce391625d3d94726c7fea0c 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 e2ef4d772b4210ec6d6921108fbfdbc413c901bf..0f449572ed1c01d8c1c15785774093f30ce1068c 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 | null | undefined) { + 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 | null | undefined): 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 | null | undefined): 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/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index 1634db5f6fdfad4be355fa193fb052a83844f491..de520a54ea24f5597c60a73ce132e836a3e3a613 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/PlatformPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets index 949480ec65afe8315844cc6b625392e83f9cea49..500390aeb93de65c2cd3eabe284126c1a47918e7 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 { 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 2d5c4ac2a3126a34a95acdfd54605be16dc2b005..89f07262f50722f577e0f0ecb279e5615a13099c 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; }