@capgo/inappbrowser 7.3.2 → 7.4.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.
- package/README.md +47 -41
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +149 -41
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +65 -22
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +2 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +647 -92
- package/android/src/main/res/drawable/ic_share.xml +10 -0
- package/android/src/main/res/layout/activity_browser.xml +8 -0
- package/android/src/main/res/layout/tool_bar.xml +19 -7
- package/android/src/main/res/values/strings.xml +2 -0
- package/dist/docs.json +169 -35
- package/dist/esm/definitions.d.ts +222 -29
- package/dist/esm/definitions.js +12 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +12 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +12 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +339 -44
- package/ios/Plugin/WKWebViewController.swift +478 -45
- package/package.json +1 -1
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
- package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
package/README.md
CHANGED
|
@@ -247,6 +247,11 @@ openWebView(options: OpenWebViewOptions) => Promise<any>
|
|
|
247
247
|
|
|
248
248
|
Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.
|
|
249
249
|
|
|
250
|
+
JavaScript Interface:
|
|
251
|
+
When you open a webview with this method, a JavaScript interface is automatically injected that provides:
|
|
252
|
+
- `window.mobileApp.close()`: Closes the webview from JavaScript
|
|
253
|
+
- `window.mobileApp.postMessage(obj)`: Sends a message from the webview to the app
|
|
254
|
+
|
|
250
255
|
| Param | Type |
|
|
251
256
|
| ------------- | ----------------------------------------------------------------- |
|
|
252
257
|
| **`options`** | <code><a href="#openwebviewoptions">OpenWebViewOptions</a></code> |
|
|
@@ -480,7 +485,7 @@ Reload the current web page.
|
|
|
480
485
|
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | 0.1.0 |
|
|
481
486
|
| **`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 |
|
|
482
487
|
| **`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 |
|
|
483
|
-
| **`preventDeeplink`** | <code>boolean</code> |
|
|
488
|
+
| **`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 |
|
|
484
489
|
|
|
485
490
|
|
|
486
491
|
#### Headers
|
|
@@ -520,44 +525,46 @@ Reload the current web page.
|
|
|
520
525
|
|
|
521
526
|
#### OpenWebViewOptions
|
|
522
527
|
|
|
523
|
-
| Prop | Type
|
|
524
|
-
| -------------------------------------- |
|
|
525
|
-
| **`url`** | <code>string</code>
|
|
526
|
-
| **`headers`** | <code><a href="#headers">Headers</a></code>
|
|
527
|
-
| **`credentials`** | <code><a href="#credentials">Credentials</a></code>
|
|
528
|
-
| **`
|
|
529
|
-
| **`
|
|
530
|
-
| **`
|
|
531
|
-
| **`
|
|
532
|
-
| **`
|
|
533
|
-
| **`
|
|
534
|
-
| **`
|
|
535
|
-
| **`
|
|
536
|
-
| **`
|
|
537
|
-
| **`
|
|
538
|
-
| **`
|
|
539
|
-
| **`
|
|
540
|
-
| **`
|
|
541
|
-
| **`
|
|
542
|
-
| **`
|
|
543
|
-
| **`
|
|
544
|
-
| **`
|
|
545
|
-
| **`
|
|
546
|
-
| **`
|
|
547
|
-
| **`
|
|
548
|
-
| **`
|
|
549
|
-
| **`
|
|
550
|
-
| **`
|
|
528
|
+
| Prop | Type | Description | Default | Since |
|
|
529
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
|
|
530
|
+
| **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
|
|
531
|
+
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
|
|
532
|
+
| **`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 |
|
|
533
|
+
| **`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 |
|
|
534
|
+
| **`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 |
|
|
535
|
+
| **`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 |
|
|
536
|
+
| **`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 |
|
|
537
|
+
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
|
|
538
|
+
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
539
|
+
| **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
|
|
540
|
+
| **`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> | |
|
|
541
|
+
| **`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 |
|
|
542
|
+
| **`isInspectable`** | <code>boolean</code> | Whether the website in the webview is inspectable or not, ios only | <code>false</code> | |
|
|
543
|
+
| **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
|
|
544
|
+
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
545
|
+
| **`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 |
|
|
546
|
+
| **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button | <code>'Close'</code> | 1.1.0 |
|
|
547
|
+
| **`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 |
|
|
548
|
+
| **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>'Close'</code> | 1.1.0 |
|
|
549
|
+
| **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>'Cancel'</code> | 1.1.0 |
|
|
550
|
+
| **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
|
|
551
|
+
| **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff'</code> | 1.2.5 |
|
|
552
|
+
| **`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 |
|
|
553
|
+
| **`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 |
|
|
554
|
+
| **`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 |
|
|
555
|
+
| **`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 |
|
|
556
|
+
| **`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 |
|
|
557
|
+
| **`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 |
|
|
551
558
|
|
|
552
559
|
|
|
553
560
|
#### DisclaimerOptions
|
|
554
561
|
|
|
555
|
-
| Prop | Type |
|
|
556
|
-
| ---------------- | ------------------- |
|
|
557
|
-
| **`title`** | <code>string</code> |
|
|
558
|
-
| **`message`** | <code>string</code> |
|
|
559
|
-
| **`confirmBtn`** | <code>string</code> |
|
|
560
|
-
| **`cancelBtn`** | <code>string</code> |
|
|
562
|
+
| Prop | Type | Description | Default |
|
|
563
|
+
| ---------------- | ------------------- | -------------------------------------- | ---------------------- |
|
|
564
|
+
| **`title`** | <code>string</code> | Title of the disclaimer dialog | <code>"Title"</code> |
|
|
565
|
+
| **`message`** | <code>string</code> | Message shown in the disclaimer dialog | <code>"Message"</code> |
|
|
566
|
+
| **`confirmBtn`** | <code>string</code> | Text for the confirm button | <code>"Confirm"</code> |
|
|
567
|
+
| **`cancelBtn`** | <code>string</code> | Text for the cancel button | <code>"Cancel"</code> |
|
|
561
568
|
|
|
562
569
|
|
|
563
570
|
#### PluginListenerHandle
|
|
@@ -642,12 +649,11 @@ Construct a type with a set of properties K of type T
|
|
|
642
649
|
|
|
643
650
|
#### ToolBarType
|
|
644
651
|
|
|
645
|
-
| Members | Value |
|
|
646
|
-
| ---------------- | ------------------------- |
|
|
647
|
-
| **`ACTIVITY`** | <code>"activity"</code> |
|
|
648
|
-
| **`NAVIGATION`** | <code>"navigation"</code> |
|
|
649
|
-
| **`BLANK`** | <code>"blank"</code> |
|
|
650
|
-
| **`DEFAULT`** | <code>""</code> |
|
|
652
|
+
| Members | Value | Description | Since |
|
|
653
|
+
| ---------------- | ------------------------- | ---------------------------------------------------------------- | ----- |
|
|
654
|
+
| **`ACTIVITY`** | <code>"activity"</code> | Shows a simple toolbar with just a close button and share button | 0.1.0 |
|
|
655
|
+
| **`NAVIGATION`** | <code>"navigation"</code> | Shows a full navigation toolbar with back/forward buttons | 0.1.0 |
|
|
656
|
+
| **`BLANK`** | <code>"blank"</code> | Shows no toolbar | 0.1.0 |
|
|
651
657
|
|
|
652
658
|
|
|
653
659
|
#### 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
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
144
|
-
if (data.getClipData() != null) {
|
|
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 (
|
|
151
|
-
|
|
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
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
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,6 +422,7 @@ 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))
|
|
@@ -440,31 +441,144 @@ public class InAppBrowserPlugin
|
|
|
440
441
|
}
|
|
441
442
|
|
|
442
443
|
try {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
444
|
+
// Try to set buttonNearDone if present, with better error handling
|
|
445
|
+
JSObject buttonNearDoneObj = call.getObject("buttonNearDone");
|
|
446
|
+
if (buttonNearDoneObj != null) {
|
|
447
|
+
try {
|
|
448
|
+
// Provide better debugging for buttonNearDone
|
|
449
|
+
JSObject androidObj = buttonNearDoneObj.getJSObject("android");
|
|
450
|
+
if (androidObj != null) {
|
|
451
|
+
String iconType = androidObj.getString("iconType", "asset");
|
|
452
|
+
String icon = androidObj.getString("icon", "");
|
|
453
|
+
Log.d(
|
|
454
|
+
"InAppBrowser",
|
|
455
|
+
"ButtonNearDone config - iconType: " +
|
|
456
|
+
iconType +
|
|
457
|
+
", icon: " +
|
|
458
|
+
icon
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
// For vector type, verify if resource exists
|
|
462
|
+
if ("vector".equals(iconType)) {
|
|
463
|
+
int resourceId = getContext()
|
|
464
|
+
.getResources()
|
|
465
|
+
.getIdentifier(icon, "drawable", getContext().getPackageName());
|
|
466
|
+
if (resourceId == 0) {
|
|
467
|
+
Log.e("InAppBrowser", "Vector resource not found: " + icon);
|
|
468
|
+
// List available drawable resources to help debugging
|
|
469
|
+
try {
|
|
470
|
+
Field[] drawables = R.drawable.class.getFields();
|
|
471
|
+
StringBuilder availableResources = new StringBuilder(
|
|
472
|
+
"Available resources: "
|
|
473
|
+
);
|
|
474
|
+
for (int i = 0; i < Math.min(10, drawables.length); i++) {
|
|
475
|
+
availableResources
|
|
476
|
+
.append(drawables[i].getName())
|
|
477
|
+
.append(", ");
|
|
478
|
+
}
|
|
479
|
+
if (drawables.length > 10) {
|
|
480
|
+
availableResources
|
|
481
|
+
.append("... (")
|
|
482
|
+
.append(drawables.length - 10)
|
|
483
|
+
.append(" more)");
|
|
484
|
+
}
|
|
485
|
+
Log.d("InAppBrowser", availableResources.toString());
|
|
486
|
+
} catch (Exception e) {
|
|
487
|
+
Log.e(
|
|
488
|
+
"InAppBrowser",
|
|
489
|
+
"Error listing resources: " + e.getMessage()
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
Log.d(
|
|
494
|
+
"InAppBrowser",
|
|
495
|
+
"Vector resource found with ID: " + resourceId
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Try to create the ButtonNearDone object
|
|
502
|
+
Options.ButtonNearDone buttonNearDone =
|
|
503
|
+
Options.ButtonNearDone.generateFromPluginCall(
|
|
504
|
+
call,
|
|
505
|
+
getContext().getAssets()
|
|
506
|
+
);
|
|
507
|
+
options.setButtonNearDone(buttonNearDone);
|
|
508
|
+
} catch (Exception e) {
|
|
509
|
+
Log.e(
|
|
510
|
+
"InAppBrowser",
|
|
511
|
+
"Error setting buttonNearDone: " + e.getMessage(),
|
|
512
|
+
e
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
} catch (Exception e) {
|
|
457
517
|
Log.e(
|
|
458
|
-
"
|
|
459
|
-
|
|
518
|
+
"InAppBrowser",
|
|
519
|
+
"Error processing buttonNearDone: " + e.getMessage(),
|
|
520
|
+
e
|
|
460
521
|
);
|
|
461
|
-
call.reject(String.format("ButtonNearDone RuntimeException: %s", e));
|
|
462
522
|
}
|
|
463
523
|
|
|
464
524
|
options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
|
|
465
525
|
options.setPreShowScript(call.getString("preShowScript", null));
|
|
466
526
|
options.setShareSubject(call.getString("shareSubject", null));
|
|
467
527
|
options.setToolbarType(call.getString("toolbarType", ""));
|
|
528
|
+
|
|
529
|
+
// Validate preShowScript requires isPresentAfterPageLoad
|
|
530
|
+
if (
|
|
531
|
+
call.hasOption("preShowScript") &&
|
|
532
|
+
!Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
|
|
533
|
+
) {
|
|
534
|
+
call.reject("preShowScript requires isPresentAfterPageLoad to be true");
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Validate closeModal options
|
|
539
|
+
if (Boolean.TRUE.equals(call.getBoolean("closeModal", false))) {
|
|
540
|
+
options.setCloseModal(true);
|
|
541
|
+
options.setCloseModalTitle(call.getString("closeModalTitle", "Close"));
|
|
542
|
+
options.setCloseModalDescription(
|
|
543
|
+
call.getString("closeModalDescription", "Are you sure ?")
|
|
544
|
+
);
|
|
545
|
+
options.setCloseModalOk(call.getString("closeModalOk", "Ok"));
|
|
546
|
+
options.setCloseModalCancel(call.getString("closeModalCancel", "Cancel"));
|
|
547
|
+
} else {
|
|
548
|
+
// Reject if closeModal is false but closeModal options are provided
|
|
549
|
+
if (
|
|
550
|
+
call.hasOption("closeModalTitle") ||
|
|
551
|
+
call.hasOption("closeModalDescription") ||
|
|
552
|
+
call.hasOption("closeModalOk") ||
|
|
553
|
+
call.hasOption("closeModalCancel")
|
|
554
|
+
) {
|
|
555
|
+
call.reject("closeModal options require closeModal to be true");
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
options.setCloseModal(false);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Validate shareDisclaimer requires shareSubject
|
|
562
|
+
if (call.hasOption("shareDisclaimer") && !call.hasOption("shareSubject")) {
|
|
563
|
+
call.reject("shareDisclaimer requires shareSubject to be provided");
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Validate buttonNearDone compatibility with toolbar type
|
|
568
|
+
if (call.hasOption("buttonNearDone")) {
|
|
569
|
+
String toolbarType = options.getToolbarType();
|
|
570
|
+
if (
|
|
571
|
+
TextUtils.equals(toolbarType, "activity") ||
|
|
572
|
+
TextUtils.equals(toolbarType, "navigation") ||
|
|
573
|
+
TextUtils.equals(toolbarType, "blank")
|
|
574
|
+
) {
|
|
575
|
+
call.reject(
|
|
576
|
+
"buttonNearDone is not compatible with toolbarType: " + toolbarType
|
|
577
|
+
);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
468
582
|
options.setActiveNativeNavigationForWebview(
|
|
469
583
|
Boolean.TRUE.equals(
|
|
470
584
|
call.getBoolean("activeNativeNavigationForWebview", false)
|
|
@@ -478,17 +592,6 @@ public class InAppBrowserPlugin
|
|
|
478
592
|
options.setPresentAfterPageLoad(
|
|
479
593
|
Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
|
|
480
594
|
);
|
|
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
595
|
options.setPluginCall(call);
|
|
493
596
|
// options.getToolbarItemTypes().add(ToolbarItemType.RELOAD); TODO: fix this
|
|
494
597
|
options.setCallbacks(
|
|
@@ -518,6 +621,11 @@ public class InAppBrowserPlugin
|
|
|
518
621
|
notifyListeners("buttonNearDoneClick", new JSObject());
|
|
519
622
|
}
|
|
520
623
|
|
|
624
|
+
@Override
|
|
625
|
+
public void confirmBtnClicked() {
|
|
626
|
+
notifyListeners("confirmBtnClicked", new JSObject());
|
|
627
|
+
}
|
|
628
|
+
|
|
521
629
|
@Override
|
|
522
630
|
public void javascriptCallback(String message) {
|
|
523
631
|
// Handle the message received from JavaScript
|
|
@@ -15,19 +15,23 @@ public class Options {
|
|
|
15
15
|
|
|
16
16
|
public enum AllIconTypes {
|
|
17
17
|
ASSET,
|
|
18
|
+
VECTOR,
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
private final AllIconTypes
|
|
21
|
+
private final AllIconTypes iconTypeEnum;
|
|
22
|
+
private final String iconType;
|
|
21
23
|
private final String icon;
|
|
22
24
|
private final int height;
|
|
23
25
|
private final int width;
|
|
24
26
|
|
|
25
27
|
private ButtonNearDone(
|
|
26
|
-
AllIconTypes
|
|
28
|
+
AllIconTypes iconTypeEnum,
|
|
29
|
+
String iconType,
|
|
27
30
|
String icon,
|
|
28
31
|
int height,
|
|
29
32
|
int width
|
|
30
33
|
) {
|
|
34
|
+
this.iconTypeEnum = iconTypeEnum;
|
|
31
35
|
this.iconType = iconType;
|
|
32
36
|
this.icon = icon;
|
|
33
37
|
this.height = height;
|
|
@@ -51,9 +55,16 @@ public class Options {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
String iconType = android.getString("iconType", "asset");
|
|
54
|
-
|
|
58
|
+
AllIconTypes iconTypeEnum;
|
|
59
|
+
|
|
60
|
+
// Validate and process icon type
|
|
61
|
+
if ("asset".equals(iconType)) {
|
|
62
|
+
iconTypeEnum = AllIconTypes.ASSET;
|
|
63
|
+
} else if ("vector".equals(iconType)) {
|
|
64
|
+
iconTypeEnum = AllIconTypes.VECTOR;
|
|
65
|
+
} else {
|
|
55
66
|
throw new IllegalArgumentException(
|
|
56
|
-
"buttonNearDone.android.iconType
|
|
67
|
+
"buttonNearDone.android.iconType must be 'asset' or 'vector'"
|
|
57
68
|
);
|
|
58
69
|
}
|
|
59
70
|
|
|
@@ -64,31 +75,50 @@ public class Options {
|
|
|
64
75
|
);
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
// For asset type, verify the file exists
|
|
79
|
+
if (iconTypeEnum == AllIconTypes.ASSET) {
|
|
80
|
+
InputStream fileInputString = null;
|
|
68
81
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
fileInputString = assetManager.open(icon);
|
|
72
|
-
// do nothing
|
|
73
|
-
} catch (IOException e) {
|
|
74
|
-
throw new IllegalArgumentException(
|
|
75
|
-
"buttonNearDone.android.icon cannot be found in the assetManager"
|
|
76
|
-
);
|
|
77
|
-
} finally {
|
|
78
|
-
// Close the input stream if it was opened
|
|
79
|
-
if (fileInputString != null) {
|
|
82
|
+
try {
|
|
83
|
+
// Try to find in public folder first
|
|
80
84
|
try {
|
|
81
|
-
fileInputString.
|
|
85
|
+
fileInputString = assetManager.open("public/" + icon);
|
|
82
86
|
} catch (IOException e) {
|
|
83
|
-
|
|
87
|
+
// If not in public, try in root assets
|
|
88
|
+
try {
|
|
89
|
+
fileInputString = assetManager.open(icon);
|
|
90
|
+
} catch (IOException e2) {
|
|
91
|
+
throw new IllegalArgumentException(
|
|
92
|
+
"buttonNearDone.android.icon cannot be found in the assetManager"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// File exists, do nothing
|
|
97
|
+
} finally {
|
|
98
|
+
// Close the input stream if it was opened
|
|
99
|
+
if (fileInputString != null) {
|
|
100
|
+
try {
|
|
101
|
+
fileInputString.close();
|
|
102
|
+
} catch (IOException e) {
|
|
103
|
+
e.printStackTrace();
|
|
104
|
+
}
|
|
84
105
|
}
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
|
-
|
|
108
|
+
// For vector type, we don't validate here since resources are checked at runtime
|
|
109
|
+
else if (iconTypeEnum == AllIconTypes.VECTOR) {
|
|
110
|
+
// Vector resources will be validated when used
|
|
111
|
+
System.out.println(
|
|
112
|
+
"Vector resource will be validated at runtime: " + icon
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Integer width = android.getInteger("width", 24);
|
|
117
|
+
Integer height = android.getInteger("height", 24);
|
|
88
118
|
|
|
89
|
-
Integer height = android.getInteger("height", 48);
|
|
90
119
|
final ButtonNearDone buttonNearDone1 = new ButtonNearDone(
|
|
91
|
-
|
|
120
|
+
iconTypeEnum,
|
|
121
|
+
iconType,
|
|
92
122
|
icon,
|
|
93
123
|
height,
|
|
94
124
|
width
|
|
@@ -96,7 +126,11 @@ public class Options {
|
|
|
96
126
|
return buttonNearDone1;
|
|
97
127
|
}
|
|
98
128
|
|
|
99
|
-
public AllIconTypes
|
|
129
|
+
public AllIconTypes getIconTypeEnum() {
|
|
130
|
+
return iconTypeEnum;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public String getIconType() {
|
|
100
134
|
return iconType;
|
|
101
135
|
}
|
|
102
136
|
|
|
@@ -136,6 +170,7 @@ public class Options {
|
|
|
136
170
|
private boolean ShowArrow;
|
|
137
171
|
private boolean ignoreUntrustedSSLError;
|
|
138
172
|
private String preShowScript;
|
|
173
|
+
private String toolbarTextColor;
|
|
139
174
|
private Pattern proxyRequestsPattern = null;
|
|
140
175
|
|
|
141
176
|
public Pattern getProxyRequestsPattern() {
|
|
@@ -320,6 +355,14 @@ public class Options {
|
|
|
320
355
|
this.ToolbarColor = toolbarColor;
|
|
321
356
|
}
|
|
322
357
|
|
|
358
|
+
public String getToolbarTextColor() {
|
|
359
|
+
return toolbarTextColor;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public void setToolbarTextColor(String toolbarTextColor) {
|
|
363
|
+
this.toolbarTextColor = toolbarTextColor;
|
|
364
|
+
}
|
|
365
|
+
|
|
323
366
|
public boolean showArrow() {
|
|
324
367
|
return ShowArrow;
|
|
325
368
|
}
|