@capgo/capacitor-inappbrowser 8.6.34 → 8.7.0-beta.pr596.340.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.
- package/README.md +127 -1
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java +194 -3
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +30 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +388 -8
- package/dist/docs.json +303 -4
- package/dist/esm/definitions.d.ts +127 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +10 -1
- package/dist/esm/web.js +16 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +16 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +16 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +442 -57
- package/ios/Sources/InAppBrowserPlugin/ProxySchemeHandler.swift +0 -1
- package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -426,10 +426,14 @@ The W3C Payment Request API (used by Google Pay) requires Android WebView 120+.
|
|
|
426
426
|
* [`clearCookies(...)`](#clearcookies)
|
|
427
427
|
* [`clearAllCookies(...)`](#clearallcookies)
|
|
428
428
|
* [`clearCache(...)`](#clearcache)
|
|
429
|
+
* [`clearAllBrowsingData()`](#clearallbrowsingdata)
|
|
429
430
|
* [`getCookies(...)`](#getcookies)
|
|
430
431
|
* [`close(...)`](#close)
|
|
431
432
|
* [`hide(...)`](#hide)
|
|
432
433
|
* [`show(...)`](#show)
|
|
434
|
+
* [`sendToBack(...)`](#sendtoback)
|
|
435
|
+
* [`bringToFront(...)`](#bringtofront)
|
|
436
|
+
* [`dispatchInputEvent(...)`](#dispatchinputevent)
|
|
433
437
|
* [`openWebView(...)`](#openwebview)
|
|
434
438
|
* [`executeScript(...)`](#executescript)
|
|
435
439
|
* [`postMessage(...)`](#postmessage)
|
|
@@ -563,6 +567,24 @@ When `id` is omitted, applies to all open webviews.
|
|
|
563
567
|
--------------------
|
|
564
568
|
|
|
565
569
|
|
|
570
|
+
### clearAllBrowsingData()
|
|
571
|
+
|
|
572
|
+
```typescript
|
|
573
|
+
clearAllBrowsingData() => Promise<any>
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
Clear all browsing data from the default store and any opened managed webviews.
|
|
577
|
+
|
|
578
|
+
This removes cookies, disk cache, memory cache, local storage, session storage, IndexedDB,
|
|
579
|
+
WebSQL where supported, form data, and HTTP auth data where the platform exposes it.
|
|
580
|
+
|
|
581
|
+
**Returns:** <code>Promise<any></code>
|
|
582
|
+
|
|
583
|
+
**Since:** 8.6.36
|
|
584
|
+
|
|
585
|
+
--------------------
|
|
586
|
+
|
|
587
|
+
|
|
566
588
|
### getCookies(...)
|
|
567
589
|
|
|
568
590
|
```typescript
|
|
@@ -635,6 +657,54 @@ When `id` is omitted, targets the active webview.
|
|
|
635
657
|
--------------------
|
|
636
658
|
|
|
637
659
|
|
|
660
|
+
### sendToBack(...)
|
|
661
|
+
|
|
662
|
+
```typescript
|
|
663
|
+
sendToBack(options?: LayerOptions | undefined) => Promise<void>
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
Moves the native browser behind the Capacitor host WebView.
|
|
667
|
+
Use `dispatchInputEvent()` to forward overlay gestures to the browser while it is behind the app UI.
|
|
668
|
+
|
|
669
|
+
| Param | Type |
|
|
670
|
+
| ------------- | ----------------------------------------------------- |
|
|
671
|
+
| **`options`** | <code><a href="#layeroptions">LayerOptions</a></code> |
|
|
672
|
+
|
|
673
|
+
--------------------
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
### bringToFront(...)
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
bringToFront(options?: { id?: string | undefined; } | undefined) => Promise<void>
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
Moves a browser that was behind the host WebView back to the front.
|
|
683
|
+
When `id` is omitted, targets the active webview.
|
|
684
|
+
|
|
685
|
+
| Param | Type |
|
|
686
|
+
| ------------- | ----------------------------- |
|
|
687
|
+
| **`options`** | <code>{ id?: string; }</code> |
|
|
688
|
+
|
|
689
|
+
--------------------
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
### dispatchInputEvent(...)
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
dispatchInputEvent(options: DispatchInputEventOptions) => Promise<void>
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
Dispatches a click, touch, or scroll event to a managed browser.
|
|
699
|
+
Coordinates are relative to the browser viewport in CSS pixels.
|
|
700
|
+
|
|
701
|
+
| Param | Type |
|
|
702
|
+
| ------------- | ------------------------------------------------------------------------------- |
|
|
703
|
+
| **`options`** | <code><a href="#dispatchinputeventoptions">DispatchInputEventOptions</a></code> |
|
|
704
|
+
|
|
705
|
+
--------------------
|
|
706
|
+
|
|
707
|
+
|
|
638
708
|
### openWebView(...)
|
|
639
709
|
|
|
640
710
|
```typescript
|
|
@@ -759,6 +829,10 @@ Listen for url change, only for openWebView
|
|
|
759
829
|
addListener(eventName: 'buttonNearDoneClick', listenerFunc: ButtonNearListener) => Promise<PluginListenerHandle>
|
|
760
830
|
```
|
|
761
831
|
|
|
832
|
+
Listen for buttonNearDone clicks.
|
|
833
|
+
|
|
834
|
+
The event payload contains the webview `id`.
|
|
835
|
+
|
|
762
836
|
| Param | Type |
|
|
763
837
|
| ------------------ | ----------------------------------------------------------------- |
|
|
764
838
|
| **`eventName`** | <code>'buttonNearDoneClick'</code> |
|
|
@@ -766,6 +840,8 @@ addListener(eventName: 'buttonNearDoneClick', listenerFunc: ButtonNearListener)
|
|
|
766
840
|
|
|
767
841
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
768
842
|
|
|
843
|
+
**Since:** 0.0.1
|
|
844
|
+
|
|
769
845
|
--------------------
|
|
770
846
|
|
|
771
847
|
|
|
@@ -1225,6 +1301,36 @@ And in the AndroidManifest.xml file:
|
|
|
1225
1301
|
| **`isAnimated`** | <code>boolean</code> | Whether the webview closing is animated or not, ios only | <code>true</code> |
|
|
1226
1302
|
|
|
1227
1303
|
|
|
1304
|
+
#### LayerOptions
|
|
1305
|
+
|
|
1306
|
+
| Prop | Type | Description | Default |
|
|
1307
|
+
| --------------------------- | -------------------- | ------------------------------------------------------------------------------------ | ----------------- |
|
|
1308
|
+
| **`id`** | <code>string</code> | Target webview id. If omitted, targets the active webview. | |
|
|
1309
|
+
| **`transparentBackground`** | <code>boolean</code> | Makes the Capacitor host WebView transparent while this native webview is behind it. | <code>true</code> |
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
#### DispatchPointerInputEventOptions
|
|
1313
|
+
|
|
1314
|
+
| Prop | Type | Description |
|
|
1315
|
+
| ---------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
1316
|
+
| **`id`** | <code>string</code> | Target webview id. If omitted, targets the active webview. |
|
|
1317
|
+
| **`type`** | <code><a href="#webviewpointerinputeventtype">WebViewPointerInputEventType</a></code> | Input event to dispatch to the webview. |
|
|
1318
|
+
| **`x`** | <code>number</code> | X coordinate in CSS pixels from the webview's left edge. |
|
|
1319
|
+
| **`y`** | <code>number</code> | Y coordinate in CSS pixels from the webview's top edge. |
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
#### DispatchScrollInputEventOptions
|
|
1323
|
+
|
|
1324
|
+
| Prop | Type | Description |
|
|
1325
|
+
| ------------ | --------------------- | -------------------------------------------------------------------- |
|
|
1326
|
+
| **`id`** | <code>string</code> | Target webview id. If omitted, targets the active webview. |
|
|
1327
|
+
| **`type`** | <code>'scroll'</code> | Input event to dispatch to the webview. |
|
|
1328
|
+
| **`x`** | <code>number</code> | X coordinate in CSS pixels from the webview's left edge. |
|
|
1329
|
+
| **`y`** | <code>number</code> | Y coordinate in CSS pixels from the webview's top edge. |
|
|
1330
|
+
| **`deltaX`** | <code>number</code> | Horizontal scroll delta in CSS pixels. Used when `type` is `scroll`. |
|
|
1331
|
+
| **`deltaY`** | <code>number</code> | Vertical scroll delta in CSS pixels. Used when `type` is `scroll`. |
|
|
1332
|
+
|
|
1333
|
+
|
|
1228
1334
|
#### OpenWebViewOptions
|
|
1229
1335
|
|
|
1230
1336
|
| Prop | Type | Description | Default | Since |
|
|
@@ -1238,6 +1344,7 @@ And in the AndroidManifest.xml file:
|
|
|
1238
1344
|
| **`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) - `window.mobileApp.hide()` / `window.mobileApp.show()` when allowWebViewJsVisibilityControl is true in CapacitorConfig - `window.mobileApp.takeScreenshot()` when `allowScreenshotsFromWebPage` is true | | 6.10.0 |
|
|
1239
1345
|
| **`allowScreenshotsFromWebPage`** | <code>boolean</code> | Allows page JavaScript to call `window.mobileApp.takeScreenshot()`. Disabled by default so only the host app can trigger native screenshots through the plugin API. | <code>false</code> | 8.4.0 |
|
|
1240
1346
|
| **`captureConsoleLogs`** | <code>boolean</code> | Emits `consoleMessage` events for JavaScript `console.*` output coming from the managed page. Useful when the webview stays hidden and you still need page-level diagnostics. | <code>false</code> | 8.6.0 |
|
|
1347
|
+
| **`persistWebViewData`** | <code>boolean</code> | Controls whether the webview should persist website data such as cache, cookies, local storage, IndexedDB, and session data. When false, iOS uses a non-persistent `WKWebsiteDataStore`. Android disables per-view cache and DOM/database storage where the system WebView supports it. Android cookies use the shared WebView cookie store, so call `clearAllBrowsingData()` to remove cookies and other global data. | <code>true</code> | 8.6.36 |
|
|
1241
1348
|
| **`handleDownloads`** | <code>boolean</code> | Automatically handles downloads triggered inside the webview without requiring a custom JavaScript bridge. When enabled: - Standard attachment responses are written to a temporary file. - `blob:` downloads are also captured when the platform supports them. - Previewable files reopen inside the in-app browser when possible. - Other files are handed off to the native preview or viewer flow. - `downloadCompleted` and `downloadFailed` events notify the host app about the saved file. | <code>false</code> | 8.6.0 |
|
|
1242
1349
|
| **`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 |
|
|
1243
1350
|
| **`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 |
|
|
@@ -1283,6 +1390,8 @@ And in the AndroidManifest.xml file:
|
|
|
1283
1390
|
| **`height`** | <code>number</code> | Height of the webview in pixels. If not set, webview will be fullscreen height. | <code>undefined (fullscreen)</code> | |
|
|
1284
1391
|
| **`x`** | <code>number</code> | X position of the webview in pixels from the left edge. Only effective when width is set. | <code>0</code> | |
|
|
1285
1392
|
| **`y`** | <code>number</code> | Y position of the webview in pixels from the top edge. Only effective when height is set. | <code>0</code> | |
|
|
1393
|
+
| **`toBack`** | <code>boolean</code> | Places the native browser behind the Capacitor host WebView. Make the app background transparent to reveal it, or rely on `transparentBackground` to clear the host WebView. | <code>false</code> | |
|
|
1394
|
+
| **`transparentBackground`** | <code>boolean</code> | When `toBack` is true, makes the Capacitor host WebView transparent so the native browser can be seen behind Ionic content. Ignored when the browser is in front. | <code>true</code> | |
|
|
1286
1395
|
| **`disableOverscroll`** | <code>boolean</code> | Disables the bounce (overscroll) effect on iOS WebView. When enabled, prevents the rubber band scrolling effect when users scroll beyond content boundaries. This is useful for: - Creating a more native, app-like experience - Preventing accidental overscroll states - Avoiding issues when keyboard opens/closes Note: This option only affects iOS. Android does not have this bounce effect by default. | <code>false</code> | 8.0.2 |
|
|
1287
1396
|
| **`hidden`** | <code>boolean</code> | Opens the webview in hidden mode (not visible to user but fully functional). When hidden, the webview loads and executes JavaScript but is not displayed. All control methods (executeScript, postMessage, setUrl, etc.) work while hidden. Use close() to clean up the hidden webview when done. | <code>false</code> | 8.0.7 |
|
|
1288
1397
|
| **`invisibilityMode`** | <code><a href="#invisibilitymode">InvisibilityMode</a></code> | Controls how a hidden webview reports its visibility and size. - AWARE: webview is aware it's hidden (dimensions may be zero). - FAKE_VISIBLE: webview is hidden but reports fullscreen dimensions (uses alpha=0 to remain invisible). | <code>InvisibilityMode.AWARE</code> | |
|
|
@@ -1356,6 +1465,13 @@ Any regex property that is omitted is treated as a wildcard.
|
|
|
1356
1465
|
| **`url`** | <code>string</code> | Emit when the url changes | 0.0.1 |
|
|
1357
1466
|
|
|
1358
1467
|
|
|
1468
|
+
#### ButtonNearDoneEvent
|
|
1469
|
+
|
|
1470
|
+
| Prop | Type | Description | Since |
|
|
1471
|
+
| -------- | ------------------- | -------------------- | ------ |
|
|
1472
|
+
| **`id`** | <code>string</code> | Webview instance id. | 8.6.36 |
|
|
1473
|
+
|
|
1474
|
+
|
|
1359
1475
|
#### BtnEvent
|
|
1360
1476
|
|
|
1361
1477
|
| Prop | Type | Description | Since |
|
|
@@ -1561,6 +1677,16 @@ Construct a type with a set of properties K of type T
|
|
|
1561
1677
|
<code><a href="#omit">Omit</a><<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'></code>
|
|
1562
1678
|
|
|
1563
1679
|
|
|
1680
|
+
#### DispatchInputEventOptions
|
|
1681
|
+
|
|
1682
|
+
<code><a href="#dispatchpointerinputeventoptions">DispatchPointerInputEventOptions</a> | <a href="#dispatchscrollinputeventoptions">DispatchScrollInputEventOptions</a></code>
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
#### WebViewPointerInputEventType
|
|
1686
|
+
|
|
1687
|
+
<code>'click' | 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel'</code>
|
|
1688
|
+
|
|
1689
|
+
|
|
1564
1690
|
#### UrlChangeListener
|
|
1565
1691
|
|
|
1566
1692
|
<code>(state: <a href="#urlevent">UrlEvent</a>): void</code>
|
|
@@ -1568,7 +1694,7 @@ Construct a type with a set of properties K of type T
|
|
|
1568
1694
|
|
|
1569
1695
|
#### ButtonNearListener
|
|
1570
1696
|
|
|
1571
|
-
<code>(state:
|
|
1697
|
+
<code>(state: <a href="#buttonneardoneevent">ButtonNearDoneEvent</a>): void</code>
|
|
1572
1698
|
|
|
1573
1699
|
|
|
1574
1700
|
#### ConfirmBtnListener
|
|
@@ -19,7 +19,9 @@ import android.text.TextUtils;
|
|
|
19
19
|
import android.util.Log;
|
|
20
20
|
import android.webkit.CookieManager;
|
|
21
21
|
import android.webkit.PermissionRequest;
|
|
22
|
+
import android.webkit.WebStorage;
|
|
22
23
|
import android.webkit.WebView;
|
|
24
|
+
import android.webkit.WebViewDatabase;
|
|
23
25
|
import androidx.activity.result.ActivityResult;
|
|
24
26
|
import androidx.activity.result.ActivityResultLauncher;
|
|
25
27
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
@@ -405,6 +407,35 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
405
407
|
return webViewDialog;
|
|
406
408
|
}
|
|
407
409
|
|
|
410
|
+
private double getNumberOption(PluginCall call, String name, double defaultValue) {
|
|
411
|
+
Object value = call.getData().opt(name);
|
|
412
|
+
if (value instanceof Number numberValue) {
|
|
413
|
+
return numberValue.doubleValue();
|
|
414
|
+
}
|
|
415
|
+
return defaultValue;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
private Double getFiniteNumberOption(PluginCall call, String name) {
|
|
419
|
+
Object value = call.getData().opt(name);
|
|
420
|
+
if (value instanceof Number numberValue) {
|
|
421
|
+
double doubleValue = numberValue.doubleValue();
|
|
422
|
+
if (Double.isFinite(doubleValue)) {
|
|
423
|
+
return doubleValue;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private boolean isPointerInputEvent(String type) {
|
|
430
|
+
return (
|
|
431
|
+
"click".equals(type) ||
|
|
432
|
+
"touchstart".equals(type) ||
|
|
433
|
+
"touchmove".equals(type) ||
|
|
434
|
+
"touchend".equals(type) ||
|
|
435
|
+
"touchcancel".equals(type)
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
408
439
|
private ArrayList<WebView> cacheWebViewsFor(String targetId) {
|
|
409
440
|
ArrayList<WebView> targetWebViews = new ArrayList<>();
|
|
410
441
|
if (targetId != null) {
|
|
@@ -813,6 +844,41 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
813
844
|
call.resolve();
|
|
814
845
|
}
|
|
815
846
|
|
|
847
|
+
@PluginMethod
|
|
848
|
+
public void clearAllBrowsingData(PluginCall call) {
|
|
849
|
+
this.getActivity().runOnUiThread(() -> {
|
|
850
|
+
try {
|
|
851
|
+
ArrayList<WebView> targetWebViews = cacheWebViewsFor(null);
|
|
852
|
+
WebView bridgeWebView = getBridge() != null ? getBridge().getWebView() : null;
|
|
853
|
+
if (bridgeWebView != null && !targetWebViews.contains(bridgeWebView)) {
|
|
854
|
+
targetWebViews.add(bridgeWebView);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
for (WebView targetWebView : targetWebViews) {
|
|
858
|
+
targetWebView.stopLoading();
|
|
859
|
+
targetWebView.clearCache(true);
|
|
860
|
+
targetWebView.clearHistory();
|
|
861
|
+
targetWebView.clearFormData();
|
|
862
|
+
targetWebView.clearSslPreferences();
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
WebStorage.getInstance().deleteAllData();
|
|
866
|
+
WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(getContext());
|
|
867
|
+
webViewDatabase.clearFormData();
|
|
868
|
+
webViewDatabase.clearHttpAuthUsernamePassword();
|
|
869
|
+
|
|
870
|
+
CookieManager cookieManager = CookieManager.getInstance();
|
|
871
|
+
cookieManager.removeAllCookies((value) -> {
|
|
872
|
+
cookieManager.flush();
|
|
873
|
+
call.resolve();
|
|
874
|
+
});
|
|
875
|
+
} catch (Exception e) {
|
|
876
|
+
Log.e("InAppBrowser", "Error clearing browsing data: " + e.getMessage());
|
|
877
|
+
call.reject("Failed to clear browsing data: " + e.getMessage());
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
|
|
816
882
|
@PluginMethod
|
|
817
883
|
public void clearCookies(PluginCall call) {
|
|
818
884
|
String url = call.getString("url", currentUrl);
|
|
@@ -942,6 +1008,7 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
942
1008
|
options.setCaptureConsoleLogs(Boolean.TRUE.equals(call.getBoolean("captureConsoleLogs", false)));
|
|
943
1009
|
options.setHandleDownloads(Boolean.TRUE.equals(call.getBoolean("handleDownloads", false)));
|
|
944
1010
|
|
|
1011
|
+
options.setPersistWebViewData(call.getBoolean("persistWebViewData", true));
|
|
945
1012
|
// Set text zoom if specified in options (default is 100)
|
|
946
1013
|
Integer textZoom = call.getInt("textZoom");
|
|
947
1014
|
if (textZoom != null) {
|
|
@@ -1173,6 +1240,8 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
1173
1240
|
}
|
|
1174
1241
|
|
|
1175
1242
|
options.setHidden(Boolean.TRUE.equals(call.getBoolean("hidden", false)));
|
|
1243
|
+
options.setToBack(Boolean.TRUE.equals(call.getBoolean("toBack", false)));
|
|
1244
|
+
options.setTransparentBackground(call.getBoolean("transparentBackground", true));
|
|
1176
1245
|
boolean allowWebViewJsVisibilityControl = getConfig().getBoolean("allowWebViewJsVisibilityControl", false);
|
|
1177
1246
|
options.setAllowWebViewJsVisibilityControl(allowWebViewJsVisibilityControl);
|
|
1178
1247
|
options.setInvisibilityMode(Options.InvisibilityMode.fromString(call.getString("invisibilityMode", "AWARE")));
|
|
@@ -1303,10 +1372,16 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
1303
1372
|
call.reject("WebView is not initialized");
|
|
1304
1373
|
return;
|
|
1305
1374
|
}
|
|
1306
|
-
if (!dialog.isShowing()) {
|
|
1307
|
-
dialog.show();
|
|
1308
|
-
}
|
|
1309
1375
|
dialog.setHidden(false);
|
|
1376
|
+
Options options = dialog.getOptions();
|
|
1377
|
+
if (options != null && options.isToBack()) {
|
|
1378
|
+
if (!dialog.sendToBack(options.getTransparentBackground())) {
|
|
1379
|
+
call.reject("Failed to send webview to back");
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
} else {
|
|
1383
|
+
dialog.bringToFrontLayer();
|
|
1384
|
+
}
|
|
1310
1385
|
if (dialog.getInstanceId() != null) {
|
|
1311
1386
|
setActiveWebView(dialog.getInstanceId(), dialog);
|
|
1312
1387
|
}
|
|
@@ -1316,6 +1391,122 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
1316
1391
|
);
|
|
1317
1392
|
}
|
|
1318
1393
|
|
|
1394
|
+
@PluginMethod
|
|
1395
|
+
public void sendToBack(PluginCall call) {
|
|
1396
|
+
String targetId = resolveTargetId(call);
|
|
1397
|
+
WebViewDialog targetDialog = resolveDialog(targetId);
|
|
1398
|
+
if (targetDialog == null) {
|
|
1399
|
+
call.reject("WebView is not initialized");
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
boolean transparentBackground = call.getBoolean("transparentBackground", true);
|
|
1404
|
+
this.getActivity().runOnUiThread(
|
|
1405
|
+
new Runnable() {
|
|
1406
|
+
@Override
|
|
1407
|
+
public void run() {
|
|
1408
|
+
WebViewDialog dialog = resolveDialog(targetId);
|
|
1409
|
+
if (dialog == null) {
|
|
1410
|
+
call.reject("WebView is not initialized");
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
if (!dialog.sendToBack(transparentBackground)) {
|
|
1414
|
+
call.reject("Failed to send webview to back");
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (dialog.getInstanceId() != null) {
|
|
1418
|
+
setActiveWebView(dialog.getInstanceId(), dialog);
|
|
1419
|
+
}
|
|
1420
|
+
call.resolve();
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
@PluginMethod
|
|
1427
|
+
public void bringToFront(PluginCall call) {
|
|
1428
|
+
String targetId = resolveTargetId(call);
|
|
1429
|
+
WebViewDialog targetDialog = resolveDialog(targetId);
|
|
1430
|
+
if (targetDialog == null) {
|
|
1431
|
+
call.reject("WebView is not initialized");
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
this.getActivity().runOnUiThread(
|
|
1436
|
+
new Runnable() {
|
|
1437
|
+
@Override
|
|
1438
|
+
public void run() {
|
|
1439
|
+
WebViewDialog dialog = resolveDialog(targetId);
|
|
1440
|
+
if (dialog == null) {
|
|
1441
|
+
call.reject("WebView is not initialized");
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
dialog.bringToFrontLayer();
|
|
1445
|
+
if (dialog.getInstanceId() != null) {
|
|
1446
|
+
setActiveWebView(dialog.getInstanceId(), dialog);
|
|
1447
|
+
}
|
|
1448
|
+
call.resolve();
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
@PluginMethod
|
|
1455
|
+
public void dispatchInputEvent(PluginCall call) {
|
|
1456
|
+
String type = call.getString("type");
|
|
1457
|
+
if (type == null || type.trim().isEmpty()) {
|
|
1458
|
+
call.reject("Input event type is required");
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
String targetId = resolveTargetId(call);
|
|
1462
|
+
WebViewDialog targetDialog = resolveDialog(targetId);
|
|
1463
|
+
if (targetDialog == null) {
|
|
1464
|
+
call.reject("WebView is not initialized");
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
Double xValue = getFiniteNumberOption(call, "x");
|
|
1469
|
+
Double yValue = getFiniteNumberOption(call, "y");
|
|
1470
|
+
Double deltaXValue = getFiniteNumberOption(call, "deltaX");
|
|
1471
|
+
Double deltaYValue = getFiniteNumberOption(call, "deltaY");
|
|
1472
|
+
if ("scroll".equals(type)) {
|
|
1473
|
+
if (xValue == null || yValue == null || deltaXValue == null || deltaYValue == null) {
|
|
1474
|
+
call.reject("dispatchInputEvent scroll requires finite x, y, deltaX, and deltaY");
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
} else if (isPointerInputEvent(type)) {
|
|
1478
|
+
if (xValue == null || yValue == null) {
|
|
1479
|
+
call.reject("dispatchInputEvent " + type + " requires finite x and y");
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
} else {
|
|
1483
|
+
call.reject("Unsupported input event type: " + type);
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
double x = xValue;
|
|
1488
|
+
double y = yValue;
|
|
1489
|
+
double deltaX = deltaXValue != null ? deltaXValue : 0d;
|
|
1490
|
+
double deltaY = deltaYValue != null ? deltaYValue : 0d;
|
|
1491
|
+
this.getActivity().runOnUiThread(
|
|
1492
|
+
new Runnable() {
|
|
1493
|
+
@Override
|
|
1494
|
+
public void run() {
|
|
1495
|
+
WebViewDialog dialog = resolveDialog(targetId);
|
|
1496
|
+
if (dialog == null) {
|
|
1497
|
+
call.reject("WebView is not initialized");
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
if (!dialog.dispatchInputEvent(type, x, y, deltaX, deltaY)) {
|
|
1501
|
+
call.reject("Unsupported input event type or invalid input payload: " + type);
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
call.resolve();
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1319
1510
|
@PluginMethod
|
|
1320
1511
|
public void executeScript(PluginCall call) {
|
|
1321
1512
|
String script = call.getString("code");
|
|
@@ -191,11 +191,14 @@ public class Options {
|
|
|
191
191
|
private Integer x = null;
|
|
192
192
|
private Integer y = null;
|
|
193
193
|
private boolean hidden = false;
|
|
194
|
+
private boolean toBack = false;
|
|
195
|
+
private boolean transparentBackground = true;
|
|
194
196
|
private boolean showScreenshotButton = false;
|
|
195
197
|
private boolean allowWebViewJsVisibilityControl = false;
|
|
196
198
|
private boolean allowScreenshotsFromWebPage = false;
|
|
197
199
|
private boolean captureConsoleLogs = false;
|
|
198
200
|
private boolean handleDownloads = false;
|
|
201
|
+
private boolean persistWebViewData = true;
|
|
199
202
|
private InvisibilityMode invisibilityMode = InvisibilityMode.AWARE;
|
|
200
203
|
private String httpMethod = null;
|
|
201
204
|
private String httpBody = null;
|
|
@@ -234,6 +237,22 @@ public class Options {
|
|
|
234
237
|
this.y = y;
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
public boolean isToBack() {
|
|
241
|
+
return toBack;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public void setToBack(boolean toBack) {
|
|
245
|
+
this.toBack = toBack;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public boolean getTransparentBackground() {
|
|
249
|
+
return transparentBackground;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void setTransparentBackground(boolean transparentBackground) {
|
|
253
|
+
this.transparentBackground = transparentBackground;
|
|
254
|
+
}
|
|
255
|
+
|
|
237
256
|
public int getTextZoom() {
|
|
238
257
|
return textZoom;
|
|
239
258
|
}
|
|
@@ -278,6 +297,14 @@ public class Options {
|
|
|
278
297
|
this.handleDownloads = handleDownloads;
|
|
279
298
|
}
|
|
280
299
|
|
|
300
|
+
public boolean getPersistWebViewData() {
|
|
301
|
+
return persistWebViewData;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
public void setPersistWebViewData(boolean persistWebViewData) {
|
|
305
|
+
this.persistWebViewData = persistWebViewData;
|
|
306
|
+
}
|
|
307
|
+
|
|
281
308
|
public void setMaterialPicker(boolean materialPicker) {
|
|
282
309
|
this.materialPicker = materialPicker;
|
|
283
310
|
}
|
|
@@ -708,7 +735,10 @@ public class Options {
|
|
|
708
735
|
copy.setEnableGooglePaySupport(enableGooglePaySupport);
|
|
709
736
|
copy.setBlockedHosts(new ArrayList<>(getBlockedHosts()));
|
|
710
737
|
copy.setWidth(width);
|
|
738
|
+
copy.setPersistWebViewData(persistWebViewData);
|
|
711
739
|
copy.setHeight(height);
|
|
740
|
+
copy.setToBack(toBack);
|
|
741
|
+
copy.setTransparentBackground(transparentBackground);
|
|
712
742
|
copy.setX(x);
|
|
713
743
|
copy.setY(y);
|
|
714
744
|
copy.setHidden(hidden || hiddenPopupWindow);
|