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.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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 case android.R.id.paste: | 613 case android.R.id.paste: |
614 mWebContents.paste(); | 614 mWebContents.paste(); |
615 return true; | 615 return true; |
616 default: | 616 default: |
617 return false; | 617 return false; |
618 } | 618 } |
619 } | 619 } |
620 | 620 |
621 boolean performEditorAction(int actionCode) { | 621 boolean performEditorAction(int actionCode) { |
622 if (!isValid()) return false; | 622 if (!isValid()) return false; |
623 if (actionCode == EditorInfo.IME_ACTION_NEXT) { | 623 switch (actionCode) { |
624 sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB, | 624 case EditorInfo.IME_ACTION_NEXT: |
625 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE | 625 restartInput(); |
Changwan Ryu
2017/04/27 16:34:53
I don't think you need to restart input here at al
AKVT
2017/05/03 14:35:11
Done.
| |
626 | KeyEvent.FLAG_EDITOR_ACTION); | 626 advanceFocusInForm(true); |
627 } else { | 627 break; |
628 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, | 628 case EditorInfo.IME_ACTION_PREVIOUS: |
629 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE | 629 restartInput(); |
630 | KeyEvent.FLAG_EDITOR_ACTION); | 630 advanceFocusInForm(false); |
631 break; | |
632 default: | |
633 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, | |
634 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_M ODE | |
635 | KeyEvent.FLAG_EDITOR_ACTION); | |
636 break; | |
631 } | 637 } |
632 return true; | 638 return true; |
633 } | 639 } |
634 | 640 |
641 /** | |
642 * Advances the focus to next input field in the current form. | |
643 * | |
644 * @param forward indicates whether to advance forward or backward direction . | |
645 */ | |
646 public void advanceFocusInForm(boolean forward) { | |
Changwan Ryu
2017/04/27 16:34:53
public -> private
AKVT
2017/05/03 14:35:11
Done.
| |
647 if (mNativeImeAdapterAndroid == 0) return; | |
648 nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, forward); | |
649 } | |
650 | |
635 void notifyUserAction() { | 651 void notifyUserAction() { |
636 mInputMethodManagerWrapper.notifyUserAction(); | 652 mInputMethodManagerWrapper.notifyUserAction(); |
637 } | 653 } |
638 | 654 |
639 @VisibleForTesting | 655 @VisibleForTesting |
640 protected void sendSyntheticKeyPress(int keyCode, int flags) { | 656 protected void sendSyntheticKeyPress(int keyCode, int flags) { |
641 long eventTime = SystemClock.uptimeMillis(); | 657 long eventTime = SystemClock.uptimeMillis(); |
642 sendKeyEvent(new KeyEvent(eventTime, eventTime, | 658 sendKeyEvent(new KeyEvent(eventTime, eventTime, |
643 KeyEvent.ACTION_DOWN, keyCode, 0, 0, | 659 KeyEvent.ACTION_DOWN, keyCode, 0, 0, |
644 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, | 660 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
900 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid, | 916 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid, |
901 int start, int end); | 917 int start, int end); |
902 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end); | 918 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end); |
903 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , | 919 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , |
904 int before, int after); | 920 int before, int after); |
905 private native void nativeDeleteSurroundingTextInCodePoints( | 921 private native void nativeDeleteSurroundingTextInCodePoints( |
906 long nativeImeAdapterAndroid, int before, int after); | 922 long nativeImeAdapterAndroid, int before, int after); |
907 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid); | 923 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid); |
908 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, | 924 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, |
909 boolean immediateRequest, boolean monitorRequest); | 925 boolean immediateRequest, boolean monitorRequest); |
926 private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, b oolean forward); | |
910 } | 927 } |
OLD | NEW |