Merge pull request 'merge_dev_into_43443' (#14) from merge_dev_into_43443 into feature/MB-43443
Reviewed-on: #14 Reviewed-by: Alexey Ganin <alexey.ganin@noreply.localhost>
This commit is contained in:
commit
b67048e5ea
|
|
@ -20,11 +20,11 @@ import ru.touchin.utils.ActionThrottler.DEFAULT_THROTTLE_DELAY_MS
|
|||
*/
|
||||
fun String.getSpannedTextWithUrls(
|
||||
removeUnderline: Boolean = true,
|
||||
flags: Int = HtmlCompat.FROM_HTML_MODE_COMPACT
|
||||
htmlFormatFlags: Int = HtmlCompat.FROM_HTML_MODE_COMPACT
|
||||
): Spanned {
|
||||
// HtmlCompat.fromHtml doesn't respect line breaks
|
||||
val text = this.replace(lineBreakRegex, "<br/>")
|
||||
val spannableText = SpannableString(HtmlCompat.fromHtml(text, flags))
|
||||
val spannableText = SpannableString(HtmlCompat.fromHtml(text, htmlFormatFlags))
|
||||
|
||||
// Linkify removes all previous URLSpan's, we need to save all created spans for reapply after Linkify
|
||||
val spans = spannableText.getUrlSpans()
|
||||
|
|
@ -33,7 +33,7 @@ fun String.getSpannedTextWithUrls(
|
|||
spannableText.setSpan(it.span, it.start, it.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
|
||||
if (!removeUnderline) {
|
||||
if (removeUnderline) {
|
||||
spannableText.getUrlSpans()
|
||||
.forEach { urlSpan ->
|
||||
spannableText.removeSpan(urlSpan.span)
|
||||
|
|
|
|||
Loading…
Reference in New Issue