diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-04 11:22:03 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-04 11:22:03 +0100 |
| commit | f5a736755a151be6753a2f939c493a7f9ad5bf06 (patch) | |
| tree | 924944cc98e578cba5d12fa1ff77ac6f909e857c /app/src/main/java | |
| parent | d1266d1fbd4588c872bd6af30278b32c33e39eb9 (diff) | |
| download | HardenedPass-f5a736755a151be6753a2f939c493a7f9ad5bf06.tar.gz HardenedPass-f5a736755a151be6753a2f939c493a7f9ad5bf06.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'app/src/main/java')
| -rw-r--r-- | app/src/main/java/app/passwordstore/ui/autofill/AutofillModel.kt | 38 |
1 files changed, 38 insertions, 0 deletions
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. <danix@danix.xyz> + * 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<File>, + root: File, + structure: DirectoryStructure, +): ImmutableList<ListRow> = + 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() |
