feat: OTP tag #2122

This commit is contained in:
J-Jamet
2025-10-07 11:56:14 +02:00
parent 989e47ed12
commit 02c514272e
4 changed files with 6 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ object OtpEntryFields {
// Field from KeePassXC
private const val OTP_FIELD = "otp"
private const val OTP_TAG = "OTP"
// URL parameters (https://github.com/google/google-authenticator/wiki/Key-Uri-Format)
private const val OTP_SCHEME = "otpauth"
@@ -438,13 +439,14 @@ object OtpEntryFields {
fun EntryInfo.setOtp(otpString: String): Boolean {
// Replace the OTP field
parseOTPUri(otpString)?.let { otpElement ->
tags.put(OTP_TAG)
if (title.isEmpty())
title = otpElement.issuer
if (username.isEmpty())
username = otpElement.name
// Add OTP field
val mutableCustomFields = customFields as ArrayList<Field>
val otpField = OtpEntryFields.buildOtpField(otpElement, null, null)
val otpField = buildOtpField(otpElement, null, null)
if (mutableCustomFields.contains(otpField)) {
mutableCustomFields.remove(otpField)
}