mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Merge pull request #8847 from element-hq/fix/jme/send-mentions-using-user-id-as-text
When sending user mentions, always send the user id as the fallback text
This commit is contained in:
commit
4d27c848e2
4 changed files with 5 additions and 16 deletions
|
@ -26,10 +26,7 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
|
||||||
import org.matrix.android.sdk.api.util.TextContent
|
import org.matrix.android.sdk.api.util.TextContent
|
||||||
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
|
|
||||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
|
||||||
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
||||||
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
|
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
|
||||||
|
|
||||||
|
@ -56,12 +53,6 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
HtmlRenderer.builder().softbreak("<br />").build(),
|
HtmlRenderer.builder().softbreak("<br />").build(),
|
||||||
TextPillsUtils(
|
TextPillsUtils(
|
||||||
MentionLinkSpecComparator(),
|
MentionLinkSpecComparator(),
|
||||||
DisplayNameResolver(
|
|
||||||
MatrixConfiguration(
|
|
||||||
applicationFlavor = "TestFlavor",
|
|
||||||
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TestPermalinkService()
|
TestPermalinkService()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,6 @@ import android.text.SpannableString
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
||||||
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -29,7 +28,6 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
internal class TextPillsUtils @Inject constructor(
|
internal class TextPillsUtils @Inject constructor(
|
||||||
private val mentionLinkSpecComparator: MentionLinkSpecComparator,
|
private val mentionLinkSpecComparator: MentionLinkSpecComparator,
|
||||||
private val displayNameResolver: DisplayNameResolver,
|
|
||||||
private val permalinkService: PermalinkService
|
private val permalinkService: PermalinkService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -70,7 +68,7 @@ internal class TextPillsUtils @Inject constructor(
|
||||||
// append text before pill
|
// append text before pill
|
||||||
append(text, currIndex, start)
|
append(text, currIndex, start)
|
||||||
// append the pill
|
// append the pill
|
||||||
append(String.format(template, urlSpan.matrixItem.id, displayNameResolver.getBestName(urlSpan.matrixItem)))
|
append(String.format(template, urlSpan.matrixItem.id, urlSpan.matrixItem.id))
|
||||||
currIndex = end
|
currIndex = end
|
||||||
}
|
}
|
||||||
// append text after the last pill
|
// append text after the last pill
|
||||||
|
|
|
@ -246,10 +246,10 @@ class AutoCompleter @AssistedInject constructor(
|
||||||
val linkText = when (matrixItem) {
|
val linkText = when (matrixItem) {
|
||||||
is MatrixItem.RoomAliasItem,
|
is MatrixItem.RoomAliasItem,
|
||||||
is MatrixItem.RoomItem,
|
is MatrixItem.RoomItem,
|
||||||
is MatrixItem.SpaceItem ->
|
is MatrixItem.SpaceItem,
|
||||||
|
is MatrixItem.UserItem ->
|
||||||
matrixItem.id
|
matrixItem.id
|
||||||
is MatrixItem.EveryoneInRoomItem,
|
is MatrixItem.EveryoneInRoomItem,
|
||||||
is MatrixItem.UserItem,
|
|
||||||
is MatrixItem.EventItem ->
|
is MatrixItem.EventItem ->
|
||||||
matrixItem.getBestName()
|
matrixItem.getBestName()
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,14 +796,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
||||||
composer.editText.setSelection(Command.EMOTE.command.length + 1)
|
composer.editText.setSelection(Command.EMOTE.command.length + 1)
|
||||||
} else {
|
} else {
|
||||||
val roomMember = timelineViewModel.getMember(userId)
|
val roomMember = timelineViewModel.getMember(userId)
|
||||||
val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
|
|
||||||
if ((composer as? RichTextComposerLayout)?.isTextFormattingEnabled == true) {
|
if ((composer as? RichTextComposerLayout)?.isTextFormattingEnabled == true) {
|
||||||
// Rich text editor is enabled so we need to use its APIs
|
// Rich text editor is enabled so we need to use its APIs
|
||||||
permalinkService.createPermalink(userId)?.let { url ->
|
permalinkService.createPermalink(userId)?.let { url ->
|
||||||
(composer as RichTextComposerLayout).insertMention(url, displayName)
|
(composer as RichTextComposerLayout).insertMention(url, userId)
|
||||||
composer.editText.append(" ")
|
composer.editText.append(" ")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
|
||||||
val pill = buildSpannedString {
|
val pill = buildSpannedString {
|
||||||
append(displayName)
|
append(displayName)
|
||||||
setSpan(
|
setSpan(
|
||||||
|
|
Loading…
Reference in a new issue