Uh oh!
There was an error while loading. Please reload this page.
Use getRealMetrics for display metrics. Closes #4934 - #4935
Conversation
facebook-github-bot
commented
Dec 23, 2015
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.
Why not display.getRealMetrics?
There was a problem hiding this comment.
In case the method is missing (API < 17). As far as I can tell Rn supports 15+?
There was a problem hiding this comment.
@jaysoo Yes, but you're already checking Build.VERSION.SDK_INT >= 17
af5906c to
0c65ffaComparefacebook-github-bot
commented
Dec 23, 2015
@jaysoo updated the pull request. |
jaysoo
commented
Dec 23, 2015
@satya164 Updated the PR to not silently catch exceptions. Reflection exceptions are logged using |
There was a problem hiding this comment.
Why use Reflection if you're already checking Build.VERSION.SDK_INT >= 17?
0c65ffa to
f86a428Comparefacebook-github-bot
commented
Dec 23, 2015
@jaysoo updated the pull request. |
f86a428 to
897c930Comparefacebook-github-bot
commented
Dec 23, 2015
@jaysoo updated the pull request. |
jaysoo
commented
Dec 23, 2015
@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.
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).
mkonicek
commented
Dec 24, 2015
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. |
jaysoo
commented
Dec 24, 2015
@mkonicek Thanks for the feedback. I'll make the changes tonight. :) |
897c930 to
4e62be9Comparefacebook-github-bot
commented
Dec 24, 2015
@jaysoo updated the pull request. |
4e62be9 to
f664a4cComparejaysoo
commented
Dec 24, 2015
@mkonicek Updated the PR:
|
facebook-github-bot
commented
Dec 24, 2015
@jaysoo updated the pull request. |
getRealMetrics for display metricsgetRealMetrics for display metrics. Closes #4934facebook-github-bot
commented
Jan 7, 2016
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. |
satya164
commented
Jan 22, 2016
ping @bestander :) |
bestander
commented
Jan 25, 2016
bumped @astreet, he controls the ship |
mkonicek
commented
Jan 26, 2016
Looks like internal integration tests are failing but can't tell if it's related. Open sourcing them will help. |
bestander
commented
Jan 26, 2016
on it now |
bestander
commented
Jan 26, 2016
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. |
jaysoo
commented
Jan 26, 2016
@bestander Sure, I'd be happy to. :) Is there anything I should keep in mind for the tests? |
bestander
commented
Jan 27, 2016
@jaysoo, nothing too special. Here is a sample I am importing: |
bestander
commented
Jan 27, 2016
50fd080 to
e09f29eComparefacebook-github-bot
commented
Jan 28, 2016
@jaysoo updated the pull request. |
jaysoo
commented
Jan 28, 2016
@bestander taking a quick look now. Sorry for delay. |
jaysoo
commented
Jan 28, 2016
@bestander Ran |
bestander
commented
Jan 28, 2016
Now it feels strange 0_o |
bestander
commented
Jan 28, 2016
I was quite sure that tests would fail in circleCI but they passed just fine. |
bestander
commented
Jan 28, 2016
@facebook-github-bot shipit |
facebook-github-bot
commented
Jan 28, 2016
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. |
bestander
commented
Jan 29, 2016
@jaysoo just a heads up, I found the issue with our internal test runners. |
bestander
commented
Feb 1, 2016
jaysoo
commented
Feb 1, 2016
@bestander You sir are awesome! Thanks for the help! And everyone else on this issue. 💯 |
ide
commented
Feb 4, 2016
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

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.