|
@@ -14,6 +14,8 @@ import com.facebook.react.uimanager.PixelUtil;
|
14
|
14
|
|
15
|
15
|
import java.util.Map;
|
16
|
16
|
|
|
17
|
+import androidx.annotation.Nullable;
|
|
18
|
+
|
17
|
19
|
/* package */ class SafeAreaUtils {
|
18
|
20
|
static WritableMap edgeInsetsToJsMap(EdgeInsets insets) {
|
19
|
21
|
WritableMap insetsMap = Arguments.createMap();
|
|
@@ -36,13 +38,16 @@ import java.util.Map;
|
36
|
38
|
PixelUtil.toDIPFromPixel(insets.left));
|
37
|
39
|
}
|
38
|
40
|
|
39
|
|
- static EdgeInsets getSafeAreaInsets(WindowManager windowManager, View rootView) {
|
|
41
|
+ static @Nullable EdgeInsets getSafeAreaInsets(WindowManager windowManager, View rootView) {
|
40
|
42
|
// Window insets are parts of the window that are covered by system views (status bar,
|
41
|
43
|
// navigation bar, notches). There are no apis the get these values for android < M so we
|
42
|
44
|
// do a best effort polyfill.
|
43
|
45
|
EdgeInsets windowInsets;
|
44
|
46
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
45
|
47
|
WindowInsets insets = rootView.getRootWindowInsets();
|
|
48
|
+ if (insets == null) {
|
|
49
|
+ return null;
|
|
50
|
+ }
|
46
|
51
|
windowInsets = new EdgeInsets(
|
47
|
52
|
insets.getSystemWindowInsetTop(),
|
48
|
53
|
insets.getSystemWindowInsetRight(),
|