Merge "Add dialog present support for AutofillService." into tm-dev am: 037bcfce15 am: 258d865bf0

Original change: https://googleplex-android-review.googlesource.com/c/platform/development/+/18030509

Change-Id: I94af50decb5fcdbc0198d168254b931a77de6baf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Joanne Chung
2022-05-03 10:27:09 +00:00
committed by Automerger Merge Worker
2 changed files with 21 additions and 2 deletions

View File

@@ -134,8 +134,13 @@ public class InlineFillService extends AutofillService {
response.addDataset(InlineRequestHelper.createInlineActionDataset(context, fields,
inlineRequest.get(), R.drawable.ic_settings));
}
// 3. Add fill dialog
RemoteViews dialogPresentation =
ResponseHelper.newDatasetPresentation(packageName, "Dialog Header");
response.setDialogHeader(dialogPresentation);
response.setFillDialogTriggerIds(fields.valueAt(0), fields.valueAt(1));
// 3.Add save info
// 4.Add save info
Collection<AutofillId> ids = fields.values();
AutofillId[] requiredIds = new AutofillId[ids.size()];
ids.toArray(requiredIds);
@@ -143,7 +148,7 @@ public class InlineFillService extends AutofillService {
// We're simple, so we're generic
new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());
// 4.Profit!
// 5.Profit!
return response.build();
}

View File

@@ -59,8 +59,10 @@ class ResponseHelper {
// Set presentation
final Presentations.Builder fieldPresentationsBuilder =
new Presentations.Builder();
// Dropdown presentation
final RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
fieldPresentationsBuilder.setMenuPresentation(presentation);
// Inline presentation
if (inlineRequest.isPresent()) {
Log.d(TAG, "Found InlineSuggestionsRequest in FillRequest: " + inlineRequest);
final InlinePresentation inlinePresentation =
@@ -68,6 +70,11 @@ class ResponseHelper {
displayValue, index);
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
}
// Dialog presentation
RemoteViews dialogPresentation =
newDatasetPresentation(packageName, "Dialog Presentation " + (index + 1));
fieldPresentationsBuilder.setDialogPresentation(dialogPresentation);
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
dataset.setField(id, fieldBuilder.build());
}
@@ -92,15 +99,22 @@ class ResponseHelper {
Field.Builder fieldBuilder = new Field.Builder();
fieldBuilder.setValue(AutofillValue.forText(value));
// Dropdown presentation
final Presentations.Builder fieldPresentationsBuilder =
new Presentations.Builder();
fieldPresentationsBuilder.setMenuPresentation(presentation);
// Inline presentation
if (inlineRequest.isPresent()) {
final InlinePresentation inlinePresentation =
InlineRequestHelper.createInlineDataset(context, inlineRequest.get(),
displayValue, index);
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
}
// Dialog presentation
RemoteViews dialogPresentation =
newDatasetPresentation(packageName, "Dialog Presentation " + (index + 1));
fieldPresentationsBuilder.setDialogPresentation(dialogPresentation);
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
lockedDataset.setField(id, fieldBuilder.build());
lockedDataset.setId(null).setAuthentication(authentication);