@capgo/inappbrowser 7.10.5 → 7.10.8
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.
|
@@ -878,6 +878,18 @@ public class WebViewDialog extends Dialog {
|
|
|
878
878
|
_webView.requestFocus();
|
|
879
879
|
_webView.requestFocusFromTouch();
|
|
880
880
|
|
|
881
|
+
// Inject JavaScript interface early to ensure it's available immediately
|
|
882
|
+
// This complements the injection in onPageFinished and doUpdateVisitedHistory
|
|
883
|
+
_webView.post(() -> {
|
|
884
|
+
if (_webView != null) {
|
|
885
|
+
injectJavaScriptInterface();
|
|
886
|
+
Log.d(
|
|
887
|
+
"InAppBrowser",
|
|
888
|
+
"JavaScript interface injected early after URL load"
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
|
|
881
893
|
setupToolbar();
|
|
882
894
|
setWebViewClient();
|
|
883
895
|
|
|
@@ -1138,6 +1150,27 @@ public class WebViewDialog extends Dialog {
|
|
|
1138
1150
|
String script =
|
|
1139
1151
|
"(function() {" +
|
|
1140
1152
|
" if (window.AndroidInterface) {" +
|
|
1153
|
+
" // Create mobileApp object for backward compatibility" +
|
|
1154
|
+
" if (!window.mobileApp) {" +
|
|
1155
|
+
" window.mobileApp = {" +
|
|
1156
|
+
" postMessage: function(message) {" +
|
|
1157
|
+
" try {" +
|
|
1158
|
+
" var msg = typeof message === 'string' ? message : JSON.stringify(message);" +
|
|
1159
|
+
" window.AndroidInterface.postMessage(msg);" +
|
|
1160
|
+
" } catch(e) {" +
|
|
1161
|
+
" console.error('Error in mobileApp.postMessage:', e);" +
|
|
1162
|
+
" }" +
|
|
1163
|
+
" }," +
|
|
1164
|
+
" close: function() {" +
|
|
1165
|
+
" try {" +
|
|
1166
|
+
" window.AndroidInterface.close();" +
|
|
1167
|
+
" } catch(e) {" +
|
|
1168
|
+
" console.error('Error in mobileApp.close:', e);" +
|
|
1169
|
+
" }" +
|
|
1170
|
+
" }" +
|
|
1171
|
+
" };" +
|
|
1172
|
+
" }" +
|
|
1173
|
+
" // Also provide direct window methods for convenience" +
|
|
1141
1174
|
" window.postMessage = function(data) {" +
|
|
1142
1175
|
" try {" +
|
|
1143
1176
|
" var message = typeof data === 'string' ? data : JSON.stringify(data);" +
|
|
@@ -1154,6 +1187,16 @@ public class WebViewDialog extends Dialog {
|
|
|
1154
1187
|
" }" +
|
|
1155
1188
|
" };" +
|
|
1156
1189
|
" }" +
|
|
1190
|
+
" // Override window.print function to use our PrintInterface" +
|
|
1191
|
+
" if (window.PrintInterface) {" +
|
|
1192
|
+
" window.print = function() {" +
|
|
1193
|
+
" try {" +
|
|
1194
|
+
" window.PrintInterface.print();" +
|
|
1195
|
+
" } catch(e) {" +
|
|
1196
|
+
" console.error('Error in print:', e);" +
|
|
1197
|
+
" }" +
|
|
1198
|
+
" };" +
|
|
1199
|
+
" }" +
|
|
1157
1200
|
"})();";
|
|
1158
1201
|
|
|
1159
1202
|
_webView.post(() -> {
|