@capacitor/android 8.3.5-nightly-20260529T161937.0 → 8.4.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.
@@ -16,6 +16,7 @@ import androidx.core.view.WindowCompat;
16
16
  import androidx.core.view.WindowInsetsCompat;
17
17
  import androidx.core.view.WindowInsetsControllerCompat;
18
18
  import androidx.webkit.WebViewCompat;
19
+ import com.getcapacitor.Logger;
19
20
  import com.getcapacitor.Plugin;
20
21
  import com.getcapacitor.PluginCall;
21
22
  import com.getcapacitor.PluginMethod;
@@ -32,6 +33,7 @@ public class SystemBars extends Plugin {
32
33
  static final String BAR_STATUS_BAR = "StatusBar";
33
34
  static final String BAR_GESTURE_BAR = "NavigationBar";
34
35
 
36
+ // TODO: In Cap 9, add an additional option "full"
35
37
  static final String INSETS_HANDLING_CSS = "css";
36
38
  static final String INSETS_HANDLING_DISABLE = "disable";
37
39
 
@@ -53,7 +55,7 @@ public class SystemBars extends Plugin {
53
55
  capacitorSystemBarsCheckMetaViewport();
54
56
  """;
55
57
 
56
- private boolean insetHandlingEnabled = true;
58
+ private String insetsHandling = INSETS_HANDLING_CSS;
57
59
  private boolean hasViewportCover = false;
58
60
 
59
61
  private String currentStatusBarStyle = STYLE_DEFAULT;
@@ -94,9 +96,15 @@ public class SystemBars extends Plugin {
94
96
  String style = getConfig().getString("style", STYLE_DEFAULT).toUpperCase(Locale.US);
95
97
  boolean hidden = getConfig().getBoolean("hidden", false);
96
98
 
97
- String insetsHandling = getConfig().getString("insetsHandling", "css");
98
- if (insetsHandling.equals(INSETS_HANDLING_DISABLE)) {
99
- insetHandlingEnabled = false;
99
+ String configuredInsetsHandling = getConfig().getString("insetsHandling", INSETS_HANDLING_CSS);
100
+ if (INSETS_HANDLING_CSS.equals(configuredInsetsHandling) || INSETS_HANDLING_DISABLE.equals(configuredInsetsHandling)) {
101
+ insetsHandling = configuredInsetsHandling;
102
+ } else {
103
+ Logger.warn(
104
+ "SystemBars",
105
+ "Unknown insetsHandling value '" + configuredInsetsHandling + "'. Falling back to '" + INSETS_HANDLING_CSS + "'."
106
+ );
107
+ insetsHandling = INSETS_HANDLING_CSS;
100
108
  }
101
109
 
102
110
  initWindowInsetsListener();
@@ -146,13 +154,15 @@ public class SystemBars extends Plugin {
146
154
 
147
155
  @JavascriptInterface
148
156
  public void onDOMReady() {
149
- getActivity().runOnUiThread(() -> {
150
- this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> {
151
- hasViewportCover = res.equals("true");
157
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
158
+ getActivity().runOnUiThread(() -> {
159
+ this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> {
160
+ hasViewportCover = res.equals("true");
152
161
 
153
- getBridge().getWebView().requestApplyInsets();
162
+ getBridge().getWebView().requestApplyInsets();
163
+ });
154
164
  });
155
- });
165
+ }
156
166
  }
157
167
 
158
168
  private Insets calcSafeAreaInsets(WindowInsetsCompat insets) {
@@ -164,22 +174,28 @@ public class SystemBars extends Plugin {
164
174
  }
165
175
 
166
176
  private void initSafeAreaCSSVariables() {
167
- WindowInsetsCompat insets;
177
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
178
+ WindowInsetsCompat insets;
168
179
 
169
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
170
- View v = (View) this.getBridge().getWebView().getParent();
171
- insets = ViewCompat.getRootWindowInsets(v);
172
- } else {
173
- insets = WindowInsetsCompat.CONSUMED;
174
- }
180
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
181
+ View v = (View) this.getBridge().getWebView().getParent();
182
+ insets = ViewCompat.getRootWindowInsets(v);
183
+ } else {
184
+ insets = WindowInsetsCompat.CONSUMED;
185
+ }
175
186
 
176
- if (insets != null) {
177
- Insets safeAreaInsets = calcSafeAreaInsets(insets);
178
- injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
187
+ if (insets != null) {
188
+ Insets safeAreaInsets = calcSafeAreaInsets(insets);
189
+ injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
190
+ }
179
191
  }
180
192
  }
181
193
 
182
194
  private void initWindowInsetsListener() {
195
+ if (INSETS_HANDLING_DISABLE.equals(insetsHandling)) {
196
+ return;
197
+ }
198
+
183
199
  ViewCompat.setOnApplyWindowInsetsListener((View) getBridge().getWebView().getParent(), (v, insets) -> {
184
200
  boolean shouldPassthroughInsets = getWebViewMajorVersion() >= WEBVIEW_VERSION_WITH_SAFE_AREA_FIX && hasViewportCover;
185
201
 
@@ -288,19 +304,21 @@ public class SystemBars extends Plugin {
288
304
  WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(window, window.getDecorView());
289
305
 
290
306
  if (hide) {
291
- if (bar.isEmpty() || bar.equals(BAR_STATUS_BAR)) {
307
+ if (bar.isEmpty()) {
308
+ windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
309
+ } else if (bar.equals(BAR_STATUS_BAR)) {
292
310
  windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
293
- }
294
- if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) {
311
+ } else if (bar.equals(BAR_GESTURE_BAR)) {
295
312
  windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.navigationBars());
296
313
  }
297
314
  return;
298
315
  }
299
316
 
300
- if (bar.isEmpty() || bar.equals(BAR_STATUS_BAR)) {
317
+ if (bar.isEmpty()) {
301
318
  windowInsetsControllerCompat.show(WindowInsetsCompat.Type.systemBars());
302
- }
303
- if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) {
319
+ } else if (bar.equals(BAR_STATUS_BAR)) {
320
+ windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
321
+ } else if (bar.equals(BAR_GESTURE_BAR)) {
304
322
  windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars());
305
323
  }
306
324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "8.3.5-nightly-20260529T161937.0",
3
+ "version": "8.4.0",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
@@ -23,7 +23,7 @@
23
23
  "verify": "./gradlew clean lint build test -b capacitor/build.gradle"
24
24
  },
25
25
  "peerDependencies": {
26
- "@capacitor/core": "^8.3.0-nightly-20260529T161937.0"
26
+ "@capacitor/core": "^8.4.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"