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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.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: Modified patch as suggested 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 nativeSetComposingText(mNativeImeAdapterAndroid, text, textStr, newCursorPosition); 354 nativeSetComposingText(mNativeImeAdapterAndroid, text, textStr, newCursorPosition);
355 } 355 }
356 nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeKeyU p, 356 nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, sEventTypeKeyU p,
357 timeStampMs, keyCode, 0); 357 timeStampMs, keyCode, 0);
358 } 358 }
359 359
360 return true; 360 return true;
361 } 361 }
362 362
363 void finishComposingText() { 363 void finishComposingText() {
364 if (mNativeImeAdapterAndroid == 0) return; 364 if (mNativeImeAdapterAndroid == 0) return;
aurimas (slooooooooow) 2014/07/01 19:31:14 Should we add a call to onImeEvent here as well?
jdduke (slow) 2014/07/01 19:36:37 I don't think so, and neither in the other functio
365 nativeFinishComposingText(mNativeImeAdapterAndroid); 365 nativeFinishComposingText(mNativeImeAdapterAndroid);
366 } 366 }
367 367
368 boolean translateAndSendNativeEvents(KeyEvent event) { 368 boolean translateAndSendNativeEvents(KeyEvent event) {
369 if (mNativeImeAdapterAndroid == 0) return false; 369 if (mNativeImeAdapterAndroid == 0) return false;
370 370
371 int action = event.getAction(); 371 int action = event.getAction();
372 if (action != KeyEvent.ACTION_DOWN && 372 if (action != KeyEvent.ACTION_DOWN &&
373 action != KeyEvent.ACTION_UP) { 373 action != KeyEvent.ACTION_UP) {
374 // action == KeyEvent.ACTION_MULTIPLE 374 // action == KeyEvent.ACTION_MULTIPLE
(...skipping 24 matching lines...) Expand all
399 399
400 /** 400 /**
401 * Send a request to the native counterpart to delete a given range of chara cters. 401 * Send a request to the native counterpart to delete a given range of chara cters.
402 * @param beforeLength Number of characters to extend the selection by befor e the existing 402 * @param beforeLength Number of characters to extend the selection by befor e the existing
403 * selection. 403 * selection.
404 * @param afterLength Number of characters to extend the selection by after the existing 404 * @param afterLength Number of characters to extend the selection by after the existing
405 * selection. 405 * selection.
406 * @return Whether the native counterpart of ImeAdapter received the call. 406 * @return Whether the native counterpart of ImeAdapter received the call.
407 */ 407 */
408 boolean deleteSurroundingText(int beforeLength, int afterLength) { 408 boolean deleteSurroundingText(int beforeLength, int afterLength) {
409 mViewEmbedder.onImeEvent(false);
409 if (mNativeImeAdapterAndroid == 0) return false; 410 if (mNativeImeAdapterAndroid == 0) return false;
410 // Can't send the deletion key code yet because it will delete an extra char at the end. 411 // Can't send the deletion key code yet because it will delete an extra char at the end.
411 // Also the deleteSurroundingText message is not always ordered properly with key event 412 // Also the deleteSurroundingText message is not always ordered properly with key event
412 // messages yet. 413 // messages yet.
413 // TODO(guohui): fix the ordering and send the deletion key code for sin gle-char deletion. 414 // TODO(guohui): fix the ordering and send the deletion key code for sin gle-char deletion.
414 sendSyntheticKeyEvent( 415 sendSyntheticKeyEvent(
415 sEventTypeRawKeyDown, SystemClock.uptimeMillis(), KeyEvent.KEYCO DE_UNKNOWN, 0); 416 sEventTypeRawKeyDown, SystemClock.uptimeMillis(), KeyEvent.KEYCO DE_UNKNOWN, 0);
416 nativeDeleteSurroundingText(mNativeImeAdapterAndroid, beforeLength, afte rLength); 417 nativeDeleteSurroundingText(mNativeImeAdapterAndroid, beforeLength, afte rLength);
417 sendSyntheticKeyEvent( 418 sendSyntheticKeyEvent(
418 sEventTypeKeyUp, SystemClock.uptimeMillis(), KeyEvent.KEYCODE_UN KNOWN, 0); 419 sEventTypeKeyUp, SystemClock.uptimeMillis(), KeyEvent.KEYCODE_UN KNOWN, 0);
419 return true; 420 return true;
420 } 421 }
421 422
422 /** 423 /**
423 * Send a request to the native counterpart to set the selection to given ra nge. 424 * Send a request to the native counterpart to set the selection to given ra nge.
424 * @param start Selection start index. 425 * @param start Selection start index.
425 * @param end Selection end index. 426 * @param end Selection end index.
426 * @return Whether the native counterpart of ImeAdapter received the call. 427 * @return Whether the native counterpart of ImeAdapter received the call.
427 */ 428 */
428 boolean setEditableSelectionOffsets(int start, int end) { 429 boolean setEditableSelectionOffsets(int start, int end) {
429 if (mNativeImeAdapterAndroid == 0) return false; 430 if (mNativeImeAdapterAndroid == 0) return false;
aurimas (slooooooooow) 2014/07/01 19:31:14 Should we add a call to onImeEvent here as well?
430 nativeSetEditableSelectionOffsets(mNativeImeAdapterAndroid, start, end); 431 nativeSetEditableSelectionOffsets(mNativeImeAdapterAndroid, start, end);
431 return true; 432 return true;
432 } 433 }
433 434
434 /** 435 /**
435 * Send a request to the native counterpart to set compositing region to giv en indices. 436 * Send a request to the native counterpart to set compositing region to giv en indices.
436 * @param start The start of the composition. 437 * @param start The start of the composition.
437 * @param end The end of the composition. 438 * @param end The end of the composition.
438 * @return Whether the native counterpart of ImeAdapter received the call. 439 * @return Whether the native counterpart of ImeAdapter received the call.
439 */ 440 */
440 boolean setComposingRegion(int start, int end) { 441 boolean setComposingRegion(int start, int end) {
441 if (mNativeImeAdapterAndroid == 0) return false; 442 if (mNativeImeAdapterAndroid == 0) return false;
aurimas (slooooooooow) 2014/07/01 19:31:14 Should we add a call to onImeEvent here as well?
442 nativeSetComposingRegion(mNativeImeAdapterAndroid, start, end); 443 nativeSetComposingRegion(mNativeImeAdapterAndroid, start, end);
443 return true; 444 return true;
444 } 445 }
445 446
446 /** 447 /**
447 * Send a request to the native counterpart to unselect text. 448 * Send a request to the native counterpart to unselect text.
448 * @return Whether the native counterpart of ImeAdapter received the call. 449 * @return Whether the native counterpart of ImeAdapter received the call.
449 */ 450 */
450 public boolean unselect() { 451 public boolean unselect() {
451 if (mNativeImeAdapterAndroid == 0) return false; 452 if (mNativeImeAdapterAndroid == 0) return false;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 592 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
592 int before, int after); 593 int before, int after);
593 594
594 private native void nativeUnselect(long nativeImeAdapterAndroid); 595 private native void nativeUnselect(long nativeImeAdapterAndroid);
595 private native void nativeSelectAll(long nativeImeAdapterAndroid); 596 private native void nativeSelectAll(long nativeImeAdapterAndroid);
596 private native void nativeCut(long nativeImeAdapterAndroid); 597 private native void nativeCut(long nativeImeAdapterAndroid);
597 private native void nativeCopy(long nativeImeAdapterAndroid); 598 private native void nativeCopy(long nativeImeAdapterAndroid);
598 private native void nativePaste(long nativeImeAdapterAndroid); 599 private native void nativePaste(long nativeImeAdapterAndroid);
599 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); 600 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid);
600 } 601 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698