@capgo/inappbrowser 8.1.5 → 8.1.7

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.
@@ -50,7 +50,7 @@ import org.json.JSONObject;
50
50
  )
51
51
  public class InAppBrowserPlugin extends Plugin implements WebViewDialog.PermissionHandler {
52
52
 
53
- private final String pluginVersion = "8.1.5";
53
+ private final String pluginVersion = "8.1.7";
54
54
 
55
55
  public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
56
56
  private CustomTabsClient customTabsClient;
@@ -551,6 +551,7 @@ public class InAppBrowserPlugin extends Plugin implements WebViewDialog.Permissi
551
551
  @Override
552
552
  public void closeEvent(String url) {
553
553
  notifyListeners("closeEvent", new JSObject().put("url", url));
554
+ webViewDialog = null;
554
555
  }
555
556
 
556
557
  @Override
@@ -775,6 +776,10 @@ public class InAppBrowserPlugin extends Plugin implements WebViewDialog.Permissi
775
776
  call.reject("WebView is not initialized");
776
777
  return;
777
778
  }
779
+ if (!webViewDialog.isFakeVisibleMode()) {
780
+ call.reject("show() is only supported when invisibilityMode is FAKE_VISIBLE");
781
+ return;
782
+ }
778
783
  if (!webViewDialog.isShowing()) {
779
784
  webViewDialog.show();
780
785
  }
@@ -965,21 +965,27 @@ public class WebViewDialog extends Dialog {
965
965
  window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
966
966
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
967
967
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
968
+ window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
968
969
  window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
969
970
 
970
971
  if (decorView != null) {
971
972
  decorView.setAlpha(0f);
972
- decorView.setVisibility(View.VISIBLE);
973
+ if (_options.getInvisibilityMode() == Options.InvisibilityMode.AWARE) {
974
+ decorView.setVisibility(View.GONE);
975
+ } else {
976
+ decorView.setVisibility(View.INVISIBLE);
977
+ }
973
978
  }
974
979
 
975
980
  if (_webView != null) {
976
981
  if (_options.getInvisibilityMode() == Options.InvisibilityMode.AWARE) {
982
+ window.setLayout(1, 1);
977
983
  _webView.setAlpha(0f);
978
984
  _webView.setVisibility(View.INVISIBLE);
979
985
  _webView.setLayoutParams(new ViewGroup.LayoutParams(0, 0));
980
986
  } else {
981
987
  _webView.setAlpha(0f);
982
- _webView.setVisibility(View.VISIBLE);
988
+ _webView.setVisibility(View.INVISIBLE);
983
989
  }
984
990
  }
985
991
 
@@ -1026,7 +1032,26 @@ public class WebViewDialog extends Dialog {
1026
1032
  public void setHidden(boolean hidden) {
1027
1033
  if (hidden) {
1028
1034
  if (!isHiddenModeActive) {
1029
- applyHiddenMode();
1035
+ if (getWindow() == null) {
1036
+ try {
1037
+ show();
1038
+ Window window = getWindow();
1039
+ if (window == null) {
1040
+ Log.w("InAppBrowser", "Unable to apply hidden mode: window is null after show()");
1041
+ return;
1042
+ }
1043
+ View decorView = window.getDecorView();
1044
+ if (decorView == null) {
1045
+ Log.w("InAppBrowser", "Unable to apply hidden mode: decorView is null after show()");
1046
+ return;
1047
+ }
1048
+ decorView.post(this::applyHiddenMode);
1049
+ } catch (Exception e) {
1050
+ Log.w("InAppBrowser", "Unable to show dialog before hiding", e);
1051
+ }
1052
+ } else {
1053
+ applyHiddenMode();
1054
+ }
1030
1055
  }
1031
1056
  } else {
1032
1057
  if (isHiddenModeActive) {
@@ -1042,6 +1067,10 @@ public class WebViewDialog extends Dialog {
1042
1067
  return isHiddenModeActive;
1043
1068
  }
1044
1069
 
1070
+ public boolean isFakeVisibleMode() {
1071
+ return _options != null && _options.getInvisibilityMode() == Options.InvisibilityMode.FAKE_VISIBLE;
1072
+ }
1073
+
1045
1074
  /**
1046
1075
  * Apply window insets to the WebView to properly handle edge-to-edge display
1047
1076
  * and fix status bar overlap issues on Android 15+
@@ -2853,9 +2882,6 @@ public class WebViewDialog extends Dialog {
2853
2882
  } else if (!_options.getDisableGoBackOnNativeApplication()) {
2854
2883
  String currentUrl = getUrl();
2855
2884
  _options.getCallbacks().closeEvent(currentUrl);
2856
- if (_webView != null) {
2857
- _webView.destroy();
2858
- }
2859
2885
  super.onBackPressed();
2860
2886
  }
2861
2887
  }
@@ -28,7 +28,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
28
28
  case aware = "AWARE"
29
29
  case fakeVisible = "FAKE_VISIBLE"
30
30
  }
31
- private let pluginVersion: String = "8.1.5"
31
+ private let pluginVersion: String = "8.1.7"
32
32
  public let identifier = "InAppBrowserPlugin"
33
33
  public let jsName = "InAppBrowser"
34
34
  public let pluginMethods: [CAPPluginMethod] = [
@@ -57,6 +57,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
57
57
  var isHidden = false
58
58
  var invisibilityMode: InvisibilityMode = .aware
59
59
  var webViewController: WKWebViewController?
60
+ private weak var presentationContainerView: UIView?
61
+ private var presentationContainerWasInteractive = true
62
+ private var presentationContainerPreviousAlpha: CGFloat = 1
60
63
  private var closeModalTitle: String?
61
64
  private var closeModalDescription: String?
62
65
  private var closeModalOk: String?
@@ -829,6 +832,15 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
829
832
  if let navController = self.navigationWebViewController, navController.presentingViewController != nil {
830
833
  navController.view.isHidden = true
831
834
  navController.view.isUserInteractionEnabled = false
835
+ if let containerView = navController.view.superview {
836
+ if self.presentationContainerView == nil || self.presentationContainerView !== containerView {
837
+ self.presentationContainerView = containerView
838
+ self.presentationContainerWasInteractive = containerView.isUserInteractionEnabled
839
+ self.presentationContainerPreviousAlpha = containerView.alpha
840
+ }
841
+ containerView.isUserInteractionEnabled = false
842
+ containerView.alpha = 0
843
+ }
832
844
  }
833
845
 
834
846
  if !self.attachWebViewToWindow(webView) {
@@ -843,6 +855,13 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
843
855
  if let navController = self.navigationWebViewController {
844
856
  navController.view.isHidden = false
845
857
  navController.view.isUserInteractionEnabled = true
858
+ if let containerView = self.presentationContainerView {
859
+ containerView.isUserInteractionEnabled = self.presentationContainerWasInteractive
860
+ containerView.alpha = self.presentationContainerPreviousAlpha
861
+ self.presentationContainerView = nil
862
+ self.presentationContainerWasInteractive = true
863
+ self.presentationContainerPreviousAlpha = 1
864
+ }
846
865
 
847
866
  if navController.presentingViewController == nil {
848
867
  self.bridge?.viewController?.present(navController, animated: true, completion: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "8.1.5",
3
+ "version": "8.1.7",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",