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) { private fun insertMatrixItemIntoRichTextEditor(editorEditText: EditorEditText, matrixItem: MatrixItem) {
if (matrixItem is MatrixItem.EveryoneInRoomItem) { if (matrixItem is MatrixItem.EveryoneInRoomItem) {
editorEditText.replaceTextSuggestion(matrixItem.displayName) 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 return
} }
@ -253,7 +254,7 @@ class AutoCompleter @AssistedInject constructor(
matrixItem.getBestName() 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) { 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 override val attachmentButton: ImageButton
get() = views.attachmentButton get() = views.attachmentButton
val richTextEditText: EditText get() = val richTextEditText: EditText
views.richTextComposerEditText get() = views.richTextComposerEditText
val plainTextEditText: EditText get() = val plainTextEditText: EditText
views.plainTextComposerEditText get() = views.plainTextComposerEditText
var pillDisplayHandler: PillDisplayHandler? = null var pillDisplayHandler: PillDisplayHandler? = null
@ -237,14 +237,16 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
views.composerEditTextOuterBorder.background = borderShapeDrawable views.composerEditTextOuterBorder.background = borderShapeDrawable
setupRichTextMenu() setupRichTextMenu()
views.richTextComposerEditText.mentionDisplayHandler = object : MentionDisplayHandler { views.richTextComposerEditText.updateStyle(
styleConfig = views.richTextComposerEditText.styleConfig,
mentionDisplayHandler = object : MentionDisplayHandler {
override fun resolveMentionDisplay(text: String, url: String): TextDisplay = override fun resolveMentionDisplay(text: String, url: String): TextDisplay =
pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain
override fun resolveAtRoomMentionDisplay(): TextDisplay = override fun resolveAtRoomMentionDisplay(): TextDisplay =
pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain
} }
)
updateTextFieldBorder(isFullScreen) updateTextFieldBorder(isFullScreen)
} }