From 5133cb5c8fc2a2873a5c6cee7f0718c86b49a7e2 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Sun, 13 Feb 2022 15:52:30 +0100 Subject: [PATCH] Fix auto type --- .../java/com/kunzisoft/keepass/database/element/Entry.kt | 9 +++++++++ .../main/java/com/kunzisoft/keepass/model/EntryInfo.kt | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/app/src/main/java/com/kunzisoft/keepass/database/element/Entry.kt b/app/src/main/java/com/kunzisoft/keepass/database/element/Entry.kt index d6d6c0827..d7c6d9211 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/element/Entry.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/element/Entry.kt @@ -26,6 +26,7 @@ import com.kunzisoft.androidclearchroma.ChromaUtil import com.kunzisoft.keepass.database.element.binary.AttachmentPool import com.kunzisoft.keepass.database.element.database.DatabaseKDBX import com.kunzisoft.keepass.database.element.database.DatabaseVersioned +import com.kunzisoft.keepass.database.element.entry.AutoType import com.kunzisoft.keepass.database.element.entry.EntryKDB import com.kunzisoft.keepass.database.element.entry.EntryKDBX import com.kunzisoft.keepass.database.element.entry.EntryVersionedInterface @@ -282,6 +283,12 @@ class Entry : Node, EntryVersionedInterface { entryKDBX?.customData = value } + var autoType: AutoType + get() = entryKDBX?.autoType ?: AutoType() + set(value) { + entryKDBX?.autoType = value + } + private fun isTan(): Boolean { return title == PMS_TAN_ENTRY && username.isNotEmpty() } @@ -467,6 +474,7 @@ class Entry : Node, EntryVersionedInterface { entryInfo.backgroundColor = backgroundColor entryInfo.foregroundColor = foregroundColor entryInfo.customData = customData + entryInfo.autoType = autoType entryInfo.customFields = getExtraFields().toMutableList() // Add otpElement to generate token entryInfo.otpModel = getOtpElement()?.otpModel @@ -505,6 +513,7 @@ class Entry : Node, EntryVersionedInterface { backgroundColor = newEntryInfo.backgroundColor foregroundColor = newEntryInfo.foregroundColor customData = newEntryInfo.customData + autoType = newEntryInfo.autoType addExtraFields(newEntryInfo.customFields) database?.attachmentPool?.let { binaryPool -> newEntryInfo.attachments.forEach { attachment -> diff --git a/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt b/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt index 12d1b4b0a..8a7fb3e11 100644 --- a/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt +++ b/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt @@ -23,6 +23,7 @@ import android.os.Parcel import android.os.ParcelUuid import android.os.Parcelable import com.kunzisoft.keepass.database.element.* +import com.kunzisoft.keepass.database.element.entry.AutoType import com.kunzisoft.keepass.database.element.security.ProtectedString import com.kunzisoft.keepass.database.element.template.TemplateField import com.kunzisoft.keepass.otp.OtpElement @@ -42,6 +43,7 @@ class EntryInfo : NodeInfo { var foregroundColor: Int? = null var customFields: MutableList = mutableListOf() var attachments: MutableList = mutableListOf() + var autoType: AutoType = AutoType() var otpModel: OtpModel? = null var isTemplate: Boolean = false @@ -60,6 +62,7 @@ class EntryInfo : NodeInfo { foregroundColor = if (readFgColor == -1) null else readFgColor parcel.readList(customFields, Field::class.java.classLoader) parcel.readList(attachments, Attachment::class.java.classLoader) + autoType = parcel.readParcelable(AutoType::class.java.classLoader) ?: autoType otpModel = parcel.readParcelable(OtpModel::class.java.classLoader) ?: otpModel isTemplate = parcel.readByte().toInt() != 0 } @@ -80,6 +83,7 @@ class EntryInfo : NodeInfo { parcel.writeInt(foregroundColor ?: -1) parcel.writeList(customFields) parcel.writeList(attachments) + parcel.writeParcelable(autoType, flags) parcel.writeParcelable(otpModel, flags) parcel.writeByte((if (isTemplate) 1 else 0).toByte()) } @@ -209,6 +213,7 @@ class EntryInfo : NodeInfo { if (foregroundColor != other.foregroundColor) return false if (customFields != other.customFields) return false if (attachments != other.attachments) return false + if (autoType != other.autoType) return false if (otpModel != other.otpModel) return false if (isTemplate != other.isTemplate) return false @@ -227,6 +232,7 @@ class EntryInfo : NodeInfo { result = 31 * result + foregroundColor.hashCode() result = 31 * result + customFields.hashCode() result = 31 * result + attachments.hashCode() + result = 31 * result + autoType.hashCode() result = 31 * result + (otpModel?.hashCode() ?: 0) result = 31 * result + isTemplate.hashCode() return result