From 915a1a5cfacfcd4aa03c1f486c11864e951025d3 Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Tue, 9 May 2017 12:28:45 -0700 Subject: Update autofill test apps Change-Id: Ib9b5ffa56a0ee7ca0f662a687b5db460e7378249 --- FillService/res/layout/pathology.xml | 33 +++++++++++++++++++++++++++ FillService/src/foo/bar/fill/FillService.java | 27 +++++++++++----------- 2 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 FillService/res/layout/pathology.xml diff --git a/FillService/res/layout/pathology.xml b/FillService/res/layout/pathology.xml new file mode 100644 index 0000000..6ec9bfd --- /dev/null +++ b/FillService/res/layout/pathology.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/FillService/src/foo/bar/fill/FillService.java b/FillService/src/foo/bar/fill/FillService.java index 7666ed8..c253e7c 100644 --- a/FillService/src/foo/bar/fill/FillService.java +++ b/FillService/src/foo/bar/fill/FillService.java @@ -43,7 +43,7 @@ import java.util.function.Predicate; import foo.bar.fill.R; public class FillService extends AutofillService { - static final boolean TEST_RESPONSE_AUTH = true; + static final boolean TEST_RESPONSE_AUTH = false; public static final String RESPONSE_ID = "RESPONSE_ID"; @@ -74,7 +74,7 @@ public class FillService extends AutofillService { public void onFillRequest(@NonNull FillRequest request, @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback) { - AssistStructure structure = request.getStructure(); + AssistStructure structure = request.getFillContexts().get(0).getStructure(); ViewNode username = findUsername(structure); ViewNode password = findPassword(structure); @@ -89,20 +89,21 @@ public class FillService extends AutofillService { PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT) .getIntentSender(); - RemoteViews presentation = new RemoteViews(getPackageName(), R.layout.list_item); + RemoteViews presentation = new RemoteViews(getPackageName(), R.layout.pathology); - presentation.setTextViewText(R.id.text1, "First"); - Intent firstIntent = new Intent(this, FirstActivity.class); - presentation.setOnClickPendingIntent(R.id.text1, PendingIntent.getActivity( - this, 0, firstIntent, PendingIntent.FLAG_CANCEL_CURRENT)); +// presentation.setTextViewText(R.id.text1, "First"); +// Intent firstIntent = new Intent(this, FirstActivity.class); +// presentation.setOnClickPendingIntent(R.id.text1, PendingIntent.getActivity( +// this, 0, firstIntent, PendingIntent.FLAG_CANCEL_CURRENT)); - presentation.setTextViewText(R.id.text2, "Second"); - Intent secondIntent = new Intent(this, SecondActivity.class); - presentation.setOnClickPendingIntent(R.id.text2, PendingIntent.getActivity( - this, 0, secondIntent, PendingIntent.FLAG_CANCEL_CURRENT)); +// presentation.setTextViewText(R.id.text2, "Second"); +// Intent secondIntent = new Intent(this, SecondActivity.class); +// presentation.setOnClickPendingIntent(R.id.text2, PendingIntent.getActivity( +// this, 0, secondIntent, PendingIntent.FLAG_CANCEL_CURRENT)); response = new FillResponse.Builder() - .setAuthentication(sender, presentation) + .setAuthentication(new AutofillId[]{username.getAutofillId(), + password.getAutofillId()}, sender, presentation) .build(); } else { Intent intent = new Intent(this, AuthActivity.class); @@ -124,7 +125,7 @@ public class FillService extends AutofillService { presentation4.setTextViewText(R.id.text1, DATASET4_NAME); RemoteViews presentation5 = new RemoteViews(getPackageName(), R.layout.list_item); - presentation5.setTextViewText(R.id.text1, DATASET5_NAME); + presentation5.setTextViewText(R.id.text1, /*DATASET5_NAME*/ "Auth needed"); response = new FillResponse.Builder() .addDataset(new Dataset.Builder(presentation1) -- cgit v1.2.3