Merge "Add dialog present support for AutofillService." into tm-dev
This commit is contained in:
@@ -134,8 +134,13 @@ public class InlineFillService extends AutofillService {
|
|||||||
response.addDataset(InlineRequestHelper.createInlineActionDataset(context, fields,
|
response.addDataset(InlineRequestHelper.createInlineActionDataset(context, fields,
|
||||||
inlineRequest.get(), R.drawable.ic_settings));
|
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();
|
Collection<AutofillId> ids = fields.values();
|
||||||
AutofillId[] requiredIds = new AutofillId[ids.size()];
|
AutofillId[] requiredIds = new AutofillId[ids.size()];
|
||||||
ids.toArray(requiredIds);
|
ids.toArray(requiredIds);
|
||||||
@@ -143,7 +148,7 @@ public class InlineFillService extends AutofillService {
|
|||||||
// We're simple, so we're generic
|
// We're simple, so we're generic
|
||||||
new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());
|
new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC, requiredIds).build());
|
||||||
|
|
||||||
// 4.Profit!
|
// 5.Profit!
|
||||||
return response.build();
|
return response.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ class ResponseHelper {
|
|||||||
// Set presentation
|
// Set presentation
|
||||||
final Presentations.Builder fieldPresentationsBuilder =
|
final Presentations.Builder fieldPresentationsBuilder =
|
||||||
new Presentations.Builder();
|
new Presentations.Builder();
|
||||||
|
// Dropdown presentation
|
||||||
final RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
final RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
||||||
fieldPresentationsBuilder.setMenuPresentation(presentation);
|
fieldPresentationsBuilder.setMenuPresentation(presentation);
|
||||||
|
// Inline presentation
|
||||||
if (inlineRequest.isPresent()) {
|
if (inlineRequest.isPresent()) {
|
||||||
Log.d(TAG, "Found InlineSuggestionsRequest in FillRequest: " + inlineRequest);
|
Log.d(TAG, "Found InlineSuggestionsRequest in FillRequest: " + inlineRequest);
|
||||||
final InlinePresentation inlinePresentation =
|
final InlinePresentation inlinePresentation =
|
||||||
@@ -68,6 +70,11 @@ class ResponseHelper {
|
|||||||
displayValue, index);
|
displayValue, index);
|
||||||
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
||||||
}
|
}
|
||||||
|
// Dialog presentation
|
||||||
|
RemoteViews dialogPresentation =
|
||||||
|
newDatasetPresentation(packageName, "Dialog Presentation " + (index + 1));
|
||||||
|
fieldPresentationsBuilder.setDialogPresentation(dialogPresentation);
|
||||||
|
|
||||||
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
||||||
dataset.setField(id, fieldBuilder.build());
|
dataset.setField(id, fieldBuilder.build());
|
||||||
}
|
}
|
||||||
@@ -92,15 +99,22 @@ class ResponseHelper {
|
|||||||
|
|
||||||
Field.Builder fieldBuilder = new Field.Builder();
|
Field.Builder fieldBuilder = new Field.Builder();
|
||||||
fieldBuilder.setValue(AutofillValue.forText(value));
|
fieldBuilder.setValue(AutofillValue.forText(value));
|
||||||
|
// Dropdown presentation
|
||||||
final Presentations.Builder fieldPresentationsBuilder =
|
final Presentations.Builder fieldPresentationsBuilder =
|
||||||
new Presentations.Builder();
|
new Presentations.Builder();
|
||||||
fieldPresentationsBuilder.setMenuPresentation(presentation);
|
fieldPresentationsBuilder.setMenuPresentation(presentation);
|
||||||
|
// Inline presentation
|
||||||
if (inlineRequest.isPresent()) {
|
if (inlineRequest.isPresent()) {
|
||||||
final InlinePresentation inlinePresentation =
|
final InlinePresentation inlinePresentation =
|
||||||
InlineRequestHelper.createInlineDataset(context, inlineRequest.get(),
|
InlineRequestHelper.createInlineDataset(context, inlineRequest.get(),
|
||||||
displayValue, index);
|
displayValue, index);
|
||||||
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
||||||
}
|
}
|
||||||
|
// Dialog presentation
|
||||||
|
RemoteViews dialogPresentation =
|
||||||
|
newDatasetPresentation(packageName, "Dialog Presentation " + (index + 1));
|
||||||
|
fieldPresentationsBuilder.setDialogPresentation(dialogPresentation);
|
||||||
|
|
||||||
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
||||||
lockedDataset.setField(id, fieldBuilder.build());
|
lockedDataset.setField(id, fieldBuilder.build());
|
||||||
lockedDataset.setId(null).setAuthentication(authentication);
|
lockedDataset.setId(null).setAuthentication(authentication);
|
||||||
|
|||||||
Reference in New Issue
Block a user