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

Unified 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: Fixed FocusController and ImeAdapter related review comments. Created 3 years, 7 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 d7f70154e5fef20d7d0675f27394d7e41102cd08..d0014580bc8fb9641e9e4a23bee7e31ca6c23301 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
@@ -30,6 +30,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;
@@ -620,18 +621,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();
}
@@ -907,4 +922,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);
}

Powered by Google App Engine
This is Rietveld 408576698