|
38 | 38 | import android.widget.FrameLayout; |
39 | 39 | import androidx.annotation.Nullable; |
40 | 40 | import androidx.annotation.RequiresApi; |
| 41 | +import androidx.core.view.ViewCompat; |
| 42 | +import androidx.core.view.WindowInsetsCompat; |
41 | 43 | import androidx.window.layout.WindowMetricsCalculator; |
42 | 44 | import com.facebook.common.logging.FLog; |
43 | 45 | import com.facebook.infer.annotation.Assertions; |
@@ -1024,13 +1026,25 @@ private void checkForKeyboardEventsLegacy() { |
1024 | 1026 | } |
1025 | 1027 | } |
1026 | 1028 |
|
| 1029 | + int heightPixels = getContext().getResources().getDisplayMetrics().heightPixels; |
1027 | 1030 | final ReactContext reactContext = getCurrentReactContext(); |
1028 | 1031 | final Activity activity = reactContext != null ? reactContext.getCurrentActivity() : null; |
1029 | 1032 |
|
1030 | | - final int heightPixels = activity != null && WindowUtilKt.isEdgeToEdgeFeatureFlagOn() |
1031 | | - ? WindowMetricsCalculator.getOrCreate() |
1032 | | - .computeCurrentWindowMetrics(activity).getBounds().height() |
1033 | | - : getContext().getResources().getDisplayMetrics().heightPixels; |
| 1033 | + if (activity != null) { |
| 1034 | + heightPixels = WindowMetricsCalculator.getOrCreate() |
| 1035 | + .computeCurrentWindowMetrics(activity).getBounds().height(); |
| 1036 | + |
| 1037 | + if (!WindowUtilKt.isEdgeToEdgeFeatureFlagOn()) { |
| 1038 | + WindowInsetsCompat rootWindowInsets = |
| 1039 | + ViewCompat.getRootWindowInsets(activity.getWindow().getDecorView()); |
| 1040 | + |
| 1041 | + if (rootWindowInsets != null) { |
| 1042 | + androidx.core.graphics.Insets insets = |
| 1043 | + rootWindowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); |
| 1044 | + heightPixels -= (insets.top + insets.bottom); |
| 1045 | + } |
| 1046 | + } |
| 1047 | + } |
1034 | 1048 |
|
1035 | 1049 | final int heightDiff = heightPixels - mVisibleViewArea.bottom + notchHeight; |
1036 | 1050 |
|
|
0 commit comments