Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion framework/src/org/apache/cordova/SystemBarPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ public class SystemBarPlugin extends CordovaPlugin {
private int overrideStatusBarBackgroundColor = INVALID_COLOR;

private boolean canEdgeToEdge = false;
private String edgeToEdgeGlyphTheme = null;

@Override
protected void pluginInitialize() {
context = cordova.getContext();
resources = context.getResources();
canEdgeToEdge = preferences.getBoolean("AndroidEdgeToEdge", false);
edgeToEdgeGlyphTheme = preferences.getString("EdgeToEdgeGlyphTheme", null);

}

@Override
Expand Down Expand Up @@ -236,8 +239,20 @@ private void updateStatusBar(int bgColor) {
}

// Automatically set the font and icon color of the system bars based on background color.
// Determines whether to pass true to setAppearanceLightStatusBars().
// Despite what the official Android docs say, passing true results in DARK glyphs
// (suitable for light backgrounds) and passing false results in LIGHT glyphs
// (suitable for dark backgrounds).
//
// In edge-to-edge mode the nav bar background is transparent, so luminance-based
// detection doesn't work. The EdgeToEdgeGlyphTheme preference lets developers
// explicitly choose "dark" or "light" glyphs to match their app's background.
boolean isStatusBarBackgroundColorLight;
if(bgColor == Color.TRANSPARENT) {
if (canEdgeToEdge && "dark".equalsIgnoreCase(edgeToEdgeGlyphTheme)) {
isStatusBarBackgroundColorLight = true;
} else if (canEdgeToEdge && "light".equalsIgnoreCase(edgeToEdgeGlyphTheme)) {
isStatusBarBackgroundColorLight = false;
} else if(bgColor == Color.TRANSPARENT) {
isStatusBarBackgroundColorLight = isColorLight(getUiModeColor());
} else {
isStatusBarBackgroundColorLight = isColorLight(bgColor);
Expand Down
Loading