Pin screenshot dimensions to fixed dp size#48
Draft
EmilioBejasa wants to merge 12 commits intomainfrom
Draft
Conversation
Use ViewHelpers to layout the content view at a fixed 360x640dp before snapping, so screenshots are consistent regardless of emulator screen size. Also snaps android.R.id.content instead of the decor view root to exclude the status and navigation bars. Both dimensions are overridable via getScreenshotWidthDp() and getScreenshotHeightDp(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Get the first child of the content FrameLayout (the React Native root view) to exclude status bar and navigation bar black bars from screenshots. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Draw the full window to a Bitmap, then use the content view's global visible rect to crop out the status bar and navigation bar. The cropped result is rendered in an ImageView at fixed dp dimensions before snapping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
getGlobalVisibleRect returns full screen bounds with edge-to-edge rendering. Use WindowInsets.Type.statusBars/navigationBars to get exact pixel insets for cropping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FIT_CENTER was adding gray bars when the cropped bitmap's aspect ratio didn't exactly match the target dp size. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Scale the system-bar-cropped bitmap to exact target pixel dimensions before rendering in ImageView, eliminating any size mismatch that caused letterboxing bars. Apply the same crop-and-scale approach to ScreenshotTest.testActualApp so all screenshots are bar-free and consistently sized. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WindowInsets may return 0 in instrumentation test context. Use resources.getIdentifier for status_bar_height and navigation_bar_height which work reliably regardless of context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
android.R.id.content is positioned between system bars, so no bitmap manipulation or inset calculation is needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
android.R.id.content is full-screen-sized in AppCompat; system bar heights are applied as padding to it. Its first child (the React root view) is already sized to the usable area between bars. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This API directly returns the rect between system bars without any guessing about inset heights or view hierarchy navigation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ViewHelpers.setupView()to layout the content view at a fixed 360x640dp before snapping screenshotsandroid.R.id.contentinstead ofdecorView.rootViewto exclude status/navigation barsgetScreenshotWidthDp()andgetScreenshotHeightDp()Test plan
🤖 Generated with Claude Code