diff options
| author | TYM Tsai <tymtsai@google.com> | 2022-02-18 23:36:07 +0800 |
|---|---|---|
| committer | TYM Tsai <tymtsai@google.com> | 2022-03-23 15:02:12 +0800 |
| commit | 8f502801e16d13acdd6fd381777eefc5ef463118 (patch) | |
| tree | f956e3a626a794088488528687c9cecb2e4c75f8 /core/java/android/widget/TextView.java | |
| parent | 3c5b9738c7058201a806a622445d265a767c2b95 (diff) | |
Make TextView do not show IME when fill dialog popup
Make to show fill dialog only if IME is not showing. And if the field
will show fill dialog, ignore to show ime when clicks on the field.
Bug: 210926084
Test: Manual
launch sample and click on password field -> show fill dialog
click on username field (no fill dialog) -> show fill UI and IME
IME is showing and click on password field -> show fill UI
Test: atest android.autofillservice.cts.dialog.LoginActivityTest
Test: atest android.widget.cts.EditTextTest
Change-Id: I6080510d87c50969d85fd9ed746ceba7e3c1c685
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 3c8fcb978fbd..836bbe8fa054 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -11458,7 +11458,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Show the IME, except when selecting in read-only text. final InputMethodManager imm = getInputMethodManager(); viewClicked(imm); - if (isTextEditable() && mEditor.mShowSoftInputOnFocus && imm != null) { + if (isTextEditable() && mEditor.mShowSoftInputOnFocus && imm != null + && !showAutofillDialog()) { imm.showSoftInput(this, 0); } @@ -11476,6 +11477,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return superResult; } + /** + * The fill dialog UI is a more conspicuous and efficient interface than dropdown UI. + * If autofill suggestions are available when the user clicks on a field that supports filling + * the dialog UI, Autofill will pop up a fill dialog. The dialog will take up a larger area + * to display the datasets, so it is easy for users to pay attention to the datasets and + * selecting a dataset. The autofill dialog is shown as the bottom sheet, the better + * experience is not to show the IME if there is a fill dialog. + */ + private boolean showAutofillDialog() { + final AutofillManager afm = mContext.getSystemService(AutofillManager.class); + if (afm != null) { + return afm.showAutofillDialog(this); + } + return false; + } + @Override public boolean onGenericMotionEvent(MotionEvent event) { if (mMovement != null && mText instanceof Spannable && mLayout != null) { |
