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

Unified Diff: blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java

Issue 1779673003: Added network components for blimp text input feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java
diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java b/blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java
index 9c50e8538e75709eb1b36b2031deaceffe4446c6..d13f62ee5f46cb6cc351637ca318c9266835351f 100644
--- a/blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java
+++ b/blimp/client/app/android/java/src/org/chromium/blimp/input/WebInputBox.java
@@ -5,6 +5,7 @@
package org.chromium.blimp.input;
import android.content.Context;
+import android.text.InputType;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
@@ -16,6 +17,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.blimp.session.BlimpClientSession;
import org.chromium.ui.UiUtils;
+import org.chromium.ui.base.ime.TextInputType;
/**
* A {@link View} that allows users to enter text into a web page.
@@ -30,8 +32,9 @@ public class WebInputBox extends EditText {
super(context, attrs);
setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_NEXT
- || actionId == EditorInfo.IME_ACTION_DONE) {
+ if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE
nyquist 2016/03/10 00:57:13 Nit: This if-statement is getting rather large. Sh
shaktisahu 2016/03/15 23:44:13 Done.
+ || actionId == EditorInfo.IME_ACTION_SEARCH
+ || actionId == EditorInfo.IME_ACTION_GO) {
onImeTextEntered(v.getText().toString());
hideIme();
return true;
@@ -101,8 +104,52 @@ public class WebInputBox extends EditText {
}
@CalledByNative
- private void onImeRequested(boolean show) {
+ private void onImeRequested(boolean show, int inputType, String text) {
+ // Set the IME options and input type based on the input type received from engine.
+ setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
David Trainor- moved to gerrit 2016/03/14 17:59:41 Do we want to do this if we're not showing the IME
shaktisahu 2016/03/15 23:44:13 Done.
+ switch (inputType) {
+ case TextInputType.TEXT:
+ setInputType(InputType.TYPE_CLASS_TEXT);
+ setImeOptions(EditorInfo.IME_ACTION_GO);
+ break;
+ case TextInputType.PASSWORD:
+ setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ setImeOptions(EditorInfo.IME_ACTION_GO);
+ break;
+ case TextInputType.SEARCH:
+ setImeOptions(EditorInfo.IME_ACTION_SEARCH);
+ break;
+ case TextInputType.EMAIL:
+ setInputType(
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
+ setImeOptions(EditorInfo.IME_ACTION_GO);
+ break;
+ case TextInputType.NUMBER:
+ setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL
+ | InputType.TYPE_NUMBER_FLAG_DECIMAL);
+ setImeOptions(EditorInfo.IME_ACTION_NEXT);
+ break;
+ case TextInputType.TELEPHONE:
+ setInputType(InputType.TYPE_CLASS_PHONE);
+ setImeOptions(EditorInfo.IME_ACTION_NEXT);
+ break;
+ case TextInputType.URL:
+ setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
+ setImeOptions(EditorInfo.IME_ACTION_GO);
+ break;
+ case TextInputType.TEXT_AREA:
+ case TextInputType.CONTENT_EDITABLE:
+ setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
+ setImeOptions(EditorInfo.IME_ACTION_NONE);
+ break;
+ default:
+ setInputType(InputType.TYPE_CLASS_TEXT);
+ }
+
if (show) {
+ setText(text);
+ // Set the cursor at the end.
+ setSelection(getText().length());
showIme();
} else {
hideIme();
Khushal 2016/03/10 07:54:10 Do you need to set all the Ime options if you're j
shaktisahu 2016/03/15 23:44:13 Done.

Powered by Google App Engine
This is Rietveld 408576698