capacitor-plugin-status-bar 2.0.8 → 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);
@@ -497,11 +499,12 @@ public class CapacitorStatusBar extends Plugin {
497
499
 
498
500
  private void applyStatusBarBackground(Activity activity, @ColorInt int color) {
499
501
  Log.d(TAG, "applyStatusBarBackground: color=#" + Integer.toHexString(color) + ", API=" + Build.VERSION.SDK_INT);
500
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
501
- // 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
502
504
  ensureStatusBarOverlay(activity, color);
503
505
  } else {
504
- // 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().
505
508
  activity.getWindow().setStatusBarColor(color);
506
509
  }
507
510
  }
@@ -629,25 +632,32 @@ public class CapacitorStatusBar extends Plugin {
629
632
  */
630
633
  private void makeStatusBarBackgroundTransparent(Activity activity) {
631
634
  Log.d(TAG, "makeStatusBarBackgroundTransparent: API=" + Build.VERSION.SDK_INT);
635
+ Window window = activity.getWindow();
636
+ ViewGroup decorView = (ViewGroup) window.getDecorView();
632
637
 
633
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
634
- // Android 12+: Set overlay backgrounds to transparent
635
- ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
636
-
638
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
639
+ // Android 15+: both bars use overlay views
637
640
  View statusBarOverlay = decorView.findViewWithTag(STATUS_BAR_OVERLAY_TAG);
638
641
  if (statusBarOverlay != null) {
639
642
  statusBarOverlay.setBackgroundColor(Color.TRANSPARENT);
640
643
  Log.d(TAG, "makeStatusBarBackgroundTransparent: status bar overlay made transparent");
641
644
  }
642
-
643
645
  View navBarOverlay = decorView.findViewWithTag(NAV_BAR_OVERLAY_TAG);
644
646
  if (navBarOverlay != null) {
645
647
  navBarOverlay.setBackgroundColor(Color.TRANSPARENT);
646
- 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");
647
658
  }
648
659
  } else {
649
- // Android < 13: Use native window API directly
650
- Window window = activity.getWindow();
660
+ // Android < 12: both bars use native window API
651
661
  window.setStatusBarColor(Color.TRANSPARENT);
652
662
  window.setNavigationBarColor(Color.TRANSPARENT);
653
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.8",
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",