Rename for clarity

This commit is contained in:
Benoit Marty 2021-12-13 14:56:21 +01:00
parent ab70ee5ae2
commit 04d23ce7f6

View File

@ -30,7 +30,7 @@ object VectorLinkify {
if (keepExistingUrlSpan) { if (keepExistingUrlSpan) {
// Keep track of existing URLSpans, and mark them as important // 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)) 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) LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES or Linkify.PHONE_NUMBERS)
// we might want to modify some matches // we might want to modify some matches
spannable.forEachSpanIndexed { _, urlSpan, start, end -> spannable.forEachUrlSpanIndexed { _, urlSpan, start, end ->
spannable.removeSpan(urlSpan) spannable.removeSpan(urlSpan)
// remove short PN, too much false positive // remove short PN, too much false positive
@ -47,7 +47,7 @@ object VectorLinkify {
if (end - start > 6) { // Do not match under 7 digit if (end - start > 6) { // Do not match under 7 digit
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
} }
return@forEachSpanIndexed return@forEachUrlSpanIndexed
} }
// include mailto: if found before match // include mailto: if found before match
@ -60,7 +60,7 @@ object VectorLinkify {
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
} }
return@forEachSpanIndexed return@forEachUrlSpanIndexed
} }
// Handle url matches // Handle url matches
@ -70,7 +70,7 @@ object VectorLinkify {
// modify the span to include the slash // modify the span to include the slash
val spec = LinkSpec(URLSpan(urlSpan.url + "/"), start, end + 1) val spec = LinkSpec(URLSpan(urlSpan.url + "/"), start, end + 1)
createdSpans.add(spec) createdSpans.add(spec)
return@forEachSpanIndexed return@forEachUrlSpanIndexed
} }
// Try to do something for ending ) issues/3020 // Try to do something for ending ) issues/3020
if (spannable[end - 1] == ')') { if (spannable[end - 1] == ')') {
@ -87,7 +87,7 @@ object VectorLinkify {
val span = URLSpan(spannable.substring(start, end - 1)) val span = URLSpan(spannable.substring(start, end - 1))
val spec = LinkSpec(span, start, end - 1) val spec = LinkSpec(span, start, end - 1)
createdSpans.add(spec) 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) 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) spannable.removeSpan(urlSpan)
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end)) createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
} }
@ -174,7 +174,7 @@ object VectorLinkify {
return@MatchFilter true 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) getSpans(0, length, URLSpan::class.java)
.forEachIndexed { index, urlSpan -> .forEachIndexed { index, urlSpan ->
val start = getSpanStart(urlSpan) val start = getSpanStart(urlSpan)