Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java

Issue 351403002: Handler shown in editable field should be removed on any key press on keypad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.SystemClock; 7 import android.os.SystemClock;
8 import android.text.Editable; 8 import android.text.Editable;
9 import android.text.InputType; 9 import android.text.InputType;
10 import android.text.Selection; 10 import android.text.Selection;
11 import android.text.TextUtils; 11 import android.text.TextUtils;
12 import android.util.Log; 12 import android.util.Log;
13 import android.view.KeyEvent; 13 import android.view.KeyEvent;
14 import android.view.View; 14 import android.view.View;
15 import android.view.inputmethod.BaseInputConnection; 15 import android.view.inputmethod.BaseInputConnection;
16 import android.view.inputmethod.EditorInfo; 16 import android.view.inputmethod.EditorInfo;
17 import android.view.inputmethod.ExtractedText; 17 import android.view.inputmethod.ExtractedText;
18 import android.view.inputmethod.ExtractedTextRequest; 18 import android.view.inputmethod.ExtractedTextRequest;
19 19
20 import com.google.common.annotations.VisibleForTesting; 20 import com.google.common.annotations.VisibleForTesting;
21 21
22 import org.chromium.content.browser.ContentView;
23
22 /** 24 /**
23 * InputConnection is created by ContentView.onCreateInputConnection. 25 * InputConnection is created by ContentView.onCreateInputConnection.
24 * It then adapts android's IME to chrome's RenderWidgetHostView using the 26 * It then adapts android's IME to chrome's RenderWidgetHostView using the
25 * native ImeAdapterAndroid via the class ImeAdapter. 27 * native ImeAdapterAndroid via the class ImeAdapter.
26 */ 28 */
27 public class AdapterInputConnection extends BaseInputConnection { 29 public class AdapterInputConnection extends BaseInputConnection {
28 private static final String TAG = "AdapterInputConnection"; 30 private static final String TAG = "AdapterInputConnection";
29 private static final boolean DEBUG = false; 31 private static final boolean DEBUG = false;
30 /** 32 /**
31 * Selection value should be -1 if not known. See EditorInfo.java for detail s. 33 * Selection value should be -1 if not known. See EditorInfo.java for detail s.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 * @see BaseInputConnection#sendKeyEvent(android.view.KeyEvent) 333 * @see BaseInputConnection#sendKeyEvent(android.view.KeyEvent)
332 */ 334 */
333 @Override 335 @Override
334 public boolean sendKeyEvent(KeyEvent event) { 336 public boolean sendKeyEvent(KeyEvent event) {
335 if (DEBUG) { 337 if (DEBUG) {
336 Log.w(TAG, "sendKeyEvent [" + event.getAction() + "] [" + event.getK eyCode() + "]"); 338 Log.w(TAG, "sendKeyEvent [" + event.getAction() + "] [" + event.getK eyCode() + "]");
337 } 339 }
338 // If this is a key-up, and backspace/del or if the key has a character representation, 340 // If this is a key-up, and backspace/del or if the key has a character representation,
339 // need to update the underlying Editable (i.e. the local representation of the text 341 // need to update the underlying Editable (i.e. the local representation of the text
340 // being edited). 342 // being edited).
343 ((ContentView)mInternalView).
344 getInsertionHandleController().hideAndDisallowAutomaticShowing() ;
341 if (event.getAction() == KeyEvent.ACTION_UP) { 345 if (event.getAction() == KeyEvent.ACTION_UP) {
342 if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) { 346 if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
343 deleteSurroundingText(1, 0); 347 deleteSurroundingText(1, 0);
344 return true; 348 return true;
345 } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) { 349 } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) {
346 deleteSurroundingText(0, 1); 350 deleteSurroundingText(0, 1);
347 return true; 351 return true;
348 } else { 352 } else {
349 int unicodeChar = event.getUnicodeChar(); 353 int unicodeChar = event.getUnicodeChar();
350 if (unicodeChar != 0) { 354 if (unicodeChar != 0) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 @VisibleForTesting 500 @VisibleForTesting
497 ImeState getImeStateForTesting() { 501 ImeState getImeStateForTesting() {
498 String text = mEditable.toString(); 502 String text = mEditable.toString();
499 int selectionStart = Selection.getSelectionStart(mEditable); 503 int selectionStart = Selection.getSelectionStart(mEditable);
500 int selectionEnd = Selection.getSelectionEnd(mEditable); 504 int selectionEnd = Selection.getSelectionEnd(mEditable);
501 int compositionStart = getComposingSpanStart(mEditable); 505 int compositionStart = getComposingSpanStart(mEditable);
502 int compositionEnd = getComposingSpanEnd(mEditable); 506 int compositionEnd = getComposingSpanEnd(mEditable);
503 return new ImeState(text, selectionStart, selectionEnd, compositionStart , compositionEnd); 507 return new ImeState(text, selectionStart, selectionEnd, compositionStart , compositionEnd);
504 } 508 }
505 } 509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698