Fix relinkifying tags in posts from remote servers (#2359)
* Fix relinkifying tags in posts from remote servers * Completely ignore urls, and (case-insensitively) match tag names instead
This commit is contained in:
parent
2c91b1148c
commit
cdefcc441f
2 changed files with 15 additions and 43 deletions
|
@ -98,15 +98,16 @@ fun setClickableText(
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun getTagName(text: CharSequence, tags: List<HashTag>?, span: URLSpan): String? {
|
||||
fun getTagName(text: CharSequence, tags: List<HashTag>?): String? {
|
||||
val scrapedName = text.subSequence(1, text.length).toString()
|
||||
return when (tags) {
|
||||
null -> text.subSequence(1, text.length).toString()
|
||||
else -> tags.firstOrNull { it.url == span.url }?.name
|
||||
null -> scrapedName
|
||||
else -> tags.firstOrNull { it.name.equals(scrapedName, true) }?.name
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCustomSpanForTag(text: CharSequence, tags: List<HashTag>?, span: URLSpan, listener: LinkListener): ClickableSpan? {
|
||||
return getTagName(text, tags, span)?.let {
|
||||
return getTagName(text, tags)?.let {
|
||||
object : NoUnderlineURLSpan(span.url) {
|
||||
override fun onClick(view: View) = listener.onViewTag(it)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue