@capacitor/status-bar 7.0.0-nightly-20241119T150535.0 → 7.0.0-nightly-20241121T150537.0

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.
@@ -1,9 +1,11 @@
1
1
  package com.capacitorjs.plugins.statusbar;
2
2
 
3
3
  import android.graphics.Color;
4
+ import android.os.Build;
4
5
  import android.util.DisplayMetrics;
5
6
  import android.view.View;
6
7
  import android.view.Window;
8
+ import android.view.WindowInsets;
7
9
  import android.view.WindowManager;
8
10
  import androidx.appcompat.app.AppCompatActivity;
9
11
  import androidx.core.view.ViewCompat;
@@ -113,15 +115,19 @@ public class StatusBar {
113
115
  }
114
116
 
115
117
  private int getStatusBarHeight() {
116
- int statusbarHeight = 0;
117
- int resourceId = activity.getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
118
- if (resourceId > 0) {
119
- statusbarHeight = (int) activity.getApplicationContext().getResources().getDimension(resourceId);
118
+ DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
119
+
120
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
121
+ WindowInsets insets = activity.getWindowManager().getCurrentWindowMetrics().getWindowInsets();
122
+ return (int) (insets.getInsets(WindowInsets.Type.statusBars()).top / metrics.density);
120
123
  }
121
124
 
122
- DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics();
123
- float densityDpi = metrics.density;
125
+ WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();
126
+ if (insets != null) {
127
+ return (int) (insets.getSystemWindowInsetTop() / metrics.density);
128
+ }
124
129
 
125
- return (int) (statusbarHeight / densityDpi);
130
+ // Fallback if the insets are not available
131
+ return 0;
126
132
  }
127
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/status-bar",
3
- "version": "7.0.0-nightly-20241119T150535.0",
3
+ "version": "7.0.0-nightly-20241121T150537.0",
4
4
  "description": "The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "ebdb19346e629f53504624aade11371d72b11a6c"
84
+ "gitHead": "8449b188496d710699bc6f5bc031a28f44e29fbe"
85
85
  }