Skip to content

Render custom emoji inline and play animated images - #169

Merged
malkoG merged 2 commits into
hackers-pub:mainfrom
malkoG:fix/inline-custom-emoji
Sep 29, 2026
Merged

malkoG merged 2 commits into
hackers-pub:mainfrom
malkoG:fix/inline-custom-emoji

Conversation

@malkoG

@malkoG malkoG commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #166

Summary

Custom emoji rendering (HtmlContent.kt)

  • hackers.pub serves custom emoji as <img alt=":name:" style="height:1em;vertical-align:middle;display:inline-block;"> (renderCustomEmojis in models/emoji.ts). There is no class, because sanitization strips class/style from <img> before emoji are injected.
  • The app only treated <img> as inline when it sat inside a link/mention or had class="inline-block". As a result:
    • Feed / previews (Bug 3): emoji were silently dropped.
    • Post detail (Bug 1): emoji were pulled out as full-width image blocks, which split the paragraph and made them huge.
  • Emoji are now recognized by an alt shortcode (or the web frontend's class="emoji") and kept in the text flow. They are sized relative to the surrounding text (1.2em) instead of a fixed 18dp circle crop. Mention avatars are unchanged.

Animated images (Bug 2)

  • Adds coil-gif, which registers itself through Coil's service loader:
    • API 28+: AnimatedImageDecoder (GIF, animated WebP, and animated HEIF on API 30+)
    • API 26–27: GifDecoder (GIF only)
  • Applies app-wide, so animated custom emoji, remote avatars, and inline images now play.

Notes

  • Local hackers.pub avatars stay static. The server's transformAvatar reads only the first frame, and AvatarPicker re-encodes uploads as JPEG. That is out of scope here.
  • Reaction notifications with a custom emoji still show only the text. NotificationsScreen uses Notification.React.emoji and ignores customEmoji. Left for a follow-up.

Test plan

  • HtmlContentKtTest: new cases for server emoji markup, class="emoji", and plain body images still leaving the text flow
  • ./gradlew :app:lintDebug
  • Full unit test suite (verified locally)
  • Emulator (API 33): an animated GIF remote avatar plays on the profile screen
  • Device: confirmed working
  • Release (minified) build keeps the coil-gif service loader registration

🤖 Generated with Claude Code

malkoG and others added 2 commits September 30, 2026 02:45
hackers.pub serves custom emoji as <img alt=":name:" style="height:1em;...">
with no class or size attributes. parseInlineImage only accepted images
inside links/mentions or with class inline-block, so emoji were dropped in
preview mode, and extractImageBlocks pulled them out as full-width blocks
in full mode, splitting the paragraph.

Recognize emoji by an alt shortcode (or the web frontend's emoji class),
keep them in the text flow, and size them relative to the surrounding text
instead of a fixed 18dp circle crop.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add the coil-gif module. It registers itself through Coil's service
loader: AnimatedImageDecoder on API 28+ (GIF, animated WebP, and
animated HEIF on API 30+) and GifDecoder on API 26-27 (GIF only).
This makes animated avatars, custom emoji, and inline images play
instead of showing only the first frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ed97498e-71fc-4f94-8a03-59c39a6ca65a

📥 Commits

Reviewing files that changed from the base of the PR and between f1f76bc and bbbbcb2.

📒 Files selected for processing (4)
  • app/build.gradle.kts
  • app/src/main/java/pub/hackers/android/ui/components/HtmlContent.kt
  • app/src/test/java/pub/hackers/android/ui/components/HtmlContentKtTest.kt
  • gradle/libs.versions.toml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@malkoG
malkoG merged commit 07b61fa into hackers-pub:main Sep 29, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom emoji bugs

1 participant