use of android.view.autofill.AutofillValue in project TinyKeePass by sorz.
the class AutofillUtils method buildDataset.
@Nullable
static Dataset buildDataset(Context context, Entry entry, StructureParser.Result struct) {
String title = makeEntryTitle(context, entry);
RemoteViews views = getRemoteViews(context, title, R.drawable.ic_person_blue_24dp);
views.setImageViewBitmap(R.id.imageIcon, getIcon(entry));
Dataset.Builder builder = new Dataset.Builder(views);
builder.setId(entry.getUuid().toString());
if (notEmpty(entry.getPassword())) {
AutofillValue value = AutofillValue.forText(entry.getPassword());
struct.password.forEach(id -> builder.setValue(id, value));
}
if (notEmpty(entry.getUsername())) {
AutofillValue value = AutofillValue.forText(entry.getUsername());
Stream<AutofillId> ids = struct.username.stream();
if (entry.getUsername().contains("@") || struct.username.isEmpty())
ids = Stream.concat(ids, struct.email.stream());
ids.forEach(id -> builder.setValue(id, value));
}
try {
return builder.build();
} catch (IllegalArgumentException e) {
// if not value be set
return null;
}
}
Aggregations