同步黄区需求代码

Signed-off-by: zhouyongfei <zhouyongfei@huawei.com>
This commit is contained in:
zhouyongfei
2022-01-13 19:49:53 +08:00
parent 59f7b58f6c
commit b1a3a0c558
32 changed files with 934 additions and 122 deletions
@@ -18,6 +18,7 @@
#include <errors.h>
#include "iremote_broker.h"
#include "global.h"
#include "input_method_utils.h"
/**
* brief Definition of interface IInputDataChannel
@@ -29,15 +30,27 @@ namespace MiscServices {
public:
enum {
INSERT_TEXT = 0,
DELETE_FORWARD,
DELETE_BACKWARD,
CLOSE,
GET_TEXT_BEFORE_CURSOR,
GET_TEXT_AFTER_CURSOR,
SEND_KEYBOARD_STATUS,
SEND_FUNCTION_KEY,
MOVE_CURSOR,
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.inputmethod.IInputDataChannel");
virtual bool InsertText(const std::u16string& text) = 0;
virtual bool DeleteForward(int32_t length) = 0;
virtual bool DeleteBackward(int32_t length) = 0;
virtual void Close() = 0;
virtual std::u16string GetTextBeforeCursor() = 0;
virtual std::u16string GetTextAfterCursor() = 0;
virtual void SendKeyboardStatus(int32_t status) = 0;
virtual void SendFunctionKey(int32_t funcKey) = 0;
virtual void MoveCursor(int32_t keyCode) = 0;
};
}
}
@@ -18,6 +18,7 @@
#include "iremote_proxy.h"
#include "i_input_data_channel.h"
#include "input_method_utils.h"
namespace OHOS {
namespace MiscServices {
@@ -28,8 +29,14 @@ namespace MiscServices {
DISALLOW_COPY_AND_MOVE(InputDataChannelProxy);
bool InsertText(const std::u16string& text) override;
bool DeleteForward(int32_t length) override;
bool DeleteBackward(int32_t length) override;
void Close() override;
std::u16string GetTextBeforeCursor() override;
std::u16string GetTextAfterCursor() override;
void SendKeyboardStatus(int32_t status) override;
void SendFunctionKey(int32_t funcKey) override;
void MoveCursor(int32_t keyCode) override;
private:
static inline BrokerDelegator<InputDataChannelProxy> delegator_;
@@ -20,9 +20,13 @@
#include "i_input_data_channel.h"
#include "iremote_stub.h"
#include "message_handler.h"
#include "input_method_utils.h"
#include "input_method_controller.h"
namespace OHOS {
namespace MiscServices {
class InputMethodController;
class InputDataChannelStub : public IRemoteStub<IInputDataChannel> {
public:
DISALLOW_COPY_AND_MOVE(InputDataChannelStub);
@@ -33,8 +37,14 @@ namespace MiscServices {
void SetHandler(MessageHandler *handler);
bool InsertText(const std::u16string& text) override;
bool DeleteForward(int32_t length) override;
bool DeleteBackward(int32_t length) override;
void Close() override;
std::u16string GetTextBeforeCursor() override;
std::u16string GetTextAfterCursor() override;
void SendKeyboardStatus(int32_t status) override;
void SendFunctionKey(int32_t funcKey) override;
void MoveCursor(int32_t keyCode) override;
private:
MessageHandler *msgHandler;
};
@@ -27,6 +27,7 @@
#include "message_handler.h"
#include "iremote_object.h"
#include "input_method_utils.h"
#include "key_event.h"
namespace OHOS {
namespace MiscServices {
@@ -55,6 +56,8 @@ namespace MiscServices {
public:
static sptr<InputMethodController> GetInstance();
void Attach(sptr<OnTextChangedListener> &listener);
std::u16string GetTextBeforeCursor();
std::u16string GetTextAfterCursor();
void ShowTextInput();
void HideTextInput();
void Close();
@@ -62,6 +65,7 @@ namespace MiscServices {
void OnCursorUpdate(CursorInfo cursorInfo);
void OnSelectionChange(std::u16string text, int start, int end);
void OnConfigurationChange(Configuration info);
bool dispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent);
private:
InputMethodController();
~InputMethodController();
@@ -83,8 +87,10 @@ namespace MiscServices {
OnTextChangedListener *textListener;
InputAttribute mAttribute;
std::u16string mTextString;
int mSelectStart;
int mSelectEnd;
int mSelectOldBegin = 0;
int mSelectOldEnd = 0;
int mSelectNewBegin = 0;
int mSelectNewEnd = 0;
static std::mutex instanceLock_;
static sptr<InputMethodController> instance_;
@@ -29,6 +29,7 @@
namespace OHOS {
namespace MiscServices {
class InputDataChannelStub;
class InputMethodSystemAbilityProxy : public IRemoteProxy<IInputMethodSystemAbility> {
public:
explicit InputMethodSystemAbilityProxy(const sptr<IRemoteObject> &object);
@@ -32,6 +32,7 @@ namespace MiscServices {
};
enum class TextInputType {
NONE = -1,
TEXT = 0,
MULTILINE,
NUMBER,
@@ -61,6 +62,7 @@ namespace MiscServices {
{
enterKeyType = keyType;
}
TextInputType GetTextInputType() const
{
return textInputType;
@@ -93,7 +95,7 @@ namespace MiscServices {
};
enum class FunctionKey {
NONE = 0,
CONFIRM,
CONFIRM
};
class KeyboardInfo {
public:
@@ -116,7 +118,6 @@ namespace MiscServices {
{
functionKey = static_cast<FunctionKey>(key);
}
private:
KeyboardStatus keyboardStatus = KeyboardStatus::NONE;
FunctionKey functionKey = FunctionKey::NONE;