Sample app: Use authentication instead of inline actions
Test: manual Bug: 150499490 Change-Id: Ifc827cd1d633bf26a3450c392cc7da1211d02cfa
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="foo.bar.inline" >
|
package="foo.bar.inline" >
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
||||||
<application>
|
<application>
|
||||||
<service
|
<service
|
||||||
android:name=".InlineFillService"
|
android:name=".InlineFillService"
|
||||||
@@ -26,4 +25,3 @@
|
|||||||
android:exported="true"/>
|
android:exported="true"/>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import android.service.autofill.FillCallback;
|
|||||||
import android.service.autofill.FillContext;
|
import android.service.autofill.FillContext;
|
||||||
import android.service.autofill.FillRequest;
|
import android.service.autofill.FillRequest;
|
||||||
import android.service.autofill.FillResponse;
|
import android.service.autofill.FillResponse;
|
||||||
import android.service.autofill.InlineAction;
|
|
||||||
import android.service.autofill.InlinePresentation;
|
import android.service.autofill.InlinePresentation;
|
||||||
import android.service.autofill.SaveCallback;
|
import android.service.autofill.SaveCallback;
|
||||||
import android.service.autofill.SaveInfo;
|
import android.service.autofill.SaveInfo;
|
||||||
@@ -182,8 +181,9 @@ public class InlineFillService extends AutofillService {
|
|||||||
// value from the request for this.
|
// value from the request for this.
|
||||||
final int height = inlineRequest.getPresentationSpecs().get(0).getMinSize().getHeight();
|
final int height = inlineRequest.getPresentationSpecs().get(0).getMinSize().getHeight();
|
||||||
final Size actionIconSize = new Size(height, height);
|
final Size actionIconSize = new Size(height, height);
|
||||||
response.addInlineAction(
|
response.addDataset(
|
||||||
newInlineAction(context, actionIconSize, R.drawable.ic_settings));
|
newInlineActionDataset(context, actionIconSize, R.drawable.ic_settings,
|
||||||
|
fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.Add save info
|
// 2.Add save info
|
||||||
@@ -198,8 +198,8 @@ public class InlineFillService extends AutofillService {
|
|||||||
return response.build();
|
return response.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
static InlineAction newInlineAction(@NonNull Context context,
|
static Dataset newInlineActionDataset(@NonNull Context context,
|
||||||
@NonNull Size size, int drawable) {
|
@NonNull Size size, int drawable, ArrayMap<String, AutofillId> fields) {
|
||||||
Intent intent = new Intent().setComponent(
|
Intent intent = new Intent().setComponent(
|
||||||
new ComponentName(context.getPackageName(), SettingsActivity.class.getName()));
|
new ComponentName(context.getPackageName(), SettingsActivity.class.getName()));
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
|
||||||
@@ -209,9 +209,14 @@ public class InlineFillService extends AutofillService {
|
|||||||
.build();
|
.build();
|
||||||
final InlinePresentationSpec currentSpec = new InlinePresentationSpec.Builder(size,
|
final InlinePresentationSpec currentSpec = new InlinePresentationSpec.Builder(size,
|
||||||
size).build();
|
size).build();
|
||||||
return new InlineAction(
|
Dataset.Builder builder = new Dataset.Builder()
|
||||||
new InlinePresentation(suggestionSlice, currentSpec, /** pined= */true),
|
.setInlinePresentation(
|
||||||
pendingIntent.getIntentSender());
|
new InlinePresentation(suggestionSlice, currentSpec, /** pined= */true))
|
||||||
|
.setAuthentication(pendingIntent.getIntentSender());
|
||||||
|
for (AutofillId fieldId : fields.values()) {
|
||||||
|
builder.setValue(fieldId, null);
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Dataset newUnlockedDataset(@NonNull Context context,
|
static Dataset newUnlockedDataset(@NonNull Context context,
|
||||||
|
|||||||
Reference in New Issue
Block a user