mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-04 15:52:34 -08:00
fix: color selection
This commit is contained in:
1 parent
d47a12c3d9
commit
5bbf436e4e
2 files changed
+29
-12
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user