Fix background ripple for VectorPreferences

Change-Id: I03c7ab6b69e70f4552658725c52919efacdbb143
This commit is contained in:
SpiritCroc 2021-09-24 10:14:19 +02:00
parent a7680ddbac
commit d190cc9f0f
2 changed files with 12 additions and 2 deletions

View File

@ -24,10 +24,13 @@ import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.Typeface import android.graphics.Typeface
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.widget.ImageViewCompat import androidx.core.widget.ImageViewCompat
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
@ -138,7 +141,9 @@ open class VectorPreference : Preference {
start() start()
} }
} else { } 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) { } catch (e: Exception) {
Timber.e(e, "onBindView") Timber.e(e, "onBindView")

View File

@ -22,8 +22,11 @@ import android.animation.ValueAnimator
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue
import android.widget.TextView import android.widget.TextView
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import im.vector.app.R import im.vector.app.R
@ -88,7 +91,9 @@ class VectorSwitchPreference : SwitchPreference {
start() start()
} }
} else { } 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) super.onBindViewHolder(holder)