Sample AF app: Return static icon in the InlineFillService
Test: manual Bug: 147394280 Change-Id: I311a3aac05f874c42e400eea2ee343ae0eb01da5
This commit is contained in:
BIN
samples/InlineFillService/res/drawable/ic_settings.png
Normal file
BIN
samples/InlineFillService/res/drawable/ic_settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 869 B |
@@ -35,6 +35,7 @@ import android.service.autofill.SaveInfo;
|
|||||||
import android.service.autofill.SaveRequest;
|
import android.service.autofill.SaveRequest;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Size;
|
||||||
import android.view.autofill.AutofillId;
|
import android.view.autofill.AutofillId;
|
||||||
import android.view.autofill.AutofillValue;
|
import android.view.autofill.AutofillValue;
|
||||||
import android.view.inline.InlinePresentationSpec;
|
import android.view.inline.InlinePresentationSpec;
|
||||||
@@ -104,6 +105,15 @@ public class InlineFillService extends AutofillService {
|
|||||||
response.addDataset(unlockedDataset);
|
response.addDataset(unlockedDataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(inlineRequest != null) {
|
||||||
|
// Reuse the first spec's height for the inline action size, as there isn't dedicated
|
||||||
|
// value from the request for this.
|
||||||
|
final int height = inlineRequest.getPresentationSpecs().get(0).getMinSize().getHeight();
|
||||||
|
final Size actionIconSize = new Size(height, height);
|
||||||
|
response.addInlineAction(
|
||||||
|
newInlineAction(context, actionIconSize, R.drawable.ic_settings));
|
||||||
|
}
|
||||||
|
|
||||||
// 2.Add save info
|
// 2.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()];
|
||||||
@@ -116,6 +126,18 @@ public class InlineFillService extends AutofillService {
|
|||||||
return response.build();
|
return response.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static InlinePresentation newInlineAction(@NonNull Context context,
|
||||||
|
@NonNull Size size, int drawable) {
|
||||||
|
final Slice suggestionSlice = new Slice.Builder(Uri.parse("inline.slice"),
|
||||||
|
new SliceSpec("InlinePresentation", 1))
|
||||||
|
.addIcon(Icon.createWithResource(context, drawable), null,
|
||||||
|
Collections.singletonList(""))
|
||||||
|
.build();
|
||||||
|
final InlinePresentationSpec currentSpec = new InlinePresentationSpec.Builder(size,
|
||||||
|
size).build();
|
||||||
|
return new InlinePresentation(suggestionSlice, currentSpec, /** pined= */ true);
|
||||||
|
}
|
||||||
|
|
||||||
static Dataset newUnlockedDataset(@NonNull Context context,
|
static Dataset newUnlockedDataset(@NonNull Context context,
|
||||||
@NonNull Map<String, AutofillId> fields, @NonNull String packageName, int i,
|
@NonNull Map<String, AutofillId> fields, @NonNull String packageName, int i,
|
||||||
@Nullable InlineSuggestionsRequest inlineRequest) {
|
@Nullable InlineSuggestionsRequest inlineRequest) {
|
||||||
|
|||||||
Reference in New Issue
Block a user