Fix old issues

This commit is contained in:
h4h13 2020-04-15 14:19:28 +05:30
parent c6fc672cd1
commit 893f7fafdd
7 changed files with 23 additions and 14 deletions

View file

@ -19,9 +19,10 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.getAdaptiveIconDrawable
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil
@ -44,16 +45,15 @@ class ColorIconsImageView @JvmOverloads constructor(
}
fun setIconBackgroundColor(color: Int) {
background = getAdaptiveIconDrawable(context)
background = ContextCompat.getDrawable(context, R.drawable.color_circle_gradient)
if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtil.getInstance(context).desaturatedColor()) {
val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
backgroundTintList = ColorStateList.valueOf(desaturatedColor)
imageTintList =
ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorSurface))
} else {
backgroundTintList = ColorStateList.valueOf(color)
imageTintList =
ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorSurface))
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.22f))
imageTintList = ColorStateList.valueOf(ColorUtil.withAlpha(color, 0.75f))
}
requestLayout()
invalidate()