From c67b817ecf662b964439c197f353351ff0a31aa9 Mon Sep 17 00:00:00 2001 From: duanaoqi Date: Fri, 27 Sep 2024 09:26:25 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E8=A7=A3=E5=86=B3scrollBar=E5=9C=A8pc?= =?UTF-8?q?=E4=B8=8A=E6=97=A0=E6=B3=95=E6=A8=AA=E5=90=91=E6=8B=96=E6=8B=BD?= =?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: duanaoqi --- shell/platform/ohos/ohos_touch_processor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_touch_processor.cpp b/shell/platform/ohos/ohos_touch_processor.cpp index 1c04f38f03..037e3a527d 100644 --- a/shell/platform/ohos/ohos_touch_processor.cpp +++ b/shell/platform/ohos/ohos_touch_processor.cpp @@ -239,11 +239,12 @@ void OhosTouchProcessor::HandleMouseEvent( pointerData.pressure = 0.0; pointerData.pressure_max = 1.0; pointerData.pressure_min = 0.0; - pointerData.kind = PointerData::DeviceKind::kMouse; + pointerData.kind = PointerData::DeviceKind::kTouch; pointerData.buttons = getPointerButtonFromMouse(mouseEvent.button); // hover support if (mouseEvent.button == OH_NATIVEXCOMPONENT_NONE_BUTTON && pointerData.change == PointerData::Change::kMove) { pointerData.change = PointerData::Change::kHover; + pointerData.kind = PointerData::DeviceKind::kMouse; pointerData.buttons = 0; } pointerData.pan_x = 0.0; -- Gitee From 7d327ffa54792614237bed2d575fd6d07026d10b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 24 Sep 2024 22:37:33 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E5=9B=BE=E7=89=87=E5=9C=BA=E6=99=AF=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= =?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: hezhengyi --- shell/platform/ohos/ohos_external_texture_gl.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index a5f2ab3df7..3c4c9f91a2 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -224,10 +224,6 @@ void OHOSExternalTextureGL::OnTextureUnregistered() << ", Id()=" << Id() << ", nativeImage_=" << nativeImage_ << ", backGroundNativeImage_=" << backGroundNativeImage_; - if (state_ != AttachmentState::attached) { - FML_LOG(ERROR) << "OHOSExternalTextureGL::OnTextureUnregistered, the current status is not attached"; - return; - } first_update_ = false; if (nativeImage_ != nullptr) { OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); -- Gitee From 6c45b7c0515c5bea8c707191297fa5fc3c22e264 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 12:06:41 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=96=B9=E6=B3=95=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_main.cpp | 34 ------------------- .../platform/ohos/ohos_xcomponent_adapter.cpp | 4 +-- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index 90b6620729..6e5553f5cf 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -35,40 +35,6 @@ namespace flutter { -std::vector StringArrayToVector(napi_env env, - napi_value arrayValue) { - napi_status status; - uint32_t arrayLength = 0; - status = napi_get_array_length(env, arrayValue, &arrayLength); - LOGE("StringArrayToVector get array length %{pubilc}d", arrayLength); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_array_length error "); - } - std::vector stringArray; - for (uint32_t i = 0; i < arrayLength; i++) { - napi_value elementValue; - status = napi_get_element(env, arrayValue, i, &elementValue); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_element error"); - } - size_t stringLength; - status = napi_get_value_string_utf8(env, elementValue, nullptr, 0, - &stringLength); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_value_string_utf8 error"); - } - - std::string stringValue(stringLength, '\0'); - status = napi_get_value_string_utf8(env, elementValue, &stringValue[0], - stringLength + 1, nullptr); - if (status != napi_ok) { - LOGE("StringArrayToVector napi_get_value_string_utf8 error"); - } - stringArray.push_back(stringValue); - } - return stringArray; -} - OhosMain::OhosMain(const flutter::Settings& settings) : settings_(settings), observatory_uri_callback_() {} diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 562e17f44b..4d49b0c753 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -345,14 +345,14 @@ void XComponentBase::OnSurfaceChanged(OH_NativeXComponent* component, void* wind int32_t ret = OH_NativeXComponent_GetXComponentSize(component, window, &width_, &height_); if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { - LOGD("XComponent Current width:%{public}d,height:%{public}d", + LOGD("XComponentManger::OnSurfaceChanged Current width:%{public}d,height:%{public}d", static_cast(width_), static_cast(height_)); } if (isEngineAttached_) { PlatformViewOHOSNapi::SurfaceChanged(std::stoll(shellholderId_), width_, height_); } else { - LOGE("OnSurfaceChanged XComponentBase is not attached"); + LOGE("XComponentManger::OnSurfaceChanged XComponentBase is not attached"); } } -- Gitee From 63e0aed14ff083146fce100b9b550f61ea336864 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 12:08:33 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E7=BB=98=E5=88=B6=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- .../ohos/ohos_external_texture_gl.cpp | 34 +++++++------------ .../platform/ohos/ohos_external_texture_gl.h | 4 +-- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 3c4c9f91a2..c414e5c3ee 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -95,9 +95,9 @@ void OHOSExternalTextureGL::Attach() OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; + FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - FML_DLOG(INFO) << "OHOSExternalTextureGL::Paint, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); + FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); if (nativeImage_ == nullptr) { nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); if (nativeImage_ == nullptr) { @@ -130,19 +130,14 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_LOG(ERROR) << "OHOSExternalTextureGL::Paint, the current status is detached"; return; } - if (state_ == AttachmentState::uninitialized) { - Attach(); - if (!freeze && new_frame_ready_ && pixelMap_ != nullptr) { + if (!freeze && new_frame_ready_) { + if (pixelMap_ != nullptr) { ProducePixelMapToNativeImage(); - Update(); } + Update(); new_frame_ready_ = false; } - if (!freeze && texture_update_ && pixelMap_ == nullptr) { - Update(); - } - GrGLTextureInfo textureInfo; if (!freeze && !first_update_ && !isEmulator_ && !new_frame_ready_ && pixelMap_ == nullptr) { @@ -189,13 +184,13 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, void OHOSExternalTextureGL::OnGrContextCreated() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextCreated"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextCreated"; state_ = AttachmentState::uninitialized; } void OHOSExternalTextureGL::OnGrContextDestroyed() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::OnGrContextDestroyed"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextDestroyed"; if (state_ == AttachmentState::attached) { Detach(); glDeleteTextures(1, &texture_name_); @@ -208,14 +203,12 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() void OHOSExternalTextureGL::MarkNewFrameAvailable() { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::MarkNewFrameAvailable"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::MarkNewFrameAvailable"; new_frame_ready_ = true; - texture_update_ = true; - if (pixelMap_ == nullptr) { - Update(); - } else { - FML_DLOG(INFO) << "pixelMap_ is nullptr, texture_name_=" << texture_name_; + if (texture_name_ == 0) { + Attach(); } + Update(); } void OHOSExternalTextureGL::OnTextureUnregistered() @@ -248,7 +241,6 @@ void OHOSExternalTextureGL::Update() FML_LOG(ERROR) << "OHOSExternalTextureGL OH_NativeImage_UpdateSurfaceImage err code:" << ret; return; } - texture_update_ = false; first_update_ = true; UpdateTransform(nativeImage_); } @@ -296,7 +288,7 @@ void OHOSExternalTextureGL::DispatchImage(ImageNative* image) void OHOSExternalTextureGL::setBackground(int32_t width, int32_t height) { - FML_DLOG(INFO)<<" OHOSExternalTextureGL::setBackground"; + FML_DLOG(INFO) << " OHOSExternalTextureGL::setBackground"; if (backGroundNativeImage_ != nullptr) { return; } @@ -305,7 +297,7 @@ void OHOSExternalTextureGL::setBackground(int32_t width, int32_t height) OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { - FML_DLOG(INFO)<<"ResourceContextMakeCurrent successed"; + FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &backGroundTextureName_); FML_DLOG(INFO) << "OHOSExternalTextureGL::setBackground, glGenTextures backGroundTextureName_=" << backGroundTextureName_; if (backGroundNativeImage_ == nullptr) { diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 495eb02594..5ac18743a6 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -92,12 +92,10 @@ class OHOSExternalTextureGL : public flutter::Texture { enum class AttachmentState { uninitialized, attached, detached }; - std::atomic state_; + AttachmentState state_; bool new_frame_ready_ = false; - bool texture_update_ = false; - GLuint texture_name_ = 0; GLuint backGroundTextureName_ = 0; -- Gitee From 8dc0fc8c71dc57b0626faacbec4ac5129612588c Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Sun, 29 Sep 2024 17:06:19 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E9=81=BF=E5=85=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=B8=8E=E5=85=B6=E4=BB=96=E5=BA=94=E7=94=A8=E6=8A=A2=E5=8D=A0?= =?UTF-8?q?=E8=AF=A5=E7=9B=91=E5=90=AC=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20=E4=BF=AE=E6=94=B9=E9=94=AE=E7=9B=98=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E4=B8=8D=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEclient=E6=97=B6=E5=AF=B9=E6=98=AF=E5=90=A6=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E9=94=AE=E7=9B=98=E5=81=9A=E5=86=B3=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../ets/plugin/editing/TextInputPlugin.ets | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 aba17a326c..8924615383 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 @@ -174,12 +174,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.listenNoShowKeyboard() } - /// 通过监听规避区域内,是否有软键盘区域来进行监听。该方法在回到桌面和锁屏依然可以正常监听 + /// 通过监听键盘高度,决定是否需要弹出键盘 listenShowKeyboard() { let windowStage = FlutterManager.getInstance() .getWindowStage(FlutterManager.getInstance().getUIAbility(getContext(this))); windowStage.getMainWindow((err: BusinessError, currentWindow ) => { - currentWindow.on('avoidAreaChange', this.avoidAreaChangeCallback) + currentWindow.on('keyboardHeightChange', this.keyboardHeightChangeCallback); }); } @@ -188,7 +188,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { let windowStage = FlutterManager.getInstance() .getWindowStage(FlutterManager.getInstance().getUIAbility(getContext(this))); windowStage.getMainWindow((err: BusinessError, currentWindow ) => { - currentWindow.off('avoidAreaChange', this.avoidAreaChangeCallback) + currentWindow.off('keyboardHeightChange', this.keyboardHeightChangeCallback); }); } @@ -209,6 +209,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { } }; await this.inputMethodController.attach(false, textConfig); + this.firstShow = true } catch (err) { Log.e(TextInputMethodHandlerImpl.TAG, "Failed to attach:" + JSON.stringify(err)); } @@ -235,7 +236,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mRestartInputPending = true; this.mEditable.addEditingStateListener(this.plugin); - this.firstShow = true } canShowTextInput(): boolean { @@ -316,15 +316,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { }) } - private avoidAreaChangeCallback = (data: window.AvoidAreaOptions) => { + private keyboardHeightChangeCallback = (data: number) => { console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); - if (data.type !== window.AvoidAreaType.TYPE_KEYBOARD) { - return; - } - if (data.area.bottomRect.height == 0) { - this.firstShow = true + if (data == 0) { + this.showType = keyboardType.ENTRY } else { - this.firstShow = false + this.showType = keyboardType.NONE } } -- Gitee From 2e8edd5e5ce4c9925f62a262bb5cb0a748c43373 Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Sun, 29 Sep 2024 17:07:45 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=9C=B0=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../flutter/src/main/ets/plugin/editing/TextInputPlugin.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8924615383..2c260f49bd 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 @@ -319,9 +319,9 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { private keyboardHeightChangeCallback = (data: number) => { console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); if (data == 0) { - this.showType = keyboardType.ENTRY + this.firstShow = true } else { - this.showType = keyboardType.NONE + this.firstShow = false } } -- Gitee From c009e39c0aa076f9dd98f61c40fc01b46bf8c77b Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Sun, 29 Sep 2024 20:38:25 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E7=BB=98=E5=88=B6=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_external_texture_gl.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index c414e5c3ee..92fdfd3441 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -130,17 +130,10 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, FML_LOG(ERROR) << "OHOSExternalTextureGL::Paint, the current status is detached"; return; } - if (!freeze && new_frame_ready_) { - if (pixelMap_ != nullptr) { - ProducePixelMapToNativeImage(); - } - Update(); - new_frame_ready_ = false; - } GrGLTextureInfo textureInfo; - if (!freeze && !first_update_ && !isEmulator_ && !new_frame_ready_ && pixelMap_ == nullptr) { + if (!freeze && !first_update_ && !isEmulator_ && backGroundTextureName_ == 0 && pixelMap_ == nullptr) { setBackground(bounds.width(), bounds.height()); textureInfo = {GL_TEXTURE_EXTERNAL_OES, backGroundTextureName_, GL_RGBA8_OES}; } else { @@ -208,6 +201,9 @@ void OHOSExternalTextureGL::MarkNewFrameAvailable() if (texture_name_ == 0) { Attach(); } + if (pixelMap_ != nullptr) { // 外接纹理图片场景 + ProducePixelMapToNativeImage(); + } Update(); } -- Gitee From 30c31d91e79c33c6d467811df3428e4caa9366d7 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Mon, 30 Sep 2024 11:36:49 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?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 --- shell/platform/ohos/ohos_external_texture_gl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 92fdfd3441..46fa22e2a0 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -97,7 +97,8 @@ void OHOSExternalTextureGL::Attach() if (result->GetResult()) { FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; glGenTextures(1, &texture_name_); - FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" << texture_name_ << ", Id()=" << Id(); + FML_DLOG(INFO) << "OHOSExternalTextureGL::Attach, glGenTextures texture_name_=" + << texture_name_ << ", Id()=" << Id(); if (nativeImage_ == nullptr) { nativeImage_ = OH_NativeImage_Create(texture_name_, GL_TEXTURE_EXTERNAL_OES); if (nativeImage_ == nullptr) { -- Gitee From 16fa4876184bd917c9f524aaebcd0e4485651d97 Mon Sep 17 00:00:00 2001 From: keminLuo Date: Mon, 30 Sep 2024 16:14:17 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmaterial3=E5=9C=A8debug?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E9=97=AA=E9=80=80=EF=BC=8C=E5=8F=8A?= =?UTF-8?q?skia=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: keminLuo --- attachment/repos/skia.patch | 195 +++++++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 60 deletions(-) diff --git a/attachment/repos/skia.patch b/attachment/repos/skia.patch index 5cda561c5a..adad9f220a 100644 --- a/attachment/repos/skia.patch +++ b/attachment/repos/skia.patch @@ -1,5 +1,5 @@ diff --git a/BUILD.gn b/BUILD.gn -index ebbd898ec9..2d4257e8d7 100644 +index ebbd898ec9..015bb75414 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -26,16 +26,21 @@ import("gn/ios.gni") @@ -142,16 +142,22 @@ index ebbd898ec9..2d4257e8d7 100644 ] if (!skia_enable_winuwp) { -@@ -1559,7 +1612,7 @@ skia_component("skia") { - ] +@@ -1566,6 +1619,14 @@ skia_component("skia") { + } } -- if (is_linux || is_wasm) { -+ if (is_linux || is_wasm || is_ohos) { - sources += [ "src/ports/SkDebug_stdio.cpp" ] - if (skia_use_egl) { - libs += [ "GLESv2" ] -@@ -1962,7 +2015,7 @@ if (skia_enable_tools) { ++ if (is_ohos) { ++ sources += [ "src/ports/SkDebug_ohos.cpp" ] ++ if (skia_use_egl) { ++ libs += [ "GLESv2" ] ++ } ++ libs += [ "hilog_ndk.z" ] ++ } ++ + if (is_mac) { + public += [ "include/ports/SkCFObject.h" ] + sources += [ +@@ -1962,7 +2023,7 @@ if (skia_enable_tools) { if (is_android || skia_use_egl) { sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ] libs += [ "EGL" ] @@ -160,7 +166,7 @@ index ebbd898ec9..2d4257e8d7 100644 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ] libs += [ "GLU", -@@ -2281,7 +2334,7 @@ if (skia_enable_tools) { +@@ -2281,7 +2342,7 @@ if (skia_enable_tools) { ] } @@ -169,7 +175,7 @@ index ebbd898ec9..2d4257e8d7 100644 if (skia_enable_skottie) { test_app("skottie_tool") { deps = [ "modules/skottie:tool" ] -@@ -2777,7 +2830,7 @@ if (skia_enable_tools) { +@@ -2777,7 +2838,7 @@ if (skia_enable_tools) { "tools/sk_app/android/surface_glue_android.h", ] libs += [ "android" ] @@ -178,7 +184,7 @@ index ebbd898ec9..2d4257e8d7 100644 sources += [ "tools/SkGetExecutablePath_linux.cpp", "tools/sk_app/unix/RasterWindowContext_unix.cpp", -@@ -2830,7 +2883,7 @@ if (skia_enable_tools) { +@@ -2830,7 +2891,7 @@ if (skia_enable_tools) { sources += [ "tools/sk_app/GLWindowContext.h" ] if (is_android) { sources += [ "tools/sk_app/android/GLWindowContext_android.cpp" ] @@ -187,7 +193,7 @@ index ebbd898ec9..2d4257e8d7 100644 sources += [ "tools/sk_app/unix/GLWindowContext_unix.cpp" ] } else if (is_win) { sources += [ "tools/sk_app/win/GLWindowContext_win.cpp" ] -@@ -2855,7 +2908,7 @@ if (skia_enable_tools) { +@@ -2855,7 +2916,7 @@ if (skia_enable_tools) { sources += [ "tools/sk_app/VulkanWindowContext.h" ] if (is_android) { sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ] @@ -196,7 +202,7 @@ index ebbd898ec9..2d4257e8d7 100644 sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ] libs += [ "X11-xcb" ] } else if (is_win) { -@@ -2887,7 +2940,7 @@ if (skia_enable_tools) { +@@ -2887,7 +2948,7 @@ if (skia_enable_tools) { if (skia_use_dawn) { sources += [ "tools/sk_app/DawnWindowContext.cpp" ] sources += [ "tools/sk_app/DawnWindowContext.h" ] @@ -205,7 +211,7 @@ index ebbd898ec9..2d4257e8d7 100644 if (dawn_enable_vulkan) { sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ] defines = [ "VK_USE_PLATFORM_XCB_KHR" ] -@@ -2931,7 +2984,7 @@ if (skia_enable_tools) { +@@ -2931,7 +2992,7 @@ if (skia_enable_tools) { } } @@ -214,7 +220,7 @@ index ebbd898ec9..2d4257e8d7 100644 test_app("fiddle_examples") { sources = [ "tools/fiddle/all_examples.cpp", -@@ -3088,7 +3141,7 @@ if (skia_enable_tools) { +@@ -3088,7 +3149,7 @@ if (skia_enable_tools) { } } @@ -327,6 +333,21 @@ index b43526fe1f..fb34289da7 100644 ldflags = [ "-rdynamic", "-Wl,-rpath,\$ORIGIN", +diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp +index bdcf607d04..2e92ed05f3 100644 +--- a/src/core/SkRRect.cpp ++++ b/src/core/SkRRect.cpp +@@ -231,8 +231,8 @@ bool SkRRect::scaleRadii() { + double scale = 1.0; + + // The sides of the rectangle may be larger than a float. +- double width = (double)fRect.fRight - (double)fRect.fLeft; +- double height = (double)fRect.fBottom - (double)fRect.fTop; ++ double width = (double)(fRect.fRight - fRect.fLeft); ++ double height = (double)(fRect.fBottom - fRect.fTop); + scale = compute_min_scale(fRadii[0].fX, fRadii[1].fX, width, scale); + scale = compute_min_scale(fRadii[1].fY, fRadii[2].fY, height, scale); + scale = compute_min_scale(fRadii[2].fX, fRadii[3].fX, width, scale); diff --git a/src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp b/src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp index 78225b4610..c2105852b1 100644 --- a/src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp @@ -1070,12 +1091,50 @@ index 0000000000..eb318dc3a3 +#endif + +#endif /* __gl2platform_h_ */ +diff --git a/src/ports/SkDebug_ohos.cpp b/src/ports/SkDebug_ohos.cpp +new file mode 100644 +index 0000000000..0e5e0829b6 +--- /dev/null ++++ b/src/ports/SkDebug_ohos.cpp +@@ -0,0 +1,32 @@ ++// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "include/core/SkTypes.h" ++ ++#include ++#include ++ ++ ++#ifdef HILOG_LOG_DOMAIN ++ #undef HILOG_LOG_DOMAIN ++#endif ++ ++#ifdef HILOG_LOG_TAG ++ #undef HILOG_LOG_DOMAIN ++#endif ++ ++ ++#define HILOG_LOG_DOMAIN 0x0000 ++#define HILOG_LOG_TAG "Skia" ++ ++void SkDebugf(const char format[], ...) { ++ char outStr[1024] = { 0 }; ++ va_list args; ++ va_start(args, format); ++ (void)vsnprintf(outStr,sizeof(outStr), format, args); ++ va_end(args); ++ ++ (void)OH_LOG_Print(LOG_APP, LOG_INFO, HILOG_LOG_DOMAIN,\ ++ HILOG_LOG_TAG, "%{public}s", outStr); ++} diff --git a/src/ports/skia_ohos/FontConfig_ohos.cpp b/src/ports/skia_ohos/FontConfig_ohos.cpp new file mode 100644 -index 0000000000..10c967ee02 +index 0000000000..2dfc1348c1 --- /dev/null +++ b/src/ports/skia_ohos/FontConfig_ohos.cpp -@@ -0,0 +1,1308 @@ +@@ -0,0 +1,1312 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. @@ -1138,6 +1197,10 @@ index 0000000000..10c967ee02 + */ +int FontConfig_OHOS::getFamilyCount() const +{ ++#if ENABLE_DEBUG ++ dumpGeneric(); ++ dumpFallback(); ++#endif + return genericFamilySet.size(); +} + @@ -1490,7 +1553,7 @@ index 0000000000..10c967ee02 + */ +void FontConfig_OHOS::dumpFont(const FontInfo& font) const +{ -+ LOGI("name=%s, family=%s, weight=%d, width=%d, slant=%d, index=%d", ++ SkDEBUGF("name=%s, family=%s, weight=%d, width=%d, slant=%d, index=%d", + font.fname.c_str(), font.familyName.c_str(), font.style.weight(), font.style.width(), font.style.slant(), + font.index); + int count = font.axisSet.axis.size(); @@ -1502,7 +1565,7 @@ index 0000000000..10c967ee02 + str.append(","); + } + } -+ LOGI("axis={%s}\n", str.c_str()); ++ SkDEBUGF("axis={%s}\n", str.c_str()); + } +} + @@ -1510,9 +1573,9 @@ index 0000000000..10c967ee02 + */ +void FontConfig_OHOS::dumpGeneric() const +{ -+ LOGI("\n"); ++ SkDEBUGF("\n"); + for (unsigned int i = 0; i < genericFamilySet.size(); i++) { -+ LOGI("[%d] familyName : %s - %d\n", i, genericFamilySet[i]->familyName.c_str(), ++ SkDEBUGF("[%d] familyName : %s - %d\n", i, genericFamilySet[i]->familyName.c_str(), + static_cast(genericFamilySet[i]->typefaceSet->size())); + for (int j = 0; j < genericFamilySet[i]->typefaceSet->size(); j++) { + if ((*(genericFamilySet[i]->typefaceSet))[j].get()) { @@ -1520,10 +1583,10 @@ index 0000000000..10c967ee02 + if (font) { + dumpFont(*font); + } else { -+ LOGE("font [%d] is null\n", j); ++ SkDEBUGF("font [%d] is null\n", j); + } + } else { -+ LOGE("typefeace [%d] is null\n", j); ++ SkDEBUGF("typefeace [%d] is null\n", j); + } + } + } @@ -1533,21 +1596,21 @@ index 0000000000..10c967ee02 + */ +void FontConfig_OHOS::dumpFallback() const +{ -+ LOGI("\n"); ++ SkDEBUGF("\n"); + int count = 0; + fallbackForMap.foreach([this, &count](const SkString& key, + const FallbackSetPos& setIndex) { -+ LOGI("[%d] family : %s - %d\n", count++, key.c_str(), setIndex.count); ++ SkDEBUGF("[%d] family : %s - %d\n", count++, key.c_str(), setIndex.count); + for (unsigned int i = setIndex.index; i < setIndex.index + setIndex.count; i++) { + const TypefaceSet& tpSet = *(fallbackSet[i]->typefaceSet.get()); -+ LOGI("[%s] - %d\n", fallbackSet[i]->familyName.c_str(), static_cast(tpSet.size())); ++ SkDEBUGF("[%s] - %d\n", fallbackSet[i]->familyName.c_str(), static_cast(tpSet.size())); + + for (unsigned int j = 0; j < tpSet.size(); j++) { + const FontInfo* font = tpSet[j]->getFontInfo(); + if (font) { + this->dumpFont(*font); + } else { -+ LOGE("font [%d] is null\n", j); ++ SkDEBUGF("font [%d] is null\n", j); + } + } + } @@ -1897,7 +1960,7 @@ index 0000000000..10c967ee02 + if (root.size() != keyCount) { + text.appendf("%s#0", key); + errSet.emplace_back(ret, text.c_str()); -+ LOGE("%s : '%s' size should be 2, but here it's %d\n", errToString(ret), key, root.size()); ++ SkDEBUGF("%s : '%s' size should be 2, but here it's %d\n", errToString(ret), key, root.size()); + return ret; + } else if (!root[0].isString()) { + text.appendf("%s#1", key); @@ -2043,7 +2106,7 @@ index 0000000000..10c967ee02 + } else { + err = ERROR_FONT_INVALID_STREAM; + } -+ LOGE("%s : %s\n", errToString(err), fname); ++ SkDEBUGF("%s : %s\n", errToString(err), fname); + char* fnameCopy = strdup(fname); + errSet.emplace_back(err, basename(fnameCopy)); + free(fnameCopy); @@ -2295,7 +2358,7 @@ index 0000000000..10c967ee02 +{ + errSet.emplace_back(err, key); + if (err != ERROR_CONFIG_INVALID_VALUE_TYPE) { -+ LOGE("%s : %s\n", errToString(err), key); ++ SkDEBUGF("%s : %s\n", errToString(err), key); + } else { + const char* types[] = { + "null", @@ -2310,10 +2373,10 @@ index 0000000000..10c967ee02 + int size = sizeof(types) / sizeof(char*); + if ((expected >= 0 && expected < size) && + (actual >= 0 && actual < size)) { -+ LOGE("%s : '%s' should be '%s', but here it's '%s'\n", ++ SkDEBUGF("%s : '%s' should be '%s', but here it's '%s'\n", + errToString(err), key, types[expected], types[actual]); + } else { -+ LOGE("%s : %s\n", errToString(err), key); ++ SkDEBUGF("%s : %s\n", errToString(err), key); + } + } + return err; @@ -2386,10 +2449,10 @@ index 0000000000..10c967ee02 +} diff --git a/src/ports/skia_ohos/FontConfig_ohos.h b/src/ports/skia_ohos/FontConfig_ohos.h new file mode 100644 -index 0000000000..d23dc47c44 +index 0000000000..edd2c51495 --- /dev/null +++ b/src/ports/skia_ohos/FontConfig_ohos.h -@@ -0,0 +1,234 @@ +@@ -0,0 +1,217 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. @@ -2410,23 +2473,6 @@ index 0000000000..d23dc47c44 +#include "FontInfo_ohos.h" +#include "SkTypeface_ohos.h" + -+#ifdef ENABLE_DEBUG -+ -+#define LOGE(fmt, args...) \ -+ printf("E %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) -+#define LOGI(fmt, args...) \ -+ printf("I %s:%d - " fmt, __FUNCTION__, __LINE__, ##args) -+#define LOGW(fmt, args...) \ -+ printf("W %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) -+ -+#else -+ -+#define LOGE SkDEBUGF -+#define LOGI SkDEBUGF -+#define LOGW SkDEBUGF -+ -+#endif -+ +struct FontInfo; +struct FallbackInfo; +struct GenericFamily; @@ -2777,7 +2823,7 @@ index 0000000000..0b851ae3fa +#endif /* FONTINFO_OHOS_H */ diff --git a/src/ports/skia_ohos/SkFontMgr_ohos.cpp b/src/ports/skia_ohos/SkFontMgr_ohos.cpp new file mode 100644 -index 0000000000..029d105ebc +index 0000000000..a18757d5d5 --- /dev/null +++ b/src/ports/skia_ohos/SkFontMgr_ohos.cpp @@ -0,0 +1,437 @@ @@ -2918,7 +2964,7 @@ index 0000000000..029d105ebc + } + } + if (item == nullptr) { -+ LOGE("%s : '%s' must be a fallback key in the config file\n", ++ SkDEBUGF("%s : '%s' must be a fallback key in the config file\n", + FontConfig_OHOS::errToString(ERROR_FAMILY_NOT_FOUND), defaultFamily.c_str()); + return nullptr; + } @@ -3136,7 +3182,7 @@ index 0000000000..029d105ebc + + std::unique_ptr stream = SkStreamAsset::MakeFromFile(path); + if (stream == nullptr) { -+ LOGE("%s : %s\n", FontConfig_OHOS::errToString(ERROR_FONT_NOT_EXIST), path); ++ SkDEBUGF("%s : %s\n", FontConfig_OHOS::errToString(ERROR_FONT_NOT_EXIST), path); + return nullptr; + } + SkFontArguments args; @@ -3163,7 +3209,7 @@ index 0000000000..029d105ebc + if (typeface) { + return sk_sp(typeface); + } -+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_NO_AVAILABLE_FAMILY)); ++ SkDEBUGF("%s\n", FontConfig_OHOS::errToString(ERROR_NO_AVAILABLE_FAMILY)); + return nullptr; +} + @@ -3187,14 +3233,14 @@ index 0000000000..029d105ebc + if (axisCount == 0) { + if (!fontScanner.scanFont(stream.get(), ttcIndex, &fontInfo.familyName, &fontInfo.style, + &fontInfo.isFixedWidth, nullptr)) { -+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); ++ SkDEBUGF("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); + return nullptr; + } + } else { + AxisDefinitions axisDef; + if (!fontScanner.scanFont(stream.get(), ttcIndex, &fontInfo.familyName, &fontInfo.style, + &fontInfo.isFixedWidth, &axisDef)) { -+ LOGE("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); ++ SkDEBUGF("%s\n", FontConfig_OHOS::errToString(ERROR_FONT_INVALID_STREAM)); + return nullptr; + } + if (axisDef.size() > 0) { @@ -3461,10 +3507,10 @@ index 0000000000..b9fb40cf1e +#endif /* SKFONTSTYLESET_OHOS_H */ diff --git a/src/ports/skia_ohos/SkTypeface_ohos.cpp b/src/ports/skia_ohos/SkTypeface_ohos.cpp new file mode 100644 -index 0000000000..3141944c32 +index 0000000000..05d3d56d1b --- /dev/null +++ b/src/ports/skia_ohos/SkTypeface_ohos.cpp -@@ -0,0 +1,139 @@ +@@ -0,0 +1,165 @@ +// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. @@ -3475,6 +3521,29 @@ index 0000000000..3141944c32 +#include "SkFontHost_FreeType_common.h" +#include "SkTArray.h" + ++#if ENABLE_DEBUG ++/*! To print out the font information ++ * \param font the font object to be printed ++ */ ++void DumpFont(const FontInfo& font) const ++{ ++ SkDEBUGF("name=%s, family=%s, weight=%d, width=%d, slant=%d, index=%d", ++ font.fname.c_str(), font.familyName.c_str(), font.style.weight(), font.style.width(), font.style.slant(), ++ font.index); ++ int count = font.axisSet.axis.size(); ++ if (count > 0) { ++ SkString str; ++ for (unsigned int i = 0; i < count; i++) { ++ str.appendU32(SkFixedFloorToInt(font.axisSet.axis[i])); ++ if (i < count - 1) { ++ str.append(","); ++ } ++ } ++ SkDEBUGF("axis={%s}\n", str.c_str()); ++ } ++} ++#endif ++ +/*! Constructor + * \param familyName the specified family name for the typeface + * \param info the font information for the typeface @@ -3531,6 +3600,9 @@ index 0000000000..3141944c32 + if (fontInfo->stream.get() == nullptr) { + return nullptr; + } ++#if ENABLE_DEBUG ++ DumpFont(*fontInfo); ++#endif + return std::make_unique(fontInfo->stream->duplicate(), fontInfo->index, 0, + fontInfo->axisSet.axis.data(), fontInfo->axisSet.axis.size(), nullptr, 0); +} @@ -3740,3 +3812,6 @@ index fca2f34ded..65955a7041 100644 OutputStream* rawOut = fOut; StringStream body; fOut = &body; +-- +2.25.1 + -- Gitee From a9d0411eba9c923f1976bfb6ec2cb385a1d68f69 Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Mon, 30 Sep 2024 16:50:49 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9TextInputPlugins?= =?UTF-8?q?=E8=BD=AF=E9=94=AE=E7=9B=98=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../ets/plugin/editing/TextInputPlugin.ets | 63 +++++-------------- 1 file changed, 15 insertions(+), 48 deletions(-) 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 2c260f49bd..e812dfb757 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 @@ -86,14 +86,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { private plugin: EditingStateWatcher | Any; private imcFlag: boolean = false; private inputTypeNone: string = 'NONE' - private firstShow: boolean = true; + private keyboardStatus: inputMethod.KeyboardStatus = inputMethod.KeyboardStatus.HIDE; + private inputAttribute: inputMethod.InputAttribute = { textInputType: 0, enterKeyType: 1 } constructor(plugin: TextInputPlugin | Any) { this.textConfig = { - inputAttribute: { - textInputType: 0, - enterKeyType: 1 - } + inputAttribute: this.inputAttribute }; this.plugin = plugin; this.mEditable = new ListenableEditingState(null, 0); @@ -148,16 +146,14 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { } private async showTextInput(): Promise { - if (!this.firstShow) { - return + if (this.keyboardStatus == inputMethod.KeyboardStatus.SHOW) { + return; } - this.listenShowKeyboard() await this.attach(true); if (!this.imcFlag) { this.listenKeyBoardEvent(); } this.inputMethodController.showTextInput().then(() => { - this.firstShow = false Log.d(TextInputMethodHandlerImpl.TAG, "Succeeded in showing softKeyboard"); }).catch((err: Any) => { Log.e(TextInputMethodHandlerImpl.TAG, "Failed to show softKeyboard:" + JSON.stringify(err)); @@ -166,30 +162,10 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { private async hideTextInput(): Promise { this.inputMethodController.hideTextInput().then(() => { - this.firstShow = true Log.d(TextInputMethodHandlerImpl.TAG, "Succeeded in hide softKeyboard"); }).catch((err: Any) => { Log.e(TextInputMethodHandlerImpl.TAG, "Failed to hide softKeyboard:" + JSON.stringify(err)); }) - this.listenNoShowKeyboard() - } - - /// 通过监听键盘高度,决定是否需要弹出键盘 - listenShowKeyboard() { - let windowStage = FlutterManager.getInstance() - .getWindowStage(FlutterManager.getInstance().getUIAbility(getContext(this))); - windowStage.getMainWindow((err: BusinessError, currentWindow ) => { - currentWindow.on('keyboardHeightChange', this.keyboardHeightChangeCallback); - }); - } - - /// 取消监听规避区域的软键盘范围 - listenNoShowKeyboard() { - let windowStage = FlutterManager.getInstance() - .getWindowStage(FlutterManager.getInstance().getUIAbility(getContext(this))); - windowStage.getMainWindow((err: BusinessError, currentWindow ) => { - currentWindow.off('keyboardHeightChange', this.keyboardHeightChangeCallback); - }); } async attach(showKeyboard: boolean): Promise { @@ -200,16 +176,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { } } - async resetAttach(): Promise { + async updateAttribute(): Promise { + if (this.keyboardStatus == inputMethod.KeyboardStatus.HIDE) { + return; + } try { - let textConfig: inputMethod.TextConfig = { - inputAttribute: { - textInputType: 0, - enterKeyType: 1 - } - }; - await this.inputMethodController.attach(false, textConfig); - this.firstShow = true + await this.inputMethodController.updateAttribute(this.inputAttribute); } catch (err) { Log.e(TextInputMethodHandlerImpl.TAG, "Failed to attach:" + JSON.stringify(err)); } @@ -236,6 +208,10 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mRestartInputPending = true; this.mEditable.addEditingStateListener(this.plugin); + + this.inputAttribute = this.textConfig.inputAttribute; + + this.updateAttribute(); } canShowTextInput(): boolean { @@ -316,15 +292,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { }) } - private keyboardHeightChangeCallback = (data: number) => { - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); - if (data == 0) { - this.firstShow = true - } else { - this.firstShow = false - } - } - private insertTextCallback = (text: string) => { Log.d(TextInputMethodHandlerImpl.TAG, "insertText: " + text); this.mEditable.handleInsertTextEvent(text); @@ -353,6 +320,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { } private sendKeyboardStatusCallback = (state: inputMethod.KeyboardStatus) => { + this.keyboardStatus = state; if (state == inputMethod.KeyboardStatus.HIDE) { this.plugin.textInputChannel.onConnectionClosed(this.inputTarget.id); this.hideTextInput() @@ -381,7 +349,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mEditable.removeEditingStateListener(this.plugin); this.configuration = null; this.inputTarget = new InputTarget(Type.NO_TARGET, 0); - this.resetAttach(); } } -- Gitee From d154d824493c5a065a11bcbdf670e5ecb17c9844 Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Mon, 30 Sep 2024 16:53:09 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9updateAttribute?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../flutter/src/main/ets/plugin/editing/TextInputPlugin.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e812dfb757..c499dacb39 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 @@ -183,7 +183,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { try { await this.inputMethodController.updateAttribute(this.inputAttribute); } catch (err) { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to attach:" + JSON.stringify(err)); + Log.e(TextInputMethodHandlerImpl.TAG, "Failed to updateAttribute:" + JSON.stringify(err)); } } -- Gitee