mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-26 16:28:08 +00:00
Fixed mentions in chat message if there are more than one
This commit is contained in:
parent
3da7dd03fc
commit
31f3886480
1 changed files with 7 additions and 5 deletions
|
|
@ -673,6 +673,7 @@ class MessageModel
|
|||
// Check for mentions
|
||||
val chatRoom = chatMessage.chatRoom
|
||||
val matcher = Pattern.compile(MENTION_REGEXP).matcher(textContent)
|
||||
var offset = 0
|
||||
while (matcher.find()) {
|
||||
val start = matcher.start()
|
||||
val end = matcher.end()
|
||||
|
|
@ -698,11 +699,11 @@ class MessageModel
|
|||
)
|
||||
val friend = avatarModel.friend
|
||||
val displayName = friend.name ?: LinphoneUtils.getDisplayName(address)
|
||||
Log.d(
|
||||
"$TAG Using display name [$displayName] instead of username [$source]"
|
||||
Log.i(
|
||||
"$TAG Using display name [$displayName] instead of mention username [$source]"
|
||||
)
|
||||
|
||||
spannableBuilder.replace(start, end, "@$displayName")
|
||||
spannableBuilder.replace(start + offset, end + offset, "@$displayName")
|
||||
val span = PatternClickableSpan.StyledClickableSpan(
|
||||
object : SpannableClickedListener {
|
||||
@UiThread
|
||||
|
|
@ -719,10 +720,11 @@ class MessageModel
|
|||
)
|
||||
spannableBuilder.setSpan(
|
||||
span,
|
||||
start,
|
||||
start + displayName.length + 1,
|
||||
start + offset,
|
||||
start + offset + displayName.length + 1,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
offset += displayName.length - source.length
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue