Skip to content

Commit

Permalink
Fixed getSoftMenuBarHeight() not returning the right value on notched…
Browse files Browse the repository at this point in the history
… devices (#50)
  • Loading branch information
mathieubruguier authored and Sunhat committed Apr 2, 2019
1 parent da3e749 commit c41652e
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,12 @@ private float getSoftMenuBarHeight(DisplayMetrics metrics) {
if(hasPermanentMenuKey()) {
return 0;
}
final float realHeight = getRealHeight(metrics);
final Context ctx = getReactApplicationContext();
final DisplayMetrics usableMetrics = ctx.getResources().getDisplayMetrics();

// Passing getMetrics will update the value of the Object DisplayMetrics metrics
((WindowManager) mReactContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getMetrics(metrics);
final int usableHeight = usableMetrics.heightPixels;

return Math.max(0, realHeight - usableHeight / metrics.density);
final int heightResId = ctx.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
return
heightResId > 0
? ctx.getResources().getDimensionPixelSize(heightResId) / metrics.density
: 0;
}

private float getRealHeight(DisplayMetrics metrics) {
Expand Down

0 comments on commit c41652e

Please sign in to comment.