mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix node selection color
This commit is contained in:
@@ -27,6 +27,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.SortedList
|
||||
import androidx.recyclerview.widget.SortedListAdapterCallback
|
||||
@@ -73,7 +74,11 @@ class NodeAdapter (private val context: Context)
|
||||
|
||||
private val mDatabase: Database
|
||||
|
||||
@ColorInt
|
||||
private val contentSelectionColor: Int
|
||||
@ColorInt
|
||||
private val iconGroupColor: Int
|
||||
@ColorInt
|
||||
private val iconEntryColor: Int
|
||||
|
||||
/**
|
||||
@@ -97,6 +102,10 @@ class NodeAdapter (private val context: Context)
|
||||
// Database
|
||||
this.mDatabase = Database.getInstance()
|
||||
|
||||
// Color of content selection
|
||||
val taContentSelectionColor = context.theme.obtainStyledAttributes(intArrayOf(R.attr.textColorInverse))
|
||||
this.contentSelectionColor = taContentSelectionColor.getColor(0, Color.WHITE)
|
||||
taContentSelectionColor.recycle()
|
||||
// Retrieve the color to tint the icon
|
||||
val taTextColorPrimary = context.theme.obtainStyledAttributes(intArrayOf(android.R.attr.textColorPrimary))
|
||||
this.iconGroupColor = taTextColorPrimary.getColor(0, Color.BLACK)
|
||||
@@ -280,11 +289,18 @@ class NodeAdapter (private val context: Context)
|
||||
|
||||
override fun onBindViewHolder(holder: NodeViewHolder, position: Int) {
|
||||
val subNode = nodeSortedList.get(position)
|
||||
|
||||
// Node selection
|
||||
holder.container.isSelected = actionNodesList.contains(subNode)
|
||||
|
||||
// Assign image
|
||||
val iconColor = when (subNode.type) {
|
||||
val iconColor = if (holder.container.isSelected)
|
||||
contentSelectionColor
|
||||
else when (subNode.type) {
|
||||
Type.GROUP -> iconGroupColor
|
||||
Type.ENTRY -> iconEntryColor
|
||||
}
|
||||
holder.imageIdentifier?.setColorFilter(iconColor)
|
||||
holder.icon.apply {
|
||||
assignDatabaseIcon(mDatabase.drawFactory, subNode.icon, iconColor)
|
||||
// Relative size of the icon
|
||||
@@ -347,8 +363,6 @@ class NodeAdapter (private val context: Context)
|
||||
holder.container.setOnLongClickListener {
|
||||
nodeClickCallback?.onNodeLongClick(subNode) ?: false
|
||||
}
|
||||
|
||||
holder.container.isSelected = actionNodesList.contains(subNode)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
@@ -372,6 +386,7 @@ class NodeAdapter (private val context: Context)
|
||||
|
||||
class NodeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var container: View = itemView.findViewById(R.id.node_container)
|
||||
var imageIdentifier: ImageView? = itemView.findViewById(R.id.node_image_identifier)
|
||||
var icon: ImageView = itemView.findViewById(R.id.node_icon)
|
||||
var text: TextView = itemView.findViewById(R.id.node_text)
|
||||
var subText: TextView = itemView.findViewById(R.id.node_subtext)
|
||||
|
||||
5
app/src/main/res/color/entry_subtitle_color.xml
Normal file
5
app/src/main/res/color/entry_subtitle_color.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_selected="true" android:color="@color/colorTextInverse"/>
|
||||
<item android:color="?android:attr/textColorSecondary"/>
|
||||
</selector>
|
||||
5
app/src/main/res/color/entry_title_color.xml
Normal file
5
app/src/main/res/color/entry_title_color.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_selected="true" android:color="@color/colorTextInverse"/>
|
||||
<item android:color="?android:attr/textColor"/>
|
||||
</selector>
|
||||
5
app/src/main/res/color/group_subtitle_color.xml
Normal file
5
app/src/main/res/color/group_subtitle_color.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_selected="true" android:color="@color/colorTextInverse"/>
|
||||
<item android:color="?android:attr/textColorSecondary"/>
|
||||
</selector>
|
||||
5
app/src/main/res/color/group_title_color.xml
Normal file
5
app/src/main/res/color/group_title_color.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_selected="true" android:color="@color/colorTextInverse"/>
|
||||
<item android:color="?android:attr/textColorPrimary"/>
|
||||
</selector>
|
||||
@@ -67,7 +67,7 @@
|
||||
tools:text="Node Title"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
style="@style/KeepassDXStyle.TextAppearance.Default" /> <!-- style override -->
|
||||
style="@style/KeepassDXStyle.TextAppearance.Entry.Title" />
|
||||
<TextView
|
||||
android:id="@+id/node_subtext"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -76,7 +76,7 @@
|
||||
tools:text="Node SubTitle"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
style="@style/KeepassDXStyle.TextAppearance.Secondary" /> <!-- style override -->
|
||||
style="@style/KeepassDXStyle.TextAppearance.Entry.SubTitle" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -35,11 +35,10 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/group_arrow"
|
||||
android:id="@+id/node_image_identifier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_arrow_right_white_24dp"
|
||||
android:tint="?android:attr/textColorPrimary"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_centerVertical="true"
|
||||
@@ -58,8 +57,8 @@
|
||||
android:src="@drawable/ic_blank_32dp"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@+id/group_arrow"
|
||||
android:layout_toEndOf="@+id/group_arrow" />
|
||||
android:layout_toRightOf="@+id/node_image_identifier"
|
||||
android:layout_toEndOf="@+id/node_image_identifier" />
|
||||
<TextView
|
||||
android:id="@+id/node_child_numbers"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -90,7 +89,7 @@
|
||||
tools:text="Node Title"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
style="@style/KeepassDXStyle.TextAppearance.Title" /> <!-- style override -->
|
||||
style="@style/KeepassDXStyle.TextAppearance.Group.Title" />
|
||||
<TextView
|
||||
android:id="@+id/node_subtext"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -100,7 +99,7 @@
|
||||
android:layout_marginTop="-4dp"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
style="@style/KeepassDXStyle.TextAppearance.Secondary" /> <!-- style override -->
|
||||
style="@style/KeepassDXStyle.TextAppearance.Group.SubTitle" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -271,6 +271,26 @@
|
||||
<item name="backgroundTint">?attr/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<!-- Nodes Text Style -->
|
||||
<style name="KeepassDXStyle.TextAppearance.Entry.Title" parent="KeepassDXStyle.TextAppearance">
|
||||
<item name="android:textColor">@color/entry_title_color</item>
|
||||
<item name="android:tint">@color/entry_title_color</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.TextAppearance.Entry.SubTitle" parent="KeepassDXStyle.TextAppearance.Small">
|
||||
<item name="android:textColor">@color/entry_subtitle_color</item>
|
||||
<item name="android:tint">@color/entry_subtitle_color</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.TextAppearance.Group.Title" parent="KeepassDXStyle.TextAppearance">
|
||||
<item name="android:textColor">@color/group_title_color</item>
|
||||
<item name="android:tint">@color/group_title_color</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.TextAppearance.Group.SubTitle" parent="KeepassDXStyle.TextAppearance.Small">
|
||||
<item name="android:textColor">@color/group_subtitle_color</item>
|
||||
<item name="android:tint">@color/group_subtitle_color</item>
|
||||
</style>
|
||||
|
||||
<!-- Button Style -->
|
||||
<style name="KeepassDXStyle.v21.Button" parent="Base.TextAppearance.AppCompat.Button">
|
||||
<item name="android:gravity">center</item>
|
||||
|
||||
Reference in New Issue
Block a user