@capgo/inappbrowser 8.1.3 → 8.1.5
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.
|
@@ -50,7 +50,7 @@ import org.json.JSONObject;
|
|
|
50
50
|
)
|
|
51
51
|
public class InAppBrowserPlugin extends Plugin implements WebViewDialog.PermissionHandler {
|
|
52
52
|
|
|
53
|
-
private final String pluginVersion = "8.1.
|
|
53
|
+
private final String pluginVersion = "8.1.5";
|
|
54
54
|
|
|
55
55
|
public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
|
|
56
56
|
private CustomTabsClient customTabsClient;
|
|
@@ -404,6 +404,8 @@ public class WebViewDialog extends Dialog {
|
|
|
404
404
|
applyInsets();
|
|
405
405
|
|
|
406
406
|
_webView.addJavascriptInterface(new JavaScriptInterface(), "AndroidInterface");
|
|
407
|
+
// Provide window.mobileApp at document start via native interface
|
|
408
|
+
_webView.addJavascriptInterface(new JavaScriptInterface(), "mobileApp");
|
|
407
409
|
_webView.addJavascriptInterface(new PreShowScriptInterface(), "PreShowScriptInterface");
|
|
408
410
|
_webView.addJavascriptInterface(new PrintInterface(this._context, _webView), "PrintInterface");
|
|
409
411
|
_webView.getSettings().setJavaScriptEnabled(true);
|
|
@@ -1138,13 +1140,20 @@ public class WebViewDialog extends Dialog {
|
|
|
1138
1140
|
// Apply system insets to WebView content view (compatible with all Android versions)
|
|
1139
1141
|
ViewCompat.setOnApplyWindowInsetsListener(_webView, (v, windowInsets) -> {
|
|
1140
1142
|
Insets bars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
|
1143
|
+
Insets navigationBars = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
|
|
1144
|
+
Insets systemGestures = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures());
|
|
1145
|
+
Insets mandatoryGestures = windowInsets.getInsets(WindowInsetsCompat.Type.mandatorySystemGestures());
|
|
1141
1146
|
Insets ime = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
|
|
1142
1147
|
Boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
|
|
1143
1148
|
|
|
1144
1149
|
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
|
1145
1150
|
|
|
1146
1151
|
// Apply safe margin inset to bottom margin if enabled in options or fallback to 0px
|
|
1147
|
-
int
|
|
1152
|
+
int safeBottomInset = Math.max(
|
|
1153
|
+
bars.bottom,
|
|
1154
|
+
Math.max(navigationBars.bottom, Math.max(systemGestures.bottom, mandatoryGestures.bottom))
|
|
1155
|
+
);
|
|
1156
|
+
int navBottom = _options.getEnabledSafeMargin() ? safeBottomInset : 0;
|
|
1148
1157
|
|
|
1149
1158
|
// Apply top inset only if useTopInset option is enabled or fallback to 0px
|
|
1150
1159
|
int navTop = _options.getUseTopInset() ? bars.top : 0;
|
|
@@ -1161,6 +1170,7 @@ public class WebViewDialog extends Dialog {
|
|
|
1161
1170
|
|
|
1162
1171
|
return WindowInsetsCompat.CONSUMED;
|
|
1163
1172
|
});
|
|
1173
|
+
ViewCompat.requestApplyInsets(_webView);
|
|
1164
1174
|
|
|
1165
1175
|
// Handle window decoration - version-specific handling
|
|
1166
1176
|
if (getWindow() != null) {
|
|
@@ -1278,27 +1288,27 @@ public class WebViewDialog extends Dialog {
|
|
|
1278
1288
|
String script = String.format(
|
|
1279
1289
|
"""
|
|
1280
1290
|
(function() {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1291
|
+
// Prefer AndroidInterface when available, otherwise fall back to native window.mobileApp
|
|
1292
|
+
var nativeBridge = window.AndroidInterface || window.mobileApp;
|
|
1293
|
+
if (nativeBridge) {
|
|
1294
|
+
// Wrap native bridge to normalize behavior (stringify objects, expose close/hide/show)
|
|
1295
|
+
window.mobileApp = {
|
|
1296
|
+
postMessage: function(message) {
|
|
1297
|
+
try {
|
|
1298
|
+
var msg = typeof message === 'string' ? message : JSON.stringify(message);
|
|
1299
|
+
nativeBridge.postMessage(msg);
|
|
1300
|
+
} catch(e) {
|
|
1301
|
+
console.error('Error in mobileApp.postMessage:', e);
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
close: function() {
|
|
1305
|
+
try {
|
|
1306
|
+
nativeBridge.close();
|
|
1307
|
+
} catch(e) {
|
|
1308
|
+
console.error('Error in mobileApp.close:', e);
|
|
1309
|
+
}
|
|
1310
|
+
}%s
|
|
1311
|
+
};
|
|
1302
1312
|
}
|
|
1303
1313
|
// Override window.print function to use our PrintInterface
|
|
1304
1314
|
if (window.PrintInterface) {
|
|
@@ -2977,20 +2987,8 @@ public class WebViewDialog extends Dialog {
|
|
|
2977
2987
|
}
|
|
2978
2988
|
}
|
|
2979
2989
|
|
|
2980
|
-
// Shutdown executor service
|
|
2981
|
-
|
|
2982
|
-
try {
|
|
2983
|
-
executorService.shutdown();
|
|
2984
|
-
if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
|
|
2985
|
-
executorService.shutdownNow();
|
|
2986
|
-
}
|
|
2987
|
-
} catch (InterruptedException e) {
|
|
2988
|
-
Thread.currentThread().interrupt();
|
|
2989
|
-
executorService.shutdownNow();
|
|
2990
|
-
} catch (Exception e) {
|
|
2991
|
-
Log.e("InAppBrowser", "Error shutting down executor: " + e.getMessage());
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2990
|
+
// Shutdown executor service asynchronously to avoid blocking UI thread
|
|
2991
|
+
shutdownExecutorServiceAsync();
|
|
2994
2992
|
|
|
2995
2993
|
// Clear any remaining proxied requests
|
|
2996
2994
|
synchronized (proxiedRequestsHashmap) {
|
|
@@ -3004,6 +3002,30 @@ public class WebViewDialog extends Dialog {
|
|
|
3004
3002
|
}
|
|
3005
3003
|
}
|
|
3006
3004
|
|
|
3005
|
+
private void shutdownExecutorServiceAsync() {
|
|
3006
|
+
if (executorService.isShutdown()) {
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
Thread shutdownThread = new Thread(
|
|
3010
|
+
() -> {
|
|
3011
|
+
try {
|
|
3012
|
+
executorService.shutdown();
|
|
3013
|
+
if (!executorService.awaitTermination(500, TimeUnit.MILLISECONDS)) {
|
|
3014
|
+
executorService.shutdownNow();
|
|
3015
|
+
}
|
|
3016
|
+
} catch (InterruptedException e) {
|
|
3017
|
+
Thread.currentThread().interrupt();
|
|
3018
|
+
executorService.shutdownNow();
|
|
3019
|
+
} catch (Exception e) {
|
|
3020
|
+
Log.e("InAppBrowser", "Error shutting down executor: " + e.getMessage());
|
|
3021
|
+
}
|
|
3022
|
+
},
|
|
3023
|
+
"InAppBrowser-ExecutorShutdown"
|
|
3024
|
+
);
|
|
3025
|
+
shutdownThread.setDaemon(true);
|
|
3026
|
+
shutdownThread.start();
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3007
3029
|
public void addProxiedRequest(String key, ProxiedRequest request) {
|
|
3008
3030
|
synchronized (proxiedRequestsHashmap) {
|
|
3009
3031
|
proxiedRequestsHashmap.put(key, request);
|
|
@@ -28,7 +28,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
28
28
|
case aware = "AWARE"
|
|
29
29
|
case fakeVisible = "FAKE_VISIBLE"
|
|
30
30
|
}
|
|
31
|
-
private let pluginVersion: String = "8.1.
|
|
31
|
+
private let pluginVersion: String = "8.1.5"
|
|
32
32
|
public let identifier = "InAppBrowserPlugin"
|
|
33
33
|
public let jsName = "InAppBrowser"
|
|
34
34
|
public let pluginMethods: [CAPPluginMethod] = [
|