mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix entry extra field view
This commit is contained in:
@@ -85,12 +85,23 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
entryExpiresCheckBox = findViewById(R.id.entry_edit_expires_checkbox)
|
||||
entryExpiresTextView = findViewById(R.id.entry_edit_expires_text)
|
||||
entryNotesView = findViewById(R.id.entry_edit_notes)
|
||||
entryExtraFieldsContainer = findViewById(R.id.entry_edit_advanced_container)
|
||||
entryExtraFieldsContainer = findViewById(R.id.entry_edit_extra_fields_container)
|
||||
|
||||
entryExpiresCheckBox.setOnCheckedChangeListener { _, _ ->
|
||||
assignExpiresDateText()
|
||||
}
|
||||
|
||||
entryExtraFieldsContainer.setOnHierarchyChangeListener(object: OnHierarchyChangeListener {
|
||||
override fun onChildViewRemoved(parent: View?, child: View?) {}
|
||||
|
||||
override fun onChildViewAdded(parent: View?, child: View?) {
|
||||
parent?.let {
|
||||
if ((parent as ViewGroup).childCount == 1)
|
||||
parent.expand()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Retrieve the textColor to tint the icon
|
||||
val taIconColor = context.theme.obtainStyledAttributes(intArrayOf(android.R.attr.textColor))
|
||||
iconColor = taIconColor.getColor(0, Color.WHITE)
|
||||
@@ -235,23 +246,9 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
if (extraFieldView == null) {
|
||||
extraFieldView = EntryEditExtraField(context)
|
||||
extraFieldView.setFontVisibility(fontInVisibility)
|
||||
extraFieldView.setDeleteButtonClickListener(OnClickListener {
|
||||
try {
|
||||
extraFieldView.collapse(true) {
|
||||
entryExtraFieldsContainer.apply {
|
||||
removeView(this)
|
||||
invalidate()
|
||||
}
|
||||
extraFieldView.setDeleteButtonClickListener(null)
|
||||
}
|
||||
} catch (e: ClassCastException) {
|
||||
Log.e(javaClass.name, "Unable to delete view", e)
|
||||
}
|
||||
})
|
||||
// No need animation because of scroll
|
||||
entryExtraFieldsContainer.apply {
|
||||
addView(extraFieldView)
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
extraFieldView.customField = customField
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import android.widget.RelativeLayout
|
||||
@@ -72,10 +73,13 @@ class EntryEditExtraField @JvmOverloads constructor(context: Context,
|
||||
deleteButton = findViewById(R.id.entry_extra_field_delete)
|
||||
|
||||
mValueViewInputType = valueView.inputType
|
||||
}
|
||||
|
||||
fun setDeleteButtonClickListener(listener: OnClickListener?) {
|
||||
deleteButton.setOnClickListener(listener)
|
||||
deleteButton.setOnClickListener {
|
||||
collapse(true) {
|
||||
(parent as ViewGroup?)?.apply {
|
||||
removeView(this@EntryEditExtraField)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/entry_edit_extra_fields_container_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/card_view_margin_bottom"
|
||||
@@ -208,7 +209,7 @@
|
||||
android:layout_marginRight="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/entry_edit_container">
|
||||
<LinearLayout
|
||||
android:id="@+id/entry_edit_advanced_container"
|
||||
android:id="@+id/entry_edit_extra_fields_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
@@ -216,4 +217,5 @@
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user