use of org.sorz.lab.tinykeepass.search.SearchIndex in project TinyKeePass by sorz.
the class AuthActivity method onDatabaseOpened.
@Override
protected void onDatabaseOpened() {
StructureParser.Result result = parseStructure();
KeePassFile keePass = KeePassStorage.get(this);
SearchIndex index = new SearchIndex(keePass);
StringBuilder queryBuilder = new StringBuilder();
result.title.forEach(title -> queryBuilder.append(title).append(' '));
Stream<Entry> entryStream = index.search(queryBuilder.toString()).map(keePass::getEntryByUUID);
FillResponse.Builder responseBuilder = new FillResponse.Builder();
// add matched entities
entryStream.map(entry -> AutofillUtils.buildDataset(this, entry, result)).filter(Objects::nonNull).limit(MAX_NUM_CANDIDATE_ENTRIES).forEach(responseBuilder::addDataset);
// add "show all" item
RemoteViews presentation = AutofillUtils.getRemoteViews(this, getString(R.string.autofill_item_show_all), R.drawable.ic_more_horiz_gray_24dp);
presentation.setTextColor(R.id.textView, getColor(R.color.hint));
Dataset.Builder datasetBuilder = new Dataset.Builder(presentation).setAuthentication(EntrySelectActivity.getAuthIntentSenderForResponse(this));
result.allAutofillIds().forEach(id -> datasetBuilder.setValue(id, null));
responseBuilder.addDataset(datasetBuilder.build());
setFillResponse(responseBuilder.build());
finish();
}
Aggregations