google / cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Apache License 2.0
4.74k stars 1.03k forks source link

autoFocus is lost after switching camera facing #220

Open siralam opened 6 years ago

siralam commented 6 years ago

OMG... How come such an apparent bug.

In updateAutoFocus(), mAutoFocus is set to false if the camera does not support autoFocus.

So: (1) mAutoFocus is now true (2) Switch to front camera, which does not support auto focus (3) mAutoFocus is now false (4) Switch back to back camera (5) in updateAutoFocus, since mAutoFocus is false, the camera is directly set to not auto focus.

The best approach to solve this problem is to separate autoFocus from setting, and whether we need to auto focus now.

siralam commented 6 years ago

For those who want to solve this problem, you may take a look at my commits. Just 4 lines of code to change in total:

https://github.com/siralam/CameraViewPlus/commit/8890f5f9e84a77c63122649fac16b3150509113b

https://github.com/siralam/CameraViewPlus/commit/5e1d4a83681a3cf689982c943358cea0f6dee59b