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 status bar height calculation for all cutout sizes #44805

Closed
wants to merge 1 commit into from

Conversation

Abbondanzo
Copy link
Contributor

Summary:
Google has discouraged attempting to read the status_bar_height resource since 2017. With the introduction of display cutouts there can be a mismatch between the resource value and the true status bar size (and issues like this one popped up). The recommended approach is to instead call getInsets with the proper status bar and navigation flags provided by WindowInsets. On older APIs where getInsets is not supported, we have access to systemWindowInsetTop.

Changelog:
[Android][Fixed] - Fixed StatusBar.currentHeight calculations to honor all cutout sizes

Differential Revision: D58088036

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 5, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D58088036

@analysis-bot
Copy link

analysis-bot commented Jun 5, 2024

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,675,003 -13
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 23,044,513 -1
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: ce10ce4
Branch: main

Copy link

@JhonySpark JhonySpark left a comment

Choose a reason for hiding this comment

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

Good solution

Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Jun 5, 2024
Summary:

Google has discouraged attempting to read the `status_bar_height` resource [since 2017](https://youtu.be/_mGDMVRO3iE?si=qGQd7gLa_qTmfLGL&t=1079). With the introduction of display cutouts there can be a mismatch between the resource value and the true status bar size (and issues like [this one](facebook#33612) popped up). The recommended approach is to instead call `getInsets` with the proper status bar and navigation flags provided by `WindowInsets`. On older APIs where `getInsets` is not supported, we have access to `systemWindowInsetTop`.

Changelog:
[Android][Fixed] - Fixed StatusBar.currentHeight calculations to honor all cutout sizes

Differential Revision: D58088036
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D58088036

Summary:

Google has discouraged attempting to read the `status_bar_height` resource [since 2017](https://youtu.be/_mGDMVRO3iE?si=qGQd7gLa_qTmfLGL&t=1079). With the introduction of display cutouts there can be a mismatch between the resource value and the true status bar size (and issues like [this one](facebook#33612) popped up). The recommended approach is to instead call `getInsets` with the proper status bar and navigation flags provided by `WindowInsets`. On older APIs where `getInsets` is not supported, we have access to `systemWindowInsetTop`.

Changelog:
[Android][Fixed] - Fixed StatusBar.currentHeight calculations to honor all cutout sizes

Reviewed By: tdn120

Differential Revision: D58088036
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D58088036

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 10, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 0b8222a.

Copy link

This pull request was successfully merged by Peter Abbondanzo in 0b8222a.

When will my fix make it into a release? | How to file a pick request?

@Abbondanzo Abbondanzo deleted the export-D58088036 branch June 10, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants