mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-26 20:06:37 -08:00
fix: Tags color
This commit is contained in:
9 files changed
+66
-75
No files matched your search
@@ -28,6 +28,7 @@ import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.kunzisoft.keepass.R
|
||||
@@ -80,35 +81,19 @@ class TagsAdapter(
|
||||
}
|
||||
when (globalViewType) {
|
||||
TagViewType.SMALL -> {
|
||||
// Tint text depending on selection
|
||||
holder.name.setTextColor(if (tagIsSelected) mColorOnSecondary else mColorSecondary)
|
||||
// Tint background depending on selection
|
||||
ViewCompat.setBackgroundTintList(
|
||||
holder.name,
|
||||
ColorStateList.valueOf(
|
||||
(if (tagIsSelected) mColorOnSecondary else mColorSecondary)
|
||||
)
|
||||
)
|
||||
val color = if (tagIsSelected) mColorOnSecondary else mColorSecondary
|
||||
// Tint depending on selection
|
||||
holder.name.setTextColor(color)
|
||||
ViewCompat.setBackgroundTintList(holder.name, ColorStateList.valueOf(color))
|
||||
}
|
||||
TagViewType.CHIP -> {
|
||||
holder.container?.let {
|
||||
ViewCompat.setBackgroundTintList(
|
||||
it,
|
||||
ColorStateList.valueOf(
|
||||
(if (tagIsSelected) mColorSecondary else mTextColor)
|
||||
)
|
||||
)
|
||||
}
|
||||
holder.check?.let { checkView ->
|
||||
checkView.visibility = if (tagIsSelected) View.VISIBLE else View.GONE
|
||||
ViewCompat.setBackgroundTintList(
|
||||
checkView,
|
||||
ColorStateList.valueOf(
|
||||
(if (tagIsSelected) mColorSecondary else mTextColor)
|
||||
)
|
||||
)
|
||||
}
|
||||
holder.name.setTextColor(if (tagIsSelected) mColorSecondary else mTextColor)
|
||||
val color = if (tagIsSelected) mColorSecondary else mTextColor
|
||||
ViewCompat.setBackgroundTintList(holder.name, ColorStateList.valueOf(color))
|
||||
holder.name.setTextColor(color)
|
||||
holder.name.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||
if (tagIsSelected) R.drawable.ic_check_white_14dp else 0, 0, 0, 0
|
||||
)
|
||||
TextViewCompat.setCompoundDrawableTintList(holder.name, ColorStateList.valueOf(color))
|
||||
}
|
||||
else -> {
|
||||
// No text color change in standard mode
|
||||
@@ -186,9 +171,6 @@ class TagsAdapter(
|
||||
}
|
||||
|
||||
class TagViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
var container: View? = itemView.findViewById(R.id.tag_container)
|
||||
var check: View? = itemView.findViewById(R.id.tag_check)
|
||||
var name: TextView = itemView.findViewById(R.id.tag_name)
|
||||
|
||||
fun bind(item: Tag, listener: OnItemClickListener?) {
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.kunzisoft.keepass.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.element.Tags
|
||||
import com.tokenautocomplete.CharacterTokenizer
|
||||
@@ -17,6 +21,8 @@ class TagsCompletionView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : TokenCompleteTextView<String>(context, attrs) {
|
||||
|
||||
@ColorInt
|
||||
private val mColorSecondary: Int
|
||||
private val layoutInflater = context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE)
|
||||
as? LayoutInflater?
|
||||
|
||||
@@ -24,6 +30,10 @@ class TagsCompletionView @JvmOverloads constructor(
|
||||
allowCollapse(false)
|
||||
setTokenizer(CharacterTokenizer(Tags.DELIMITERS, Tags.DELIMITER.toString()))
|
||||
setTokenClickStyle(TokenClickStyle.Delete)
|
||||
|
||||
context.obtainStyledAttributes(intArrayOf(R.attr.colorSecondary)).also { taColorSecondary ->
|
||||
this.mColorSecondary = taColorSecondary.getColor(0, Color.GRAY)
|
||||
}.recycle()
|
||||
}
|
||||
|
||||
override fun defaultObject(completionText: String): String {
|
||||
@@ -33,8 +43,9 @@ class TagsCompletionView @JvmOverloads constructor(
|
||||
override fun getViewForObject(obj: String): View? {
|
||||
val viewGroup = layoutInflater?.inflate(R.layout.item_tag_edit, parent as ViewGroup, false)
|
||||
as? ViewGroup?
|
||||
viewGroup?.findViewById<TextView>(R.id.tag_name)?.apply {
|
||||
viewGroup?.findViewById<AppCompatTextView>(R.id.tag_name)?.apply {
|
||||
text = obj
|
||||
ViewCompat.setBackgroundTintList(this, ColorStateList.valueOf(mColorSecondary))
|
||||
}
|
||||
return viewGroup
|
||||
}
|
||||
|
||||
@@ -1,5 +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/white"/>
|
||||
<item android:state_selected="true" android:color="?attr/colorOnSecondary"/>
|
||||
<item android:color="?android:attr/textColorSecondary"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
||||
@@ -17,17 +17,18 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="24dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/background_tag"
|
||||
android:backgroundTint="?attr/colorSecondary"
|
||||
app:backgroundTint="?attr/colorSecondary"
|
||||
tools:text="text"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="12sp"
|
||||
|
||||
@@ -17,39 +17,23 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/tag_container"
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="4dp"
|
||||
android:layout_marginVertical="4dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
app:drawableStartCompat="@drawable/ic_check_white_14dp"
|
||||
app:drawableTint="?attr/colorSecondary"
|
||||
android:drawablePadding="4dp"
|
||||
android:background="@drawable/background_tag"
|
||||
app:backgroundTint="?android:attr/textColor"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/tag_check"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/ic_check_white_24dp"
|
||||
app:tint="?attr/colorSecondary"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/menu_delete" />
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="?android:attr/textColor"
|
||||
android:minHeight="24dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="text"
|
||||
android:textSize="14sp"
|
||||
android:paddingHorizontal="4dp" />
|
||||
</LinearLayout>
|
||||
android:minHeight="24dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginHorizontal="4dp"
|
||||
android:layout_marginVertical="4dp"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="text"
|
||||
android:textSize="14sp" />
|
||||
@@ -17,24 +17,27 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="6dp"
|
||||
android:background="@drawable/background_tag"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:background="@drawable/background_tag"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="text"
|
||||
android:textSize="12sp"
|
||||
android:paddingHorizontal="4dp" />
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="22dp" />
|
||||
<ImageView
|
||||
android:id="@+id/tag_remove"
|
||||
android:layout_width="24dp"
|
||||
@@ -42,7 +45,6 @@
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/ic_close_white_24dp"
|
||||
app:tint="?attr/colorSecondary"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:contentDescription="@string/menu_delete" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
@@ -17,20 +17,21 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/tag_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/background_tag"
|
||||
android:backgroundTint="?attr/colorSecondary"
|
||||
app:backgroundTint="?attr/colorSecondary"
|
||||
tools:text="text"
|
||||
android:textColor="?attr/colorSecondary"
|
||||
android:textSize="12sp"
|
||||
android:paddingVertical="0dp"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"/>
|
||||
android:layout_marginBottom="2dp" />
|
||||
@@ -282,6 +282,7 @@
|
||||
<item name="chipCornerRadius">8dp</item>
|
||||
<item name="chipIconVisible">true</item>
|
||||
<item name="chipIconTint">@color/text_secondary_color</item>
|
||||
<item name="android:textColor">@color/text_secondary_color</item>
|
||||
<item name="checkedIconVisible">false</item>
|
||||
<item name="closeIconSize">24dp</item>
|
||||
<item name="ensureMinTouchTargetSize">false</item>
|
||||
|
||||
Reference in new issue
Block a user