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

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

Issue 2948593002: Relanding [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Rebased the patch Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
index 0dc13ed95d8e0d83b6b02969c7c76234bcb62276..de5b64a0ab2681a7dfa7b48d56f22b46057a5abe 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
@@ -31,6 +31,7 @@ import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
+import org.chromium.blink_public.web.WebFocusType;
import org.chromium.blink_public.web.WebInputEventModifier;
import org.chromium.blink_public.web.WebInputEventType;
import org.chromium.blink_public.web.WebTextInputMode;
@@ -633,18 +634,32 @@ public class ImeAdapter {
boolean performEditorAction(int actionCode) {
if (!isValid()) return false;
- if (actionCode == EditorInfo.IME_ACTION_NEXT) {
- sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB,
- KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE
- | KeyEvent.FLAG_EDITOR_ACTION);
- } else {
- sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER,
- KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE
- | KeyEvent.FLAG_EDITOR_ACTION);
+ switch (actionCode) {
+ case EditorInfo.IME_ACTION_NEXT:
+ advanceFocusInForm(WebFocusType.FORWARD);
+ break;
+ case EditorInfo.IME_ACTION_PREVIOUS:
+ advanceFocusInForm(WebFocusType.BACKWARD);
+ break;
+ default:
+ sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER,
+ KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE
+ | KeyEvent.FLAG_EDITOR_ACTION);
+ break;
}
return true;
}
+ /**
+ * Advances the focus to next input field in the current form.
+ *
+ * @param focusType indicates whether to advance forward or backward direction.
+ */
+ private void advanceFocusInForm(int focusType) {
+ if (mNativeImeAdapterAndroid == 0) return;
+ nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, focusType);
+ }
+
void notifyUserAction() {
mInputMethodManagerWrapper.notifyUserAction();
}
@@ -920,4 +935,5 @@ public class ImeAdapter {
private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapterAndroid);
private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid,
boolean immediateRequest, boolean monitorRequest);
+ private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, int focusType);
}
« no previous file with comments | « content/common/frame_messages.h ('k') | content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698