Fix template after autofill search save

This commit is contained in:
J-Jamet
2021-08-02 18:36:42 +02:00
parent 8a2bd23c32
commit 96d2edb641
3 changed files with 24 additions and 21 deletions

View File

@@ -695,7 +695,10 @@ class GroupActivity : LockingActivity(),
private fun updateEntryWithSearchInfo(entry: Entry, searchInfo: SearchInfo) {
val newEntry = Entry(entry)
newEntry.setEntryInfo(mDatabase, newEntry.getEntryInfo(mDatabase, true).apply {
newEntry.setEntryInfo(mDatabase, newEntry.getEntryInfo(mDatabase,
raw = true,
removeTemplateConfiguration = false
).apply {
saveSearchInfo(mDatabase, searchInfo)
})
// In selection mode, it's forced read-only, so update not allowed

View File

@@ -397,10 +397,16 @@ class Entry : Node, EntryVersionedInterface<Group> {
* Retrieve generated entry info.
* If are not [raw] data, remove parameter fields and add auto generated elements in auto custom fields
*/
fun getEntryInfo(database: Database?, raw: Boolean = false): EntryInfo {
fun getEntryInfo(database: Database?,
raw: Boolean = false,
removeTemplateConfiguration: Boolean = true): EntryInfo {
val entryInfo = EntryInfo()
// Remove unwanted template fields
(database?.removeTemplateConfiguration(this) ?: this).apply {
val baseInfo = if (removeTemplateConfiguration)
database?.removeTemplateConfiguration(this) ?: this
else
this
baseInfo.apply {
if (raw)
database?.stopManageEntry(this)
else

View File

@@ -170,24 +170,18 @@ class EntryInfo : NodeInfo {
if (database?.allowEntryCustomFields() == true) {
val creditCard: CreditCard? = registerInfo.creditCard
creditCard?.let { cc ->
cc.cardholder?.let {
val v = ProtectedString(false, it)
addUniqueField(Field(TemplateField.LABEL_HOLDER, v))
}
cc.expiration?.let {
expires = true
expiryTime = DateInstant(cc.expiration.millis)
}
cc.number?.let {
val v = ProtectedString(false, it)
addUniqueField(Field(TemplateField.LABEL_NUMBER, v))
}
cc.cvv?.let {
val v = ProtectedString(true, it)
addUniqueField(Field(TemplateField.LABEL_CVV, v))
}
creditCard?.cardholder?.let {
addUniqueField(Field(TemplateField.LABEL_HOLDER, ProtectedString(false, it)))
}
creditCard?.expiration?.let {
expires = true
expiryTime = DateInstant(creditCard.expiration.millis)
}
creditCard?.number?.let {
addUniqueField(Field(TemplateField.LABEL_NUMBER, ProtectedString(false, it)))
}
creditCard?.cvv?.let {
addUniqueField(Field(TemplateField.LABEL_CVV, ProtectedString(true, it)))
}
}
}