Fix field order by using LinkedHashMap #611

This commit is contained in:
J-Jamet
2020-08-08 13:34:28 +02:00
parent 99c488fc9e
commit e578f23ebe
4 changed files with 16 additions and 21 deletions

View File

@@ -310,10 +310,7 @@ class EntryActivity : LockingActivity() {
if (entry.allowCustomFields()) {
entryContentsView?.clearExtraFields()
for (element in entry.customFields.entries) {
val label = element.key
val value = element.value
for ((label, value) in entry.customFields) {
val allowCopyProtectedField = !value.isProtected || allowCopyPasswordAndProtectedFields
if (allowCopyProtectedField) {
entryContentsView?.addExtraField(label, value, allowCopyProtectedField, View.OnClickListener {

View File

@@ -25,14 +25,12 @@ import android.os.Parcelable
import com.kunzisoft.keepass.utils.ParcelableUtil
import com.kunzisoft.keepass.utils.UnsignedInt
import java.util.HashMap
class AutoType : Parcelable {
var enabled = true
var obfuscationOptions = OBF_OPT_NONE
var defaultSequence = ""
private var windowSeqPairs = HashMap<String, String>()
private var windowSeqPairs = LinkedHashMap<String, String>()
constructor()

View File

@@ -36,6 +36,7 @@ import com.kunzisoft.keepass.database.element.security.ProtectedString
import com.kunzisoft.keepass.utils.ParcelableUtil
import com.kunzisoft.keepass.utils.UnsignedLong
import java.util.*
import kotlin.collections.LinkedHashMap
class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInterface {
@@ -58,9 +59,9 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
super.icon = value
}
var iconCustom = IconImageCustom.UNKNOWN_ICON
private var customData = HashMap<String, String>()
var fields = HashMap<String, ProtectedString>()
var binaries = HashMap<String, BinaryAttachment>()
private var customData = LinkedHashMap<String, String>()
var fields = LinkedHashMap<String, ProtectedString>()
var binaries = LinkedHashMap<String, BinaryAttachment>()
var foregroundColor = ""
var backgroundColor = ""
var overrideURL = ""
@@ -260,13 +261,11 @@ class EntryKDBX : EntryVersioned<UUID, UUID, GroupKDBX, EntryKDBX>, NodeKDBXInte
|| key == STR_NOTES)
}
var customFields = HashMap<String, ProtectedString>()
var customFields = LinkedHashMap<String, ProtectedString>()
get() {
field.clear()
for (entry in fields.entries) {
val key = entry.key
val value = entry.value
if (!isStandardField(entry.key)) {
for ((key, value) in fields) {
if (!isStandardField(key)) {
field[key] = ProtectedString(value.isProtected, decodeRefKey(mDecodeRef, key))
}
}

View File

@@ -22,6 +22,7 @@ package com.kunzisoft.keepass.utils
import android.os.Parcel
import android.os.Parcelable
import java.util.*
import kotlin.collections.LinkedHashMap
object ParcelableUtil {
@@ -51,7 +52,7 @@ object ParcelableUtil {
// For writing map with string key to a Parcel
fun <V : Parcelable> writeStringParcelableMap(
parcel: Parcel, flags: Int, map: Map<String, V>) {
parcel: Parcel, flags: Int, map: LinkedHashMap<String, V>) {
parcel.writeInt(map.size)
for ((key, value) in map) {
parcel.writeString(key)
@@ -61,9 +62,9 @@ object ParcelableUtil {
// For reading map with string key from a Parcel
fun <V : Parcelable> readStringParcelableMap(
parcel: Parcel, vClass: Class<V>): HashMap<String, V> {
parcel: Parcel, vClass: Class<V>): LinkedHashMap<String, V> {
val size = parcel.readInt()
val map = HashMap<String, V>(size)
val map = LinkedHashMap<String, V>(size)
for (i in 0 until size) {
val key: String? = parcel.readString()
val value: V? = vClass.cast(parcel.readParcelable(vClass.classLoader))
@@ -75,7 +76,7 @@ object ParcelableUtil {
// For writing map with string key and string value to a Parcel
fun writeStringParcelableMap(dest: Parcel, map: Map<String, String>) {
fun writeStringParcelableMap(dest: Parcel, map: LinkedHashMap<String, String>) {
dest.writeInt(map.size)
for ((key, value) in map) {
dest.writeString(key)
@@ -84,9 +85,9 @@ object ParcelableUtil {
}
// For reading map with string key and string value from a Parcel
fun readStringParcelableMap(parcel: Parcel): HashMap<String, String> {
fun readStringParcelableMap(parcel: Parcel): LinkedHashMap<String, String> {
val size = parcel.readInt()
val map = HashMap<String, String>(size)
val map = LinkedHashMap<String, String>(size)
for (i in 0 until size) {
val key: String? = parcel.readString()
val value: String? = parcel.readString()