esafirm / android-image-picker

Image Picker for Android 🤖
MIT License
1.11k stars 327 forks source link

Enhancement: Start video recording on camera icon clicked when "OnlyVideo" is enabled #411

Open kavitamp opened 1 year ago

kavitamp commented 1 year ago

Issue:

When OnlyVideo is enabled the camera icon opens in the camera mode instead of the video mode

Description and steps:

When OnlyVideo is enabled and the user clicks on the camera icon, it opens the camera instead of the video. Steps:

  1. Enable "Only Video" mode
  2. Click on any video picker functionality
  3. Click on the camera icon
  4. The picture mode is displayed instead of the video mode

Expected behavior:

When OnlyVideo is enabled and the user clicks on the camera icon, it opens the camera instead of the video.

Issue recording:

https://user-images.githubusercontent.com/20037228/196473466-53e77776-e33c-4a48-83e6-1ef36d4ed0ec.mp4

Fixed issue recording:

https://user-images.githubusercontent.com/20037228/196473491-db29dc0f-8006-4c4a-b4e5-455702ab9ce1.mp4

Please let me know if you have any feedback. Thank you!

Close #260

esafirm commented 1 year ago

Nice addition @kavitamp , as a matter of fact, we had an iteration about this from a year back in here https://github.com/esafirm/android-image-picker/pull/322

The changes on that PR are already good IMO, but it containing conflicts. So maybe you could take a look and apply the changes to this PR instead? Thanks

kavitamp commented 1 year ago

So maybe you could take a look and apply the changes to this PR instead?

@esafirm, so basically you want me to update the remaining changes of https://github.com/esafirm/android-image-picker/pull/322 PR in mine, including video icons, etc?

kavitamp commented 1 year ago

@esafirm I have updated the code and have added a video icon in the menu bar, please take a look

kavitamp commented 1 year ago

@esafirm, I have fixed comments, please take a look.

esafirm commented 1 year ago

Cool @kavitamp just testing the feature in an emulator, but it seems there's an error with the Camera app in it

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference
                                                                                                        at com.android.camera.VideoModule.saveVideo(VideoModule.java:1263)
                                                                                                        at com.android.camera.VideoModule.stopVideoRecording(VideoModule.java:1513)
                                                                                                        at com.android.camera.VideoModule.onStopVideoRecording(VideoModule.java:656)
                                                                                                        at com.android.camera.VideoModule.onShutterButtonClick(VideoModule.java:697)
                                                                                                        at com.android.camera.ShutterButton.performClick(ShutterButton.java:190)
                                                                                                        at android.view.View.performClickInternal(View.java:7483)
                                                                                                        at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
                                                                                                        at android.view.View$PerformClick.run(View.java:29334)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                        at android.os.Looper.loop(Looper.java:288)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Will check in the real device later

esafirm commented 1 year ago

@kavitamp anyway, it would be great if you can provide an instrumentation test for this as well. Thanks

mohamedagamy commented 1 year ago

please upgrade gradle and remove kotlin extensions. @kavitamp. please approve this pull request @esafirm.