jasonelle-archive / jasonelle-v2

🛸 🏘️ Jasonelle issues, releases, discussions and wiki repository.
https://jasonelle.com
Mozilla Public License 2.0
422 stars 58 forks source link

Input "type=file" doesn't work on Android #90

Open atlowell-smpl opened 4 years ago

atlowell-smpl commented 4 years ago

Describe the bug So it appears from my searches online that this bug is not unique to this project. It's existed for at least 9 years in various forms. Basically, any tags with type="file" set do nothing when pressed in android in a webview. Since Jasonette uses a webview, it would probably make sense to see if it could be addressed in our project. I've found this stackoverflow link (https://stackoverflow.com/questions/5907369/file-upload-in-webview) with a various number of answers. It seems like there's not one simple answer that works for all android versions.

Example Jasonette Document URL Any url will show this, as long as it shows a page that has an in it.

Additional context> You can use the $media.camera action instead of , but seeing as there seem to be several other issues with that functionality, it might be nice to fix this as a fallback,

clsource commented 4 years ago

Hello, @atlowell-smpl yes it seems some web components need special considerations. Thankfully Jasonelle can manage with a little help of agents. http://jasonelle.com/docs/legacy/agents/

and the http://jasonelle.com/docs/legacy/actions/#mediapicker native action.

Combining those two you can have the native media picker instead of the web view alternative, solving the issue :)

If you would like some examples you could look at the following example

https://github.com/jasonelle/beerjs

that helps demostrating using agents inside a webcontainer 👍

atlowell-smpl commented 4 years ago

I actually made an attempt to do this in my app (with camera instead of mediapicker, but same principle), and I got almost there. Then I realized that the service I was using (bubble.io) required authentication headers to be specified for custom API requests, while clicking the input was handled by them automatically.

So I looked around more. I managed to get inputs working for API 21+ taking inspiration from the following repository:

https://github.com/mgks/Os-FileUp

It should be noted that I had to spread the code out between JasonViewActivity and JasonAgentService. I also had to change some of the code to use FileProvider to get it working on certain devices.

clsource commented 3 years ago

Hello now Webview in Android works with file upload

https://github.com/jasonelle/jasonelle/issues/100

Please check it out 👍