Skip to content

Commit

Permalink
fix: Mark view as important for AutoFill after requesting an AutoFill
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep authored Sep 23, 2024
1 parent 36d811e commit c6c2086
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public final class TerminalView extends View {
*/
@RequiresApi(api = Build.VERSION_CODES.O)
private int mAutoFillType = AUTOFILL_TYPE_NONE;

@RequiresApi(api = Build.VERSION_CODES.O)
private int mAutoFillImportance = IMPORTANT_FOR_AUTOFILL_NO;

/**
* The current AutoFill hints returned for {@link View#getAutofillHints()} ()} by {@link #getAutofillHints()} ()}.
Expand Down Expand Up @@ -1078,13 +1081,14 @@ public AutofillValue getAutofillValue() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public int getImportantForAutofill() {
return IMPORTANT_FOR_AUTOFILL_NO;
return mAutoFillImportance;
}

@RequiresApi(api = Build.VERSION_CODES.O)
private synchronized void resetAutoFill() {
// Restore none type so that AutoFill UI isn't shown anymore.
mAutoFillType = AUTOFILL_TYPE_NONE;
mAutoFillImportance = IMPORTANT_FOR_AUTOFILL_NO;
mAutoFillHints = new String[0];
}

Expand Down Expand Up @@ -1134,6 +1138,7 @@ public synchronized void requestAutoFill(String[] autoFillHints) {
if (autofillManager != null && autofillManager.isEnabled()) {
// Update type that will be returned by `getAutofillType()` so that AutoFill UI is shown.
mAutoFillType = AUTOFILL_TYPE_TEXT;
mAutoFillImportance = IMPORTANT_FOR_AUTOFILL_YES;
// Update hints that will be returned by `getAutofillHints()` for which to show AutoFill UI.
mAutoFillHints = autoFillHints;
autofillManager.requestAutofill(this);
Expand Down

0 comments on commit c6c2086

Please sign in to comment.