Merge pull request #204 from rpopovici/master

fix auto-focus mode on android
This commit is contained in:
Zack 2016-02-18 10:02:16 -08:00
commit 80d9ed6f25
2 changed files with 13 additions and 5 deletions

View File

@ -131,16 +131,20 @@ public class RCTCamera {
}
CameraInfoWrapper cameraInfo = _cameraInfos.get(type);
int rotation = cameraInfo.info.orientation;
int displayRotation;
int rotation;
int orientation = cameraInfo.info.orientation;
if (cameraInfo.info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
rotation = (720 - rotation - _actualDeviceOrientation * 90) % 360;
rotation = (orientation + _actualDeviceOrientation * 90) % 360;
displayRotation = (720 - orientation - _actualDeviceOrientation * 90) % 360;
} else {
rotation = (rotation - _actualDeviceOrientation * 90 + 360) % 360;
rotation = (orientation - _actualDeviceOrientation * 90 + 360) % 360;
displayRotation = rotation;
}
cameraInfo.rotation = rotation;
// TODO: take in account the _orientation prop
camera.setDisplayOrientation(cameraInfo.rotation);
camera.setDisplayOrientation(displayRotation);
Camera.Parameters parameters = camera.getParameters();
parameters.setRotation(cameraInfo.rotation);

View File

@ -9,6 +9,7 @@ import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.view.TextureView;
import java.util.List;
class RCTCameraViewFinder extends TextureView implements TextureView.SurfaceTextureListener {
private int _cameraType;
@ -90,7 +91,10 @@ class RCTCameraViewFinder extends TextureView implements TextureView.SurfaceText
try {
_camera = RCTCamera.getInstance().acquireCameraInstance(_cameraType);
Camera.Parameters parameters = _camera.getParameters();
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
_camera.setParameters(parameters);
_camera.setPreviewTexture(_surfaceTexture);
_camera.startPreview();