-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big emoji-only messages #3295
Big emoji-only messages #3295
Conversation
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
cc @SpiritCroc |
...ment/android/features/messages/impl/timeline/model/event/TimelineItemEventContentProvider.kt
Outdated
Show resolved
Hide resolved
Thanks! Sign-offSigned-off-by: Tobias Büttner [email protected] |
(big) 😑 Yet, not a single other match for this on github passes the second argument: https://github.com/search?q=BundledEmojiCompatConfig&type=code This library is becoming more effort than it's worth. We don't even need the font compat rubbish 💩 |
7095631
to
3d793ee
Compare
I contemplated the options for a while, and opted to stick with androidx-emoji2 for a couple of reasons
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'm a bit torn about this: we already have the emojibase library for using emojis, getting the categories, etc., so I don't really like the idea of adding another one with mostly the same functionality - even though it's the official one. It also probably adds some small overhead on the app init time.
On the other side, the implementation is quite simple and works well, and duplicating the logic of EmojiCompat
seems like an overkill.
Also, the logic isn't exactly the same as iOS: they only use a large text style if the message contains a single emoji and nothing else, so maybe we should do the same.
@bmarty any thoughts about this?
...ment/android/features/messages/impl/timeline/model/event/TimelineItemEventContentProvider.kt
Outdated
Show resolved
Hide resolved
import androidx.emoji2.text.EmojiCompat | ||
import timber.log.Timber | ||
|
||
fun String.containsOnlyEmojis(maxEmojis: Int = Integer.MAX_VALUE): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to remind myself how to write JavaDoc KDoc(?), but done
Fully agree here. In fact, I'm quite frustrated that we need a library for this at all. It should just be pattern matching really. If the spec wasn't so awful, I'd do it with a regex.
But then how will I get my large chefs kiss? |
I'm not a huge fan of the emoji2 lib either. Docs say:
Sounds annoying to add just for emoji detection. But in the end for my needs it was still the best solution, regarding detecting all emojis properly, and keeping maintenance effort low. Also I thought I saw some dependency pulling in emoji2 anyway back when I implemented this, but maybe my memory fails me with that since I don't find it anymore. |
Based on that excerpt from the docs, it makes using this library a non-starter. It's dead weight. I'll go back to the drawing board yet again. Maybe I'll try to understand the unicode spec a bit more and write some lightweight logic to detect emojis. |
We probably need a product decision about rendering messages with only Emojis with a bigger font. This very old feature has been introduced before the Matrix protocol supports reaction. So now that we have reaction, maybe we do not need this feature. Also, ideally, the "only emoji" detection could be done by the Rust SDK, so that the algorithm is shared with iOS. (note: tracked by #1438) CC @mxandreas |
I took some more time trying to implement this with a regex, but after reading into the unicode spec, I realised that it would be a pretty monumental feat to implement something that correctly catches all various of the cases and variants that can apply to specific emojis (of which there are a LOT). I guess it sorta explains why many of these libraries ship huge tables- it's so they can account for all of the variants. For example here is just one set of variants for one of the many ranges of emoji graphemes: https://en.wikipedia.org/wiki/Miscellaneous_Symbols_and_Pictographs#Table_of_emojis_with_modifiers I settled on implementing with https://github.com/sigpwned/emoji4j as it seems relatively well maintained and simple/lightweight. The implementation has emoji-specific grapheme selection which is what we want. There are a few edge cases that it doesn't account for (but I think they're all from unicode 15.1.. it only supports up to 15), otherwise it seems to work great. |
a10f8a0
to
6a307a2
Compare
I can see @amshakal 's comment on the original ticket that this is nice to have (but I understand it is still something to have), she is probably better to comment what were the arguments for it. |
Updates since the last push:
From my testing now, this seems functionally correct with every emoji that I've tested and parity with EW/EA/EXI |
CI OOMed (again). It's pretty flaky. |
Done, but I think it also needs a screenshot update. |
6f081eb
to
571359c
Compare
Ok, the screenshot test failure looks like this: I think it's because in the mocked data to display we forgot to enforce a locale. If you go here and add |
Perfect, thanks for the help! I'd have never found that 😆 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3295 +/- ##
===========================================
- Coverage 82.75% 82.74% -0.01%
===========================================
Files 1680 1681 +1
Lines 39382 39399 +17
Branches 4777 4784 +7
===========================================
+ Hits 32591 32602 +11
- Misses 5117 5118 +1
- Partials 1674 1679 +5 ☔ View full report in Codecov by Sentry. |
I recommend we implement large-sized emojis in our messaging app because this aligns with user expectations based on the behavior of standard messaging apps. Most apps render a single or a few emojis larger because they have the space, and this small detail can enhance the user experience by adding a sense of delight and improving visual accessibility. While this isn’t a core functional feature, it’s a subtle enhancement that users have come to appreciate. As a baseline, we could start by making a single emoji larger, which is the minimum implementation seen across popular messaging platforms. For example, WhatsApp uses this for up to three emojis, Signal for up to four, Slack doesn’t limit emoji size, and Telegram reduces emoji size incrementally after six. Ultimately, I support adding this feature, even if it's just for single emojis. However, I’m also open to allowing multiple large emojis, similar to other platforms, if we want to provide a more flexible user experience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM then!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some remarks, then I guess the PR can be merged, thanks!
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/utils/Emoji.kt
Outdated
Show resolved
Hide resolved
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/utils/Emoji.kt
Outdated
Show resolved
Hide resolved
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/utils/Emoji.kt
Outdated
Show resolved
Hide resolved
Different system locales can generate different screenshots, causing CI to be unhappy. Hardcoding a locale ensures the same date format is always used. Signed-off-by: Joe Groocock <[email protected]>
Adapted from SpiritCroc's SchildNext implementation from SchildiChat/schildichat-android-next@7eba87f Fixes: element-hq#1438 Signed-off-by: Tobias Büttner <[email protected]> Signed-off-by: Joe Groocock <[email protected]>
One final remark- it seems that maybe this isn't a unanimously desired feature. Perhaps additionally to this, we could add a toggle for it, like Element Web has? |
We try to limit the number of settings EX has, so I guess it's fine if this behavior cannot be disabled. Thanks! |
Content
Render emoji-only messages in a larger text
Adapted from SpiritCroc's SchildNext implementation from SchildiChat/schildichat-android-next@7eba87f
Authored-by: SpiritCroc [email protected]
Submitted-by: Joe Groocock [email protected]
Motivation and context
Parity with Element-X iOS, Element Web, and pretty much any other chat client ever.
Fixes #1438
Screenshots / GIFs
Tests
Tested devices
Checklist