Merge "Auto append password hint for TextView" into tm-dev am: 2ab23eed06

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17750671

Change-Id: Ie03d8f9bef55f59e1a1920783bcb0f3d37223756
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TYM Tsai
2022-04-21 09:18:01 +00:00
committed by Automerger Merge Worker
2 changed files with 23 additions and 0 deletions

View File

@@ -1281,6 +1281,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/ */
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"; 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. * Hints for the autofill services that describes the content of the view.
*/ */

View File

@@ -6974,6 +6974,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mEditor.mInputType = type; 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 * @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. * a {@code Locale} object that can be used to customize key various listeners.