Commit d00c465
Fix screenshot API in Android implementation (#4107)
* Fix Android screenshot API to include PeerComponents
The screenshot() method in AndroidImplementation was missing PeerComponents
(native Android views like BrowserComponent, MapView, etc.) in the captured
image on devices running Android < API 26 (Oreo).
The issue was in the AndroidScreenshotTask.tryFallbackDraw() method, which
only drew the CodenameOneSurface view itself. PeerComponents are added as
siblings to the CodenameOneSurface within the parent RelativeLayout container,
so they were not being captured.
The fix:
- Draw the parent container (RelativeLayout) instead of just the view
- Calculate and apply proper canvas translation to align the content
- Maintain backward compatibility by falling back to view-only drawing
if no parent is found
Note: The PixelCopy method (API 26+) already worked correctly as it captures
the entire window, so this only affects older Android versions.
* Fixed Android screenshot test
---------
Co-authored-by: Claude <[email protected]>1 parent 72e3105 commit d00c465
File tree
2 files changed
+29
-2
lines changed- Ports/Android/src/com/codename1/impl/android
- scripts/android/screenshots
2 files changed
+29
-2
lines changedLines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
88 | 115 | | |
89 | 116 | | |
90 | 117 | | |
| |||
Loading
0 commit comments