| Index: ui/platform_window/android/platform_ime_controller_android.cc
|
| diff --git a/ui/platform_window/android/platform_ime_controller_android.cc b/ui/platform_window/android/platform_ime_controller_android.cc
|
| index 58a04ec95835bb9c153fb7d1d786e15d7d38b4a2..0fe3c02ca6928cc333202f3381496a175a11a96c 100644
|
| --- a/ui/platform_window/android/platform_ime_controller_android.cc
|
| +++ b/ui/platform_window/android/platform_ime_controller_android.cc
|
| @@ -7,15 +7,21 @@
|
| #include "base/android/jni_android.h"
|
| #include "base/android/jni_string.h"
|
| #include "jni/PlatformImeControllerAndroid_jni.h"
|
| +#include "ui/base/ime/input_method.h"
|
| +#include "ui/base/ime/text_input_client.h"
|
| +
|
| +#include "base/debug/stack_trace.h"
|
|
|
| namespace ui {
|
|
|
| // static
|
| bool PlatformImeControllerAndroid::Register(JNIEnv* env) {
|
| + LOG(ERROR) << " ~~~ PlatformImeControllerAndroid::Register";
|
| return RegisterNativesImpl(env);
|
| }
|
|
|
| -PlatformImeControllerAndroid::PlatformImeControllerAndroid() {
|
| +PlatformImeControllerAndroid::PlatformImeControllerAndroid()
|
| + : keyboard_visible_(false), input_method_(nullptr) {
|
| }
|
|
|
| PlatformImeControllerAndroid::~PlatformImeControllerAndroid() {
|
| @@ -26,11 +32,25 @@ void PlatformImeControllerAndroid::Init(JNIEnv* env, jobject jobj) {
|
| java_platform_ime_controller_android_ = JavaObjectWeakGlobalRef(env, jobj);
|
| }
|
|
|
| +void PlatformImeControllerAndroid::SetInputMethod(
|
| + ui::InputMethod* input_method) {
|
| + LOG(ERROR) << "auraclank: PlatformImeControllerAndroid::SetInputMethod"
|
| + << "input_method=" << input_method;
|
| + input_method->AddObserver(this);
|
| + input_method_ = input_method;
|
| +}
|
| +
|
| +void PlatformImeControllerAndroid::OnTextInputTypeChanged(
|
| + const ui::TextInputClient* client) {
|
| + OnTextInputStateChanged(client);
|
| +}
|
| +
|
| void PlatformImeControllerAndroid::UpdateTextInputState(
|
| const TextInputState& state) {
|
| if (java_platform_ime_controller_android_.is_empty())
|
| return;
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| +
|
| Java_PlatformImeControllerAndroid_updateTextInputState(
|
| env,
|
| java_platform_ime_controller_android_.get(env).obj(),
|
| @@ -44,8 +64,12 @@ void PlatformImeControllerAndroid::UpdateTextInputState(
|
| }
|
|
|
| void PlatformImeControllerAndroid::SetImeVisibility(bool visible) {
|
| + LOG(ERROR) << "auraclank: PlatformImeControllerAndroid::SetImeVisibility";
|
| if (java_platform_ime_controller_android_.is_empty())
|
| return;
|
| + if (visible == keyboard_visible_)
|
| + return;
|
| + keyboard_visible_ = visible;
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| Java_PlatformImeControllerAndroid_setImeVisibility(
|
| env,
|
| @@ -53,4 +77,37 @@ void PlatformImeControllerAndroid::SetImeVisibility(bool visible) {
|
| visible);
|
| }
|
|
|
| +// InputMethodObserver:
|
| +void PlatformImeControllerAndroid::OnTextInputStateChanged(
|
| + const ui::TextInputClient* client) {
|
| + TextInputState state;
|
| + if (client) {
|
| + state.type = client->GetTextInputType();
|
| + state.flags = client->GetTextInputFlags();
|
| + // TODO(mfomitchev): Is the other data needed? Does,'t seem to be used...
|
| + // state.text = ???
|
| + // ...
|
| + } else {
|
| + state.type = ui::TEXT_INPUT_TYPE_NONE;
|
| + }
|
| + UpdateTextInputState(state);
|
| +
|
| + // TODO(mfomitchev): Not sure if needed
|
| + if (state.type == ui::TEXT_INPUT_TYPE_NONE)
|
| + SetImeVisibility(false);
|
| + else
|
| + SetImeVisibility(true);
|
| +}
|
| +
|
| +void PlatformImeControllerAndroid::OnInputMethodDestroyed(
|
| + const ui::InputMethod* input_method) {
|
| + LOG(ERROR) << "auraclank: PlatformImeControllerAndroid::OnInputMethodDestroyed";
|
| + SetImeVisibility(false);
|
| +}
|
| +
|
| +void PlatformImeControllerAndroid::OnShowImeIfNeeded() {
|
| + LOG(ERROR) << "auraclank: PlatformImeControllerAndroid::OnShowImeIfNeeded";
|
| + SetImeVisibility(true);
|
| +}
|
| +
|
| } // namespace ui
|
|
|