@capgo/capacitor-inappbrowser 8.20.0 → 8.20.1

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.
@@ -581,6 +581,7 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
581
581
  private ActivityResultLauncher<Intent> fileChooserLauncher;
582
582
  private boolean openWebViewResolved;
583
583
  private boolean isDismissing = false;
584
+ private AlertDialog backCloseConfirmDialog;
584
585
  private PermissionRequest pendingCameraLaunchPermissionRequest;
585
586
 
586
587
  // Temporary URI for storing camera capture
@@ -1067,6 +1068,10 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
1067
1068
 
1068
1069
  activity.runOnUiThread(() -> {
1069
1070
  try {
1071
+ if (isDismissing) {
1072
+ // Dismissal already started (e.g. close button or back); do not close twice.
1073
+ return;
1074
+ }
1070
1075
  String currentUrl = getUrl();
1071
1076
  dismiss();
1072
1077
 
@@ -2974,6 +2979,10 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
2974
2979
  public void onCloseWindow(WebView window) {
2975
2980
  Log.d("InAppBrowser", "onCloseWindow called");
2976
2981
  if (window == _webView) {
2982
+ if (isDismissing) {
2983
+ // Dismissal already started (e.g. close button or back); do not close twice.
2984
+ return;
2985
+ }
2977
2986
  String currentUrl = getUrl();
2978
2987
  dismiss();
2979
2988
  if (_options != null && _options.getCallbacks() != null) {
@@ -3243,6 +3252,26 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
3243
3252
  case DISMISS:
3244
3253
  default:
3245
3254
  String currentUrl = getUrl();
3255
+ Pattern urlPattern = _options.getCloseModalURLPattern();
3256
+ if (_options.getCloseModal() && (urlPattern == null || urlPattern.matcher(currentUrl).find())) {
3257
+ // Confirm like the toolbar close button; OK does the same close as below
3258
+ backCloseConfirmDialog = new AlertDialog.Builder(_context)
3259
+ .setTitle(_options.getCloseModalTitle())
3260
+ .setMessage(_options.getCloseModalDescription())
3261
+ .setPositiveButton(_options.getCloseModalOk(), (dialog, which) -> {
3262
+ if (isDismissing) {
3263
+ return;
3264
+ }
3265
+ if (_options.getCallbacks() != null) {
3266
+ _options.getCallbacks().confirmBtnClicked(currentUrl);
3267
+ _options.getCallbacks().closeEvent(currentUrl);
3268
+ }
3269
+ dismiss();
3270
+ })
3271
+ .setNegativeButton(_options.getCloseModalCancel(), null)
3272
+ .show();
3273
+ return;
3274
+ }
3246
3275
  if (_options.getCallbacks() != null) {
3247
3276
  _options.getCallbacks().closeEvent(currentUrl);
3248
3277
  }
@@ -6768,6 +6797,10 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti
6768
6797
 
6769
6798
  @Override
6770
6799
  public void dismiss() {
6800
+ if (backCloseConfirmDialog != null) {
6801
+ backCloseConfirmDialog.dismiss();
6802
+ backCloseConfirmDialog = null;
6803
+ }
6771
6804
  clearFullscreen();
6772
6805
  unregisterConfigurationCallbacks();
6773
6806
  scheduleHostWebViewInsetRestore();
@@ -446,7 +446,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
446
446
  case aware = "AWARE"
447
447
  case fakeVisible = "FAKE_VISIBLE"
448
448
  }
449
- private let pluginVersion: String = "8.20.0"
449
+ private let pluginVersion: String = "8.20.1"
450
450
  public let identifier = "CapgoInAppBrowserPlugin"
451
451
  public let jsName = "CapgoInAppBrowser"
452
452
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-inappbrowser",
3
- "version": "8.20.0",
3
+ "version": "8.20.1",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",