Search in sources :

Example 1 with FillContext

use of android.service.autofill.FillContext in project KeePassDX by Kunzisoft.

the class KeeAutofillService method onFillRequest.

@Override
public void onFillRequest(@NonNull FillRequest request, @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback) {
    List<FillContext> fillContexts = request.getFillContexts();
    AssistStructure latestStructure = fillContexts.get(fillContexts.size() - 1).getStructure();
    cancellationSignal.setOnCancelListener(() -> Log.e(TAG, "Cancel autofill not implemented in this sample."));
    FillResponse.Builder responseBuilder = new FillResponse.Builder();
    // Check user's settings for authenticating Responses and Datasets.
    StructureParser.Result parseResult = new StructureParser(latestStructure).parse();
    AutofillId[] autofillIds = parseResult.allAutofillIds();
    if (!Arrays.asList(autofillIds).isEmpty()) {
        // If the entire Autofill Response is authenticated, AuthActivity is used
        // to generate Response.
        IntentSender sender = AutoFillAuthActivity.getAuthIntentSenderForResponse(this);
        RemoteViews presentation = new RemoteViews(getPackageName(), R.layout.autofill_service_unlock);
        responseBuilder.setAuthentication(autofillIds, sender, presentation);
        callback.onSuccess(responseBuilder.build());
    }
}
Also used : RemoteViews(android.widget.RemoteViews) FillResponse(android.service.autofill.FillResponse) FillContext(android.service.autofill.FillContext) AssistStructure(android.app.assist.AssistStructure) AutofillId(android.view.autofill.AutofillId) IntentSender(android.content.IntentSender)

Aggregations

AssistStructure (android.app.assist.AssistStructure)1 IntentSender (android.content.IntentSender)1 FillContext (android.service.autofill.FillContext)1 FillResponse (android.service.autofill.FillResponse)1 AutofillId (android.view.autofill.AutofillId)1 RemoteViews (android.widget.RemoteViews)1