@capgo/capacitor-inappbrowser 8.6.20 → 8.6.22
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.
|
@@ -1416,6 +1416,8 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
1418
1418
|
private void downloadUrlToFile(String url, String userAgent, String contentDisposition, String mimeType) {
|
|
1419
|
+
// WebView methods must run on the main thread; capture the page URL before the background download starts.
|
|
1420
|
+
final String pageUrl = currentManagedDownloadPageUrl();
|
|
1419
1421
|
executorService.execute(() -> {
|
|
1420
1422
|
HttpURLConnection connection = null;
|
|
1421
1423
|
InputStream inputStream = null;
|
|
@@ -1423,7 +1425,6 @@ public class WebViewDialog extends Dialog implements ProxyResponseRouting.ProxyR
|
|
|
1423
1425
|
boolean downloadSucceeded = false;
|
|
1424
1426
|
|
|
1425
1427
|
try {
|
|
1426
|
-
String pageUrl = currentManagedDownloadPageUrl();
|
|
1427
1428
|
String currentUrl = url;
|
|
1428
1429
|
int redirectsFollowed = 0;
|
|
1429
1430
|
while (true) {
|
|
@@ -51,6 +51,27 @@ enum ProxyResponseRoutingSupport {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
enum CustomWebViewFrameSupport {
|
|
55
|
+
static func resolvedFrame(
|
|
56
|
+
width: CGFloat?,
|
|
57
|
+
height: CGFloat?,
|
|
58
|
+
x: CGFloat?,
|
|
59
|
+
y: CGFloat?,
|
|
60
|
+
fallbackSize: CGSize
|
|
61
|
+
) -> CGRect? {
|
|
62
|
+
guard let height else {
|
|
63
|
+
return nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return CGRect(
|
|
67
|
+
x: x ?? 0,
|
|
68
|
+
y: y ?? 0,
|
|
69
|
+
width: width ?? fallbackSize.width,
|
|
70
|
+
height: height
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
54
75
|
extension UIColor {
|
|
55
76
|
|
|
56
77
|
convenience init(hexString: String) {
|
|
@@ -77,7 +98,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
77
98
|
case aware = "AWARE"
|
|
78
99
|
case fakeVisible = "FAKE_VISIBLE"
|
|
79
100
|
}
|
|
80
|
-
private let pluginVersion: String = "8.6.
|
|
101
|
+
private let pluginVersion: String = "8.6.22"
|
|
81
102
|
public let identifier = "CapgoInAppBrowserPlugin"
|
|
82
103
|
public let jsName = "CapgoInAppBrowser"
|
|
83
104
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -1153,29 +1174,29 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1153
1174
|
// Create a pass-through container
|
|
1154
1175
|
let containerView = PassThroughView()
|
|
1155
1176
|
containerView.backgroundColor = .clear
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
let
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
x:
|
|
1163
|
-
y:
|
|
1164
|
-
|
|
1165
|
-
height: finalHeight
|
|
1177
|
+
containerView.frame = UIScreen.main.bounds
|
|
1178
|
+
containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
1179
|
+
|
|
1180
|
+
let targetFrame = CustomWebViewFrameSupport.resolvedFrame(
|
|
1181
|
+
width: width.map { CGFloat($0) },
|
|
1182
|
+
height: height.map { CGFloat($0) },
|
|
1183
|
+
x: xPos.map { CGFloat($0) },
|
|
1184
|
+
y: yPos.map { CGFloat($0) },
|
|
1185
|
+
fallbackSize: UIScreen.main.bounds.size
|
|
1166
1186
|
)
|
|
1187
|
+
containerView.targetFrame = targetFrame
|
|
1167
1188
|
|
|
1168
1189
|
// Replace the navigation controller's view with our pass-through container
|
|
1169
1190
|
if let navController = self.navigationWebViewController,
|
|
1170
1191
|
let originalView = navController.view {
|
|
1171
1192
|
navController.view = containerView
|
|
1172
1193
|
containerView.addSubview(originalView)
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1194
|
+
containerView.framedContentView = originalView
|
|
1195
|
+
originalView.translatesAutoresizingMaskIntoConstraints = true
|
|
1196
|
+
originalView.autoresizingMask = []
|
|
1197
|
+
if let targetFrame {
|
|
1198
|
+
originalView.frame = targetFrame
|
|
1199
|
+
}
|
|
1179
1200
|
}
|
|
1180
1201
|
} else {
|
|
1181
1202
|
self.navigationWebViewController?.modalPresentationStyle = .overCurrentContext
|
|
@@ -1824,6 +1845,11 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1824
1845
|
let xPos = call.getFloat("x")
|
|
1825
1846
|
let yPos = call.getFloat("y")
|
|
1826
1847
|
|
|
1848
|
+
if width != nil && height == nil {
|
|
1849
|
+
call.reject("Height must be specified when width is provided")
|
|
1850
|
+
return
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1827
1853
|
DispatchQueue.main.async {
|
|
1828
1854
|
let targetId = call.getString("id") ?? self.activeWebViewId
|
|
1829
1855
|
guard let webViewController = self.resolveWebViewController(for: targetId) else {
|
|
@@ -2881,26 +2881,32 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
2881
2881
|
|
|
2882
2882
|
/// Apply custom dimensions to the view if specified
|
|
2883
2883
|
open func applyCustomDimensions() {
|
|
2884
|
-
guard let navigationController = navigationController
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2884
|
+
guard let navigationController = navigationController,
|
|
2885
|
+
let targetFrame = CustomWebViewFrameSupport.resolvedFrame(
|
|
2886
|
+
width: customWidth,
|
|
2887
|
+
height: customHeight,
|
|
2888
|
+
x: customX,
|
|
2889
|
+
y: customY,
|
|
2890
|
+
fallbackSize: UIScreen.main.bounds.size
|
|
2891
|
+
) else {
|
|
2892
|
+
return
|
|
2893
2893
|
}
|
|
2894
|
-
// If only height is specified, use fullscreen width
|
|
2895
|
-
else if let height = customHeight, customWidth == nil {
|
|
2896
|
-
let xPos = customX ?? 0
|
|
2897
|
-
let yPos = customY ?? 0
|
|
2898
|
-
let screenWidth = UIScreen.main.bounds.width
|
|
2899
2894
|
|
|
2900
|
-
|
|
2901
|
-
|
|
2895
|
+
if let passThroughView = navigationController.view as? PassThroughView {
|
|
2896
|
+
passThroughView.targetFrame = targetFrame
|
|
2897
|
+
let contentView = passThroughView.framedContentView ?? passThroughView.subviews.first
|
|
2898
|
+
contentView?.frame = targetFrame
|
|
2899
|
+
contentView?.setNeedsLayout()
|
|
2900
|
+
contentView?.layoutIfNeeded()
|
|
2901
|
+
passThroughView.setNeedsLayout()
|
|
2902
|
+
passThroughView.layoutIfNeeded()
|
|
2903
|
+
} else {
|
|
2904
|
+
navigationController.view.frame = targetFrame
|
|
2905
|
+
navigationController.view.setNeedsLayout()
|
|
2906
|
+
navigationController.view.layoutIfNeeded()
|
|
2902
2907
|
}
|
|
2903
|
-
|
|
2908
|
+
|
|
2909
|
+
refreshWebViewViewportIfNeeded(force: true)
|
|
2904
2910
|
}
|
|
2905
2911
|
|
|
2906
2912
|
/// Update dimensions at runtime
|
|
@@ -3035,7 +3041,22 @@ class BlockBarButtonItem: UIBarButtonItem {
|
|
|
3035
3041
|
|
|
3036
3042
|
/// Custom view that passes touches outside a target frame to the underlying view
|
|
3037
3043
|
class PassThroughView: UIView {
|
|
3038
|
-
var targetFrame: CGRect?
|
|
3044
|
+
var targetFrame: CGRect? {
|
|
3045
|
+
didSet {
|
|
3046
|
+
setNeedsLayout()
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
weak var framedContentView: UIView?
|
|
3050
|
+
|
|
3051
|
+
override func layoutSubviews() {
|
|
3052
|
+
super.layoutSubviews()
|
|
3053
|
+
|
|
3054
|
+
guard let targetFrame, let framedContentView else {
|
|
3055
|
+
return
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
framedContentView.frame = targetFrame
|
|
3059
|
+
}
|
|
3039
3060
|
|
|
3040
3061
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
3041
3062
|
// If we have a target frame and the touch is outside it, pass through
|