RTE: fix API break...

This commit is contained in:
Benoit Marty 2023-12-20 10:15:39 +01:00 committed by Benoit Marty
parent d145c3108d
commit fac8dd333a
2 changed files with 15 additions and 12 deletions

View File

@ -232,6 +232,7 @@ class AutoCompleter @AssistedInject constructor(
private fun insertMatrixItemIntoRichTextEditor(editorEditText: EditorEditText, matrixItem: MatrixItem) {
if (matrixItem is MatrixItem.EveryoneInRoomItem) {
editorEditText.replaceTextSuggestion(matrixItem.displayName)
// Note: not using editorEditText.insertAtRoomMentionAtSuggestion() since we want to keep the existing look and feel of the mention for @room.
return
}
@ -253,7 +254,7 @@ class AutoCompleter @AssistedInject constructor(
matrixItem.getBestName()
}
editorEditText.setLinkSuggestion(url = permalink, text = linkText)
editorEditText.insertMentionAtSuggestion(url = permalink, text = linkText)
}
private fun insertMatrixItemIntoEditable(editText: EditText, editable: Editable, firstChar: Char, matrixItem: MatrixItem) {

View File

@ -105,10 +105,10 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
override val attachmentButton: ImageButton
get() = views.attachmentButton
val richTextEditText: EditText get() =
views.richTextComposerEditText
val plainTextEditText: EditText get() =
views.plainTextComposerEditText
val richTextEditText: EditText
get() = views.richTextComposerEditText
val plainTextEditText: EditText
get() = views.plainTextComposerEditText
var pillDisplayHandler: PillDisplayHandler? = null
@ -237,14 +237,16 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
views.composerEditTextOuterBorder.background = borderShapeDrawable
setupRichTextMenu()
views.richTextComposerEditText.mentionDisplayHandler = object : MentionDisplayHandler {
override fun resolveMentionDisplay(text: String, url: String): TextDisplay =
pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain
override fun resolveAtRoomMentionDisplay(): TextDisplay =
pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain
}
views.richTextComposerEditText.updateStyle(
styleConfig = views.richTextComposerEditText.styleConfig,
mentionDisplayHandler = object : MentionDisplayHandler {
override fun resolveMentionDisplay(text: String, url: String): TextDisplay =
pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain
override fun resolveAtRoomMentionDisplay(): TextDisplay =
pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain
}
)
updateTextFieldBorder(isFullScreen)
}