Auto populate Title and Username from OTP Auth

This commit is contained in:
J-Jamet
2020-11-12 15:08:27 +01:00
parent c57515fed5
commit 22a3541b7b
2 changed files with 6 additions and 1 deletions

View File

@@ -129,6 +129,11 @@ class EntryInfo : Parcelable {
searchInfo.otpString?.let { otpString ->
// Replace the OTP field
OtpEntryFields.parseOTPUri(otpString)?.let { otpElement ->
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)
if (mutableCustomFields.contains(otpField)) {

View File

@@ -73,7 +73,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
override fun getName(resources: Resources): String {
otpString?.let { otpString ->
OtpEntryFields.parseOTPUri(otpString)?.let { otpElement ->
return "${otpElement.type} (${Uri.decode(otpElement.issuer)} : ${Uri.decode(otpElement.name)})"
return "${otpElement.type} (${Uri.decode(otpElement.issuer)}:${Uri.decode(otpElement.name)})"
}
}
return toString()