diff --git a/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt b/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt index bc1ed3609b..0906b398c5 100644 --- a/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt +++ b/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt @@ -30,7 +30,7 @@ object VectorLinkify { if (keepExistingUrlSpan) { // Keep track of existing URLSpans, and mark them as important - spannable.forEachSpanIndexed { _, urlSpan, start, end -> + spannable.forEachUrlSpanIndexed { _, urlSpan, start, end -> createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end, important = true)) } } @@ -39,7 +39,7 @@ object VectorLinkify { LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES or Linkify.PHONE_NUMBERS) // we might want to modify some matches - spannable.forEachSpanIndexed { _, urlSpan, start, end -> + spannable.forEachUrlSpanIndexed { _, urlSpan, start, end -> spannable.removeSpan(urlSpan) // remove short PN, too much false positive @@ -47,7 +47,7 @@ object VectorLinkify { if (end - start > 6) { // Do not match under 7 digit createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) } - return@forEachSpanIndexed + return@forEachUrlSpanIndexed } // include mailto: if found before match @@ -60,7 +60,7 @@ object VectorLinkify { createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) } - return@forEachSpanIndexed + return@forEachUrlSpanIndexed } // Handle url matches @@ -70,7 +70,7 @@ object VectorLinkify { // modify the span to include the slash val spec = LinkSpec(URLSpan(urlSpan.url + "/"), start, end + 1) createdSpans.add(spec) - return@forEachSpanIndexed + return@forEachUrlSpanIndexed } // Try to do something for ending ) issues/3020 if (spannable[end - 1] == ')') { @@ -87,7 +87,7 @@ object VectorLinkify { val span = URLSpan(spannable.substring(start, end - 1)) val spec = LinkSpec(span, start, end - 1) createdSpans.add(spec) - return@forEachSpanIndexed + return@forEachUrlSpanIndexed } } @@ -95,7 +95,7 @@ object VectorLinkify { } LinkifyCompat.addLinks(spannable, VectorAutoLinkPatterns.GEO_URI.toPattern(), "geo:", arrayOf("geo:"), geoMatchFilter, null) - spannable.forEachSpanIndexed { _, urlSpan, start, end -> + spannable.forEachUrlSpanIndexed { _, urlSpan, start, end -> spannable.removeSpan(urlSpan) createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) } @@ -174,7 +174,7 @@ object VectorLinkify { return@MatchFilter true } - private inline fun Spannable.forEachSpanIndexed(action: (index: Int, urlSpan: URLSpan, start: Int, end: Int) -> Unit) { + private inline fun Spannable.forEachUrlSpanIndexed(action: (index: Int, urlSpan: URLSpan, start: Int, end: Int) -> Unit) { getSpans(0, length, URLSpan::class.java) .forEachIndexed { index, urlSpan -> val start = getSpanStart(urlSpan)