agamemnus / cordova-plugin-xapkreader

Easily access Google Play APK expansion file data.
32 stars 55 forks source link

Performing download in the same activity rather than a different one #112

Open chipbell4 opened 6 years ago

chipbell4 commented 6 years ago

Is there any particular android limitation that forces the downloader process to be started and ran from a second Activity? Would it be possible for the Service to be started from the main plugin instance and managed there.

The reason I ask it that I could see it beneficially for integrators to be able to display progress however they want in their cordova-based HTML UI. I could see the plugin simply emitting events to interested listeners and notifying when it's done:

window.xapkreader.on('progress', (evt) => {
  document.getElementById('progress-bar').innerHTML = evt.percentage
});
window.xapkreader.on('finish', (evt) => {
  document.getElementById('progress-bar').style.visibility = 'hidden'; // or whatever
});
window.xapkreader.startDownload();

However, I am curious how to implement this giving the current branching model because it will possibly break the plugin for integrators on the old way of doing it. I'd be glad to take stab at it, but I first wanted to get some feedback on some of these issues and perhaps a some guidance on how (and if) you'd like to see it written.

Thanks!

agamemnus commented 6 years ago

Is there any particular android limitation that forces the downloader process to be started and ran from a second Activity? Would it be possible for the Service to be started from the main plugin instance and managed there.

Probably not... might need a lot of code work, though.

As long as it doesn't break backwards compatibility, feel free to work on the 6.5 branch. It wouldn't be a good idea imo to create two versions of this plugin for one version of Cordova. You could add a flag (default 0?) or something. It's (almost?) the same as 5.3.1-auto.