From a7e12b86f9953536e12bc0db9bf3312d80d7738c Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Fri, 3 Dec 2021 10:09:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?3.1=E9=9C=80=E6=B1=82=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=92=8CACE=E7=BC=96=E8=BE=91=E6=A1=86?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E5=A2=9E=E5=8A=A0=E7=9A=84=E6=96=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- frameworks/inputmethod_controller/BUILD.gn | 1 + .../include/input_method_controller.h | 10 ++++++ .../include/input_method_utils.h | 36 +++++++++++++++++++ .../src/input_method_controller.cpp | 18 ++++++++++ .../src/input_method_utils.cpp | 4 +++ services/src/peruser_session.cpp | 3 +- unitest/BUILD.gn | 2 -- unitest/src/input_method_controller_test.cpp | 12 +++++++ 8 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 frameworks/inputmethod_controller/include/input_method_utils.h create mode 100644 frameworks/inputmethod_controller/src/input_method_utils.cpp diff --git a/frameworks/inputmethod_controller/BUILD.gn b/frameworks/inputmethod_controller/BUILD.gn index 71457b178..9ed591670 100644 --- a/frameworks/inputmethod_controller/BUILD.gn +++ b/frameworks/inputmethod_controller/BUILD.gn @@ -41,6 +41,7 @@ ohos_shared_library("inputmethod_client") { "src/input_data_channel_stub.cpp", "src/input_method_controller.cpp", "src/input_method_system_ability_proxy.cpp", + "src/input_method_utils.cpp" ] deps = [ diff --git a/frameworks/inputmethod_controller/include/input_method_controller.h b/frameworks/inputmethod_controller/include/input_method_controller.h index f1ec5d6c5..891aa4fcc 100644 --- a/frameworks/inputmethod_controller/include/input_method_controller.h +++ b/frameworks/inputmethod_controller/include/input_method_controller.h @@ -26,13 +26,17 @@ #include "i_input_method_agent.h" #include "message_handler.h" #include "iremote_object.h" +#include "input_method_utils.h" namespace OHOS { namespace MiscServices { class OnTextChangedListener : public virtual RefBase { public: virtual void InsertText(const std::u16string& text) = 0; + virtual void DeleteForward(int32_t length) = 0; virtual void DeleteBackward(int32_t length) = 0; + virtual void sendKeyEventFromInputMethod(KeyEvent event) = 0; + virtual void sendKeyboardStatus(KeyboardStatus status) = 0; virtual void SetKeyboardStatus(bool status) = 0; }; @@ -52,6 +56,9 @@ namespace MiscServices { void HideTextInput(); void Close(); void OnRemoteSaDied(const wptr &object); + void onCursorUpdate(CursorInfo cursorInfo); + void OnSelectionChange(std::u16string text, int start, int end); + void onConfigurationChange(Configuration info); private: InputMethodController(); ~InputMethodController(); @@ -72,6 +79,9 @@ namespace MiscServices { sptr mAgent; OnTextChangedListener *textListener; InputAttribute mAttribute; + std::u16string mTextString; + int mSelectStart; + int mSelectEnd; static std::mutex instanceLock_; static sptr instance_; diff --git a/frameworks/inputmethod_controller/include/input_method_utils.h b/frameworks/inputmethod_controller/include/input_method_utils.h new file mode 100644 index 000000000..bbb159334 --- /dev/null +++ b/frameworks/inputmethod_controller/include/input_method_utils.h @@ -0,0 +1,36 @@ +// +// Created by OpenHarmonyUser on 2021/11/30. +// + +#ifndef FM_IMC_PROJECT_INPUT_METHOD_UTILS_H +#define FM_IMC_PROJECT_INPUT_METHOD_UTILS_H + +#endif //FM_IMC_PROJECT_INPUT_METHOD_UTILS_H +namespace OHOS { + namespace MiscServices { + class Configuration{ + public: + enum { + TEXT_FIELD_ACTION_UNSPECIFIED = 0, + TEXT_FIELD_ACTION_NONE, + TEXT_FIELD_ACTION_GO, + TEXT_FIELD_ACTION_SEARCH, + TEXT_FIELD_ACTION_SEND, + TEXT_FIELD_ACTION_NEXT, + TEXT_FIELD_ACTION_DONE, + TEXT_FIELD_ACTION_PREVIOUS + }; + int mTextFieldAction; + }; + class CursorInfo{}; + class KeyEvent{}; + class KeyboardStatus{ + public: + enum{ + KEYBOARD_STATUS_HIDE = 0, + KEYBOARD_STATUS_SHOW + }; + int mKeyboardStatus; + }; + } +} \ No newline at end of file diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index 5e926d3ca..25aeae2f5 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -252,5 +252,23 @@ using namespace MessageID; { InputMethodController::GetInstance()->OnRemoteSaDied(object); } + + void InputMethodController::onCursorUpdate(CursorInfo cursorInfo) + { + IMSA_HILOGI("InputMethodController::onCursorUpdate"); + } + + void InputMethodController::OnSelectionChange(std::u16string text, int start, int end) + { + IMSA_HILOGI("InputMethodController::OnSelectionChange"); + mTextString = text; + mSelectStart = start; + mSelectEnd = end; + } + + void InputMethodController::onConfigurationChange(Configuration info) + { + IMSA_HILOGI("InputMethodController::onConfigurationChange"); + } } } \ No newline at end of file diff --git a/frameworks/inputmethod_controller/src/input_method_utils.cpp b/frameworks/inputmethod_controller/src/input_method_utils.cpp new file mode 100644 index 000000000..6d1dfc1df --- /dev/null +++ b/frameworks/inputmethod_controller/src/input_method_utils.cpp @@ -0,0 +1,4 @@ +// +// Created by OpenHarmonyUser on 2021/11/30. +// + diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 85985997d..3be9b5ad5 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -1183,7 +1183,8 @@ namespace MiscServices { sptr stub(new (std::nothrow) InputMethodAbilityConnectionStub(0)); sptr connCallback = new (std::nothrow) AAFwk::AbilityConnectionProxy(stub); std::shared_ptr setting = AAFwk::AbilityStartSetting::GetEmptySetting(); - setting->AddProperty(AAFwk::AbilityStartSetting::WINDOW_MODE_KEY, std::to_string(AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FLOATING)); + setting->AddProperty(AAFwk::AbilityStartSetting::WINDOW_MODE_KEY, + std::to_string(AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FLOATING)); GetAbilityManagerService()->StartAbility(want, *setting, nullptr, -1); } diff --git a/unitest/BUILD.gn b/unitest/BUILD.gn index 255263088..e9c817928 100644 --- a/unitest/BUILD.gn +++ b/unitest/BUILD.gn @@ -43,7 +43,6 @@ ohos_unittest("InputMethodControllerTest") { "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//third_party/googletest:gtest_main", "//utils/native/base:utils", - "//utils/native/base:utils", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] @@ -71,7 +70,6 @@ ohos_unittest("InputMethodAbilityTest") { "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//third_party/googletest:gtest_main", "//utils/native/base:utils", - "//utils/native/base:utils", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] diff --git a/unitest/src/input_method_controller_test.cpp b/unitest/src/input_method_controller_test.cpp index 4a41ce773..f55f8f95d 100644 --- a/unitest/src/input_method_controller_test.cpp +++ b/unitest/src/input_method_controller_test.cpp @@ -52,6 +52,18 @@ namespace MiscServices { { IMSA_HILOGI("IMC TEST TextListener SetKeyboardStatus %{public}d", status); } + void DeleteForward(int32_t length) + { + IMSA_HILOGI("IMC TEST TextListener DeleteForward length: %{public}d", length); + } + void sendKeyEventFromInputMethod(KeyEvent event) + { + IMSA_HILOGI("IMC TEST TextListener sendKeyEventFromInputMethod"); + } + void sendKeyboardStatus(KeyboardStatus status) + { + IMSA_HILOGI("IMC TEST TextListener sendKeyboardStatus"); + } }; class InputMethodControllerTest : public testing::Test { public: -- Gitee From 9d6daf15d27d8144df1415e62bbf494dac79b4e4 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Fri, 3 Dec 2021 10:50:40 +0800 Subject: [PATCH 2/3] format gn file Signed-off-by: zhouyongfei --- frameworks/inputmethod_controller/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/inputmethod_controller/BUILD.gn b/frameworks/inputmethod_controller/BUILD.gn index 9ed591670..3c3b1eac5 100644 --- a/frameworks/inputmethod_controller/BUILD.gn +++ b/frameworks/inputmethod_controller/BUILD.gn @@ -41,7 +41,7 @@ ohos_shared_library("inputmethod_client") { "src/input_data_channel_stub.cpp", "src/input_method_controller.cpp", "src/input_method_system_ability_proxy.cpp", - "src/input_method_utils.cpp" + "src/input_method_utils.cpp", ] deps = [ -- Gitee From eafade8741e747b06cbef918611f192620fddf4c Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Fri, 3 Dec 2021 12:00:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- .../include/input_method_utils.h | 33 +++++++++++++------ .../src/input_method_utils.cpp | 17 ++++++++-- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/frameworks/inputmethod_controller/include/input_method_utils.h b/frameworks/inputmethod_controller/include/input_method_utils.h index bbb159334..332e78e30 100644 --- a/frameworks/inputmethod_controller/include/input_method_utils.h +++ b/frameworks/inputmethod_controller/include/input_method_utils.h @@ -1,14 +1,24 @@ -// -// Created by OpenHarmonyUser on 2021/11/30. -// +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef FM_IMC_PROJECT_INPUT_METHOD_UTILS_H #define FM_IMC_PROJECT_INPUT_METHOD_UTILS_H -#endif //FM_IMC_PROJECT_INPUT_METHOD_UTILS_H namespace OHOS { namespace MiscServices { - class Configuration{ + class Configuration { public: enum { TEXT_FIELD_ACTION_UNSPECIFIED = 0, @@ -22,15 +32,18 @@ namespace OHOS { }; int mTextFieldAction; }; - class CursorInfo{}; - class KeyEvent{}; - class KeyboardStatus{ + class CursorInfo { + }; + class KeyEvent { + }; + class KeyboardStatus { public: - enum{ + enum { KEYBOARD_STATUS_HIDE = 0, KEYBOARD_STATUS_SHOW }; int mKeyboardStatus; }; } -} \ No newline at end of file +} +#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H \ No newline at end of file diff --git a/frameworks/inputmethod_controller/src/input_method_utils.cpp b/frameworks/inputmethod_controller/src/input_method_utils.cpp index 6d1dfc1df..f7626c70f 100644 --- a/frameworks/inputmethod_controller/src/input_method_utils.cpp +++ b/frameworks/inputmethod_controller/src/input_method_utils.cpp @@ -1,4 +1,15 @@ -// -// Created by OpenHarmonyUser on 2021/11/30. -// +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -- Gitee