Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Tweak android autofill item display preview (#904)

Leendert de Borst15a1276d420d
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/AutofillService.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/AutofillService.kt
index 07db467c9..362cf2a6f 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/AutofillService.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/AutofillService.kt
@@ -219,13 +219,21 @@ class AutofillService : AutofillService() {
field.first,
AutofillValue.forText(credential.alias.email),
)
- presentationDisplayValue = "${credential.service.name} (${credential.alias.email})"
+ if (credential.alias.email.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.alias.email})"
+ } else if (!credential.username.isNullOrEmpty()) {
+ presentationDisplayValue += " (${credential.username})"
+ }
} else if (credential.username != null) {
dataSetBuilder.setValue(
field.first,
AutofillValue.forText(credential.username),
)
- presentationDisplayValue = "${credential.service.name} (${credential.username})"
+ if (credential.username.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.username})"
+ } else if ((credential.alias?.email ?: "").isNotEmpty()) {
+ presentationDisplayValue += " (${credential.alias?.email})"
+ }
}
}
FieldType.USERNAME -> {
@@ -234,13 +242,19 @@ class AutofillService : AutofillService() {
field.first,
AutofillValue.forText(credential.username),
)
- presentationDisplayValue = "${credential.service.name} (${credential.username})"
+ if (credential.username.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.username})"
+ } else if ((credential.alias?.email ?: "").isNotEmpty()) {
+ presentationDisplayValue += " (${credential.alias?.email})"
+ }
} else if (credential.alias?.email != null) {
dataSetBuilder.setValue(
field.first,
AutofillValue.forText(credential.alias.email),
)
- presentationDisplayValue = "${credential.service.name} (${credential.alias.email})"
+ if (credential.alias.email.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.alias.email})"
+ }
}
}
else -> {
@@ -250,13 +264,17 @@ class AutofillService : AutofillService() {
field.first,
AutofillValue.forText(credential.alias.email),
)
- presentationDisplayValue = "${credential.service.name} (${credential.alias.email})"
+ if (credential.alias.email.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.alias.email})"
+ }
} else if (credential.username != null) {
dataSetBuilder.setValue(
field.first,
AutofillValue.forText(credential.username),
)
- presentationDisplayValue = "${credential.service.name} (${credential.username})"
+ if (credential.username.isNotEmpty()) {
+ presentationDisplayValue += " (${credential.username})"
+ }
}
}
}
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt
index 3e2cc04bc..8f8db925e 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt
@@ -21,7 +21,9 @@ object CredentialMatcher {
credentials: List<Credential>,
appInfo: String,
): List<Credential> {
- if (appInfo.isBlank()) return credentials
+ if (appInfo.isBlank()) {
+ return credentials
+ }
val input = appInfo.trim().lowercase()
val isUrlLike = input.contains('.') && !input.contains(' ')