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

Fix alert dialog support #555

Merged
merged 10 commits into from
Dec 15, 2024
Merged

Conversation

takahirom
Copy link
Owner

@takahirom takahirom commented Nov 15, 2024

close #554

Copy link

github-actions bot commented Dec 12, 2024

@takahirom takahirom changed the base branch from main to takahirom/refactor-test/2024-12-12 December 12, 2024 10:57
Base automatically changed from takahirom/refactor-test/2024-12-12 to main December 12, 2024 14:24
}

@InternalRoborazziApi
fun fetchRobolectricWindowRoots(): List<Root> {
Copy link
Owner Author

@takahirom takahirom Dec 14, 2024

Choose a reason for hiding this comment

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

This is the method we use for captureScreenRoboImage() to fetch windows.

@@ -169,6 +173,43 @@ fun captureScreenRoboImage(
}
}

@InternalRoborazziApi
fun captureScreenIfMultipleWindows(
Copy link
Owner Author

Choose a reason for hiding this comment

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

@sergio-sastre
Thanks as always. I'm thinking about adding support for the AlertDialog() Composable.
Currently, it throws an IllegalStateException, and I would like to fix that behavior.

The basic strategy here is to use captureScreenRoboImage() (which merges all windows into one screenshot) if there are multiple windows.
Do you have any thought on this?
image

Copy link
Contributor

@sergio-sastre sergio-sastre Dec 15, 2024

Choose a reason for hiding this comment

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

@takahirom
Oh sorry, I‘ve just seen this and also saw that it was merged.
I think it is fine as first solution.

Getting it right with the windows is a tricky one.

Have you tried by converting the corresponding ComposeView to bitmap and capturing a bitmap from it? That would likely avoid the IllegalStateException. However, I am not sure whether we could use PixelCopy to draw the bitmap with elevation.

what I mean is to use sth like this composeView.drawToBitmap().captureRoboImage()

maybe worth giving it a try?

@takahirom takahirom merged commit 371cce6 into main Dec 15, 2024
7 checks passed
@takahirom takahirom deleted the takahirom/add-alertdialog-test/2024-11-15 branch December 15, 2024 07:22
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.

Dialog in Compose Preview causes IllegalStateException in generated tests
2 participants