cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

(android)feat: Added camera select to file input tags

Open kortgat opened this issue 4 years ago • 3 comments

Platforms affected

Motivation and Context

Allowing the user to use the camera or file browser with a html file input tag

https://github.com/apache/cordova-android/issues/816

Description

Reworked the action tray to use a chooser intent in cordova\engine\SystemWebChromeClient.java to add option for the camera

Testing

Tested using a emulator and actual device to take photos and upload to my server as well as upload pdf files from file system. I am also currently using this in production in my application.

Checklist

  • [ ] I've run the tests to see all new and existing tests pass
  • [ ] I added automated test coverage as appropriate for this change
  • [ ] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [ ] I've updated the documentation if necessary

kortgat avatar Dec 21 '21 06:12 kortgat

After I follow your changes, I can choose the camera, but I don't know why the photos are blurry.

nishizbdjy avatar Mar 01 '22 02:03 nishizbdjy

I was using your hotfix.zip archive to hook the camera intent, I noticed that the pictures being uploaded were unusually small - only 150x200px. I believe this is because you are accessing the "thumbnail data" instead of the full picture data.

I base this on the sample code provided in the android documentation here: https://developer.android.com/training/camera/photobasics#java

Within the onActivityResult() definition, you define Bundle bundle = data.getExtras(); on line 288, and then on line 313 you create the bitmap using Bitmap bmp = (Bitmap) bundle.get("data"); - this is exactly how they access the thumbnail with the warning "Note: This thumbnail image from "data" might be good for an icon, but not a lot more. Dealing with a full-sized image takes a bit more work. "

I will update as I continue research. Thanks for your work toward this problem!

edit: I think this is due to line 258 being commented out, and then the compressed thumbnail being written to the output path. However, uncommenting 258 and commenting out 313-318 causes the camera to crash after clicking "OK" - not sure why. Still researching...

edit2: unfortunately I'm hitting a wall with my understanding of the android java classes, but maybe the issue is not that the app is crashing, but that the URI being passed isn't valid? I might stop here for now, would really love any feedback from someone more familiar with the android backend!

Djones4822 avatar Mar 15 '22 19:03 Djones4822

How to get a complete and clear picture has anyone solved it? Expect a good solution from a skilled Android developer.

nishizbdjy avatar May 11 '22 09:05 nishizbdjy