@capacitor-plus/android 8.3.11 → 8.3.12

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.
@@ -17,6 +17,7 @@ import androidx.core.view.WindowCompat;
17
17
  import androidx.core.view.WindowInsetsCompat;
18
18
  import androidx.core.view.WindowInsetsControllerCompat;
19
19
  import androidx.webkit.WebViewCompat;
20
+ import com.getcapacitor.Logger;
20
21
  import com.getcapacitor.Plugin;
21
22
  import com.getcapacitor.PluginCall;
22
23
  import com.getcapacitor.PluginMethod;
@@ -33,6 +34,7 @@ public class SystemBars extends Plugin {
33
34
  static final String BAR_STATUS_BAR = "StatusBar";
34
35
  static final String BAR_GESTURE_BAR = "NavigationBar";
35
36
 
37
+ // TODO: In Cap 9, add an additional option "full"
36
38
  static final String INSETS_HANDLING_CSS = "css";
37
39
  static final String INSETS_HANDLING_DISABLE = "disable";
38
40
 
@@ -54,7 +56,7 @@ public class SystemBars extends Plugin {
54
56
  capacitorSystemBarsCheckMetaViewport();
55
57
  """;
56
58
 
57
- private boolean insetHandlingEnabled = true;
59
+ private String insetsHandling = INSETS_HANDLING_CSS;
58
60
  private boolean hasViewportCover = false;
59
61
 
60
62
  private String currentStatusBarStyle = STYLE_DEFAULT;
@@ -81,7 +83,7 @@ public class SystemBars extends Plugin {
81
83
  super.onPageCommitVisible(view, url);
82
84
  View parentView = (View) getBridge().getWebView().getParent();
83
85
  ViewCompat.requestApplyInsets(parentView);
84
- if (insetHandlingEnabled) {
86
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
85
87
  WindowInsetsCompat rootInsets = ViewCompat.getRootWindowInsets(parentView);
86
88
  if (rootInsets != null) {
87
89
  Insets safeArea = calcSafeAreaInsets(rootInsets);
@@ -105,9 +107,15 @@ public class SystemBars extends Plugin {
105
107
  String style = getConfig().getString("style", STYLE_DEFAULT).toUpperCase(Locale.US);
106
108
  boolean hidden = getConfig().getBoolean("hidden", false);
107
109
 
108
- String insetsHandling = getConfig().getString("insetsHandling", "css");
109
- if (insetsHandling.equals(INSETS_HANDLING_DISABLE)) {
110
- insetHandlingEnabled = false;
110
+ String configuredInsetsHandling = getConfig().getString("insetsHandling", INSETS_HANDLING_CSS);
111
+ if (INSETS_HANDLING_CSS.equals(configuredInsetsHandling) || INSETS_HANDLING_DISABLE.equals(configuredInsetsHandling)) {
112
+ insetsHandling = configuredInsetsHandling;
113
+ } else {
114
+ Logger.warn(
115
+ "SystemBars",
116
+ "Unknown insetsHandling value '" + configuredInsetsHandling + "'. Falling back to '" + INSETS_HANDLING_CSS + "'."
117
+ );
118
+ insetsHandling = INSETS_HANDLING_CSS;
111
119
  }
112
120
 
113
121
  initWindowInsetsListener();
@@ -184,12 +192,14 @@ public class SystemBars extends Plugin {
184
192
 
185
193
  @JavascriptInterface
186
194
  public void onDOMReady() {
187
- getActivity().runOnUiThread(() -> {
188
- this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> {
189
- hasViewportCover = res.equals("true");
190
- ViewCompat.requestApplyInsets((View) getBridge().getWebView().getParent());
195
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
196
+ getActivity().runOnUiThread(() -> {
197
+ this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> {
198
+ hasViewportCover = res.equals("true");
199
+ ViewCompat.requestApplyInsets((View) getBridge().getWebView().getParent());
200
+ });
191
201
  });
192
- });
202
+ }
193
203
  }
194
204
 
195
205
  private Insets calcSafeAreaInsets(WindowInsetsCompat insets) {
@@ -224,7 +234,7 @@ public class SystemBars extends Plugin {
224
234
  }
225
235
 
226
236
  private void initSafeAreaCSSVariables() {
227
- if (insetHandlingEnabled) {
237
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
228
238
  View v = (View) this.getBridge().getWebView().getParent();
229
239
  WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(v);
230
240
  if (insets != null) {
@@ -235,6 +245,10 @@ public class SystemBars extends Plugin {
235
245
  }
236
246
 
237
247
  private void initWindowInsetsListener() {
248
+ if (INSETS_HANDLING_DISABLE.equals(insetsHandling)) {
249
+ return;
250
+ }
251
+
238
252
  ViewCompat.setOnApplyWindowInsetsListener((View) getBridge().getWebView().getParent(), (v, insets) -> {
239
253
  // getRootWindowInsets() bypasses AppCompat's intermediate view consuming the bottom inset on API < 30
240
254
  WindowInsetsCompat rawInsets = ViewCompat.getRootWindowInsets(v);
@@ -250,7 +264,7 @@ public class SystemBars extends Plugin {
250
264
  // We need to correct for a possible shown IME
251
265
  v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0);
252
266
 
253
- if (hasViewportCover && insetHandlingEnabled) {
267
+ if (hasViewportCover && INSETS_HANDLING_CSS.equals(insetsHandling)) {
254
268
  Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
255
269
  injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
256
270
  }
@@ -277,7 +291,7 @@ public class SystemBars extends Plugin {
277
291
  .setInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout(), Insets.of(0, 0, 0, 0))
278
292
  .build();
279
293
 
280
- if (insetHandlingEnabled) {
294
+ if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
281
295
  Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
282
296
  injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
283
297
  }
@@ -344,20 +358,24 @@ public class SystemBars extends Plugin {
344
358
  WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(window, window.getDecorView());
345
359
 
346
360
  if (hide) {
347
- if (bar.isEmpty() || bar.equals(BAR_STATUS_BAR)) {
361
+ if (bar.isEmpty()) {
362
+ windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
363
+ navBarVisible = false;
364
+ } else if (bar.equals(BAR_STATUS_BAR)) {
348
365
  windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
349
- }
350
- if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) {
366
+ } else if (bar.equals(BAR_GESTURE_BAR)) {
351
367
  windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.navigationBars());
352
368
  navBarVisible = false;
353
369
  }
354
370
  return;
355
371
  }
356
372
 
357
- if (bar.isEmpty() || bar.equals(BAR_STATUS_BAR)) {
373
+ if (bar.isEmpty()) {
358
374
  windowInsetsControllerCompat.show(WindowInsetsCompat.Type.systemBars());
359
- }
360
- if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) {
375
+ navBarVisible = true;
376
+ } else if (bar.equals(BAR_STATUS_BAR)) {
377
+ windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
378
+ } else if (bar.equals(BAR_GESTURE_BAR)) {
361
379
  windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars());
362
380
  navBarVisible = true;
363
381
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-plus/android",
3
- "version": "8.3.11",
3
+ "version": "8.3.12",
4
4
  "description": "Capacitor+: Enhanced Capacitor with automated upstream sync - Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capgo.app/docs/plugins/capacitor-plus/",
6
6
  "author": "Capgo Team <support@capgo.app> (https://capgo.app)",