Android-AdvancedWebView icon indicating copy to clipboard operation
Android-AdvancedWebView copied to clipboard

Camera Access

Open digitalprecision opened this issue 7 years ago • 13 comments

I implemented a possible solution via #20, but it didn't work. It pulls up a lot of options like gallery, google drive, images, videos, downloads etc., but no camera option.

Any working code samples available?

digitalprecision avatar Sep 20 '16 18:09 digitalprecision

Not yet, I'm afraid.

But https://github.com/delight-im/Android-AdvancedWebView/issues/10 might be more helpful if you need some examples. There are some links that should help.

ocram avatar Oct 04 '16 22:10 ocram

There is an easy fix for this. Can you add a public callback so we can override the default behavior in AdvancedWebView onShowFileChooser method? For now I just created my own version of AdvancedWebView so I could add my activity method for handling images. But with a callback, all would be able to benefit.

digitalprecision avatar Oct 11 '16 20:10 digitalprecision

HI digitalprecision,

i have the same problem and looking for camera solution, if you dont mind can copy paste here or send your solution to [email protected]. i will be very grateful.

akuma34 avatar Oct 13 '16 20:10 akuma34

Hi @akuma34, check out this gist: https://gist.github.com/digitalprecision/735820df14f696fc2c6c8b251b2b05d6

It uses the PermissionHelper API developed by k0sh, and the standard webview API, but I was able to easily get it to work with AdvancedWebView, however I opted to use FinestWebView b/c it has more controls over the toolbar etc.

digitalprecision avatar Oct 14 '16 14:10 digitalprecision

Can you add a public callback so we can override the default behavior in AdvancedWebView onShowFileChooser method?

That may be possible. But if you supply a custom callback, the internal operations on file uploads won't work anymore, since the ValueCallback<Uri[]> cannot be invoked multiple times. What should we do here? Such a custom callback may confuse developers as it would break other built-in features of this library.

For now I just created my own version of AdvancedWebView so I could add my activity method for handling images.

That's the correct approach (for now), you're right. But again, you're right in that this shouldn't be necessary.

But with a callback, all would be able to benefit.

I don't see any better solution right now, either.

The only solution more convenient than overriding that callback is probably extending our built-in callback (that handles file uploads correctly already) to provide support for camera access out-of-the-box, right?

Looking at your Gist, that'd be my preferred solution. Couldn't we build and start the Intent instances for the camera access, etc. in this library and provide callbacks for the process of writing the files afterwards?

ocram avatar Oct 15 '16 21:10 ocram

Actually I found FinestWebView to be buggy and not load our page as desired, however AdvancedWebView does. Quick question, do you have the ability for us to add a circular progress indicator, or should I create on my own?

digitalprecision avatar Oct 17 '16 18:10 digitalprecision

@digitalprecision Thanks for splitting that question off into https://github.com/delight-im/Android-AdvancedWebView/issues/87 It's an important question and a recurring problem, so I created https://github.com/delight-im/Android-AdvancedWebView/issues/88 as well.

I'm still convinced that we need a much more convenient solution for camera access. We should decide on some callbacks to implement and re-use some of the code in your Gist.

ocram avatar Oct 17 '16 21:10 ocram

I defer to your best judgement as I am a novice android developer (do more php/mysql/systems stuff) so my guidance may not be the best in this context. Feel free to use whatever you can from the gist. Glad to contribute :)

digitalprecision avatar Oct 18 '16 00:10 digitalprecision

@digitalprecision, you've saved me a week (or even more) of time of the research as I am doing baby steps in Android development!

mmalisz avatar Apr 13 '17 08:04 mmalisz

@mmalisz Glad to help. Hoping the author patches in the functionality at some point.

digitalprecision avatar Apr 13 '17 18:04 digitalprecision

Just a pro-tip for anyone using this workaround: starting from SDK 24 files must be read using FileProvider instread of Uri.

StackOverflow

mmalisz avatar Apr 18 '17 10:04 mmalisz

For what it's worth, I ended up using parts of https://github.com/mgks/Os-FileUp to get it working.

jcrooke avatar Aug 14 '17 13:08 jcrooke

Please add camera support

nicojmb avatar Jan 09 '18 12:01 nicojmb