diff options
| author | TYM Tsai <tymtsai@google.com> | 2022-04-14 15:53:32 +0800 |
|---|---|---|
| committer | TYM Tsai <tymtsai@google.com> | 2022-04-20 03:55:33 +0800 |
| commit | 1f5c147eb5959a7e4fd03b751679cb5e00984c9c (patch) | |
| tree | bc66869354db5e67f088e40e93025c21e296fb52 /core/java/android/widget/TextView.java | |
| parent | bbf0074056a2e3122aac2d06ce828f0102bfd5e4 (diff) | |
Auto append password hint for TextView
Some TextViews are made as password via input type but does not
contain autofill password hint. This change auto append a hint
for autofill to identify.
Bug: 219844915
Test: atest android.autofillservice.cts.dialog.LoginActivityTest
Change-Id: Ifd18c56ffe788a601821d178ace41413f9e0454e
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index f9c964158e2e..572d97740187 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -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. |
