Fix delete icon color bug

This commit is contained in:
Matéo Duparc 2021-11-11 19:46:26 +01:00
parent fd5ddc02b1
commit 23a20b7ddb
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 12 additions and 3 deletions

View File

@ -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<ImageView>(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)

View File

@ -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)
}