Merge "Update Autofill sample to use new API instead of deprecated APIs." into tm-dev am: 4cb200dfb1
Original change: https://googleplex-android-review.googlesource.com/c/platform/development/+/18058628 Change-Id: If33893fface88b57fd8554298977549909f8c7e2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import android.service.autofill.FillCallback;
|
|||||||
import android.service.autofill.FillRequest;
|
import android.service.autofill.FillRequest;
|
||||||
import android.service.autofill.FillResponse;
|
import android.service.autofill.FillResponse;
|
||||||
import android.service.autofill.InlinePresentation;
|
import android.service.autofill.InlinePresentation;
|
||||||
|
import android.service.autofill.Presentations;
|
||||||
import android.service.autofill.SaveCallback;
|
import android.service.autofill.SaveCallback;
|
||||||
import android.service.autofill.SaveInfo;
|
import android.service.autofill.SaveInfo;
|
||||||
import android.service.autofill.SaveRequest;
|
import android.service.autofill.SaveRequest;
|
||||||
@@ -95,14 +96,17 @@ public class InlineFillService extends AutofillService {
|
|||||||
InlinePresentation inlinePresentation =
|
InlinePresentation inlinePresentation =
|
||||||
InlineRequestHelper.maybeCreateInlineAuthenticationResponse(context,
|
InlineRequestHelper.maybeCreateInlineAuthenticationResponse(context,
|
||||||
inlineRequest);
|
inlineRequest);
|
||||||
|
final Presentations.Builder fieldPresentationsBuilder =
|
||||||
|
new Presentations.Builder();
|
||||||
|
fieldPresentationsBuilder.setMenuPresentation(presentation);
|
||||||
|
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
||||||
response = new FillResponse.Builder()
|
response = new FillResponse.Builder()
|
||||||
.setAuthentication(ids, authentication, presentation, inlinePresentation)
|
.setAuthentication(ids, authentication, fieldPresentationsBuilder.build())
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
response = createResponse(this, fields, maxSuggestionsCount, mAuthenticateDatasets,
|
response = createResponse(this, fields, maxSuggestionsCount, mAuthenticateDatasets,
|
||||||
inlineRequest);
|
inlineRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onSuccess(response);
|
callback.onSuccess(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import static com.example.android.inlinefillservice.InlineFillService.TAG;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.service.autofill.Dataset;
|
import android.service.autofill.Dataset;
|
||||||
|
import android.service.autofill.Field;
|
||||||
import android.service.autofill.InlinePresentation;
|
import android.service.autofill.InlinePresentation;
|
||||||
|
import android.service.autofill.Presentations;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.autofill.AutofillId;
|
import android.view.autofill.AutofillId;
|
||||||
import android.view.autofill.AutofillValue;
|
import android.view.autofill.AutofillValue;
|
||||||
@@ -51,21 +53,24 @@ class ResponseHelper {
|
|||||||
Log.d(TAG, "hint: " + hint);
|
Log.d(TAG, "hint: " + hint);
|
||||||
final String displayValue = hint.contains("password") ? "password for #" + (index + 1)
|
final String displayValue = hint.contains("password") ? "password for #" + (index + 1)
|
||||||
: value;
|
: value;
|
||||||
final RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
|
||||||
|
|
||||||
// Add Inline Suggestion required info.
|
// Add Inline Suggestion required info.
|
||||||
|
Field.Builder fieldBuilder = new Field.Builder();
|
||||||
|
fieldBuilder.setValue(AutofillValue.forText(value));
|
||||||
|
// Set presentation
|
||||||
|
final Presentations.Builder fieldPresentationsBuilder =
|
||||||
|
new Presentations.Builder();
|
||||||
|
final RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
||||||
|
fieldPresentationsBuilder.setMenuPresentation(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 =
|
||||||
InlineRequestHelper.createInlineDataset(context, inlineRequest.get(),
|
InlineRequestHelper.createInlineDataset(context, inlineRequest.get(),
|
||||||
displayValue, index);
|
displayValue, index);
|
||||||
dataset.setValue(id, AutofillValue.forText(value), presentation,
|
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
||||||
inlinePresentation);
|
|
||||||
} else {
|
|
||||||
dataset.setValue(id, AutofillValue.forText(value), presentation);
|
|
||||||
}
|
}
|
||||||
|
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
||||||
|
dataset.setField(id, fieldBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataset.build();
|
return dataset.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,16 +89,21 @@ class ResponseHelper {
|
|||||||
IntentSender authentication =
|
IntentSender authentication =
|
||||||
AuthActivity.newIntentSenderForDataset(context, unlockedDataset);
|
AuthActivity.newIntentSenderForDataset(context, unlockedDataset);
|
||||||
RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
RemoteViews presentation = newDatasetPresentation(packageName, displayValue);
|
||||||
|
|
||||||
|
Field.Builder fieldBuilder = new Field.Builder();
|
||||||
|
fieldBuilder.setValue(AutofillValue.forText(value));
|
||||||
|
final Presentations.Builder fieldPresentationsBuilder =
|
||||||
|
new Presentations.Builder();
|
||||||
|
fieldPresentationsBuilder.setMenuPresentation(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);
|
||||||
lockedDataset.setValue(id, null, presentation, inlinePresentation)
|
fieldPresentationsBuilder.setInlinePresentation(inlinePresentation);
|
||||||
.setAuthentication(authentication);
|
|
||||||
} else {
|
|
||||||
lockedDataset.setValue(id, null, presentation)
|
|
||||||
.setAuthentication(authentication);
|
|
||||||
}
|
}
|
||||||
|
fieldBuilder.setPresentations(fieldPresentationsBuilder.build());
|
||||||
|
lockedDataset.setField(id, fieldBuilder.build());
|
||||||
|
lockedDataset.setId(null).setAuthentication(authentication);
|
||||||
}
|
}
|
||||||
return lockedDataset.build();
|
return lockedDataset.build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user