@capgo/inappbrowser 6.11.1 → 6.13.0

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.
Files changed (30) hide show
  1. package/README.md +50 -42
  2. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +161 -41
  3. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +83 -22
  4. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +2 -0
  5. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +749 -96
  6. package/android/src/main/res/drawable/ic_share.xml +10 -0
  7. package/android/src/main/res/layout/activity_browser.xml +8 -0
  8. package/android/src/main/res/layout/content_browser.xml +10 -1
  9. package/android/src/main/res/layout/tool_bar.xml +19 -7
  10. package/android/src/main/res/values/strings.xml +2 -0
  11. package/android/src/main/res/values/themes.xml +27 -0
  12. package/dist/docs.json +211 -37
  13. package/dist/esm/definitions.d.ts +244 -31
  14. package/dist/esm/definitions.js +12 -1
  15. package/dist/esm/definitions.js.map +1 -1
  16. package/dist/plugin.cjs.js +12 -1
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +12 -1
  19. package/dist/plugin.js.map +1 -1
  20. package/ios/Plugin/InAppBrowserPlugin.swift +344 -44
  21. package/ios/Plugin/WKWebViewController.swift +499 -45
  22. package/package.json +7 -8
  23. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  24. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  25. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  26. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  27. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  28. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  29. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  30. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
package/README.md CHANGED
@@ -207,6 +207,11 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
207
207
 
208
208
  Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.
209
209
 
210
+ JavaScript Interface:
211
+ When you open a webview with this method, a JavaScript interface is automatically injected that provides:
212
+ - `window.mobileApp.close()`: Closes the webview from JavaScript
213
+ - `window.mobileApp.postMessage(obj)`: Sends a message from the webview to the app
214
+
210
215
  | Param | Type |
211
216
  | ------------- | ----------------------------------------------------------------- |
212
217
  | **`options`** | <code><a href="#openwebviewoptions">OpenWebViewOptions</a></code> |
@@ -329,7 +334,7 @@ Listen for close click only for openWebView
329
334
  addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle>
330
335
  ```
331
336
 
332
- Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS
337
+ Will be triggered when user clicks on confirm button when disclaimer is required
333
338
 
334
339
  | Param | Type |
335
340
  | ------------------ | ----------------------------------------------------------------- |
@@ -440,7 +445,7 @@ Reload the current web page.
440
445
  | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | 0.1.0 |
441
446
  | **`credentials`** | <code><a href="#credentials">Credentials</a></code> | <a href="#credentials">Credentials</a> to send with the request and all subsequent requests for the same host. | 6.1.0 |
442
447
  | **`isPresentAfterPageLoad`** | <code>boolean</code> | if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | 0.1.0 |
443
- | **`preventDeeplink`** | <code>boolean</code> | | |
448
+ | **`preventDeeplink`** | <code>boolean</code> | if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link | 0.1.0 |
444
449
 
445
450
 
446
451
  #### Headers
@@ -480,44 +485,48 @@ Reload the current web page.
480
485
 
481
486
  #### OpenWebViewOptions
482
487
 
483
- | Prop | Type | Description | Default | Since |
484
- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
485
- | **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
486
- | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
487
- | **`credentials`** | <code><a href="#credentials">Credentials</a></code> | <a href="#credentials">Credentials</a> to send with the request and all subsequent requests for the same host. | | 6.1.0 |
488
- | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options | | 0.1.0 |
489
- | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
490
- | **`shareSubject`** | <code>string</code> | Share subject | | 0.1.0 |
491
- | **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
492
- | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
493
- | **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
494
- | **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, usefull to force user to stay on the webview, Android only | <code>false</code> | |
495
- | **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
496
- | **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
497
- | **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
498
- | **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
499
- | **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
500
- | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
501
- | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button, only on IOS | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
502
- | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
503
- | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS | <code>'Cancel'</code> | 1.1.0 |
504
- | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
505
- | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff''</code> | 1.2.5 |
506
- | **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
507
- | **`ignoreUntrustedSSLError`** | <code>boolean</code> | ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website. | <code>false</code> | 6.1.0 |
508
- | **`preShowScript`** | <code>string</code> | preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser. This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds) | | 6.6.0 |
509
- | **`proxyRequests`** | <code>string</code> | proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only) | | 6.9.0 |
510
- | **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: string; }; android: { iconType: 'asset'; icon: string; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info. | | 6.7.0 |
488
+ | Prop | Type | Description | Default | Since |
489
+ | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
490
+ | **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
491
+ | **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
492
+ | **`credentials`** | <code><a href="#credentials">Credentials</a></code> | <a href="#credentials">Credentials</a> to send with the request and all subsequent requests for the same host. | | 6.1.0 |
493
+ | **`materialPicker`** | <code>boolean</code> | materialPicker: if true, uses Material Design theme for date and time pickers on Android. This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers. | <code>false</code> | 7.4.1 |
494
+ | **`jsInterface`** | | JavaScript Interface: The webview automatically injects a JavaScript interface providing: - `window.mobileApp.close()`: Closes the webview from JavaScript - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via "messageFromWebview" event) | | 6.10.0 |
495
+ | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | Share options for the webview. When provided, shows a disclaimer dialog before sharing content. This is useful for: - Warning users about sharing sensitive information - Getting user consent before sharing - Explaining what will be shared - Complying with privacy regulations Note: shareSubject is required when using shareDisclaimer | | 0.1.0 |
496
+ | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type determines the appearance and behavior of the browser's toolbar - "activity": Shows a simple toolbar with just a close button and share button - "navigation": Shows a full navigation toolbar with back/forward buttons - "blank": Shows no toolbar - "": Default toolbar with close button | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
497
+ | **`shareSubject`** | <code>string</code> | Subject text for sharing. Required when using shareDisclaimer. This text will be used as the subject line when sharing content. | | 0.1.0 |
498
+ | **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
499
+ | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser | <code>BackgroundColor.BLACK</code> | 0.1.0 |
500
+ | **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
501
+ | **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, useful to force user to stay on the webview, Android only | <code>false</code> | |
502
+ | **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
503
+ | **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
504
+ | **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
505
+ | **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
506
+ | **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
507
+ | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button | <code>'Close'</code> | 1.1.0 |
508
+ | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
509
+ | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>'Close'</code> | 1.1.0 |
510
+ | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>'Cancel'</code> | 1.1.0 |
511
+ | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
512
+ | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff'</code> | 1.2.5 |
513
+ | **`toolbarTextColor`** | <code>string</code> | toolbarTextColor: color of the buttons and title in the toolbar in hex format When set, it overrides the automatic light/dark mode detection for text color | <code>calculated based on toolbarColor brightness</code> | 6.10.0 |
514
+ | **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
515
+ | **`ignoreUntrustedSSLError`** | <code>boolean</code> | ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website. | <code>false</code> | 6.1.0 |
516
+ | **`preShowScript`** | <code>string</code> | preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser. This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds) | | 6.6.0 |
517
+ | **`proxyRequests`** | <code>string</code> | proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only) | | 6.9.0 |
518
+ | **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: string; }; android: { iconType: 'asset' \| 'vector'; icon: string; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button near the done/close button. The button is only shown when toolbarType is not "activity", "navigation", or "blank". For Android: - iconType must be "asset" - icon path should be in the public folder (e.g. "monkey.svg") - width and height are optional, defaults to 48dp - button is positioned at the end of toolbar with 8dp margin For iOS: - iconType can be "sf-symbol" or "asset" - for sf-symbol, icon should be the symbol name - for asset, icon should be the asset name | | 6.7.0 |
519
+ | **`textZoom`** | <code>number</code> | textZoom: sets the text zoom of the page in percent. Allows users to increase or decrease the text size for better readability. | <code>100</code> | 7.6.0 |
511
520
 
512
521
 
513
522
  #### DisclaimerOptions
514
523
 
515
- | Prop | Type |
516
- | ---------------- | ------------------- |
517
- | **`title`** | <code>string</code> |
518
- | **`message`** | <code>string</code> |
519
- | **`confirmBtn`** | <code>string</code> |
520
- | **`cancelBtn`** | <code>string</code> |
524
+ | Prop | Type | Description | Default |
525
+ | ---------------- | ------------------- | -------------------------------------- | ---------------------- |
526
+ | **`title`** | <code>string</code> | Title of the disclaimer dialog | <code>"Title"</code> |
527
+ | **`message`** | <code>string</code> | Message shown in the disclaimer dialog | <code>"Message"</code> |
528
+ | **`confirmBtn`** | <code>string</code> | Text for the confirm button | <code>"Confirm"</code> |
529
+ | **`cancelBtn`** | <code>string</code> | Text for the cancel button | <code>"Cancel"</code> |
521
530
 
522
531
 
523
532
  #### PluginListenerHandle
@@ -602,12 +611,11 @@ Construct a type with a set of properties K of type T
602
611
 
603
612
  #### ToolBarType
604
613
 
605
- | Members | Value |
606
- | ---------------- | ------------------------- |
607
- | **`ACTIVITY`** | <code>"activity"</code> |
608
- | **`NAVIGATION`** | <code>"navigation"</code> |
609
- | **`BLANK`** | <code>"blank"</code> |
610
- | **`DEFAULT`** | <code>""</code> |
614
+ | Members | Value | Description | Since |
615
+ | ---------------- | ------------------------- | ---------------------------------------------------------------- | ----- |
616
+ | **`ACTIVITY`** | <code>"activity"</code> | Shows a simple toolbar with just a close button and share button | 0.1.0 |
617
+ | **`NAVIGATION`** | <code>"navigation"</code> | Shows a full navigation toolbar with back/forward buttons | 0.1.0 |
618
+ | **`BLANK`** | <code>"blank"</code> | Shows no toolbar | 0.1.0 |
611
619
 
612
620
 
613
621
  #### BackgroundColor
@@ -26,6 +26,7 @@ import com.getcapacitor.PluginMethod;
26
26
  import com.getcapacitor.annotation.CapacitorPlugin;
27
27
  import com.getcapacitor.annotation.Permission;
28
28
  import com.getcapacitor.annotation.PermissionCallback;
29
+ import java.lang.reflect.Field;
29
30
  import java.util.ArrayList;
30
31
  import java.util.Iterator;
31
32
  import java.util.Objects;
@@ -126,40 +127,39 @@ public class InAppBrowserPlugin
126
127
  }
127
128
 
128
129
  @Override
129
- protected void handleOnActivityResult(
130
+ public void handleOnActivityResult(
130
131
  int requestCode,
131
132
  int resultCode,
132
133
  Intent data
133
134
  ) {
134
135
  super.handleOnActivityResult(requestCode, resultCode, data);
135
136
 
136
- // Check if the request code matches the file chooser request code
137
+ // Handle file chooser result
137
138
  if (requestCode == WebViewDialog.FILE_CHOOSER_REQUEST_CODE) {
138
139
  if (webViewDialog != null && webViewDialog.mFilePathCallback != null) {
139
140
  Uri[] results = null;
140
141
 
142
+ // Check if response is valid
141
143
  if (resultCode == Activity.RESULT_OK) {
142
144
  if (data != null) {
143
- String dataString = data.getDataString();
144
- if (data.getClipData() != null) { // If multiple file selected
145
+ // Get the data
146
+ if (data.getClipData() != null) {
147
+ // Handle multiple files
145
148
  int count = data.getClipData().getItemCount();
146
149
  results = new Uri[count];
147
150
  for (int i = 0; i < count; i++) {
148
151
  results[i] = data.getClipData().getItemAt(i).getUri();
149
152
  }
150
- } else if (dataString != null) { //if single file selected
151
- results = new Uri[] { Uri.parse(dataString) };
153
+ } else if (data.getData() != null) {
154
+ // Handle single file
155
+ results = new Uri[] { data.getData() };
152
156
  }
153
157
  }
154
158
  }
155
159
 
156
- // Pass the results back to the WebView
157
- try {
158
- webViewDialog.mFilePathCallback.onReceiveValue(results);
159
- webViewDialog.mFilePathCallback = null;
160
- } catch (Exception e) {
161
- Log.e("ACTIVITYRESULT", Objects.requireNonNull(e.getMessage()));
162
- }
160
+ // Send the result to WebView
161
+ webViewDialog.mFilePathCallback.onReceiveValue(results);
162
+ webViewDialog.mFilePathCallback = null;
163
163
  }
164
164
  }
165
165
  }
@@ -422,11 +422,18 @@ public class InAppBrowserPlugin
422
422
  options.setTitle(call.getString("title", ""));
423
423
  }
424
424
  options.setToolbarColor(call.getString("toolbarColor", "#ffffff"));
425
+ options.setToolbarTextColor(call.getString("toolbarTextColor"));
425
426
  options.setArrow(Boolean.TRUE.equals(call.getBoolean("showArrow", false)));
426
427
  options.setIgnoreUntrustedSSLError(
427
428
  Boolean.TRUE.equals(call.getBoolean("ignoreUntrustedSSLError", false))
428
429
  );
429
430
 
431
+ // Set text zoom if specified in options (default is 100)
432
+ Integer textZoom = call.getInt("textZoom");
433
+ if (textZoom != null) {
434
+ options.setTextZoom(textZoom);
435
+ }
436
+
430
437
  String proxyRequestsStr = call.getString("proxyRequests");
431
438
  if (proxyRequestsStr != null) {
432
439
  try {
@@ -440,31 +447,144 @@ public class InAppBrowserPlugin
440
447
  }
441
448
 
442
449
  try {
443
- Options.ButtonNearDone buttonNearDone =
444
- Options.ButtonNearDone.generateFromPluginCall(
445
- call,
446
- getActivity().getAssets()
447
- );
448
- options.setButtonNearDone(buttonNearDone);
449
- } catch (IllegalArgumentException illegalArgumentException) {
450
- call.reject(
451
- String.format(
452
- "ButtonNearDone rejected: %s",
453
- illegalArgumentException.getMessage()
454
- )
455
- );
456
- } catch (RuntimeException e) {
450
+ // Try to set buttonNearDone if present, with better error handling
451
+ JSObject buttonNearDoneObj = call.getObject("buttonNearDone");
452
+ if (buttonNearDoneObj != null) {
453
+ try {
454
+ // Provide better debugging for buttonNearDone
455
+ JSObject androidObj = buttonNearDoneObj.getJSObject("android");
456
+ if (androidObj != null) {
457
+ String iconType = androidObj.getString("iconType", "asset");
458
+ String icon = androidObj.getString("icon", "");
459
+ Log.d(
460
+ "InAppBrowser",
461
+ "ButtonNearDone config - iconType: " +
462
+ iconType +
463
+ ", icon: " +
464
+ icon
465
+ );
466
+
467
+ // For vector type, verify if resource exists
468
+ if ("vector".equals(iconType)) {
469
+ int resourceId = getContext()
470
+ .getResources()
471
+ .getIdentifier(icon, "drawable", getContext().getPackageName());
472
+ if (resourceId == 0) {
473
+ Log.e("InAppBrowser", "Vector resource not found: " + icon);
474
+ // List available drawable resources to help debugging
475
+ try {
476
+ Field[] drawables = R.drawable.class.getFields();
477
+ StringBuilder availableResources = new StringBuilder(
478
+ "Available resources: "
479
+ );
480
+ for (int i = 0; i < Math.min(10, drawables.length); i++) {
481
+ availableResources
482
+ .append(drawables[i].getName())
483
+ .append(", ");
484
+ }
485
+ if (drawables.length > 10) {
486
+ availableResources
487
+ .append("... (")
488
+ .append(drawables.length - 10)
489
+ .append(" more)");
490
+ }
491
+ Log.d("InAppBrowser", availableResources.toString());
492
+ } catch (Exception e) {
493
+ Log.e(
494
+ "InAppBrowser",
495
+ "Error listing resources: " + e.getMessage()
496
+ );
497
+ }
498
+ } else {
499
+ Log.d(
500
+ "InAppBrowser",
501
+ "Vector resource found with ID: " + resourceId
502
+ );
503
+ }
504
+ }
505
+ }
506
+
507
+ // Try to create the ButtonNearDone object
508
+ Options.ButtonNearDone buttonNearDone =
509
+ Options.ButtonNearDone.generateFromPluginCall(
510
+ call,
511
+ getContext().getAssets()
512
+ );
513
+ options.setButtonNearDone(buttonNearDone);
514
+ } catch (Exception e) {
515
+ Log.e(
516
+ "InAppBrowser",
517
+ "Error setting buttonNearDone: " + e.getMessage(),
518
+ e
519
+ );
520
+ }
521
+ }
522
+ } catch (Exception e) {
457
523
  Log.e(
458
- "WebViewDialog",
459
- String.format("ButtonNearDone runtime error: %s", e)
524
+ "InAppBrowser",
525
+ "Error processing buttonNearDone: " + e.getMessage(),
526
+ e
460
527
  );
461
- call.reject(String.format("ButtonNearDone RuntimeException: %s", e));
462
528
  }
463
529
 
464
530
  options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
465
531
  options.setPreShowScript(call.getString("preShowScript", null));
466
532
  options.setShareSubject(call.getString("shareSubject", null));
467
533
  options.setToolbarType(call.getString("toolbarType", ""));
534
+
535
+ // Validate preShowScript requires isPresentAfterPageLoad
536
+ if (
537
+ call.hasOption("preShowScript") &&
538
+ !Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
539
+ ) {
540
+ call.reject("preShowScript requires isPresentAfterPageLoad to be true");
541
+ return;
542
+ }
543
+
544
+ // Validate closeModal options
545
+ if (Boolean.TRUE.equals(call.getBoolean("closeModal", false))) {
546
+ options.setCloseModal(true);
547
+ options.setCloseModalTitle(call.getString("closeModalTitle", "Close"));
548
+ options.setCloseModalDescription(
549
+ call.getString("closeModalDescription", "Are you sure ?")
550
+ );
551
+ options.setCloseModalOk(call.getString("closeModalOk", "Ok"));
552
+ options.setCloseModalCancel(call.getString("closeModalCancel", "Cancel"));
553
+ } else {
554
+ // Reject if closeModal is false but closeModal options are provided
555
+ if (
556
+ call.hasOption("closeModalTitle") ||
557
+ call.hasOption("closeModalDescription") ||
558
+ call.hasOption("closeModalOk") ||
559
+ call.hasOption("closeModalCancel")
560
+ ) {
561
+ call.reject("closeModal options require closeModal to be true");
562
+ return;
563
+ }
564
+ options.setCloseModal(false);
565
+ }
566
+
567
+ // Validate shareDisclaimer requires shareSubject
568
+ if (call.hasOption("shareDisclaimer") && !call.hasOption("shareSubject")) {
569
+ call.reject("shareDisclaimer requires shareSubject to be provided");
570
+ return;
571
+ }
572
+
573
+ // Validate buttonNearDone compatibility with toolbar type
574
+ if (call.hasOption("buttonNearDone")) {
575
+ String toolbarType = options.getToolbarType();
576
+ if (
577
+ TextUtils.equals(toolbarType, "activity") ||
578
+ TextUtils.equals(toolbarType, "navigation") ||
579
+ TextUtils.equals(toolbarType, "blank")
580
+ ) {
581
+ call.reject(
582
+ "buttonNearDone is not compatible with toolbarType: " + toolbarType
583
+ );
584
+ return;
585
+ }
586
+ }
587
+
468
588
  options.setActiveNativeNavigationForWebview(
469
589
  Boolean.TRUE.equals(
470
590
  call.getBoolean("activeNativeNavigationForWebview", false)
@@ -478,18 +598,13 @@ public class InAppBrowserPlugin
478
598
  options.setPresentAfterPageLoad(
479
599
  Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
480
600
  );
481
- if (Boolean.TRUE.equals(call.getBoolean("closeModal", false))) {
482
- options.setCloseModal(true);
483
- options.setCloseModalTitle(call.getString("closeModalTitle", "Close"));
484
- options.setCloseModalDescription(
485
- call.getString("closeModalDescription", "Are you sure ?")
486
- );
487
- options.setCloseModalOk(call.getString("closeModalOk", "Ok"));
488
- options.setCloseModalCancel(call.getString("closeModalCancel", "Cancel"));
489
- } else {
490
- options.setCloseModal(false);
491
- }
492
601
  options.setPluginCall(call);
602
+
603
+ // Set Material Design picker option
604
+ options.setMaterialPicker(
605
+ Boolean.TRUE.equals(call.getBoolean("materialPicker", false))
606
+ );
607
+
493
608
  // options.getToolbarItemTypes().add(ToolbarItemType.RELOAD); TODO: fix this
494
609
  options.setCallbacks(
495
610
  new WebViewCallbacks() {
@@ -518,6 +633,11 @@ public class InAppBrowserPlugin
518
633
  notifyListeners("buttonNearDoneClick", new JSObject());
519
634
  }
520
635
 
636
+ @Override
637
+ public void confirmBtnClicked() {
638
+ notifyListeners("confirmBtnClicked", new JSObject());
639
+ }
640
+
521
641
  @Override
522
642
  public void javascriptCallback(String message) {
523
643
  // Handle the message received from JavaScript