Skip to content
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

[andr][replay] Handle hybrid AndroidViews inside Compose #126

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

murki
Copy link
Contributor

@murki murki commented Nov 18, 2024

This took an embarrassingly long time to figure out, but after following the rabbit hole in https://github.com/androidx/androidx/blob/48f6421f6615572456ee94984209cd110a4694d4/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/accessibility/android_a11y_implementation_notes.md#androidview-children I realized that the Compose LayoutNode has an (internal) reference to the legacy AndroidView if it exists.

In the example below we're creating an hybrid view via:

AndroidView(
factory = { context ->
TextView(context).apply {
movementMethod = LinkMovementMethod.getInstance()
}
},
update = {
it.text = htmlDescription
}
)

Screen Before After
Screenshot 2024-11-18 at 10 52 38 AM Screenshot 2024-11-18 at 10 52 51 AM Screenshot 2024-11-18 at 10 52 59 AM

@murki murki requested review from Reflejo and snowp November 18, 2024 16:27
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So simple!

@murki murki merged commit 12b60ff into main Nov 18, 2024
15 checks passed
@murki murki deleted the murki/bit-2947-support-legacy-androidviews-inside-compose branch November 18, 2024 18:00
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants