Use the new web email and password variations.

Bug:2460543
Bug:3094312
Bug:2692655
Bug:2710595

Use the NEXT flag when there is a following
textfield.

In TextView, treat the new variations like email and password
variations.

Requires a change in LatinIME so that these fields work propely:
https://android-git.corp.google.com/g/#change,77721

Change-Id: Id6517a016db7d50b77570ff77f2635027796da4a
This commit is contained in:
Leon Scroggins
2010-11-01 13:20:24 -04:00
parent 0cf0173070
commit b5ce0e0532
2 changed files with 47 additions and 28 deletions

View File

@ -124,6 +124,16 @@ import java.util.ArrayList;
private boolean mAutoFillable; // Is this textview part of an autofillable form?
private int mQueryId;
// Types used with setType. Keep in sync with CachedInput.h
private static final int NORMAL_TEXT_FIELD = 0;
private static final int TEXT_AREA = 1;
private static final int PASSWORD = 2;
private static final int SEARCH = 3;
private static final int EMAIL = 4;
private static final int NUMBER = 5;
private static final int TELEPHONE = 6;
private static final int URL = 7;
/**
* Create a new WebTextView.
* @param context The Context for this WebTextView.
@ -788,7 +798,7 @@ import java.util.ArrayList;
/* package */ void setInPassword(boolean inPassword) {
if (inPassword) {
setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.
TYPE_TEXT_VARIATION_PASSWORD);
TYPE_TEXT_VARIATION_WEB_PASSWORD);
createBackground();
}
// For password fields, draw the WebTextView. For others, just show
@ -940,7 +950,7 @@ import java.util.ArrayList;
/**
* Called by WebView.rebuildWebTextView(). Based on the type of the <input>
* element, set up the WebTextView, its InputType, and IME Options properly.
* @param type int corresponding to enum "type" defined in WebView.cpp.
* @param type int corresponding to enum "Type" defined in CachedInput.h.
* Does not correspond to HTMLInputElement::InputType so this
* is unaffected if that changes, and also because that has no
* type corresponding to textarea (which is its own tag).
@ -950,47 +960,47 @@ import java.util.ArrayList;
boolean single = true;
boolean inPassword = false;
int maxLength = -1;
int inputType = EditorInfo.TYPE_CLASS_TEXT;
if (mWebView.nativeFocusCandidateHasNextTextfield()) {
inputType |= EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
}
int inputType = EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;
int imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
| EditorInfo.IME_FLAG_NO_FULLSCREEN;
if (TEXT_AREA != type
&& mWebView.nativeFocusCandidateHasNextTextfield()) {
imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
}
switch (type) {
case 0: // NORMAL_TEXT_FIELD
case NORMAL_TEXT_FIELD:
imeOptions |= EditorInfo.IME_ACTION_GO;
break;
case 1: // TEXT_AREA
case TEXT_AREA:
single = false;
inputType = EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
| EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
| EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
imeOptions |= EditorInfo.IME_ACTION_NONE;
break;
case 2: // PASSWORD
case PASSWORD:
inPassword = true;
imeOptions |= EditorInfo.IME_ACTION_GO;
break;
case 3: // SEARCH
case SEARCH:
imeOptions |= EditorInfo.IME_ACTION_SEARCH;
break;
case 4: // EMAIL
// TYPE_TEXT_VARIATION_WEB_EDIT_TEXT prevents EMAIL_ADDRESS
// from working, so exclude it for now.
case EMAIL:
inputType = EditorInfo.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
imeOptions |= EditorInfo.IME_ACTION_GO;
break;
case 5: // NUMBER
case NUMBER:
inputType |= EditorInfo.TYPE_CLASS_NUMBER;
// Number and telephone do not have both a Tab key and an
// action, so set the action to NEXT
imeOptions |= EditorInfo.IME_ACTION_NEXT;
break;
case 6: // TELEPHONE
case TELEPHONE:
inputType |= EditorInfo.TYPE_CLASS_PHONE;
imeOptions |= EditorInfo.IME_ACTION_NEXT;
break;
case 7: // URL
case URL:
// TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
// exclude it for now.
imeOptions |= EditorInfo.IME_ACTION_GO;
@ -1004,7 +1014,7 @@ import java.util.ArrayList;
mWebView.requestLabel(mWebView.nativeFocusCandidateFramePointer(),
mNodePointer);
maxLength = mWebView.nativeFocusCandidateMaxLength();
if (type != 2 /* PASSWORD */) {
if (type != PASSWORD) {
String name = mWebView.nativeFocusCandidateName();
if (name != null && name.length() > 0) {
mWebView.requestFormData(name, mNodePointer, mAutoFillable);

View File

@ -759,11 +759,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
BufferType bufferType = BufferType.EDITABLE;
if ((inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION))
== (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
password = true;
}
if (inputMethod != null) {
Class<?> c;
@ -857,9 +852,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
if (password && (mInputType&EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION))
| EditorInfo.TYPE_TEXT_VARIATION_PASSWORD;
if (password) {
// Caller used the deprecated xml attribute "password". Ensure that
// the inputType is correct.
boolean normalText = (mInputType & EditorInfo.TYPE_MASK_CLASS)
== EditorInfo.TYPE_CLASS_TEXT;
if (normalText && !isPasswordInputType(mInputType)) {
mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION))
| EditorInfo.TYPE_TEXT_VARIATION_PASSWORD;
}
} else if (isPasswordInputType(mInputType)) {
// Caller did not use the deprecated xml attribute "password", but
// did set the input properly. Set password to true.
password = true;
}
if (selectallonfocus) {
@ -3046,7 +3051,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
| EditorInfo.TYPE_MASK_VARIATION);
return variation
== (EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
| EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
|| variation == (EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD);
}
private boolean isVisiblePasswordInputType(int inputType) {
@ -7335,8 +7342,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
int variation = mInputType & InputType.TYPE_MASK_VARIATION;
if (variation == InputType.TYPE_TEXT_VARIATION_URI ||
variation == InputType.TYPE_TEXT_VARIATION_PASSWORD ||
variation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD ||
variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ||
variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS ||
variation == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS ||
variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
return -1;
}