@capgo/inappbrowser 8.1.6 → 8.1.8

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.6";
53
+ private final String pluginVersion = "8.1.8";
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,29 @@ 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
+ // Set flag immediately to prevent race condition if setHidden(false)
1049
+ // is called before the posted runnable executes
1050
+ isHiddenModeActive = true;
1051
+ decorView.post(this::applyHiddenMode);
1052
+ } catch (Exception e) {
1053
+ Log.w("InAppBrowser", "Unable to show dialog before hiding", e);
1054
+ }
1055
+ } else {
1056
+ applyHiddenMode();
1057
+ }
1030
1058
  }
1031
1059
  } else {
1032
1060
  if (isHiddenModeActive) {
@@ -1042,6 +1070,10 @@ public class WebViewDialog extends Dialog {
1042
1070
  return isHiddenModeActive;
1043
1071
  }
1044
1072
 
1073
+ public boolean isFakeVisibleMode() {
1074
+ return _options != null && _options.getInvisibilityMode() == Options.InvisibilityMode.FAKE_VISIBLE;
1075
+ }
1076
+
1045
1077
  /**
1046
1078
  * Apply window insets to the WebView to properly handle edge-to-edge display
1047
1079
  * and fix status bar overlap issues on Android 15+
@@ -2853,9 +2885,6 @@ public class WebViewDialog extends Dialog {
2853
2885
  } else if (!_options.getDisableGoBackOnNativeApplication()) {
2854
2886
  String currentUrl = getUrl();
2855
2887
  _options.getCallbacks().closeEvent(currentUrl);
2856
- if (_webView != null) {
2857
- _webView.destroy();
2858
- }
2859
2888
  super.onBackPressed();
2860
2889
  }
2861
2890
  }
@@ -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.6"
31
+ private let pluginVersion: String = "8.1.8"
32
32
  public let identifier = "InAppBrowserPlugin"
33
33
  public let jsName = "InAppBrowser"
34
34
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "8.1.6",
3
+ "version": "8.1.8",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",