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

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

Issue 2523753003: Add inputmode to android ImeAdapater. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/ImeUtils.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
index b62b29399748ca059158201165b3101af878a41c..8d44066f49df260b529a4af8fdc6d3f90b2c664b 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
@@ -15,6 +15,7 @@ import android.view.inputmethod.EditorInfo;
import org.chromium.base.ThreadUtils;
import org.chromium.blink_public.web.WebTextInputFlags;
+import org.chromium.blink_public.web.WebTextInputMode;
import org.chromium.ui.base.ime.TextInputType;
import java.util.Locale;
@@ -29,12 +30,13 @@ public class ImeUtils {
*
* @param inputType Type defined in {@link TextInputType}.
* @param inputFlags Flags defined in {@link WebTextInputFlags}.
+ * @param inputMode Flags defined in {@link WebTextInputMode}.
* @param initialSelStart The initial selection start position.
* @param initialSelEnd The initial selection end position.
* @param outAttrs An instance of {@link EditorInfo} that we are going to change.
*/
- public static void computeEditorInfo(int inputType, int inputFlags, int initialSelStart,
- int initialSelEnd, EditorInfo outAttrs) {
+ public static void computeEditorInfo(int inputType, int inputFlags, int inputMode,
+ int initialSelStart, int initialSelEnd, EditorInfo outAttrs) {
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
outAttrs.inputType =
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
@@ -43,46 +45,89 @@ public class ImeUtils {
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}
- if (inputType == TextInputType.TEXT) {
- // Normal text field
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
- if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
- outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
+ int imeAction = 0;
+ if (inputMode == WebTextInputMode.kDefault) {
+ if (inputType == TextInputType.TEXT) {
+ // Normal text field
+ imeAction = EditorInfo.IME_ACTION_GO;
+ if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
+ outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
+ }
+ } else if (inputType == TextInputType.TEXT_AREA
+ || inputType == TextInputType.CONTENT_EDITABLE) {
+ outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
+ if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
+ outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
+ }
+ imeAction = EditorInfo.IME_ACTION_NONE;
+ } else if (inputType == TextInputType.PASSWORD) {
+ outAttrs.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
+ imeAction = EditorInfo.IME_ACTION_GO;
+ } else if (inputType == TextInputType.SEARCH) {
+ imeAction = EditorInfo.IME_ACTION_SEARCH;
+ } else if (inputType == TextInputType.URL) {
+ outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
+ imeAction = EditorInfo.IME_ACTION_GO;
+ } else if (inputType == TextInputType.EMAIL) {
+ // Email
+ outAttrs.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
+ imeAction = EditorInfo.IME_ACTION_GO;
+ } else if (inputType == TextInputType.TELEPHONE) {
+ // Telephone
+ // Number and telephone do not have both a Tab key and an
+ // action in default OSK, so set the action to NEXT
+ outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
+ imeAction = EditorInfo.IME_ACTION_NEXT;
+ } else if (inputType == TextInputType.NUMBER) {
+ // Number
+ outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
+ | InputType.TYPE_NUMBER_VARIATION_NORMAL
+ | InputType.TYPE_NUMBER_FLAG_DECIMAL;
+ imeAction = EditorInfo.IME_ACTION_NEXT;
}
- } else if (inputType == TextInputType.TEXT_AREA
- || inputType == TextInputType.CONTENT_EDITABLE) {
- outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
- if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
- outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
+ } else {
+ switch (inputMode) {
+ default:
+ case WebTextInputMode.kDefault:
+ case WebTextInputMode.kVerbatim:
+ case WebTextInputMode.kLatin:
+ case WebTextInputMode.kLatinName:
+ case WebTextInputMode.kLatinProse:
+ case WebTextInputMode.kFullWidthLatin:
+ case WebTextInputMode.kKana:
+ case WebTextInputMode.kKanaName:
+ case WebTextInputMode.kKataKana:
+ outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
+ if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
+ outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
+ }
+ imeAction = EditorInfo.IME_ACTION_NONE;
+ break;
+ case WebTextInputMode.kNumeric:
+ outAttrs.inputType =
+ InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL;
+ imeAction = EditorInfo.IME_ACTION_NEXT;
+ break;
+ case WebTextInputMode.kTel:
+ outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
+ imeAction = EditorInfo.IME_ACTION_NEXT;
+ break;
+ case WebTextInputMode.kEmail:
+ outAttrs.inputType = InputType.TYPE_CLASS_TEXT
+ | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
+ imeAction = EditorInfo.IME_ACTION_GO;
+ break;
+ case WebTextInputMode.kUrl:
+ outAttrs.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
+ imeAction = EditorInfo.IME_ACTION_NEXT;
+ break;
}
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
- } else if (inputType == TextInputType.PASSWORD) {
- outAttrs.inputType =
- InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
- } else if (inputType == TextInputType.SEARCH) {
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_SEARCH;
- } else if (inputType == TextInputType.URL) {
- outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
- } else if (inputType == TextInputType.EMAIL) {
- // Email
- outAttrs.inputType =
- InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
- } else if (inputType == TextInputType.TELEPHONE) {
- // Telephone
- // Number and telephone do not have both a Tab key and an
- // action in default OSK, so set the action to NEXT
- outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
- } else if (inputType == TextInputType.NUMBER) {
- // Number
- outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
- | InputType.TYPE_NUMBER_VARIATION_NORMAL | InputType.TYPE_NUMBER_FLAG_DECIMAL;
- outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
}
+ outAttrs.imeOptions |= imeAction;
// Handling of autocapitalize. Blink will send the flag taking into account the element's
// type. This is not using AutocapitalizeNone because Android does not autocapitalize by
// default and there is no way to express no capitalization.
@@ -158,4 +203,4 @@ public class ImeUtils {
static void checkOnUiThread() {
checkCondition("Should be on UI thread.", ThreadUtils.runningOnUiThread());
}
-}
+}

Powered by Google App Engine
This is Rietveld 408576698