Commit ecb3595
authored
refactor: do not rely on deep imports (#1000)
## 📜 Description
Don't rely on deep imports and provide a warning free compatibility with
RN 0.80+ (by utilizing a more official and reliable way to substitute
native module implementation).
## 💡 Motivation and Context
Starting from `react-native@0.80` deep imports were deprecated and now
if you try to use them you get a warning:
> Deep imports from the 'react-native' package are deprecated
In version `0.82` the ability to use deep imports will be completely
removed. In preparation of that RN team opened a discussion on GitHub
about those upcoming changes.
This library uses deep imports to substitute `StatusBar` implementation.
I
[opened](react-native-community/discussions-and-proposals#893 (comment))
a thread to discuss how we can overcome it. While waiting for a proposed
solution I discovered, that we can override native modules with own
implementation - this is the case that I want to use. I want to
substitute the implementation of `StatusBar` and fallback to default
implementation if `EdgeToEdge` view is disabled.
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### JS
- remove `monkey-patch` code;
### Android
- rename `StatusBarManagerCompat` to `StatusBarManager` to match name of
original module;
- added `getConstants` method;
- `StatusBarManagerCompat` now can override existing modules;
- make `active` prop public;
- make `setActive` setter field-setter to avoid compilation conflicts;
- `StatusBarManagerCompat` now respects `active` props and fallbacks to
`StatusBarManager` implementation if `edge-to-edge` view is disabled;
- added helpers like `isEnabled`/`view` to `StatusBarManagerCompat` to
reduce code duplication.
## 🤔 How Has This Been Tested?
Tested manually on:
- Pixel 7 Pro (API 36, real device);
- Pixel 3A (API 33, emulator);
## 📸 Screenshots (if appropriate):
https://github.com/user-attachments/assets/44a7e019-446b-4c7e-903f-7d4c87882b74
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed1 parent 60ec0ce commit ecb3595
10 files changed
Lines changed: 44 additions & 74 deletions
File tree
- android/src
- base/java/com/reactnativekeyboardcontroller
- fabric/java/com/reactnativekeyboardcontroller
- main/java/com/reactnativekeyboardcontroller
- managers
- modules
- views
- paper/java/com/reactnativekeyboardcontroller
- turbo/java/com/reactnativekeyboardcontroller
- src
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
| |||
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
64 | 78 | | |
65 | | - | |
66 | | - | |
| 79 | + | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
70 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
74 | 91 | | |
75 | 92 | | |
| 93 | + | |
| 94 | + | |
76 | 95 | | |
77 | 96 | | |
78 | 97 | | |
| |||
94 | 113 | | |
95 | 114 | | |
96 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
97 | 121 | | |
98 | | - | |
| 122 | + | |
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
Lines changed: 9 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
| |||
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 234 | | |
237 | 235 | | |
238 | 236 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | 218 | | |
229 | 219 | | |
230 | 220 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments