@capgo/inappbrowser 8.0.0 → 8.0.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.
Files changed (50) hide show
  1. package/CapgoInappbrowser.podspec +2 -2
  2. package/LICENSE +373 -21
  3. package/Package.swift +28 -0
  4. package/README.md +600 -74
  5. package/android/build.gradle +17 -16
  6. package/android/src/main/AndroidManifest.xml +14 -2
  7. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +952 -204
  8. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +478 -81
  9. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +10 -4
  10. package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +3023 -226
  11. package/android/src/main/res/drawable/ic_refresh.xml +9 -0
  12. package/android/src/main/res/drawable/ic_share.xml +10 -0
  13. package/android/src/main/res/layout/activity_browser.xml +10 -0
  14. package/android/src/main/res/layout/content_browser.xml +3 -2
  15. package/android/src/main/res/layout/tool_bar.xml +44 -7
  16. package/android/src/main/res/values/strings.xml +4 -0
  17. package/android/src/main/res/values/themes.xml +27 -0
  18. package/android/src/main/res/xml/file_paths.xml +14 -0
  19. package/dist/docs.json +1289 -149
  20. package/dist/esm/definitions.d.ts +614 -25
  21. package/dist/esm/definitions.js +17 -1
  22. package/dist/esm/definitions.js.map +1 -1
  23. package/dist/esm/index.d.ts +2 -2
  24. package/dist/esm/index.js +4 -4
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/web.d.ts +16 -3
  27. package/dist/esm/web.js +43 -7
  28. package/dist/esm/web.js.map +1 -1
  29. package/dist/plugin.cjs.js +60 -8
  30. package/dist/plugin.cjs.js.map +1 -1
  31. package/dist/plugin.js +60 -8
  32. package/dist/plugin.js.map +1 -1
  33. package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +952 -0
  34. package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +2006 -0
  35. package/package.json +30 -30
  36. package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
  37. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
  38. package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
  39. package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +0 -26
  40. package/ios/Plugin/Assets.xcassets/Contents.json +0 -6
  41. package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +0 -26
  42. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
  43. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
  44. package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
  45. package/ios/Plugin/InAppBrowserPlugin.h +0 -10
  46. package/ios/Plugin/InAppBrowserPlugin.m +0 -17
  47. package/ios/Plugin/InAppBrowserPlugin.swift +0 -203
  48. package/ios/Plugin/Info.plist +0 -24
  49. package/ios/Plugin/WKWebViewController.swift +0 -784
  50. /package/ios/{Plugin → Sources/InAppBrowserPlugin}/Enums.swift +0 -0
@@ -1,89 +1,486 @@
1
1
  package ee.forgr.capacitor_inappbrowser;
2
2
 
3
+ import android.content.res.AssetManager;
4
+ import androidx.annotation.Nullable;
3
5
  import com.getcapacitor.JSObject;
4
6
  import com.getcapacitor.PluginCall;
7
+ import java.io.IOException;
8
+ import java.io.InputStream;
9
+ import java.util.ArrayList;
10
+ import java.util.List;
11
+ import java.util.Objects;
12
+ import java.util.Objects;
13
+ import java.util.regex.Pattern;
5
14
 
6
15
  public class Options {
7
16
 
8
- private String title;
9
- private String url;
10
- private JSObject headers;
11
- private String toolbarType;
12
- private JSObject shareDisclaimer;
13
- private String shareSubject;
14
- private boolean isPresentAfterPageLoad;
15
- private WebViewCallbacks callbacks;
16
- private PluginCall pluginCall;
17
-
18
- public PluginCall getPluginCall() {
19
- return pluginCall;
20
- }
21
-
22
- public void setPluginCall(PluginCall pluginCall) {
23
- this.pluginCall = pluginCall;
24
- }
25
-
26
- public String getTitle() {
27
- return title;
28
- }
29
-
30
- public void setTitle(String title) {
31
- this.title = title;
32
- }
33
-
34
- public String getUrl() {
35
- return url;
36
- }
37
-
38
- public void setUrl(String url) {
39
- this.url = url;
40
- }
41
-
42
- public JSObject getHeaders() {
43
- return headers;
44
- }
45
-
46
- public void setHeaders(JSObject headers) {
47
- this.headers = headers;
48
- }
49
-
50
- public String getToolbarType() {
51
- return toolbarType;
52
- }
53
-
54
- public void setToolbarType(String toolbarType) {
55
- this.toolbarType = toolbarType;
56
- }
57
-
58
- public JSObject getShareDisclaimer() {
59
- return shareDisclaimer;
60
- }
61
-
62
- public void setShareDisclaimer(JSObject shareDisclaimer) {
63
- this.shareDisclaimer = shareDisclaimer;
64
- }
65
-
66
- public String getShareSubject() {
67
- return shareSubject;
68
- }
69
-
70
- public void setShareSubject(String shareSubject) {
71
- this.shareSubject = shareSubject;
72
- }
73
-
74
- public boolean isPresentAfterPageLoad() {
75
- return isPresentAfterPageLoad;
76
- }
77
-
78
- public void setPresentAfterPageLoad(boolean presentAfterPageLoad) {
79
- isPresentAfterPageLoad = presentAfterPageLoad;
80
- }
81
-
82
- public WebViewCallbacks getCallbacks() {
83
- return callbacks;
84
- }
85
-
86
- public void setCallbacks(WebViewCallbacks callbacks) {
87
- this.callbacks = callbacks;
88
- }
17
+ public static class ButtonNearDone {
18
+
19
+ public enum AllIconTypes {
20
+ ASSET,
21
+ VECTOR
22
+ }
23
+
24
+ private final AllIconTypes iconTypeEnum;
25
+ private final String iconType;
26
+ private final String icon;
27
+ private final int height;
28
+ private final int width;
29
+
30
+ private ButtonNearDone(AllIconTypes iconTypeEnum, String iconType, String icon, int height, int width) {
31
+ this.iconTypeEnum = iconTypeEnum;
32
+ this.iconType = iconType;
33
+ this.icon = icon;
34
+ this.height = height;
35
+ this.width = width;
36
+ }
37
+
38
+ @Nullable
39
+ public static ButtonNearDone generateFromPluginCall(PluginCall call, AssetManager assetManager)
40
+ throws IllegalArgumentException, RuntimeException {
41
+ JSObject buttonNearDone = call.getObject("buttonNearDone");
42
+ if (buttonNearDone == null) {
43
+ // Return null when "buttonNearDone" isn't configured, else throw an error
44
+ return null;
45
+ }
46
+
47
+ JSObject android = buttonNearDone.getJSObject("android");
48
+ if (android == null) {
49
+ throw new IllegalArgumentException("buttonNearDone.android is null");
50
+ }
51
+
52
+ String iconType = android.getString("iconType", "asset");
53
+ AllIconTypes iconTypeEnum;
54
+
55
+ // Validate and process icon type
56
+ if ("asset".equals(iconType)) {
57
+ iconTypeEnum = AllIconTypes.ASSET;
58
+ } else if ("vector".equals(iconType)) {
59
+ iconTypeEnum = AllIconTypes.VECTOR;
60
+ } else {
61
+ throw new IllegalArgumentException("buttonNearDone.android.iconType must be 'asset' or 'vector'");
62
+ }
63
+
64
+ String icon = android.getString("icon");
65
+ if (icon == null) {
66
+ throw new IllegalArgumentException("buttonNearDone.android.icon is null");
67
+ }
68
+
69
+ // For asset type, verify the file exists
70
+ if (iconTypeEnum == AllIconTypes.ASSET) {
71
+ InputStream fileInputString = null;
72
+
73
+ try {
74
+ // Try to find in public folder first
75
+ try {
76
+ fileInputString = assetManager.open("public/" + icon);
77
+ } catch (IOException e) {
78
+ // If not in public, try in root assets
79
+ try {
80
+ fileInputString = assetManager.open(icon);
81
+ } catch (IOException e2) {
82
+ throw new IllegalArgumentException("buttonNearDone.android.icon cannot be found in the assetManager");
83
+ }
84
+ }
85
+ // File exists, do nothing
86
+ } finally {
87
+ // Close the input stream if it was opened
88
+ if (fileInputString != null) {
89
+ try {
90
+ fileInputString.close();
91
+ } catch (IOException e) {
92
+ e.printStackTrace();
93
+ }
94
+ }
95
+ }
96
+ }
97
+ // For vector type, we don't validate here since resources are checked at runtime
98
+ else if (iconTypeEnum == AllIconTypes.VECTOR) {
99
+ // Vector resources will be validated when used
100
+ System.out.println("Vector resource will be validated at runtime: " + icon);
101
+ }
102
+
103
+ Integer width = android.getInteger("width", 24);
104
+ Integer height = android.getInteger("height", 24);
105
+
106
+ final ButtonNearDone buttonNearDone1 = new ButtonNearDone(iconTypeEnum, iconType, icon, height, width);
107
+ return buttonNearDone1;
108
+ }
109
+
110
+ public AllIconTypes getIconTypeEnum() {
111
+ return iconTypeEnum;
112
+ }
113
+
114
+ public String getIconType() {
115
+ return iconType;
116
+ }
117
+
118
+ public String getIcon() {
119
+ return icon;
120
+ }
121
+
122
+ public int getHeight() {
123
+ return height;
124
+ }
125
+
126
+ public int getWidth() {
127
+ return width;
128
+ }
129
+ }
130
+
131
+ private String title;
132
+ private boolean CloseModal;
133
+ private String CloseModalTitle;
134
+ private String CloseModalDescription;
135
+ private String CloseModalCancel;
136
+ private ButtonNearDone buttonNearDone;
137
+ private String CloseModalOk;
138
+ private String url;
139
+ private JSObject headers;
140
+ private JSObject credentials;
141
+ private String toolbarType;
142
+ private JSObject shareDisclaimer;
143
+ private String shareSubject;
144
+ private boolean disableGoBackOnNativeApplication;
145
+ private boolean activeNativeNavigationForWebview;
146
+ private boolean isPresentAfterPageLoad;
147
+ private WebViewCallbacks callbacks;
148
+ private PluginCall pluginCall;
149
+ private boolean VisibleTitle;
150
+ private String ToolbarColor;
151
+ private String BackgroundColor;
152
+ private boolean ShowArrow;
153
+ private boolean ignoreUntrustedSSLError;
154
+ private String preShowScript;
155
+ private String toolbarTextColor;
156
+ private Pattern proxyRequestsPattern = null;
157
+ private boolean materialPicker = false;
158
+ private int textZoom = 100; // Default text zoom is 100%
159
+ private boolean preventDeeplink = false;
160
+ private List<String> authorizedAppLinks = new ArrayList<>();
161
+ private boolean enabledSafeBottomMargin = false;
162
+ private boolean useTopInset = false;
163
+ private boolean enableGooglePaySupport = false;
164
+ private List<String> blockedHosts = new ArrayList<>();
165
+ private Integer width = null;
166
+ private Integer height = null;
167
+ private Integer x = null;
168
+ private Integer y = null;
169
+
170
+ public Integer getWidth() {
171
+ return width;
172
+ }
173
+
174
+ public void setWidth(Integer width) {
175
+ this.width = width;
176
+ }
177
+
178
+ public Integer getHeight() {
179
+ return height;
180
+ }
181
+
182
+ public void setHeight(Integer height) {
183
+ this.height = height;
184
+ }
185
+
186
+ public Integer getX() {
187
+ return x;
188
+ }
189
+
190
+ public void setX(Integer x) {
191
+ this.x = x;
192
+ }
193
+
194
+ public Integer getY() {
195
+ return y;
196
+ }
197
+
198
+ public void setY(Integer y) {
199
+ this.y = y;
200
+ }
201
+
202
+ public int getTextZoom() {
203
+ return textZoom;
204
+ }
205
+
206
+ public void setTextZoom(int textZoom) {
207
+ this.textZoom = textZoom;
208
+ }
209
+
210
+ public boolean getMaterialPicker() {
211
+ return materialPicker;
212
+ }
213
+
214
+ public void setMaterialPicker(boolean materialPicker) {
215
+ this.materialPicker = materialPicker;
216
+ }
217
+
218
+ public boolean getEnabledSafeMargin() {
219
+ return enabledSafeBottomMargin;
220
+ }
221
+
222
+ public void setEnabledSafeMargin(boolean enabledSafeBottomMargin) {
223
+ this.enabledSafeBottomMargin = enabledSafeBottomMargin;
224
+ }
225
+
226
+ public boolean getUseTopInset() {
227
+ return useTopInset;
228
+ }
229
+
230
+ public void setUseTopInset(boolean useTopInset) {
231
+ this.useTopInset = useTopInset;
232
+ }
233
+
234
+ public Pattern getProxyRequestsPattern() {
235
+ return proxyRequestsPattern;
236
+ }
237
+
238
+ public void setProxyRequestsPattern(Pattern proxyRequestsPattern) {
239
+ this.proxyRequestsPattern = proxyRequestsPattern;
240
+ }
241
+
242
+ public PluginCall getPluginCall() {
243
+ return pluginCall;
244
+ }
245
+
246
+ public void setPluginCall(PluginCall pluginCall) {
247
+ this.pluginCall = pluginCall;
248
+ }
249
+
250
+ public String getTitle() {
251
+ return title;
252
+ }
253
+
254
+ public void setTitle(String title) {
255
+ this.title = title;
256
+ }
257
+
258
+ public boolean getCloseModal() {
259
+ return CloseModal;
260
+ }
261
+
262
+ public void setCloseModal(boolean CloseModal) {
263
+ this.CloseModal = CloseModal;
264
+ }
265
+
266
+ public String getCloseModalTitle() {
267
+ return CloseModalTitle;
268
+ }
269
+
270
+ public void setCloseModalTitle(String CloseModalTitle) {
271
+ this.CloseModalTitle = CloseModalTitle;
272
+ }
273
+
274
+ public String getCloseModalDescription() {
275
+ return CloseModalDescription;
276
+ }
277
+
278
+ public void setCloseModalDescription(String CloseModalDescription) {
279
+ this.CloseModalDescription = CloseModalDescription;
280
+ }
281
+
282
+ public void setButtonNearDone(ButtonNearDone buttonNearDone) {
283
+ this.buttonNearDone = buttonNearDone;
284
+ }
285
+
286
+ public ButtonNearDone getButtonNearDone() {
287
+ return this.buttonNearDone;
288
+ }
289
+
290
+ public String getCloseModalCancel() {
291
+ return CloseModalCancel;
292
+ }
293
+
294
+ public void setCloseModalCancel(String CloseModalCancel) {
295
+ this.CloseModalCancel = CloseModalCancel;
296
+ }
297
+
298
+ public String getCloseModalOk() {
299
+ return CloseModalOk;
300
+ }
301
+
302
+ public void setCloseModalOk(String CloseModalOk) {
303
+ this.CloseModalOk = CloseModalOk;
304
+ }
305
+
306
+ public String getUrl() {
307
+ return url;
308
+ }
309
+
310
+ public void setUrl(String url) {
311
+ this.url = url;
312
+ }
313
+
314
+ public JSObject getHeaders() {
315
+ return headers;
316
+ }
317
+
318
+ public void setHeaders(JSObject headers) {
319
+ this.headers = headers;
320
+ }
321
+
322
+ public JSObject getCredentials() {
323
+ return credentials;
324
+ }
325
+
326
+ public void setCredentials(JSObject credentials) {
327
+ this.credentials = credentials;
328
+ }
329
+
330
+ public String getToolbarType() {
331
+ return toolbarType;
332
+ }
333
+
334
+ public void setToolbarType(String toolbarType) {
335
+ this.toolbarType = toolbarType;
336
+ }
337
+
338
+ public JSObject getShareDisclaimer() {
339
+ return shareDisclaimer;
340
+ }
341
+
342
+ public boolean showReloadButton;
343
+
344
+ public boolean getShowReloadButton() {
345
+ return showReloadButton;
346
+ }
347
+
348
+ public void setShowReloadButton(boolean showReloadButton) {
349
+ this.showReloadButton = showReloadButton;
350
+ }
351
+
352
+ public void setShareDisclaimer(JSObject shareDisclaimer) {
353
+ this.shareDisclaimer = shareDisclaimer;
354
+ }
355
+
356
+ public String getShareSubject() {
357
+ return shareSubject;
358
+ }
359
+
360
+ public void setShareSubject(String shareSubject) {
361
+ this.shareSubject = shareSubject;
362
+ }
363
+
364
+ public boolean getActiveNativeNavigationForWebview() {
365
+ return activeNativeNavigationForWebview;
366
+ }
367
+
368
+ public void setActiveNativeNavigationForWebview(boolean activeNativeNavigationForWebview) {
369
+ this.activeNativeNavigationForWebview = activeNativeNavigationForWebview;
370
+ }
371
+
372
+ public boolean getDisableGoBackOnNativeApplication() {
373
+ return disableGoBackOnNativeApplication;
374
+ }
375
+
376
+ public void setDisableGoBackOnNativeApplication(boolean disableGoBackOnNativeApplication) {
377
+ this.disableGoBackOnNativeApplication = disableGoBackOnNativeApplication;
378
+ }
379
+
380
+ public boolean isPresentAfterPageLoad() {
381
+ return isPresentAfterPageLoad;
382
+ }
383
+
384
+ public void setPresentAfterPageLoad(boolean presentAfterPageLoad) {
385
+ isPresentAfterPageLoad = presentAfterPageLoad;
386
+ }
387
+
388
+ public WebViewCallbacks getCallbacks() {
389
+ return callbacks;
390
+ }
391
+
392
+ public void setCallbacks(WebViewCallbacks callbacks) {
393
+ this.callbacks = callbacks;
394
+ }
395
+
396
+ public boolean getVisibleTitle() {
397
+ return VisibleTitle;
398
+ }
399
+
400
+ public void setVisibleTitle(boolean _visibleTitle) {
401
+ this.VisibleTitle = _visibleTitle;
402
+ }
403
+
404
+ public String getToolbarColor() {
405
+ return ToolbarColor;
406
+ }
407
+
408
+ public void setToolbarColor(String toolbarColor) {
409
+ this.ToolbarColor = toolbarColor;
410
+ }
411
+
412
+ public String getBackgroundColor() {
413
+ return BackgroundColor;
414
+ }
415
+
416
+ public void setBackgroundColor(String backgroundColor) {
417
+ this.BackgroundColor = backgroundColor;
418
+ }
419
+
420
+ public String getToolbarTextColor() {
421
+ return toolbarTextColor;
422
+ }
423
+
424
+ public void setToolbarTextColor(String toolbarTextColor) {
425
+ this.toolbarTextColor = toolbarTextColor;
426
+ }
427
+
428
+ public boolean showArrow() {
429
+ return ShowArrow;
430
+ }
431
+
432
+ public void setArrow(boolean _showArrow) {
433
+ this.ShowArrow = _showArrow;
434
+ }
435
+
436
+ public boolean ignoreUntrustedSSLError() {
437
+ return ignoreUntrustedSSLError;
438
+ }
439
+
440
+ public void setIgnoreUntrustedSSLError(boolean _ignoreUntrustedSSLError) {
441
+ this.ignoreUntrustedSSLError = _ignoreUntrustedSSLError;
442
+ }
443
+
444
+ public String getPreShowScript() {
445
+ return preShowScript;
446
+ }
447
+
448
+ public void setPreShowScript(String preLoadScript) {
449
+ this.preShowScript = preLoadScript;
450
+ }
451
+
452
+ public boolean getPreventDeeplink() {
453
+ return preventDeeplink;
454
+ }
455
+
456
+ public void setPreventDeeplink(boolean preventDeeplink) {
457
+ this.preventDeeplink = preventDeeplink;
458
+ }
459
+
460
+ public List<String> getAuthorizedAppLinks() {
461
+ return authorizedAppLinks;
462
+ }
463
+
464
+ public void setAuthorizedAppLinks(List<String> authorizedAppLinks) {
465
+ this.authorizedAppLinks = authorizedAppLinks;
466
+ }
467
+
468
+ public boolean getEnableGooglePaySupport() {
469
+ return enableGooglePaySupport;
470
+ }
471
+
472
+ public void setEnableGooglePaySupport(boolean enableGooglePaySupport) {
473
+ this.enableGooglePaySupport = enableGooglePaySupport;
474
+ }
475
+
476
+ public List<String> getBlockedHosts() {
477
+ if (blockedHosts != null) {
478
+ return blockedHosts;
479
+ }
480
+ return new ArrayList<>();
481
+ }
482
+
483
+ public void setBlockedHosts(List<String> blockedHosts) {
484
+ this.blockedHosts = blockedHosts;
485
+ }
89
486
  }
@@ -1,11 +1,17 @@
1
1
  package ee.forgr.capacitor_inappbrowser;
2
2
 
3
3
  public interface WebViewCallbacks {
4
- public void urlChangeEvent(String url);
4
+ public void urlChangeEvent(String url);
5
5
 
6
- public void closeEvent(String url);
6
+ public void closeEvent(String url);
7
7
 
8
- public void pageLoaded();
8
+ public void pageLoaded();
9
9
 
10
- public void pageLoadError();
10
+ public void pageLoadError();
11
+
12
+ public void javascriptCallback(String message);
13
+
14
+ public void buttonNearDoneClicked();
15
+
16
+ public void confirmBtnClicked(String url);
11
17
  }