Commit 7d61df3b authored by Leonardo Aramaki's avatar Leonardo Aramaki

Dont render custom emojis on composer and respect cursor position after a...

Dont render custom emojis on composer and respect cursor position after a custom emoji is added according to its shortname length
parent e286abc5
...@@ -148,9 +148,4 @@ interface ChatRoomView : LoadingView, MessageView { ...@@ -148,9 +148,4 @@ interface ChatRoomView : LoadingView, MessageView {
*/ */
fun onRoomUpdated(userCanPost: Boolean, channelIsBroadcast: Boolean, userCanMod: Boolean) fun onRoomUpdated(userCanPost: Boolean, channelIsBroadcast: Boolean, userCanMod: Boolean)
/**
* Open a DM with the user in the given [chatRoom] and pass the [permalink] for the message
* to reply.
*/
fun openDirectMessage(chatRoom: ChatRoom, permalink: String)
} }
...@@ -380,10 +380,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -380,10 +380,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
} }
} }
override fun openDirectMessage(chatRoom: ChatRoom, permalink: String) {
}
private val layoutChangeListener = private val layoutChangeListener =
View.OnLayoutChangeListener { _, _, _, _, bottom, _, _, _, oldBottom -> View.OnLayoutChangeListener { _, _, _, _, bottom, _, _, _, oldBottom ->
val y = oldBottom - bottom val y = oldBottom - bottom
...@@ -626,28 +622,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -626,28 +622,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override fun onEmojiAdded(emoji: Emoji) { override fun onEmojiAdded(emoji: Emoji) {
val cursorPosition = text_message.selectionStart val cursorPosition = text_message.selectionStart
if (cursorPosition > -1) { if (cursorPosition > -1) {
context?.let { ctx -> context?.let {
launch(UI) { val offset = if (emoji.url == null) emoji.unicode.length else emoji.shortname.length
val parsedText = EmojiParser.parseAsync(ctx, emoji.shortname).await() text_message.text?.insert(cursorPosition, EmojiParser.parse(it, emoji.shortname))
text_message.setSelection(cursorPosition + offset)
if (parsedText is Spannable) {
val spans = parsedText.getSpans(0, parsedText.length, ImageSpan::class.java)
spans.forEach {
if (it.drawable is GifDrawable) {
it.drawable.callback = this@ChatRoomFragment
(it.drawable as GifDrawable).start()
}
}
text_message.text?.insert(text_message.selectionStart, parsedText)
text_message.text?.insert(text_message.selectionStart, " ")
}
// If it has no url then it's not a custom emoji.
if (emoji.url == null) {
text_message.setSelection(cursorPosition + emoji.unicode.length)
}
}
} }
} }
} }
......
...@@ -169,7 +169,7 @@ class MessageParser @Inject constructor( ...@@ -169,7 +169,7 @@ class MessageParser @Inject constructor(
if (node is ListItem) { if (node is ListItem) {
newLine() newLine()
builder.append("$number$delimiter ") builder.append("$number$delimiter ")
super.visit(node.firstChild as Paragraph) super.visitChildren(node)
newLine() newLine()
} }
number++ number++
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment