|
9 | 9 |
|
10 | 10 | package com.facebook.react.uimanager; |
11 | 11 |
|
| 12 | +import java.lang.reflect.InvocationTargetException; |
12 | 13 | import javax.annotation.Nullable; |
13 | 14 |
|
14 | 15 | import java.util.Arrays; |
15 | 16 | import java.util.List; |
16 | 17 | import java.util.Map; |
17 | 18 |
|
| 19 | +import android.content.Context; |
| 20 | +import android.os.Build; |
18 | 21 | import android.util.DisplayMetrics; |
| 22 | +import android.view.Display; |
| 23 | +import android.view.WindowManager; |
19 | 24 |
|
20 | 25 | import com.facebook.csslayout.CSSLayoutContext; |
21 | 26 | import com.facebook.infer.annotation.Assertions; |
@@ -85,6 +90,23 @@ public UIManagerModule( |
85 | 90 | super(reactContext); |
86 | 91 | mEventDispatcher = new EventDispatcher(reactContext); |
87 | 92 | DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics(); |
| 93 | + |
| 94 | + // Get the real display metrics if we are using API level 17 or higher. |
| 95 | + // The real metrics include system decor elements (e.g. soft menu bar). |
| 96 | + // |
| 97 | + // See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics) |
| 98 | + if (Build.VERSION.SDK_INT >= 17) { |
| 99 | + WindowManager wm = (WindowManager)reactContext.getApplicationContext().getSystemService(Context.WINDOW_SERVICE); |
| 100 | + |
| 101 | + try { |
| 102 | + Display display = wm.getDefaultDisplay(); |
| 103 | + Display.class.getMethod("getRealMetrics", DisplayMetrics.class).invoke(display, displayMetrics); |
| 104 | + } catch (InvocationTargetException e) { |
| 105 | + } catch (IllegalAccessException e) { |
| 106 | + } catch (NoSuchMethodException e) { |
| 107 | + } |
| 108 | + } |
| 109 | + |
88 | 110 | DisplayMetricsHolder.setDisplayMetrics(displayMetrics); |
89 | 111 | mModuleConstants = createConstants(displayMetrics, viewManagerList); |
90 | 112 | mUIImplementation = uiImplementation; |
|
0 commit comments