Fix weird highlight shown after revealing a spoiler.
This commit is contained in:
parent
4d10be2aa5
commit
a0e4b1aaf9
1 changed files with 13 additions and 0 deletions
|
@ -2,10 +2,14 @@ package org.thoughtcrime.securesms.components.spoiler
|
|||
|
||||
import android.graphics.Color
|
||||
import android.text.Annotation
|
||||
import android.text.Selection
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.TextPaint
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
|
||||
/**
|
||||
* Helper for applying spans to text that should be rendered as a spoiler. Also
|
||||
|
@ -59,6 +63,15 @@ object SpoilerAnnotation {
|
|||
|
||||
override fun onClick(widget: View) {
|
||||
revealedSpoilers.add(spoiler.value)
|
||||
if (widget is TextView && Selection.getSelectionStart(widget.text) != -1) {
|
||||
val text: Spannable = if (widget.text is Spannable) {
|
||||
widget.text as Spannable
|
||||
} else {
|
||||
SpannableString(widget.text)
|
||||
}
|
||||
Selection.removeSelection(text)
|
||||
widget.text = text
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
|
|
Loading…
Add table
Reference in a new issue