Repository navigation
fix(mobile): composer chips match chat chips #22518
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
Merged
juliusmarminge
merged 7 commits into
pingdotgg:main
from
flamboh:fix/mobile-composer-chips-match-chat
Oct 21, 2026
+247
−375
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61239bb
fix(mobile): composer chips match chat chips
flamboh 7d4624d
fix(mobile): tint Android chip icons in the accent and coalesce icon …
flamboh 1f6ba24
fix(mobile): Android chip icons repaint in place instead of re-laying…
flamboh 7a989d0
fix(mobile): iOS composer chip renderer stays within SwiftLint's para…
flamboh 64bd3c4
style(mobile): ktlint wrapping for the Android composer chip changes
flamboh e12cf7a
refactor(mobile): Android chip icon loader stays within detekt's retu…
flamboh 9510474
Merge remote-tracking branch 'origin/main' into HEAD
flamboh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...les/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ChipIcons.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package expo.modules.t3composereditor | ||
|
|
||
| import android.content.Context | ||
| import android.graphics.Bitmap | ||
| import android.graphics.BitmapFactory | ||
| import android.net.Uri | ||
| import android.os.Handler | ||
| import android.os.Looper | ||
| import java.net.URL | ||
| import java.util.concurrent.Executors | ||
|
|
||
| internal object T3ChipIcons { | ||
| private val images = HashMap<String, Bitmap>() | ||
| private val pending = HashMap<String, MutableSet<(String) -> Unit>>() | ||
| private val downloads = Executors.newSingleThreadExecutor() | ||
| private val main = Handler(Looper.getMainLooper()) | ||
|
|
||
| fun cached(uri: String): Bitmap? = images[uri] | ||
|
|
||
| fun load(context: Context, uri: String, onLoaded: (String) -> Unit): Bitmap? = | ||
| images[uri] ?: when { | ||
| uri.isEmpty() -> null | ||
| uri.startsWith("http://") || uri.startsWith("https://") -> { | ||
| download(uri, onLoaded) | ||
| null | ||
| } | ||
| else -> decodeLocal(context, uri)?.also { images[uri] = it } | ||
| } | ||
|
|
||
| private fun download(uri: String, onLoaded: (String) -> Unit) { | ||
| val waiting = pending[uri] | ||
| if (waiting != null) { | ||
| waiting.add(onLoaded) | ||
| return | ||
| } | ||
| pending[uri] = mutableSetOf(onLoaded) | ||
| downloads.execute { | ||
| val bitmap = runCatching { | ||
| URL(uri).openStream().use(BitmapFactory::decodeStream) | ||
| }.getOrNull() | ||
| main.post { | ||
| val callbacks = pending.remove(uri).orEmpty() | ||
| if (bitmap != null) { | ||
| images[uri] = bitmap | ||
| callbacks.forEach { it(uri) } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun decodeLocal(context: Context, uri: String): Bitmap? = runCatching { | ||
| when { | ||
| uri.startsWith("/") -> BitmapFactory.decodeFile(uri) | ||
| uri.startsWith("file:") -> Uri.parse(uri).path?.let(BitmapFactory::decodeFile) | ||
| else -> context.resources.getIdentifier(uri, "drawable", context.packageName) | ||
| .takeIf { it != 0 } | ||
| ?.let { BitmapFactory.decodeResource(context.resources, it) } | ||
| } | ||
| }.getOrNull() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.