Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/plugins/system/android/com/foxdebug/system/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
import android.os.Build;



public class System extends CordovaPlugin {
private static final String TAG = "SystemPlugin";

Expand Down Expand Up @@ -633,19 +632,21 @@ public void run() {

private void sendLogToJavaScript(String level, String message) {
final String js =
"window.log(" + JSONObject.quote(level) + ", " + JSONObject.quote(message) + ");";
cordova
.getActivity()
.runOnUiThread(
new Runnable() {
@Override
public void run() {
webView.evaluateJavascript(js, null);
}
}
);
}
"if (typeof window.log === 'function')" +
" window.log(" + JSONObject.quote(level) + ", " + JSONObject.quote(message) + ");" +
"else" +
" console.log(" + JSONObject.quote(level) + ", " + JSONObject.quote(message) + ");";

cordova.getActivity().runOnUiThread(() -> {
try {
((android.webkit.WebView) webView.getEngine().getView())
.evaluateJavascript(js, null);
} catch (Exception e) {
Log.e(TAG, "Failed to send log to JavaScript: " + e.getMessage());
}
});
}

// Helper method to determine MIME type using Android's built-in MimeTypeMap
private String getMimeTypeFromExtension(String fileName) {
String extension = "";
Expand Down