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

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

Issue 2839993002: [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Created 3 years, 8 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 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.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.res.Configuration; 8 import android.content.res.Configuration;
9 import android.graphics.Rect; 9 import android.graphics.Rect;
10 import android.os.Build; 10 import android.os.Build;
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 case android.R.id.paste: 610 case android.R.id.paste:
611 mWebContents.paste(); 611 mWebContents.paste();
612 return true; 612 return true;
613 default: 613 default:
614 return false; 614 return false;
615 } 615 }
616 } 616 }
617 617
618 boolean performEditorAction(int actionCode) { 618 boolean performEditorAction(int actionCode) {
619 if (!isValid()) return false; 619 if (!isValid()) return false;
620 if (actionCode == EditorInfo.IME_ACTION_NEXT) { 620 switch (actionCode) {
621 sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB, 621 case EditorInfo.IME_ACTION_NEXT:
622 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE 622 restartInput();
623 | KeyEvent.FLAG_EDITOR_ACTION); 623 advanceFocusInForm(true);
624 } else { 624 break;
625 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, 625 case EditorInfo.IME_ACTION_PREVIOUS:
626 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE 626 restartInput();
627 | KeyEvent.FLAG_EDITOR_ACTION); 627 advanceFocusInForm(false);
628 break;
629 default:
630 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER,
631 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_M ODE
632 | KeyEvent.FLAG_EDITOR_ACTION);
633 break;
628 } 634 }
629 return true; 635 return true;
630 } 636 }
631 637
638 /**
639 * Advances the focus to next input field in the current form.
640 *
641 * @param forward indicates whether to advance forward or backward direction .
642 */
643 public void advanceFocusInForm(boolean forward) {
644 if (mNativeImeAdapterAndroid == 0) return;
645 nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, forward);
646 }
647
632 void notifyUserAction() { 648 void notifyUserAction() {
633 mInputMethodManagerWrapper.notifyUserAction(); 649 mInputMethodManagerWrapper.notifyUserAction();
634 } 650 }
635 651
636 @VisibleForTesting 652 @VisibleForTesting
637 protected void sendSyntheticKeyPress(int keyCode, int flags) { 653 protected void sendSyntheticKeyPress(int keyCode, int flags) {
638 long eventTime = SystemClock.uptimeMillis(); 654 long eventTime = SystemClock.uptimeMillis();
639 sendKeyEvent(new KeyEvent(eventTime, eventTime, 655 sendKeyEvent(new KeyEvent(eventTime, eventTime,
640 KeyEvent.ACTION_DOWN, keyCode, 0, 0, 656 KeyEvent.ACTION_DOWN, keyCode, 0, 0,
641 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 657 KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid, 911 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid,
896 int start, int end); 912 int start, int end);
897 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end); 913 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end);
898 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 914 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
899 int before, int after); 915 int before, int after);
900 private native void nativeDeleteSurroundingTextInCodePoints( 916 private native void nativeDeleteSurroundingTextInCodePoints(
901 long nativeImeAdapterAndroid, int before, int after); 917 long nativeImeAdapterAndroid, int before, int after);
902 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid); 918 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid);
903 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, 919 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid,
904 boolean immediateRequest, boolean monitorRequest); 920 boolean immediateRequest, boolean monitorRequest);
921 private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, b oolean forward);
905 } 922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698