OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.os.Handler; | 7 import android.os.Handler; |
8 import android.os.ResultReceiver; | 8 import android.os.ResultReceiver; |
9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
10 import android.text.Editable; | 10 import android.text.Editable; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 InputMethodManagerWrapper getInputMethodManagerWrapper() { | 173 InputMethodManagerWrapper getInputMethodManagerWrapper() { |
174 return mInputMethodManagerWrapper; | 174 return mInputMethodManagerWrapper; |
175 } | 175 } |
176 | 176 |
177 /** | 177 /** |
178 * Set the current active InputConnection when a new InputConnection is cons
tructed. | 178 * Set the current active InputConnection when a new InputConnection is cons
tructed. |
179 * @param inputConnection The input connection that is currently used with I
ME. | 179 * @param inputConnection The input connection that is currently used with I
ME. |
180 */ | 180 */ |
181 void setInputConnection(AdapterInputConnection inputConnection) { | 181 void setInputConnection(AdapterInputConnection inputConnection) { |
182 mInputConnection = inputConnection; | 182 mInputConnection = inputConnection; |
| 183 mLastComposeText = null; |
183 } | 184 } |
184 | 185 |
185 /** | 186 /** |
186 * Should be only used by AdapterInputConnection. | 187 * Should be only used by AdapterInputConnection. |
187 * @return The input type of currently focused element. | 188 * @return The input type of currently focused element. |
188 */ | 189 */ |
189 int getTextInputType() { | 190 int getTextInputType() { |
190 return mTextInputType; | 191 return mTextInputType; |
191 } | 192 } |
192 | 193 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 showKeyboard(); | 253 showKeyboard(); |
253 } | 254 } |
254 } | 255 } |
255 | 256 |
256 public void attach(long nativeImeAdapter, int textInputType) { | 257 public void attach(long nativeImeAdapter, int textInputType) { |
257 if (mNativeImeAdapterAndroid != 0) { | 258 if (mNativeImeAdapterAndroid != 0) { |
258 nativeResetImeAdapter(mNativeImeAdapterAndroid); | 259 nativeResetImeAdapter(mNativeImeAdapterAndroid); |
259 } | 260 } |
260 mNativeImeAdapterAndroid = nativeImeAdapter; | 261 mNativeImeAdapterAndroid = nativeImeAdapter; |
261 mTextInputType = textInputType; | 262 mTextInputType = textInputType; |
| 263 mLastComposeText = null; |
262 if (nativeImeAdapter != 0) { | 264 if (nativeImeAdapter != 0) { |
263 nativeAttachImeAdapter(mNativeImeAdapterAndroid); | 265 nativeAttachImeAdapter(mNativeImeAdapterAndroid); |
264 } | 266 } |
265 if (mTextInputType == sTextInputTypeNone) { | 267 if (mTextInputType == sTextInputTypeNone) { |
266 dismissInput(false); | 268 dismissInput(false); |
267 } | 269 } |
268 } | 270 } |
269 | 271 |
270 /** | 272 /** |
271 * Attaches the imeAdapter to its native counterpart. This is needed to star
t forwarding | 273 * Attaches the imeAdapter to its native counterpart. This is needed to star
t forwarding |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 430 } |
429 | 431 |
430 nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeKeyU
p, | 432 nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeKeyU
p, |
431 timeStampMs, keyCode, 0); | 433 timeStampMs, keyCode, 0); |
432 } | 434 } |
433 | 435 |
434 return true; | 436 return true; |
435 } | 437 } |
436 | 438 |
437 void finishComposingText() { | 439 void finishComposingText() { |
| 440 mLastComposeText = null; |
438 if (mNativeImeAdapterAndroid == 0) return; | 441 if (mNativeImeAdapterAndroid == 0) return; |
439 nativeFinishComposingText(mNativeImeAdapterAndroid); | 442 nativeFinishComposingText(mNativeImeAdapterAndroid); |
440 } | 443 } |
441 | 444 |
442 boolean translateAndSendNativeEvents(KeyEvent event) { | 445 boolean translateAndSendNativeEvents(KeyEvent event) { |
443 if (mNativeImeAdapterAndroid == 0) return false; | 446 if (mNativeImeAdapterAndroid == 0) return false; |
444 | 447 |
445 int action = event.getAction(); | 448 int action = event.getAction(); |
446 if (action != KeyEvent.ACTION_DOWN && | 449 if (action != KeyEvent.ACTION_DOWN && |
447 action != KeyEvent.ACTION_UP) { | 450 action != KeyEvent.ACTION_UP) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, | 663 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, |
661 int before, int after); | 664 int before, int after); |
662 | 665 |
663 private native void nativeUnselect(long nativeImeAdapterAndroid); | 666 private native void nativeUnselect(long nativeImeAdapterAndroid); |
664 private native void nativeSelectAll(long nativeImeAdapterAndroid); | 667 private native void nativeSelectAll(long nativeImeAdapterAndroid); |
665 private native void nativeCut(long nativeImeAdapterAndroid); | 668 private native void nativeCut(long nativeImeAdapterAndroid); |
666 private native void nativeCopy(long nativeImeAdapterAndroid); | 669 private native void nativeCopy(long nativeImeAdapterAndroid); |
667 private native void nativePaste(long nativeImeAdapterAndroid); | 670 private native void nativePaste(long nativeImeAdapterAndroid); |
668 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); | 671 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); |
669 } | 672 } |
OLD | NEW |