Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StatusBar on Android API 30 #33058

Closed
wants to merge 1 commit into from

Conversation

ieatfood
Copy link
Contributor

@ieatfood ieatfood commented Feb 7, 2022

Summary

In #32975 I implemented the new insetsController#setSystemBarsAppearance interface, but I found that on Android 11 (API 30) it doesn't appear to work which I missed in earlier testing. It works correctly on Android 12 and the deprecated systemUiVisibility interface still works fine on Android 11, so I'm having Android 11 use the deprecated mechanism.

Changelog

[Android] [Fixed] - Fix StatusBar on Android API 30

Test Plan

Tested in rn-tester on simulators using Android 9, 10, 11, 12, and on an Android 9 device.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Feb 7, 2022
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Feb 7, 2022
@facebook-github-bot
Copy link
Contributor

@ShikaSD has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

// Although systemUiVisibility is deprecated in API 30, insetsController doesn't work
// reliably and both mechanisms can affect the style. It works properly in API 31, so
// use both mechanisms on API 30 only.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do Build.VERSION.SDK_INT > Build.VERSION_CODES.R instead? Why use both ways at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I wasn't confident that even though the new way didn't appear to work on API 30 for me that it still wasn't doing something.

Changing to > would be cleaner and I can do that if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and went ahead and updated it to just >.

@ieatfood ieatfood force-pushed the android_30_statusbar_fix branch from 737b513 to d236bc6 Compare February 8, 2022 18:53
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: cd79317
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,120,914 +593
android hermes armeabi-v7a 7,720,893 -790
android hermes x86 8,490,385 -719
android hermes x86_64 8,442,342 -594
android jsc arm64-v8a 9,787,616 +496
android jsc armeabi-v7a 8,772,475 -896
android jsc x86 9,753,677 -834
android jsc x86_64 10,349,726 -704

Base commit: cd79317
Branch: main

@facebook-github-bot
Copy link
Contributor

@ShikaSD has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ieatfood in 9ed2df6.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Feb 10, 2022
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
Summary:
In facebook#32975 I implemented the new `insetsController#setSystemBarsAppearance` interface, but I found that on Android 11 (API 30) it doesn't appear to work which I missed in earlier testing. It works correctly on Android 12 and the deprecated `systemUiVisibility` interface still works fine on Android 11, so I'm having Android 11 use the deprecated mechanism.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix StatusBar on Android API 30

Pull Request resolved: facebook#33058

Test Plan: Tested in `rn-tester` on simulators using Android 9, 10, 11, 12, and on an Android 9 device.

Reviewed By: lunaleaps

Differential Revision: D34050025

Pulled By: ShikaSD

fbshipit-source-id: ad80fae1446aca368b09df810785a1cc38383450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants