From 23a20b7ddb372af1d163a2a84543359be72d633e Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Thu, 11 Nov 2021 19:46:26 +0100 Subject: [PATCH] Fix delete icon color bug --- .../hardcore/droidfs/adapters/SavedVolumesAdapter.kt | 4 +++- .../widgets/NonScrollableColoredBorderListView.kt | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/adapters/SavedVolumesAdapter.kt b/app/src/main/java/sushi/hardcore/droidfs/adapters/SavedVolumesAdapter.kt index 469bb8c..f348ea5 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/adapters/SavedVolumesAdapter.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/adapters/SavedVolumesAdapter.kt @@ -1,6 +1,7 @@ package sushi.hardcore.droidfs.adapters import android.content.Context +import android.content.res.ColorStateList import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -8,9 +9,9 @@ import android.widget.BaseAdapter import android.widget.ImageView import android.widget.TextView import sushi.hardcore.droidfs.R -import sushi.hardcore.droidfs.util.PathUtils import sushi.hardcore.droidfs.Volume import sushi.hardcore.droidfs.VolumeDatabase +import sushi.hardcore.droidfs.util.PathUtils import sushi.hardcore.droidfs.util.WidgetUtil import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder import sushi.hardcore.droidfs.widgets.NonScrollableColoredBorderListView @@ -52,6 +53,7 @@ class SavedVolumesAdapter(private val context: Context, private val themeValue: val currentVolume = getItem(position) volumeNameTextView.text = currentVolume.name val deleteImageView = view.findViewById(R.id.delete_imageview) + deleteImageView.imageTintList = ColorStateList.valueOf(nonScrollableColoredBorderListView.colorAccent) //fix a strange bug that sometimes displays the icon in white deleteImageView.setOnClickListener { val dialog = CustomAlertDialogBuilder(context, themeValue) dialog.setTitle(R.string.warning) diff --git a/app/src/main/java/sushi/hardcore/droidfs/widgets/NonScrollableColoredBorderListView.kt b/app/src/main/java/sushi/hardcore/droidfs/widgets/NonScrollableColoredBorderListView.kt index 72cb5a6..2f720ae 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/widgets/NonScrollableColoredBorderListView.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/widgets/NonScrollableColoredBorderListView.kt @@ -1,6 +1,7 @@ package sushi.hardcore.droidfs.widgets import android.content.Context +import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.util.AttributeSet import android.util.TypedValue @@ -14,10 +15,16 @@ class NonScrollableColoredBorderListView: ListView { constructor(context: Context, attrs: AttributeSet): super(context, attrs) { applyColor() } constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int): super(context, attrs, defStyleAttr) { applyColor() } - fun applyColor() { + val colorAccent: Int + + init { val typedValue = TypedValue() context.theme.resolveAttribute(R.attr.colorAccent, typedValue, true) - divider = ColorDrawable(typedValue.data) + colorAccent = typedValue.data + } + + fun applyColor() { + divider = ColorDrawable(colorAccent) dividerHeight = context.resources.displayMetrics.density.toInt()*2 background = ContextCompat.getDrawable(context, R.drawable.listview_border) }