diff --git a/frameworks/inputmethod_controller/BUILD.gn b/frameworks/inputmethod_controller/BUILD.gn index 71457b1784d173ec8ccfd012ecfeeae9a8763f86..3c3b1eac5d39124ce1d015c88f13930a4b70c587 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 f1ec5d6c5ae9e735717227a440e2045ec7861c05..891aa4fcccd03c13bd4fa1ed8ad0d8a86ab2d49c 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 0000000000000000000000000000000000000000..332e78e30370e5d5ba335f0ae20f7bbc27dad32f --- /dev/null +++ b/frameworks/inputmethod_controller/include/input_method_utils.h @@ -0,0 +1,49 @@ +/* + * 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 + +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; + }; + } +} +#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H \ 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 5e926d3cac3692f13ed792849633ec77547c2f87..25aeae2f5b1c46155ab395488bdbc44297df00dc 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 0000000000000000000000000000000000000000..f7626c70fcbe8f2f1c4ea915386b0b69e41b2d08 --- /dev/null +++ b/frameworks/inputmethod_controller/src/input_method_utils.cpp @@ -0,0 +1,15 @@ +/* + * 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. + */ + diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 85985997d4d5e99e9cb08f52936f2152a5314584..3be9b5ad56bd2b2588b34cfe19b40e08e11eed93 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 25526308897ee138a2cfc06c1daa56c52330727e..e9c817928847a2102ac44ab5097691d51817b650 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 4a41ce773ae0db4e3d31fe62d6249428a46fae48..f55f8f95de925682b75d51c85b8a0dc3bad72421 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: