mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 00:02:27 -08:00
New icon to create extra field and fix focus
This commit is contained in:
1 parent
0e5b7fbfa2
commit
2d2489443a
4 files changed
+30
-24
No files matched your search
@@ -297,9 +297,10 @@ class EntryEditActivity : LockingActivity(),
|
||||
if (expires)
|
||||
expiresDate = newEntry.expiryTime
|
||||
notes = newEntry.notes
|
||||
for ((key, value) in newEntry.customFields) {
|
||||
putCustomField(Field(key, value))
|
||||
}
|
||||
|
||||
assignExtraFields(newEntry.customFields.mapTo(ArrayList()) {
|
||||
Field(it.key, it.value)
|
||||
})
|
||||
assignAttachments(newEntry.getAttachments())
|
||||
onAttachmentDeleted { attachment, _ ->
|
||||
newEntry.removeAttachment(attachment)
|
||||
@@ -355,16 +356,16 @@ class EntryEditActivity : LockingActivity(),
|
||||
}
|
||||
|
||||
private fun scrollToView(view: View?) {
|
||||
view?.post {
|
||||
view?.postDelayed({
|
||||
view.requestFocus()
|
||||
scrollView?.post {
|
||||
scrollView?.smoothScrollTo(0, view.bottom)
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
override fun onNewCustomFieldApproved(label: String, protection: Boolean) {
|
||||
val customFieldView = entryEditContentsView?.putCustomField(
|
||||
val customFieldView = entryEditContentsView?.putExtraField(
|
||||
Field(label, ProtectedString(protection))
|
||||
)
|
||||
scrollToView(customFieldView)
|
||||
@@ -494,7 +495,7 @@ class EntryEditActivity : LockingActivity(),
|
||||
// Update the otp field with otpauth:// url
|
||||
val otpField = OtpEntryFields.buildOtpField(otpElement,
|
||||
mEntry?.title, mEntry?.username)
|
||||
val otpCustomView = entryEditContentsView?.putCustomField(otpField)
|
||||
val otpCustomView = entryEditContentsView?.putExtraField(otpField)
|
||||
scrollToView(otpCustomView)
|
||||
mEntry?.putExtraField(otpField.name, otpField.protectedValue)
|
||||
}
|
||||
|
||||
@@ -250,9 +250,22 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a custom field or create a new one if doesn't exists
|
||||
* Remove all children and add new views for each field
|
||||
*/
|
||||
fun putCustomField(customField: Field)
|
||||
fun assignExtraFields(fields: List<Field>) {
|
||||
entryExtraFieldsContainer.removeAllViews()
|
||||
fields.forEach { extraField ->
|
||||
entryExtraFieldsContainer.addView(EntryEditExtraField(context).apply {
|
||||
setFontVisibility(fontInVisibility)
|
||||
customField = extraField
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an extra field or create a new one if doesn't exists
|
||||
*/
|
||||
fun putExtraField(customField: Field)
|
||||
: EntryEditExtraField {
|
||||
var extraFieldView = getCustomFieldByLabel(customField.name)
|
||||
// Create new view if not exists
|
||||
@@ -260,9 +273,7 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
extraFieldView = EntryEditExtraField(context)
|
||||
extraFieldView.setFontVisibility(fontInVisibility)
|
||||
// No need animation because of scroll
|
||||
entryExtraFieldsContainer.apply {
|
||||
addView(extraFieldView)
|
||||
}
|
||||
entryExtraFieldsContainer.addView(extraFieldView)
|
||||
}
|
||||
extraFieldView.customField = customField
|
||||
return extraFieldView
|
||||
|
||||
Reference in new issue
Block a user