Repository navigation
Commit 0ea7132
authored
feat(android) -
## Summary:
- Adds support for loading images with `url` syntax. e.g. `backgroundImage: url("https://example.com/1.png")`.
- `background-repeat: round` now uses at least one tile, as CSS requires. This also changes gradients whose tile is more than twice the size of the box.
- This PR only includes android code changes. To fully test the PR, merge #58246 (JS/parser) and #58248 (iOS) into this one.
> Recreated from #54994, which was auto-closed when my fork was deleted. GitHub does not allow reopening a PR whose head repository is gone. Rebased onto current `main`.
### How:
Uses Fresco's image pipeline to fetch the image in `BackgroundImageURLLoader`. Keeps Fresco's `CloseableReference` open and draws the shared bitmap in the `BackgroundImageDrawable` canvas using `drawBitmap`, like Fresco's drawee. Background images with the same url share one bitmap. The reference is released when the url changes or the view is dropped.
## Changelog:
[ANDROID] [ADDED] - `url` support with `backgroundImage`
## Test Plan:
- Merge #58246, this PR and #58248, then test the examples added in the JS PR.
- Added unit tests: `./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.uimanager.drawable.*' --tests 'com.facebook.react.uimanager.style.BackgroundImageLayerTest'`
### Screenshots
Each `url()` example in RN Tester, opened by deep link, on the Android emulator, with all three PRs merged:
| URL Image | URL Image from local file | Local file at its natural size (@3x asset, 33x33) |
| --- | --- | --- |
| <img src="https://raw.githubusercontent.com/intergalacticspacehighway/react-native/c7893b2cc494b383efc609a82f71b1ceda0e6411/android-1.png" width="100" /> | <img src="https://raw.githubusercontent.com/intergalacticspacehighway/react-native/c7893b2cc494b383efc609a82f71b1ceda0e6411/android-2.png" width="100" /> | <img src="https://raw.githubusercontent.com/intergalacticspacehighway/react-native/c7893b2cc494b383efc609a82f71b1ceda0e6411/android-3.png" width="100" /> |
### Follow-ups
- Decode images at the size they are drawn, instead of full size.
- `cover` and `contain` support for `backgroundSize`.
Differential Revision: D131256210
Pull Request resolved: #58247url function support in backgroundImage
1 parent 3c504a7 commit 0ea7132
7 files changed
Lines changed: 508 additions & 39 deletions
File tree
- packages/react-native/ReactAndroid/src
- main/java/com/facebook/react
- uimanager
- drawable
- style
- views/view
- test/java/com/facebook/react/uimanager
- drawable
- style
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
62 | 80 | | |
63 | 81 | | |
64 | 82 | | |
65 | 83 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
74 | 91 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
82 | 107 | | |
83 | 108 | | |
84 | 109 | | |
| |||
95 | 120 | | |
96 | 121 | | |
97 | 122 | | |
| 123 | + | |
98 | 124 | | |
99 | 125 | | |
100 | 126 | | |
101 | 127 | | |
102 | 128 | | |
| 129 | + | |
103 | 130 | | |
104 | 131 | | |
105 | 132 | | |
| |||
129 | 156 | | |
130 | 157 | | |
131 | 158 | | |
132 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
133 | 165 | | |
134 | 166 | | |
135 | 167 | | |
| |||
166 | 198 | | |
167 | 199 | | |
168 | 200 | | |
169 | | - | |
| 201 | + | |
170 | 202 | | |
171 | 203 | | |
172 | 204 | | |
| |||
195 | 227 | | |
196 | 228 | | |
197 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
198 | 255 | | |
199 | 256 | | |
200 | 257 | | |
201 | 258 | | |
202 | 259 | | |
203 | | - | |
204 | | - | |
| 260 | + | |
| 261 | + | |
205 | 262 | | |
206 | 263 | | |
| 264 | + | |
207 | 265 | | |
208 | 266 | | |
209 | 267 | | |
210 | 268 | | |
211 | 269 | | |
212 | 270 | | |
213 | | - | |
214 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
215 | 277 | | |
216 | 278 | | |
217 | 279 | | |
| |||
303 | 365 | | |
304 | 366 | | |
305 | 367 | | |
| 368 | + | |
306 | 369 | | |
307 | 370 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
316 | 387 | | |
317 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
318 | 392 | | |
319 | 393 | | |
320 | 394 | | |
| |||
0 commit comments