Merge "Auto append password hint for TextView" into tm-dev
This commit is contained in:
@@ -1281,6 +1281,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay";
|
||||
|
||||
/**
|
||||
* A hint indicating that this view can be autofilled with a password.
|
||||
*
|
||||
* This is a heuristic-based hint that is meant to be used by UI Toolkit developers when a
|
||||
* view is a password field but doesn't specify a
|
||||
* <code>{@value View#AUTOFILL_HINT_PASSWORD}</code>.
|
||||
* @hide
|
||||
*/
|
||||
// TODO(229765029): unhide this for UI toolkit
|
||||
public static final String AUTOFILL_HINT_PASSWORD_AUTO = "passwordAuto";
|
||||
|
||||
/**
|
||||
* Hints for the autofill services that describes the content of the view.
|
||||
*/
|
||||
|
||||
@@ -6974,6 +6974,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
mEditor.mInputType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAutofillHints() {
|
||||
String[] hints = super.getAutofillHints();
|
||||
if (isAnyPasswordInputType()) {
|
||||
if (!ArrayUtils.contains(hints, AUTOFILL_HINT_PASSWORD_AUTO)) {
|
||||
hints = ArrayUtils.appendElement(String.class, hints,
|
||||
AUTOFILL_HINT_PASSWORD_AUTO);
|
||||
}
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code null} if the key listener should use pre-O (locale-independent). Otherwise
|
||||
* a {@code Locale} object that can be used to customize key various listeners.
|
||||
|
||||
Reference in New Issue
Block a user