From d190cc9f0f534ceca963958e79c9d116f791f71e Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Fri, 24 Sep 2021 10:14:19 +0200 Subject: [PATCH] Fix background ripple for VectorPreferences Change-Id: I03c7ab6b69e70f4552658725c52919efacdbb143 --- .../java/im/vector/app/core/preference/VectorPreference.kt | 7 ++++++- .../vector/app/core/preference/VectorSwitchPreference.kt | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/preference/VectorPreference.kt b/vector/src/main/java/im/vector/app/core/preference/VectorPreference.kt index 22fc1758f1..7a8e732e54 100755 --- a/vector/src/main/java/im/vector/app/core/preference/VectorPreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/VectorPreference.kt @@ -24,10 +24,13 @@ import android.content.res.ColorStateList import android.graphics.Color import android.graphics.Typeface import android.util.AttributeSet +import android.util.TypedValue import android.view.View import android.widget.ImageView import android.widget.TextView import androidx.core.animation.doOnEnd +import androidx.core.content.ContextCompat +import androidx.core.view.ViewCompat import androidx.core.widget.ImageViewCompat import androidx.preference.Preference import androidx.preference.PreferenceViewHolder @@ -138,7 +141,9 @@ open class VectorPreference : Preference { start() } } else { - itemView.setBackgroundColor(Color.TRANSPARENT) + val bgDrawable = TypedValue() + context.theme.resolveAttribute(android.R.attr.selectableItemBackground, bgDrawable, true) + ViewCompat.setBackground(itemView, ContextCompat.getDrawable(context, bgDrawable.resourceId)) } } catch (e: Exception) { Timber.e(e, "onBindView") diff --git a/vector/src/main/java/im/vector/app/core/preference/VectorSwitchPreference.kt b/vector/src/main/java/im/vector/app/core/preference/VectorSwitchPreference.kt index 346e8488b9..ac9408646f 100644 --- a/vector/src/main/java/im/vector/app/core/preference/VectorSwitchPreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/VectorSwitchPreference.kt @@ -22,8 +22,11 @@ import android.animation.ValueAnimator import android.content.Context import android.graphics.Color import android.util.AttributeSet +import android.util.TypedValue import android.widget.TextView import androidx.core.animation.doOnEnd +import androidx.core.content.ContextCompat +import androidx.core.view.ViewCompat import androidx.preference.PreferenceViewHolder import androidx.preference.SwitchPreference import im.vector.app.R @@ -88,7 +91,9 @@ class VectorSwitchPreference : SwitchPreference { start() } } else { - itemView.setBackgroundColor(Color.TRANSPARENT) + val bgDrawable = TypedValue() + context.theme.resolveAttribute(android.R.attr.selectableItemBackground, bgDrawable, true) + ViewCompat.setBackground(itemView, ContextCompat.getDrawable(context, bgDrawable.resourceId)) } super.onBindViewHolder(holder)