mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 11:09:49 +08:00
Fixed: Mark view as important for AutoFill before requesting an AutoFill
Co-authored-by: @AChep <mail@artemchep.com> Co-authored-by: @agnostic-apollo <agnosticapollo@gmail.com>
This commit is contained in:
committed by
agnostic-apollo
parent
a8a69c6d80
commit
4443b657bf
@@ -100,6 +100,20 @@ public final class TerminalView extends View {
|
|||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
private int mAutoFillType = AUTOFILL_TYPE_NONE;
|
private int mAutoFillType = AUTOFILL_TYPE_NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current AutoFill type returned for {@link View#getImportantForAutofill()} by
|
||||||
|
* {@link #getImportantForAutofill()}.
|
||||||
|
*
|
||||||
|
* The default is {@link #IMPORTANT_FOR_AUTOFILL_NO} so that view is not considered important
|
||||||
|
* for AutoFill. This value should be updated to required value, like
|
||||||
|
* {@link #IMPORTANT_FOR_AUTOFILL_YES} before calling {@link AutofillManager#requestAutofill(View)}
|
||||||
|
* so that Android and apps consider the view as important for AutoFill to process the request.
|
||||||
|
* The updated value set will automatically be restored to {@link #IMPORTANT_FOR_AUTOFILL_NO} in
|
||||||
|
* {@link #autofill(AutofillValue)} by calling {@link #resetAutoFill()}.
|
||||||
|
*/
|
||||||
|
@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()} ()}.
|
* The current AutoFill hints returned for {@link View#getAutofillHints()} ()} by {@link #getAutofillHints()} ()}.
|
||||||
*
|
*
|
||||||
@@ -1078,13 +1092,14 @@ public final class TerminalView extends View {
|
|||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
@Override
|
@Override
|
||||||
public int getImportantForAutofill() {
|
public int getImportantForAutofill() {
|
||||||
return IMPORTANT_FOR_AUTOFILL_NO;
|
return mAutoFillImportance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
private synchronized void resetAutoFill() {
|
private synchronized void resetAutoFill() {
|
||||||
// Restore none type so that AutoFill UI isn't shown anymore.
|
// Restore none type so that AutoFill UI isn't shown anymore.
|
||||||
mAutoFillType = AUTOFILL_TYPE_NONE;
|
mAutoFillType = AUTOFILL_TYPE_NONE;
|
||||||
|
mAutoFillImportance = IMPORTANT_FOR_AUTOFILL_NO;
|
||||||
mAutoFillHints = new String[0];
|
mAutoFillHints = new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1134,6 +1149,9 @@ public final class TerminalView extends View {
|
|||||||
if (autofillManager != null && autofillManager.isEnabled()) {
|
if (autofillManager != null && autofillManager.isEnabled()) {
|
||||||
// Update type that will be returned by `getAutofillType()` so that AutoFill UI is shown.
|
// Update type that will be returned by `getAutofillType()` so that AutoFill UI is shown.
|
||||||
mAutoFillType = AUTOFILL_TYPE_TEXT;
|
mAutoFillType = AUTOFILL_TYPE_TEXT;
|
||||||
|
// Update importance that will be returned by `getImportantForAutofill()` so that
|
||||||
|
// AutoFill considers the view as important.
|
||||||
|
mAutoFillImportance = IMPORTANT_FOR_AUTOFILL_YES;
|
||||||
// Update hints that will be returned by `getAutofillHints()` for which to show AutoFill UI.
|
// Update hints that will be returned by `getAutofillHints()` for which to show AutoFill UI.
|
||||||
mAutoFillHints = autoFillHints;
|
mAutoFillHints = autoFillHints;
|
||||||
autofillManager.requestAutofill(this);
|
autofillManager.requestAutofill(this);
|
||||||
|
Reference in New Issue
Block a user