@capgo/capacitor-inappbrowser 8.6.29 → 8.6.30

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.
@@ -47,10 +47,25 @@ final class SafeAreaInsetsSupport {
47
47
  }
48
48
 
49
49
  static int resolveTopMargin(boolean enabledSafeTopMargin, boolean useTopInset, int systemBarsTop, boolean appBarHandlesTopInset) {
50
+ return resolveTopMarginWithFallback(enabledSafeTopMargin, useTopInset, systemBarsTop, appBarHandlesTopInset, 0, false);
51
+ }
52
+
53
+ static int resolveTopMarginWithFallback(
54
+ boolean enabledSafeTopMargin,
55
+ boolean useTopInset,
56
+ int systemBarsTop,
57
+ boolean appBarHandlesTopInset,
58
+ int fallbackTopInset,
59
+ boolean applyFallbackWhenZero
60
+ ) {
50
61
  if (!enabledSafeTopMargin || !useTopInset || appBarHandlesTopInset) {
51
62
  return 0;
52
63
  }
53
64
 
54
- return systemBarsTop;
65
+ if (systemBarsTop > 0 || !applyFallbackWhenZero || fallbackTopInset <= 0) {
66
+ return systemBarsTop;
67
+ }
68
+
69
+ return fallbackTopInset;
55
70
  }
56
71
  }
@@ -62,6 +62,7 @@ import android.widget.Toast;
62
62
  import android.widget.Toolbar;
63
63
  import androidx.activity.result.ActivityResult;
64
64
  import androidx.activity.result.contract.ActivityResultContracts;
65
+ import androidx.coordinatorlayout.widget.CoordinatorLayout;
65
66
  import androidx.core.content.FileProvider;
66
67
  import androidx.core.graphics.Insets;
67
68
  import androidx.core.view.ViewCompat;
@@ -2576,8 +2577,13 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
2576
2577
  }
2577
2578
  }
2578
2579
 
2580
+ boolean isBlankToolbar = _options != null && TextUtils.equals(_options.getToolbarType(), "blank");
2581
+ if (isBlankToolbar) {
2582
+ configureBlankToolbarLayout();
2583
+ }
2584
+
2579
2585
  // Special handling for Android 15+
2580
- if (isAndroid15Plus) {
2586
+ if (isAndroid15Plus && !isBlankToolbar) {
2581
2587
  // Get AppBarLayout which contains the toolbar
2582
2588
  if (toolbarView != null && toolbarView.getParent() instanceof com.google.android.material.appbar.AppBarLayout appBarLayout) {
2583
2589
  // Remove elevation to eliminate shadows (only on Android 15+)
@@ -2752,18 +2758,76 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
2752
2758
  _options.getEnabledSafeMargin()
2753
2759
  );
2754
2760
  int imeBottom = keyboardVisible ? ime.bottom : 0;
2755
- int navTop = SafeAreaInsetsSupport.resolveTopMargin(
2761
+ boolean applyTopFallback = _options.getEnabledSafeTopMargin() && _options.getUseTopInset();
2762
+ int fallbackTopInset = applyTopFallback ? getSystemStatusBarHeight() : 0;
2763
+ int navTop = SafeAreaInsetsSupport.resolveTopMarginWithFallback(
2756
2764
  _options.getEnabledSafeTopMargin(),
2757
2765
  _options.getUseTopInset(),
2758
2766
  bars.top,
2759
- appBarHandlesTopInset
2767
+ appBarHandlesTopInset,
2768
+ fallbackTopInset,
2769
+ applyTopFallback
2760
2770
  );
2771
+ int bottomMargin = SafeAreaInsetsSupport.resolveBottomMargin(_options.getEnabledSafeMargin(), safeBottomInset, imeBottom);
2761
2772
 
2762
2773
  mlp.topMargin = navTop;
2763
- mlp.bottomMargin = SafeAreaInsetsSupport.resolveBottomMargin(_options.getEnabledSafeMargin(), safeBottomInset, imeBottom);
2774
+ mlp.bottomMargin = bottomMargin;
2764
2775
  mlp.leftMargin = bars.left;
2765
2776
  mlp.rightMargin = bars.right;
2766
2777
  _webView.setLayoutParams(mlp);
2778
+ injectSafeAreaCssVariables(navTop, bottomMargin, bars.left, bars.right);
2779
+ }
2780
+
2781
+ private void configureBlankToolbarLayout() {
2782
+ View appBarLayout = findViewById(R.id.app_bar_layout);
2783
+ if (appBarLayout != null) {
2784
+ appBarLayout.setVisibility(View.GONE);
2785
+ }
2786
+
2787
+ View statusBarColorView = findViewById(R.id.status_bar_color_view);
2788
+ if (statusBarColorView != null) {
2789
+ statusBarColorView.setVisibility(View.GONE);
2790
+ }
2791
+
2792
+ View contentBrowserLayout = findViewById(R.id.content_browser_layout);
2793
+ if (contentBrowserLayout != null && contentBrowserLayout.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) {
2794
+ CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) contentBrowserLayout.getLayoutParams();
2795
+ layoutParams.setBehavior(null);
2796
+ contentBrowserLayout.setLayoutParams(layoutParams);
2797
+ }
2798
+ }
2799
+
2800
+ private int getSystemStatusBarHeight() {
2801
+ int resourceId = getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
2802
+ if (resourceId <= 0) {
2803
+ return 0;
2804
+ }
2805
+
2806
+ return getContext().getResources().getDimensionPixelSize(resourceId);
2807
+ }
2808
+
2809
+ private void injectSafeAreaCssVariables(int top, int bottom, int left, int right) {
2810
+ if (_webView == null) {
2811
+ return;
2812
+ }
2813
+
2814
+ String script = String.format(
2815
+ Locale.US,
2816
+ "(function(){var root=document.documentElement;" +
2817
+ "root.style.setProperty('--safe-area-inset-top','%dpx');" +
2818
+ "root.style.setProperty('--safe-area-inset-bottom','%dpx');" +
2819
+ "root.style.setProperty('--safe-area-inset-left','%dpx');" +
2820
+ "root.style.setProperty('--safe-area-inset-right','%dpx');})();",
2821
+ top,
2822
+ bottom,
2823
+ left,
2824
+ right
2825
+ );
2826
+ _webView.post(() -> {
2827
+ if (_webView != null) {
2828
+ _webView.evaluateJavascript(script, null);
2829
+ }
2830
+ });
2767
2831
  }
2768
2832
 
2769
2833
  private View resolveSafeAreaInsetsSourceView() {
@@ -3595,6 +3659,8 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
3595
3659
  // Status bar color is already set at the top of this method, no need to set again
3596
3660
  } else if (TextUtils.equals(_options.getToolbarType(), "blank")) {
3597
3661
  _toolbar.setVisibility(View.GONE);
3662
+ configureBlankToolbarLayout();
3663
+ requestSafeAreaInsets();
3598
3664
 
3599
3665
  // Also set window background color to match status bar for blank toolbar
3600
3666
  View statusBarColorView = findViewById(R.id.status_bar_color_view);
@@ -98,7 +98,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
98
98
  case aware = "AWARE"
99
99
  case fakeVisible = "FAKE_VISIBLE"
100
100
  }
101
- private let pluginVersion: String = "8.6.29"
101
+ private let pluginVersion: String = "8.6.30"
102
102
  public let identifier = "CapgoInAppBrowserPlugin"
103
103
  public let jsName = "CapgoInAppBrowser"
104
104
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-inappbrowser",
3
- "version": "8.6.29",
3
+ "version": "8.6.30",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",