From f5a736755a151be6753a2f939c493a7f9ad5bf06 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 4 Nov 2026 11:22:03 +0100 Subject: feat(app): add the autofill picker's row model autofillRows turns the picker's search results into list rows: the origin identifier, the part that must match the site or app, becomes the row's name, and the account part and the folders above it the subtitle, as the old picker's bold title and subtitle showed them. Co-Authored-By: Claude Opus 5.5 --- .../app/passwordstore/ui/autofill/AutofillModel.kt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/src/main/java/app/passwordstore/ui/autofill/AutofillModel.kt (limited to 'app/src/main/java') diff --git a/app/src/main/java/app/passwordstore/ui/autofill/AutofillModel.kt b/app/src/main/java/app/passwordstore/ui/autofill/AutofillModel.kt new file mode 100644 index 00000000..44030d73 --- /dev/null +++ b/app/src/main/java/app/passwordstore/ui/autofill/AutofillModel.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2026 Danilo M. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package app.passwordstore.ui.autofill + +import app.passwordstore.ui.list.ListRow +import app.passwordstore.util.settings.DirectoryStructure +import java.io.File +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toImmutableList + +/** + * The autofill picker's rows for [files] (entries under [root], already ranked), in their order. + * The name is the origin identifier per [structure], the part that must match the site or app, so + * it stands out as the old picker's bold part did; the subtitle holds the account part and the + * folders above the identifier. Without an identifier the account part is the name. + */ +fun autofillRows( + files: List, + root: File, + structure: DirectoryStructure, +): ImmutableList = + files + .map { file -> + val relative = file.relativeTo(root) + val identifier = structure.getIdentifierFor(relative) + val account = structure.getAccountPartFor(relative) + val subtitle = + if (identifier == null) null + else + listOfNotNull(account, structure.getPathToIdentifierFor(relative)) + .joinToString(" ยท ") + .ifEmpty { null } + ListRow(file.absolutePath, identifier ?: account.orEmpty(), subtitle, 0) + } + .toImmutableList() -- cgit v1.2.3