Passes text color instead of context

This commit is contained in:
Benoit Marty 2019-10-29 15:51:18 +01:00
parent 42e0d0f769
commit 86667a6d8a

View file

@ -16,29 +16,26 @@
package im.vector.riotx.features.html package im.vector.riotx.features.html
import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.text.TextPaint import android.text.TextPaint
import android.text.style.ClickableSpan import android.text.style.ClickableSpan
import android.view.View import android.view.View
import im.vector.riotx.R
import im.vector.riotx.features.themes.ThemeUtils
class SpoilerSpan(val bgColor: Int, val context: Context) : ClickableSpan() { class SpoilerSpan(private val bgColor: Int, private val textColor: Int) : ClickableSpan() {
override fun onClick(widget: View) { override fun onClick(widget: View) {
isHidden = !isHidden isHidden = !isHidden
widget.invalidate() widget.invalidate()
} }
var isHidden = true private var isHidden = true
override fun updateDrawState(tp: TextPaint) { override fun updateDrawState(tp: TextPaint) {
tp.bgColor = bgColor tp.bgColor = bgColor
if (isHidden) { if (isHidden) {
tp.color = Color.TRANSPARENT tp.color = Color.TRANSPARENT
} else { } else {
tp.color = ThemeUtils.getColor(context, R.attr.riotx_text_primary) tp.color = textColor
} }
} }
} }