mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 18:38:23 +01:00
Restore original preference background after highlight animation (fixes #5094)
This commit is contained in:
parent
3b11ad8de8
commit
ab021c1302
@ -11,6 +11,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import androidx.core.animation.doOnEnd
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.preference.PreferenceController
|
import androidx.preference.PreferenceController
|
||||||
import androidx.preference.PreferenceGroup
|
import androidx.preference.PreferenceGroup
|
||||||
@ -98,6 +99,7 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
abstract fun setupPreferenceScreen(screen: PreferenceScreen): PreferenceScreen
|
abstract fun setupPreferenceScreen(screen: PreferenceScreen): PreferenceScreen
|
||||||
|
|
||||||
private fun animatePreferenceHighlight(view: View) {
|
private fun animatePreferenceHighlight(view: View) {
|
||||||
|
val origBackground = view.background
|
||||||
ValueAnimator
|
ValueAnimator
|
||||||
.ofObject(ArgbEvaluator(), Color.TRANSPARENT, view.context.getResourceColor(R.attr.rippleColor))
|
.ofObject(ArgbEvaluator(), Color.TRANSPARENT, view.context.getResourceColor(R.attr.rippleColor))
|
||||||
.apply {
|
.apply {
|
||||||
@ -106,6 +108,10 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) }
|
addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) }
|
||||||
reverse()
|
reverse()
|
||||||
}
|
}
|
||||||
|
.doOnEnd {
|
||||||
|
// Restore original ripple
|
||||||
|
view.background = origBackground
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getTitle(): String? {
|
open fun getTitle(): String? {
|
||||||
|
Loading…
Reference in New Issue
Block a user