diff --git a/CHANGELOG b/CHANGELOG index dc4939431..54f830cb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ KeePassDX(2.10.2) * Fix search fields references #987 + * Fix Auto-Types with same key #997 KeePassDX(2.10.1) * Fix parcelable with custom data #986 diff --git a/app/build.gradle b/app/build.gradle index c820d0f1b..e6e466b5d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { applicationId "com.kunzisoft.keepass" minSdkVersion 15 targetSdkVersion 30 - versionCode = 79 + versionCode = 80 versionName = "2.10.2" multiDexEnabled true diff --git a/app/src/main/java/com/kunzisoft/keepass/database/element/entry/AutoType.kt b/app/src/main/java/com/kunzisoft/keepass/database/element/entry/AutoType.kt index b4b2419a1..3c550db31 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/element/entry/AutoType.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/element/entry/AutoType.kt @@ -21,8 +21,6 @@ package com.kunzisoft.keepass.database.element.entry import android.os.Parcel import android.os.Parcelable - -import com.kunzisoft.keepass.utils.ParcelableUtil import com.kunzisoft.keepass.utils.UnsignedInt class AutoType : Parcelable { @@ -30,7 +28,7 @@ class AutoType : Parcelable { var enabled = true var obfuscationOptions = OBF_OPT_NONE var defaultSequence = "" - private var windowSeqPairs = LinkedHashMap() + private var windowSeqPairs = ArrayList() constructor() @@ -38,16 +36,15 @@ class AutoType : Parcelable { this.enabled = autoType.enabled this.obfuscationOptions = autoType.obfuscationOptions this.defaultSequence = autoType.defaultSequence - for ((key, value) in autoType.windowSeqPairs) { - this.windowSeqPairs[key] = value - } + this.windowSeqPairs.clear() + this.windowSeqPairs.addAll(autoType.windowSeqPairs) } constructor(parcel: Parcel) { this.enabled = parcel.readByte().toInt() != 0 this.obfuscationOptions = UnsignedInt(parcel.readInt()) this.defaultSequence = parcel.readString() ?: defaultSequence - this.windowSeqPairs = ParcelableUtil.readStringParcelableMap(parcel) + parcel.readTypedList(this.windowSeqPairs, AutoTypeItem.CREATOR) } override fun describeContents(): Int { @@ -58,15 +55,43 @@ class AutoType : Parcelable { dest.writeByte((if (enabled) 1 else 0).toByte()) dest.writeInt(obfuscationOptions.toKotlinInt()) dest.writeString(defaultSequence) - ParcelableUtil.writeStringParcelableMap(dest, windowSeqPairs) + dest.writeTypedList(windowSeqPairs) } - fun put(key: String, value: String) { - windowSeqPairs[key] = value + fun add(key: String, value: String) { + windowSeqPairs.add(AutoTypeItem(key, value)) } - fun entrySet(): Set> { - return windowSeqPairs.entries + fun doForEachAutoTypeItem(action: (key: String, value: String) -> Unit) { + windowSeqPairs.forEach { + action.invoke(it.key, it.value) + } + } + + private data class AutoTypeItem(var key: String, var value: String): Parcelable { + constructor(parcel: Parcel) : this( + parcel.readString() ?: "", + parcel.readString() ?: "") { + } + + override fun writeToParcel(parcel: Parcel, flags: Int) { + parcel.writeString(key) + parcel.writeString(value) + } + + override fun describeContents(): Int { + return 0 + } + + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): AutoTypeItem { + return AutoTypeItem(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } } companion object { diff --git a/app/src/main/java/com/kunzisoft/keepass/database/element/entry/EntryKDBX.kt b/app/src/main/java/com/kunzisoft/keepass/database/element/entry/EntryKDBX.kt index 03f76326a..b57eb458c 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/element/entry/EntryKDBX.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/element/entry/EntryKDBX.kt @@ -38,7 +38,6 @@ import com.kunzisoft.keepass.database.element.security.ProtectedString import com.kunzisoft.keepass.utils.ParcelableUtil import com.kunzisoft.keepass.utils.UnsignedLong import java.util.* -import java.util.function.BiConsumer import kotlin.collections.ArrayList import kotlin.collections.LinkedHashMap @@ -239,7 +238,7 @@ class EntryKDBX : EntryVersioned, NodeKDBXInte size += getAttachmentsSize(attachmentPool) size += autoType.defaultSequence.length.toLong() - for ((key, value) in autoType.entrySet()) { + autoType.doForEachAutoTypeItem { key, value -> size += key.length.toLong() size += value.length.toLong() } diff --git a/app/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInputKDBX.kt b/app/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInputKDBX.kt index 4287a32e7..2103fb149 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInputKDBX.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/file/input/DatabaseInputKDBX.kt @@ -824,7 +824,7 @@ class DatabaseInputKDBX(cacheDirectory: File, return KdbContext.Entry } else if (ctx == KdbContext.EntryAutoTypeItem && name.equals(DatabaseKDBXXML.ElemAutoTypeItem, ignoreCase = true)) { if (ctxATName != null && ctxATSeq != null) - ctxEntry?.autoType?.put(ctxATName!!, ctxATSeq!!) + ctxEntry?.autoType?.add(ctxATName!!, ctxATSeq!!) ctxATName = null ctxATSeq = null diff --git a/app/src/main/java/com/kunzisoft/keepass/database/file/output/DatabaseOutputKDBX.kt b/app/src/main/java/com/kunzisoft/keepass/database/file/output/DatabaseOutputKDBX.kt index 9294e9901..d844c1773 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/file/output/DatabaseOutputKDBX.kt +++ b/app/src/main/java/com/kunzisoft/keepass/database/file/output/DatabaseOutputKDBX.kt @@ -530,7 +530,7 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX, writeString(DatabaseKDBXXML.ElemAutoTypeDefaultSeq, autoType.defaultSequence, true) } - for ((key, value) in autoType.entrySet()) { + autoType.doForEachAutoTypeItem { key, value -> xml.startTag(null, DatabaseKDBXXML.ElemAutoTypeItem) xml.startTag(null, DatabaseKDBXXML.ElemWindow) diff --git a/fastlane/metadata/android/en-US/changelogs/79.txt b/fastlane/metadata/android/en-US/changelogs/79.txt deleted file mode 100644 index a089c677d..000000000 --- a/fastlane/metadata/android/en-US/changelogs/79.txt +++ /dev/null @@ -1 +0,0 @@ - * Fix search fields references #987 \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/80.txt b/fastlane/metadata/android/en-US/changelogs/80.txt new file mode 100644 index 000000000..aa027e772 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/80.txt @@ -0,0 +1,2 @@ + * Fix search fields references #987 + * Fix Auto-Types with same key #997 \ No newline at end of file diff --git a/fastlane/metadata/android/fr-FR/changelogs/79.txt b/fastlane/metadata/android/fr-FR/changelogs/79.txt deleted file mode 100644 index b92b52447..000000000 --- a/fastlane/metadata/android/fr-FR/changelogs/79.txt +++ /dev/null @@ -1 +0,0 @@ - * Correction de la recherche des références de champs #987 \ No newline at end of file diff --git a/fastlane/metadata/android/fr-FR/changelogs/80.txt b/fastlane/metadata/android/fr-FR/changelogs/80.txt new file mode 100644 index 000000000..193f200cd --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/80.txt @@ -0,0 +1,2 @@ + * Correction de la recherche des références de champs #987 + * Correction des Auto-Types avec la même clé #997 \ No newline at end of file