mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: color selection
This commit is contained in:
@@ -90,6 +90,8 @@ class NodesAdapter (
|
||||
private var mNodeClickCallback: NodeClickCallback? = null
|
||||
private var mClipboardHelper = ClipboardHelper(context)
|
||||
|
||||
@ColorInt
|
||||
private val mColorSurfaceContainer: Int
|
||||
@ColorInt
|
||||
private val mTextColorPrimary: Int
|
||||
@ColorInt
|
||||
@@ -116,6 +118,9 @@ class NodesAdapter (
|
||||
this.mNodeSortedListCallback = NodeSortedListCallback()
|
||||
this.mNodeSortedList = SortedList(Node::class.java, mNodeSortedListCallback)
|
||||
|
||||
val taColorSurfaceContainer = context.theme.obtainStyledAttributes(intArrayOf(R.attr.colorSurfaceContainer))
|
||||
this.mColorSurfaceContainer = taColorSurfaceContainer.getColor(0, Color.BLACK)
|
||||
taColorSurfaceContainer.recycle()
|
||||
// Retrieve the color to tint the icon
|
||||
val taTextColorPrimary = context.theme.obtainStyledAttributes(intArrayOf(android.R.attr.textColorPrimary))
|
||||
this.mTextColorPrimary = taTextColorPrimary.getColor(0, Color.BLACK)
|
||||
@@ -430,16 +435,8 @@ class NodesAdapter (
|
||||
if (entry.containsAttachment()) View.VISIBLE else View.GONE
|
||||
|
||||
// Assign colors
|
||||
ViewCompat.setBackgroundTintList(
|
||||
holder.container,
|
||||
ColorStateList.valueOf(
|
||||
if (!holder.container.isSelected) {
|
||||
(if (mShowEntryColors) entry.backgroundColor else null) ?: Color.TRANSPARENT
|
||||
} else {
|
||||
mColorSecondary
|
||||
}
|
||||
)
|
||||
)
|
||||
assignBackgroundColor(holder.container, entry)
|
||||
assignBackgroundColor(holder.otpContainer, entry)
|
||||
val foregroundColor = if (mShowEntryColors) entry.foregroundColor else null
|
||||
if (!holder.container.isSelected) {
|
||||
if (foregroundColor != null) {
|
||||
@@ -539,6 +536,22 @@ class NodesAdapter (
|
||||
}
|
||||
}
|
||||
|
||||
private fun assignBackgroundColor(view: View?, entry: Entry) {
|
||||
view?.let {
|
||||
ViewCompat.setBackgroundTintList(
|
||||
view,
|
||||
ColorStateList.valueOf(
|
||||
if (!view.isSelected) {
|
||||
(if (mShowEntryColors) entry.backgroundColor else null)
|
||||
?: mColorSurfaceContainer
|
||||
} else {
|
||||
mColorSecondary
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class OtpRunnable(val view: View?): Runnable {
|
||||
|
||||
var action: (() -> Unit)? = null
|
||||
|
||||
@@ -131,9 +131,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:background="@drawable/background_item_selection"
|
||||
android:orientation="horizontal"
|
||||
android:padding="4dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:paddingVertical="4dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/node_attachment_icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
Reference in New Issue
Block a user