Fix renaming custom field #709

This commit is contained in:
J-Jamet
2020-09-21 11:31:14 +02:00
parent 35b7633f4d
commit 8de49fa027
5 changed files with 25 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
KeePassDX(2.9)
* Fix Autofill recognition
* Fix Autofill recognition #712
* Keep value after renaming custom field #709
KeePassDX(2.8.5)
* Fix Base 64 #708

View File

@@ -413,7 +413,7 @@ class EntryEditFragment: StylishFragment() {
}
/**
* Update an extra field or create a new one if doesn't exists
* Update an extra field or create a new one if doesn't exists, the old value is lost
*/
fun putExtraField(extraField: Field) {
extraFieldsContainerView.visibility = View.VISIBLE
@@ -434,13 +434,24 @@ class EntryEditFragment: StylishFragment() {
}
}
/**
* Update an extra field and keep the old value
*/
fun replaceExtraField(oldExtraField: Field, newExtraField: Field) {
extraFieldsContainerView.visibility = View.VISIBLE
val index = mExtraFieldsList.indexOf(oldExtraField)
val oldValueEditText: EditText = extraFieldsListView.getChildAt(index)
.findViewWithTag("FIELD_VALUE_TAG")
val oldValue = oldValueEditText.text.toString()
val newExtraFieldWithOldValue = Field(newExtraField).apply {
this.protectedValue.stringValue = oldValue
}
mExtraFieldsList.removeAt(index)
mExtraFieldsList.add(index, newExtraField)
mExtraFieldsList.add(index, newExtraFieldWithOldValue)
extraFieldsListView.removeViewAt(index)
extraFieldsListView.addView(buildViewFromField(newExtraField), index)
val newView = buildViewFromField(newExtraFieldWithOldValue)
extraFieldsListView.addView(newView, index)
newView?.requestFocus()
}
fun removeExtraField(oldExtraField: Field) {

View File

@@ -33,6 +33,11 @@ class Field : Parcelable {
this.protectedValue = value
}
constructor(fieldToCopy: Field) {
this.name = fieldToCopy.name
this.protectedValue = fieldToCopy.protectedValue
}
constructor(parcel: Parcel) {
this.name = parcel.readString() ?: name
this.protectedValue = parcel.readParcelable(ProtectedString::class.java.classLoader) ?: protectedValue

View File

@@ -1 +1,2 @@
* Fix Autofill recognition #709
* Fix Autofill recognition #712
* Keep value after renaming custom field #709

View File

@@ -1 +1,2 @@
* Correction de la reconnaissance de remplissage automatique #709
* Correction de la reconnaissance de remplissage automatique #712
* La valeur du champ customisé est gardée après son renommage #709