Remove ripple effect from bottom unit when top is tapped

This commit is contained in:
Ensar Sarajčić 2023-09-14 09:53:32 +02:00
parent 230c2717b0
commit ed2e91f036
1 changed files with 6 additions and 6 deletions

View File

@ -92,13 +92,13 @@ class ConverterView @JvmOverloads constructor(
binding.topUnitHolder.backgroundTintList = ColorStateList.valueOf(context.getProperPrimaryColor().lightenColor().adjustAlpha(LOWER_ALPHA))
binding.swapButton.applyColorFilter(context.getProperPrimaryColor())
val drawable = ResourcesCompat.getDrawable(
resources, com.simplemobiletools.commons.R.drawable.pill_background, context.theme
)?.constantState?.newDrawable()?.mutate() as RippleDrawable
val bgLayerList = drawable.findDrawableByLayerId(com.simplemobiletools.commons.R.id.button_pill_background_holder) as LayerDrawable
val bgLayer = bgLayerList.findDrawableByLayerId(com.simplemobiletools.commons.R.id.button_pill_background_shape) as GradientDrawable
bgLayer.cornerRadius = context.resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big)
listOf(binding.topUnitSymbol, binding.bottomUnitSymbol).forEach {
val drawable = ResourcesCompat.getDrawable(
resources, com.simplemobiletools.commons.R.drawable.pill_background, context.theme
)?.constantState?.newDrawable()?.mutate() as RippleDrawable
val bgLayerList = drawable.findDrawableByLayerId(com.simplemobiletools.commons.R.id.button_pill_background_holder) as LayerDrawable
val bgLayer = bgLayerList.findDrawableByLayerId(com.simplemobiletools.commons.R.id.button_pill_background_shape) as GradientDrawable
bgLayer.cornerRadius = context.resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big)
it.background = drawable
it.background?.alpha = MEDIUM_ALPHA_INT
}