Merge "Properly set input type on autofill compat mode." into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-23 22:49:25 +00:00
committed by Android (Google) Code Review

View File

@@ -8536,22 +8536,25 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
structure.setHint(info.getHintText()); structure.setHint(info.getHintText());
} }
if ((info.getText() != null || info.getError() != null)) { CharSequence text = info.getText();
structure.setText(info.getText(), info.getTextSelectionStart(), boolean hasText = text != null || info.getError() != null;
info.getTextSelectionEnd()); if (hasText) {
if (forAutofill) { structure.setText(text, info.getTextSelectionStart(), info.getTextSelectionEnd());
if (info.isEditable()) { }
structure.setDataIsSensitive(true); if (forAutofill) {
if (info.isEditable()) {
structure.setDataIsSensitive(true);
if (hasText) {
structure.setAutofillType(AUTOFILL_TYPE_TEXT); structure.setAutofillType(AUTOFILL_TYPE_TEXT);
final AutofillValue autofillValue = AutofillValue.forText(structure.getText()); structure.setAutofillValue(AutofillValue.forText(text));
structure.setAutofillValue(autofillValue);
if (info.isPassword()) {
structure.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
} else {
structure.setDataIsSensitive(false);
} }
int inputType = info.getInputType();
if (inputType == 0 && info.isPassword()) {
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
}
structure.setInputType(inputType);
} else {
structure.setDataIsSensitive(false);
} }
} }
final int NCHILDREN = info.getChildCount(); final int NCHILDREN = info.getChildCount();