capacitor-plugin-status-bar 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,12 +58,14 @@ public class CapacitorStatusBar extends Plugin {
58
58
  View decorView = window.getDecorView();
59
59
 
60
60
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
61
- // Android 12+ (API 31+): Full edge-to-edge with overlay views.
62
- // Android 12+ gesture navigation ignores setStatusBarColor/setNavigationBarColor;
63
- // Android 15+ (API 35) enforces edge-to-edge mandatory. All require the overlay approach.
61
+ // Android 12+ (API 31+): enable edge-to-edge layout.
62
+ // The nav bar uses overlay views because gesture navigation ignores setNavigationBarColor().
63
+ // The status bar still uses setStatusBarColor() reliably on API 31–34;
64
+ // overlay is only needed on API 35+ where edge-to-edge is enforced and the native API is a no-op.
64
65
  WindowCompat.setDecorFitsSystemWindows(window, false);
65
66
 
66
- // Make native bar colors transparent so our overlays are the sole color source
67
+ // Set a transparent baseline; setStyle() will apply the actual color via setStatusBarColor()
68
+ // (API 31-34) or the status bar overlay (API 35+).
67
69
  window.setStatusBarColor(Color.TRANSPARENT);
68
70
  window.setNavigationBarColor(Color.TRANSPARENT);
69
71
  window.setStatusBarContrastEnforced(false);
@@ -216,30 +218,23 @@ public class CapacitorStatusBar extends Plugin {
216
218
  currentStyle = style;
217
219
  currentColorHex = colorHex;
218
220
 
219
- // Set icon appearance (light/dark) regardless of background approach
221
+ // Determine icon appearance based on style
220
222
  boolean lightBackground;
221
223
  if ("LIGHT".equalsIgnoreCase(style)) {
222
- // Light background -> dark icons
223
- setLightStatusBarIcons(window, true);
224
224
  lightBackground = true;
225
225
  } else if ("DARK".equalsIgnoreCase(style)) {
226
- // Dark background -> light icons
227
- setLightStatusBarIcons(window, false);
228
226
  lightBackground = false;
229
227
  } else if ("CUSTOM".equalsIgnoreCase(style)) {
230
228
  // CUSTOM: Derive icon color from provided custom color
231
229
  int parsed = parseColorOrDefault(colorHex, Color.BLACK);
232
- boolean isLight = isEffectiveLightColor(parsed);
233
- // If background is light, request dark icons
234
- setLightStatusBarIcons(window, isLight);
235
- lightBackground = isLight;
230
+ lightBackground = isEffectiveLightColor(parsed);
236
231
  } else {
237
232
  // Default: Auto-detect based on system theme (follow device theme)
238
233
  boolean isSystemDarkMode = isSystemInDarkMode(activity);
239
- setLightStatusBarIcons(window, !isSystemDarkMode);
240
234
  lightBackground = !isSystemDarkMode;
241
235
  }
242
236
 
237
+ // Apply background colors first
243
238
  if ("CUSTOM".equalsIgnoreCase(style) && colorHex != null) {
244
239
  int color = parseColorOrDefault(colorHex, lightBackground ? Color.WHITE : Color.BLACK);
245
240
  currentStatusBarColor = color;
@@ -265,6 +260,12 @@ public class CapacitorStatusBar extends Plugin {
265
260
  applyStatusBarBackground(activity, themeColor);
266
261
  applyNavigationBarBackground(activity, themeColor);
267
262
  }
263
+
264
+ // Set icon appearance AFTER background operations.
265
+ // On Android 13 (API 33), applyStatusBarBackground triggers requestApplyInsets()
266
+ // which causes the WindowInsetsController to reset setSystemBarsAppearance.
267
+ // Calling setLightStatusBarIcons last ensures the icon style is not overridden.
268
+ setLightStatusBarIcons(window, lightBackground);
268
269
  }
269
270
 
270
271
  /**
@@ -498,11 +499,12 @@ public class CapacitorStatusBar extends Plugin {
498
499
 
499
500
  private void applyStatusBarBackground(Activity activity, @ColorInt int color) {
500
501
  Log.d(TAG, "applyStatusBarBackground: color=#" + Integer.toHexString(color) + ", API=" + Build.VERSION.SDK_INT);
501
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
502
- // Android 12+: Use overlay views (gesture nav ignores setStatusBarColor; mandatory on 15+)
502
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
503
+ // Android 15+ (API 35+): edge-to-edge is enforced, setStatusBarColor() is a no-op
503
504
  ensureStatusBarOverlay(activity, color);
504
505
  } else {
505
- // Android < 12: Use native window API directly
506
+ // API 29–34: setStatusBarColor() works reliably for the status bar on all navigation modes.
507
+ // Note: gesture navigation only ignores setNavigationBarColor(), not setStatusBarColor().
506
508
  activity.getWindow().setStatusBarColor(color);
507
509
  }
508
510
  }
@@ -630,25 +632,32 @@ public class CapacitorStatusBar extends Plugin {
630
632
  */
631
633
  private void makeStatusBarBackgroundTransparent(Activity activity) {
632
634
  Log.d(TAG, "makeStatusBarBackgroundTransparent: API=" + Build.VERSION.SDK_INT);
635
+ Window window = activity.getWindow();
636
+ ViewGroup decorView = (ViewGroup) window.getDecorView();
633
637
 
634
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
635
- // Android 12+: Set overlay backgrounds to transparent
636
- ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
637
-
638
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
639
+ // Android 15+: both bars use overlay views
638
640
  View statusBarOverlay = decorView.findViewWithTag(STATUS_BAR_OVERLAY_TAG);
639
641
  if (statusBarOverlay != null) {
640
642
  statusBarOverlay.setBackgroundColor(Color.TRANSPARENT);
641
643
  Log.d(TAG, "makeStatusBarBackgroundTransparent: status bar overlay made transparent");
642
644
  }
643
-
644
645
  View navBarOverlay = decorView.findViewWithTag(NAV_BAR_OVERLAY_TAG);
645
646
  if (navBarOverlay != null) {
646
647
  navBarOverlay.setBackgroundColor(Color.TRANSPARENT);
647
- Log.d(TAG, "makeStatusBarBackgroundTransparent: navigation bar overlay made transparent");
648
+ Log.d(TAG, "makeStatusBarBackgroundTransparent: nav bar overlay made transparent");
649
+ }
650
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
651
+ // Android 12–14: status bar uses native API, nav bar uses overlay
652
+ window.setStatusBarColor(Color.TRANSPARENT);
653
+ Log.d(TAG, "makeStatusBarBackgroundTransparent: status bar color set transparent (native)");
654
+ View navBarOverlay = decorView.findViewWithTag(NAV_BAR_OVERLAY_TAG);
655
+ if (navBarOverlay != null) {
656
+ navBarOverlay.setBackgroundColor(Color.TRANSPARENT);
657
+ Log.d(TAG, "makeStatusBarBackgroundTransparent: nav bar overlay made transparent");
648
658
  }
649
659
  } else {
650
- // Android < 13: Use native window API directly
651
- Window window = activity.getWindow();
660
+ // Android < 12: both bars use native window API
652
661
  window.setStatusBarColor(Color.TRANSPARENT);
653
662
  window.setNavigationBarColor(Color.TRANSPARENT);
654
663
  Log.d(TAG, "makeStatusBarBackgroundTransparent: set native bar colors to transparent");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-status-bar",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "Capacitor plugin for managing the status bar style, visibility, and color on iOS and Android. Control overlay modes, background colors, and appearance for native mobile applications.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",