Skip to content

fix: use reflection for original StatusBar implementation discovery#1008

Merged
kirillzyusko merged 2 commits intomainfrom
fix/status-bar-reflection
Jul 6, 2025
Merged

fix: use reflection for original StatusBar implementation discovery#1008
kirillzyusko merged 2 commits intomainfrom
fix/status-bar-reflection

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Jul 6, 2025

📜 Description

Use reflection for StatusBarModule usage.

💡 Motivation and Context

It seems like in RN 0.80+ the StatusBarModule is internal now (kotlin). So we can't use ir directly anymore - moreover the usage of internal class will lead to compilation errors.

An ideal fix is to make it public again in react-native framework, but it'll take some time and some RN versions will still use internal modificator. So in order to assure better compatibility across different RN versions I decided to use reflection. We can not use the approach with Java's protected classes (where we create the same package name and export public wrapper), because kotlin has a stricter policy. So we have two options how to fix it:

  • reflection
  • copy-paste original code

We already use reflection in 2 places (though they will be removed in the future) I decided to add more usage and create StatusBarModuleProxy.

In this PR I also re-structured the fs and created statusbar folder where placed proxy + module implementations.

📢 Changelog

Android

  • created StatusBarModuleProxy based on reflection;
  • created statusbar folder;
  • update imports that use StatusBarModuleCompat;

🤔 How Has This Been Tested?

Tested on Pixel 3A (API 33, emulator).

📸 Screenshots (if appropriate):

Screen.Recording.2025-07-06.at.15.23.20.mov

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Jul 6, 2025
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🤖 android Android specific labels Jul 6, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 6, 2025

📊 Package size report

Current size Target Size Difference
207793 bytes 207238 bytes 555 bytes 📈

@kirillzyusko kirillzyusko marked this pull request as ready for review July 6, 2025 13:24
@kirillzyusko kirillzyusko merged commit 5a2e2a8 into main Jul 6, 2025
16 checks passed
@kirillzyusko kirillzyusko deleted the fix/status-bar-reflection branch July 6, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Android specific 🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant