Skip to content

Commit 42ea693

Browse files
committed
feat: add EdgeToEdgeGlyphTheme preference to SystemBarPlugin
References: https://outsystemsrd.atlassian.net/browse/RDMR-1284
1 parent 26f5ad0 commit 42ea693

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

framework/src/org/apache/cordova/SystemBarPlugin.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ public class SystemBarPlugin extends CordovaPlugin {
5050
private int overrideStatusBarBackgroundColor = INVALID_COLOR;
5151

5252
private boolean canEdgeToEdge = false;
53+
private String edgeToEdgeGlyphTheme = null;
5354

5455
@Override
5556
protected void pluginInitialize() {
5657
context = cordova.getContext();
5758
resources = context.getResources();
5859
canEdgeToEdge = preferences.getBoolean("AndroidEdgeToEdge", false)
5960
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM;
61+
edgeToEdgeGlyphTheme = preferences.getString("EdgeToEdgeGlyphTheme", null);
6062
}
6163

6264
@Override
@@ -237,8 +239,20 @@ private void updateStatusBar(int bgColor) {
237239
}
238240

239241
// Automatically set the font and icon color of the system bars based on background color.
242+
// Determines whether to pass true to setAppearanceLightStatusBars().
243+
// Despite what the official Android docs say, passing true results in DARK glyphs
244+
// (suitable for light backgrounds) and passing false results in LIGHT glyphs
245+
// (suitable for dark backgrounds).
246+
//
247+
// In edge-to-edge mode the nav bar background is transparent, so luminance-based
248+
// detection doesn't work. The EdgeToEdgeGlyphTheme preference lets developers
249+
// explicitly choose "dark" or "light" glyphs to match their app's background.
240250
boolean isStatusBarBackgroundColorLight;
241-
if(bgColor == Color.TRANSPARENT) {
251+
if (canEdgeToEdge && "dark".equalsIgnoreCase(edgeToEdgeGlyphTheme)) {
252+
isStatusBarBackgroundColorLight = true;
253+
} else if (canEdgeToEdge && "light".equalsIgnoreCase(edgeToEdgeGlyphTheme)) {
254+
isStatusBarBackgroundColorLight = false;
255+
} else if(bgColor == Color.TRANSPARENT) {
242256
isStatusBarBackgroundColorLight = isColorLight(getUiModeColor());
243257
} else {
244258
isStatusBarBackgroundColorLight = isColorLight(bgColor);

0 commit comments

Comments
 (0)