capacitor-plugin-status-bar 2.0.8 → 2.0.10
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+):
|
|
62
|
-
//
|
|
63
|
-
//
|
|
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
|
-
//
|
|
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.
|
|
501
|
-
// Android
|
|
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
|
-
//
|
|
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
|
}
|
|
@@ -509,11 +512,13 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
509
512
|
private void applyNavigationBarBackground(Activity activity, @ColorInt int color) {
|
|
510
513
|
Log.d(TAG, "applyNavigationBarBackground: color=#" + Integer.toHexString(color) + ", API="
|
|
511
514
|
+ Build.VERSION.SDK_INT);
|
|
512
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.
|
|
513
|
-
// Android
|
|
515
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
516
|
+
// Android 15+ (API 35+): edge-to-edge enforced, setNavigationBarColor() is a no-op
|
|
514
517
|
ensureNavBarOverlay(activity, color);
|
|
515
518
|
} else {
|
|
516
|
-
//
|
|
519
|
+
// API 29–34: setNavigationBarColor() works for button navigation.
|
|
520
|
+
// Gesture navigation ignores it (system enforces transparency for gesture handles),
|
|
521
|
+
// but in that case there is no visible nav bar to color anyway.
|
|
517
522
|
activity.getWindow().setNavigationBarColor(color);
|
|
518
523
|
}
|
|
519
524
|
}
|
|
@@ -629,25 +634,23 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
629
634
|
*/
|
|
630
635
|
private void makeStatusBarBackgroundTransparent(Activity activity) {
|
|
631
636
|
Log.d(TAG, "makeStatusBarBackgroundTransparent: API=" + Build.VERSION.SDK_INT);
|
|
637
|
+
Window window = activity.getWindow();
|
|
638
|
+
ViewGroup decorView = (ViewGroup) window.getDecorView();
|
|
632
639
|
|
|
633
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.
|
|
634
|
-
// Android
|
|
635
|
-
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
|
|
636
|
-
|
|
640
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
641
|
+
// Android 15+: both bars use overlay views
|
|
637
642
|
View statusBarOverlay = decorView.findViewWithTag(STATUS_BAR_OVERLAY_TAG);
|
|
638
643
|
if (statusBarOverlay != null) {
|
|
639
644
|
statusBarOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
640
645
|
Log.d(TAG, "makeStatusBarBackgroundTransparent: status bar overlay made transparent");
|
|
641
646
|
}
|
|
642
|
-
|
|
643
647
|
View navBarOverlay = decorView.findViewWithTag(NAV_BAR_OVERLAY_TAG);
|
|
644
648
|
if (navBarOverlay != null) {
|
|
645
649
|
navBarOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
646
|
-
Log.d(TAG, "makeStatusBarBackgroundTransparent:
|
|
650
|
+
Log.d(TAG, "makeStatusBarBackgroundTransparent: nav bar overlay made transparent");
|
|
647
651
|
}
|
|
648
652
|
} else {
|
|
649
|
-
//
|
|
650
|
-
Window window = activity.getWindow();
|
|
653
|
+
// API 29–34: both bars use native window API
|
|
651
654
|
window.setStatusBarColor(Color.TRANSPARENT);
|
|
652
655
|
window.setNavigationBarColor(Color.TRANSPARENT);
|
|
653
656
|
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.
|
|
3
|
+
"version": "2.0.10",
|
|
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",
|