diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 52e6a764d2ca74..de7f5fc59248d5 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -198,7 +198,10 @@ class StatusBar extends React.Component { static _defaultProps = createStackEntry({ animated: false, showHideTransition: 'fade', - backgroundColor: 'black', + backgroundColor: Platform.select({ + android: StatusBarManager.DEFAULT_BACKGROUND_COLOR ?? 'black', + ios: 'black', + }), barStyle: 'default', translucent: false, hidden: false, diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java index ce7a96f93ca895..e21912b5129a93 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java @@ -38,6 +38,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule { private static final String HEIGHT_KEY = "HEIGHT"; + private static final String DEFAULT_BACKGROUND_COLOR_KEY = "DEFAULT_BACKGROUND_COLOR"; public static final String NAME = "StatusBarManager"; public StatusBarModule(ReactApplicationContext reactContext) { @@ -52,14 +53,22 @@ public String getName() { @Override public @Nullable Map getConstants() { final Context context = getReactApplicationContext(); + final Activity activity = getCurrentActivity(); + final int heightResId = context.getResources() .getIdentifier("status_bar_height", "dimen", "android"); final float height = heightResId > 0 ? PixelUtil.toDIPFromPixel(context.getResources().getDimensionPixelSize(heightResId)) : 0; + String statusBarColorString = "black"; + + if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + final int statusBarColor = activity.getWindow().getStatusBarColor(); + statusBarColorString = String.format("#%06X", (0xFFFFFF & statusBarColor)); + } return MapBuilder.of( - HEIGHT_KEY, height); + HEIGHT_KEY, height, DEFAULT_BACKGROUND_COLOR_KEY, statusBarColorString); } @ReactMethod