-
Couldn't load subscription status.
- Fork 24.9k
Use getRealMetrics for display metrics. Closes #4934
#4935
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
Conversation
|
By analyzing the blame information on this pull request, we identified @mkonicek, @astreet and @andreicoman11 to be potential reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not display.getRealMetrics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case the method is missing (API < 17). As far as I can tell Rn supports 15+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaysoo Yes, but you're already checking Build.VERSION.SDK_INT >= 17
af5906c to
0c65ffa
Compare
|
@jaysoo updated the pull request. |
|
@satya164 Updated the PR to not silently catch exceptions. Reflection exceptions are logged using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use Reflection if you're already checking Build.VERSION.SDK_INT >= 17?
0c65ffa to
f86a428
Compare
|
@jaysoo updated the pull request. |
f86a428 to
897c930
Compare
|
@jaysoo updated the pull request. |
|
@satya164 Removed reflection usage. I was worried about compiling it on API 16. Tried it using emulator, and it seems like there's no problem. This also removes the try-catch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any of this fails (getSystemService returns null, the result is not of type WindowManager etc.) we probably don't want to crash the whole UIManagerModule. Can you wrap all of this in a try-catch block and log the exception using FLog (check other call sites of FLog for examples).
|
Looks legit, thanks a lot for the PR! Note that almost the whole team is on vacation until the end of the year so we'll be very slow on code review until the beginning of January. |
|
@mkonicek Thanks for the feedback. I'll make the changes tonight. :) |
897c930 to
4e62be9
Compare
|
@jaysoo updated the pull request. |
4e62be9 to
f664a4c
Compare
|
@mkonicek Updated the PR:
|
|
@jaysoo updated the pull request. |
getRealMetrics for display metricsgetRealMetrics for display metrics. Closes #4934
|
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/884116028375399/int_phab to review. |
|
ping @bestander :) |
|
bumped @astreet, he controls the ship |
|
Looks like internal integration tests are failing but can't tell if it's related. Open sourcing them will help. |
|
on it now |
|
Hi @jaysoo, I figured out what the problem was. First I tried to put a fix in your PR to make the dimensions mockable but failed to find a quick way to do it. |
|
@bestander Sure, I'd be happy to. :) Is there anything I should keep in mind for the tests? |
|
@jaysoo, nothing too special. Here is a sample I am importing: |
50fd080 to
e09f29e
Compare
|
@jaysoo updated the pull request. |
|
@bestander taking a quick look now. Sorry for delay. |
|
@bestander Ran |
|
Now it feels strange 0_o |
|
I was quite sure that tests would fail in circleCI but they passed just fine. |
|
@facebook-github-bot shipit |
|
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/884116028375399/int_phab to review. |
|
@jaysoo just a heads up, I found the issue with our internal test runners. |
|
@bestander You sir are awesome! Thanks for the help! And everyone else on this issue. 💯 |
|
The real metrics probably should be exposed via |
Summary: public #4935 changed the window dimensions for android by replacing them with the actual screen dimensions. This changes the window dimensions back to their original values and adds `Dimensions.get('screen')` for the actual screen dimensions of the device. Reviewed By: astreet Differential Revision: D2921584 fb-gh-sync-id: 5d2677029c71d50691691dc651a11e9c8b115e8f shipit-source-id: 5d2677029c71d50691691dc651a11e9c8b115e8f
Summary: public #4935 changed the window dimensions for android by replacing them with the actual screen dimensions. This changes the window dimensions back to their original values and adds `Dimensions.get('screen')` for the actual screen dimensions of the device. Reviewed By: astreet Differential Revision: D2921584 fb-gh-sync-id: 5d2677029c71d50691691dc651a11e9c8b115e8f shipit-source-id: 5d2677029c71d50691691dc651a11e9c8b115e8f
Summary: public facebook#4935 changed the window dimensions for android by replacing them with the actual screen dimensions. This changes the window dimensions back to their original values and adds `Dimensions.get('screen')` for the actual screen dimensions of the device. Reviewed By: astreet Differential Revision: D2921584 fb-gh-sync-id: 5d2677029c71d50691691dc651a11e9c8b115e8f shipit-source-id: 5d2677029c71d50691691dc651a11e9c8b115e8f
|
Solution |

Fixes #4934.
Since API level 17, there has a
Display.getRealMetricsmethod. This allows us to get the actual sizes of the screen (including soft menu bar and other system decor elements).See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
I'm not sure if there is a good way to write unit or integration tests for this. Please let me know if there are any suggestions or concerns.