python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

An java code update to let webview support file upload and download

Open yingshaoxo opened this issue 5 years ago • 2 comments

It may seem scary, but it's useful if we want to use python to make a twitter-like app. After all, we need to upload image than bare text.

But take your time, I'm not hurrying with this pull. Because I'm working on a project with the use of react.js and python for android.

I may discovery more to improve the usability of python for android. We'll see.


Here are the links that related to this issue:

https://stackoverflow.com/questions/36410012/android-cant-upload-images-using-webview

https://stackoverflow.com/questions/6474768/are-webviewclient-and-webchromeclient-mutually-exclusive/6475858#6475858

https://developpaper.com/android-webview-supports-input-file-to-enable-camera-select-photos/

yingshaoxo avatar Apr 19 '20 23:04 yingshaoxo

To help you guys better understanding this pull request, I've created a repository as an example, you can use it to build an application for testing: https://github.com/yingshaoxo/kivy-diary/tree/example_for_p4a_team/webviewTest

And also, I have pre-compiled an APK file, so you guys could get a better idea of how file upload and download is so important for our users: https://github.com/yingshaoxo/kivy-diary/releases/tag/v0.2

yingshaoxo avatar Apr 22 '20 19:04 yingshaoxo

We are doing a similar thing for packaging up a Django-based app on Android. What we ended up doing was modifying PythonActivity to make mWebView accessible to our app, and then we used pyjnius gain access to mActivity and mWebView, which allowed us to start adding native Java handlers for things like the file dialogs in your example here. This way, we don't have to commit every function we need to p4a itself.

I'm planning to spend some time this weekend cleaning up our PRs and maybe working on some sort of simple example to illustrate the approach.

kollivier avatar Apr 25 '20 17:04 kollivier