输入法联调Ace

Signed-off-by: jiangdayuan <jiangdayuan@huawei.com>
Change-Id: I1b7337395d7bdc198054f09beacaee0b7bde6d19
This commit is contained in:
jiangdayuan
2021-12-25 19:58:40 +08:00
parent 8081ef8e6f
commit 98a576bd20
5 changed files with 117 additions and 42 deletions
@@ -30,13 +30,15 @@
namespace OHOS {
namespace MiscServices {
class InputDataChannelStub;
class InputMethodSystemAbilityProxy;
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 SendKeyEventFromInputMethod(const KeyEvent& event) = 0;
virtual void SendKeyboardInfo(const KeyboardInfo& info) = 0;
virtual void SetKeyboardStatus(bool status) = 0;
};
@@ -56,9 +58,9 @@ namespace MiscServices {
void HideTextInput();
void Close();
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
void onCursorUpdate(CursorInfo cursorInfo);
void OnCursorUpdate(CursorInfo cursorInfo);
void OnSelectionChange(std::u16string text, int start, int end);
void onConfigurationChange(Configuration info);
void OnConfigurationChange(Configuration info);
private:
InputMethodController();
~InputMethodController();
@@ -91,4 +93,4 @@ namespace MiscServices {
};
}
}
#endif
#endif
@@ -16,34 +16,102 @@
#ifndef FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
#define FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
#include <stdint.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;
};
}
namespace MiscServices {
enum class EnterKeyType {
UNSPECIFIED = 0,
NONE,
GO,
SEARCH,
SEND,
NEXT,
DONE,
PREVIOUS
};
enum class TextInputType {
TEXT = 0,
MULTILINE,
NUMBER,
PHONE,
DATETIME,
EMAIL_ADDRESS,
URL,
VISIBLE_PASSWORD,
};
class Configuration {
public:
EnterKeyType GetEnterKeyType() const
{
return enterKeyType;
}
void SetEnterKeyType(EnterKeyType keyType)
{
enterKeyType = keyType;
}
TextInputType GetTextInputType() const
{
return textInputType;
}
void SetTextInputType(TextInputType textType)
{
textInputType = textType;
}
private:
EnterKeyType enterKeyType = EnterKeyType::UNSPECIFIED;
TextInputType textInputType = TextInputType::TEXT;
};
struct CursorInfo {
double left = 0.0;
double top = 0.0;
double width = 0.0;
double height = 0.0;
};
class KeyEvent {
};
enum class KeyboardStatus {
NONE = 0,
HIDE,
SHOW
};
enum class FunctionKey {
NONE = 0,
CONFIRM,
};
class KeyboardInfo {
public:
KeyboardStatus GetKeyboardStatus() const
{
return keyboardStatus;
}
void SetKeyboardStatus(int32_t status)
{
keyboardStatus = static_cast<KeyboardStatus>(status);
}
FunctionKey GetFunctionKey() const
{
return functionKey;
}
void SetFunctionKey(int32_t key)
{
functionKey = static_cast<FunctionKey>(key);
}
private:
KeyboardStatus keyboardStatus = KeyboardStatus::NONE;
FunctionKey functionKey = FunctionKey::NONE;
};
}
#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
}
#endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H
@@ -113,7 +113,7 @@ using namespace MessageID;
MessageParcel *data = msg->msgContent_;
int32_t length = data->ReadInt32();
if (textListener != nullptr) {
textListener->DeleteBackward(length);
textListener->DeleteForward(length);
}
break;
}
@@ -253,9 +253,9 @@ using namespace MessageID;
InputMethodController::GetInstance()->OnRemoteSaDied(object);
}
void InputMethodController::onCursorUpdate(CursorInfo cursorInfo)
void InputMethodController::OnCursorUpdate(CursorInfo cursorInfo)
{
IMSA_HILOGI("InputMethodController::onCursorUpdate");
IMSA_HILOGI("InputMethodController::OnCursorUpdate");
}
void InputMethodController::OnSelectionChange(std::u16string text, int start, int end)
@@ -266,9 +266,9 @@ using namespace MessageID;
mSelectEnd = end;
}
void InputMethodController::onConfigurationChange(Configuration info)
void InputMethodController::OnConfigurationChange(Configuration info)
{
IMSA_HILOGI("InputMethodController::onConfigurationChange");
IMSA_HILOGI("InputMethodController::OnConfigurationChange");
}
}
}
@@ -12,4 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "input_method_utils.h"
namespace OHOS {
namespace MiscServices {
}
}
+3 -3
View File
@@ -56,13 +56,13 @@ namespace MiscServices {
{
IMSA_HILOGI("IMC TEST TextListener DeleteForward length: %{public}d", length);
}
void sendKeyEventFromInputMethod(KeyEvent event)
void SendKeyEventFromInputMethod(const KeyEvent& event)
{
IMSA_HILOGI("IMC TEST TextListener sendKeyEventFromInputMethod");
}
void sendKeyboardStatus(KeyboardStatus status)
void SendKeyboardInfo(const KeyboardInfo& info)
{
IMSA_HILOGI("IMC TEST TextListener sendKeyboardStatus");
IMSA_HILOGI("IMC TEST TextListener SendKeyboardInfo");
}
};
class InputMethodControllerTest : public testing::Test {