diff --git a/lib/customize.js b/lib/customize.js index 7d0251f..4510a13 100644 --- a/lib/customize.js +++ b/lib/customize.js @@ -153,6 +153,12 @@ const Util = { Util.domModal.classList.remove("active"); }, saveFile : function saveFile(filename, mimeType, dataAsString) { + if (typeof Android !== "undefined" && typeof Android.saveFile === 'function') { + // Recent Gadgetbridge version that provides the saveFile interface + Android.saveFile(filename, mimeType, btoa(dataAsString)); + return; + } + let a = document.createElement("a"); // Blob downloads don't work under Gadgetbridge //let file = new Blob([dataAsString], {type: mimeType}); diff --git a/lib/interface.js b/lib/interface.js index 3b74f7a..5559ebf 100644 --- a/lib/interface.js +++ b/lib/interface.js @@ -126,6 +126,12 @@ const Util = { Util.domModal.classList.remove("active"); }, saveFile : function saveFile(filename, mimeType, dataAsString) { + if (typeof Android !== "undefined" && typeof Android.saveFile === 'function') { + // Recent Gadgetbridge version that provides the saveFile interface + Android.saveFile(filename, mimeType, btoa(dataAsString)); + return; + } + let a = document.createElement("a"); // Blob downloads don't work under Gadgetbridge //let file = new Blob([dataAsString], {type: mimeType});