Skip to content

Commit e6b5592

Browse files
committed
WIP analyze why emoji is not sent as styled emoji
There is something wrong with sending the Emoji Variation Selector. I debugged and saw that there are differences between web and android: from web: emoji ❤️ code U+2764 code U+FE0F from Android: emoji ❤ code U+2764 So this is about Emoji Variation Selector (VS-16). The emojis that are send from android are not styled (they do not include the Emoji Variation Selector). If i append FE0F to the classic emojis, it is fixed. But it seems the challenge is to decide when to append the Emoji Variation Selector. i quickly tried to append the style if there is not already one while sending. Works for classic emojis to append the style but other styled emojis are duplicated... pausing for now due to other important things.. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent d99740b commit e6b5592

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

app/src/main/java/com/nextcloud/talk/adapters/messages/Reaction.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package com.nextcloud.talk.adapters.messages
88

99
import android.content.Context
10+
import android.util.Log
1011
import android.view.View
1112
import android.view.ViewGroup
1213
import android.widget.LinearLayout
@@ -32,6 +33,16 @@ class Reaction {
3233
binding.reactionsEmojiWrapper.removeAllViews()
3334

3435
if (message.reactions != null && message.reactions!!.isNotEmpty()) {
36+
message.reactions!!.forEach {
37+
val emoji = it.key
38+
39+
Log.d("emoji", emoji)
40+
41+
emoji.codePoints().forEach { cp ->
42+
Log.d("code", "U+${cp.toString(16).uppercase()}")
43+
}
44+
}
45+
3546
binding.reactionsEmojiWrapper.visibility = View.VISIBLE
3647

3748
binding.reactionsEmojiWrapper.setOnLongClickListener {

app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,32 @@ class ReactionsRepositoryImpl @Inject constructor(
3232
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)!!
3333

3434
override fun addReaction(roomToken: String, message: ChatMessage, emoji: String): Observable<ReactionAddedModel> {
35+
36+
fun forceEmojiStyle(text: String): String {
37+
if (text.isEmpty()) return text
38+
39+
val cps = text.codePoints().toArray()
40+
val lastCp = cps.last()
41+
42+
return if (lastCp != 0xFE0F) {
43+
text + "\uFE0F"
44+
} else {
45+
text
46+
}
47+
}
48+
49+
val styledEmoji = forceEmojiStyle(emoji)
50+
3551
return ncApi.sendReaction(
3652
credentials,
3753
ApiUtils.getUrlForMessageReaction(
3854
currentUser.baseUrl!!,
3955
roomToken,
4056
message.id
4157
),
42-
emoji
58+
styledEmoji
4359
).map {
44-
val model = mapToReactionAddedModel(message, emoji, it.ocs?.meta!!)
60+
val model = mapToReactionAddedModel(message, styledEmoji, it.ocs?.meta!!)
4561
persistAddedModel(model, roomToken)
4662
return@map model
4763
}

0 commit comments

Comments
 (0)