-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Android.saveFile if available #59
Conversation
@@ -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') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear to me why we have both customize.js and interface.js, so I updated both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Customise is for when an app is about to be uploaded, and interface is for when it's already loaded.
I know there's bags of overlap now, but initially they were quite separate (customise didn't used to have anything in it to get data from the watch)
Thanks for this! It's a shame that the existing save implementation wasn't able to get the filename somehow. There are other cases in the main app loader where we save to a file as well. Although maybe only backing up so far: https://github.com/search?q=repo%3Aespruino%2FBangleApps%20fileSaveDialog&type=code
|
@gfwilliams I was not aware of that one, I only found That overwrite from android.html is an interesting idea, and it leaves me wondering if we should adopt the same strategy for saveFile too, as it is an android-specific thing that could be kept ouf ot this core repo.. |
I think in this case what you've done is good - we can put individual overrides in I guess in theory Utils.saveFile could postMessage the file to the main app and that could do the saving, but for the sake of a few lines I think your solution here is best. I'm reasonably confident the code I posted above will work, but is it possible for you to check it out with your saveFile changes to Gadgetbridge? To trigger it, it's |
Use the Android javascript interface implemented in https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/3631 if available, allowing us to get the filename and mimetype.