mirror of
https://github.com/openharmony/miscservices_inputmethod.git
synced 2026-07-16 07:44:28 -04:00
3.1需求中,需要和ACE编辑框交互增加的新接口
Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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<IRemoteObject> &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<InputMethodAgentProxy> mAgent;
|
||||
OnTextChangedListener *textListener;
|
||||
InputAttribute mAttribute;
|
||||
std::u16string mTextString;
|
||||
int mSelectStart;
|
||||
int mSelectEnd;
|
||||
|
||||
static std::mutex instanceLock_;
|
||||
static sptr<InputMethodController> instance_;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//
|
||||
// Created by OpenHarmonyUser on 2021/11/30.
|
||||
//
|
||||
|
||||
@@ -1183,7 +1183,8 @@ namespace MiscServices {
|
||||
sptr<InputMethodAbilityConnectionStub> stub(new (std::nothrow) InputMethodAbilityConnectionStub(0));
|
||||
sptr<AAFwk::AbilityConnectionProxy> connCallback = new (std::nothrow) AAFwk::AbilityConnectionProxy(stub);
|
||||
std::shared_ptr<AAFwk::AbilityStartSetting> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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" ]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user