Also linkify emails.
This commit is contained in:
parent
bce100e913
commit
bc4da250e1
2 changed files with 3 additions and 3 deletions
|
|
@ -230,7 +230,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
Pair(start, end)
|
Pair(start, end)
|
||||||
}
|
}
|
||||||
// Find and set as URLSpans any links present in the text
|
// Find and set as URLSpans any links present in the text
|
||||||
LinkifyCompat.addLinks(this, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
LinkifyCompat.addLinks(this, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
// Restore old spans if they don't conflict with the new ones
|
// Restore old spans if they don't conflict with the new ones
|
||||||
for ((urlSpan, location) in oldURLSpans) {
|
for ((urlSpan, location) in oldURLSpans) {
|
||||||
val (start, end) = location
|
val (start, end) = location
|
||||||
|
|
@ -244,6 +244,6 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
|
|
||||||
private fun String.withLinks(): CharSequence? {
|
private fun String.withLinks(): CharSequence? {
|
||||||
val spannable = toSpannable()
|
val spannable = toSpannable()
|
||||||
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
return spannable.takeIf { addedLinks }
|
return spannable.takeIf { addedLinks }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ fun ClickableLinkText(
|
||||||
fun AnnotatedString.linkify(linkStyle: SpanStyle): AnnotatedString {
|
fun AnnotatedString.linkify(linkStyle: SpanStyle): AnnotatedString {
|
||||||
val original = this
|
val original = this
|
||||||
val spannable = SpannableString(this.text)
|
val spannable = SpannableString(this.text)
|
||||||
LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
|
|
||||||
val spans = spannable.getSpans(0, spannable.length, URLSpan::class.java)
|
val spans = spannable.getSpans(0, spannable.length, URLSpan::class.java)
|
||||||
return buildAnnotatedString {
|
return buildAnnotatedString {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue