|
|
@ -18,12 +18,12 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; |
|
|
|
|
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_OFF; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_OFF; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; |
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; |
|
|
|
|
|
|
|
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP_WITH_MARKER; |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
class Camera1 extends CameraImpl { |
|
|
|
class Camera1 extends CameraImpl { |
|
|
@ -37,7 +37,7 @@ class Camera1 extends CameraImpl { |
|
|
|
private int mCameraId; |
|
|
|
private int mCameraId; |
|
|
|
private Camera mCamera; |
|
|
|
private Camera mCamera; |
|
|
|
private Camera.Parameters mCameraParameters; |
|
|
|
private Camera.Parameters mCameraParameters; |
|
|
|
private CameraProperties mCameraProperties; |
|
|
|
private ExtraProperties mExtraProperties; |
|
|
|
private Camera.CameraInfo mCameraInfo; |
|
|
|
private Camera.CameraInfo mCameraInfo; |
|
|
|
private Size mPreviewSize; |
|
|
|
private Size mPreviewSize; |
|
|
|
private Size mCaptureSize; |
|
|
|
private Size mCaptureSize; |
|
|
@ -56,10 +56,12 @@ class Camera1 extends CameraImpl { |
|
|
|
@Method private int mMethod; |
|
|
|
@Method private int mMethod; |
|
|
|
@ZoomMode private int mZoom; |
|
|
|
@ZoomMode private int mZoom; |
|
|
|
@VideoQuality private int mVideoQuality; |
|
|
|
@VideoQuality private int mVideoQuality; |
|
|
|
|
|
|
|
@WhiteBalance private int mWhiteBalance; |
|
|
|
private double mLatitude; |
|
|
|
private double mLatitude; |
|
|
|
private double mLongitude; |
|
|
|
private double mLongitude; |
|
|
|
|
|
|
|
|
|
|
|
private Handler mHandler = new Handler(); |
|
|
|
private Handler mHandler = new Handler(); |
|
|
|
|
|
|
|
private ConstantMapper.MapperImpl mMapper = new ConstantMapper.Mapper1(); |
|
|
|
|
|
|
|
|
|
|
|
Camera1(CameraListener callback, PreviewImpl preview) { |
|
|
|
Camera1(CameraListener callback, PreviewImpl preview) { |
|
|
|
super(callback, preview); |
|
|
|
super(callback, preview); |
|
|
@ -136,11 +138,7 @@ class Camera1 extends CameraImpl { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setFacing(@Facing int facing) { |
|
|
|
void setFacing(@Facing int facing) { |
|
|
|
int internalFacing = new ConstantMapper.Facing(facing).map(); |
|
|
|
int internalFacing = mMapper.mapFacing(facing); |
|
|
|
if (internalFacing == -1) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { |
|
|
|
for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { |
|
|
|
Camera.getCameraInfo(i, mCameraInfo); |
|
|
|
Camera.getCameraInfo(i, mCameraInfo); |
|
|
|
if (mCameraInfo.facing == internalFacing) { |
|
|
|
if (mCameraInfo.facing == internalFacing) { |
|
|
@ -158,30 +156,42 @@ class Camera1 extends CameraImpl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setFlash(@Flash int flash) { |
|
|
|
void setWhiteBalance(@WhiteBalance int whiteBalance) { |
|
|
|
|
|
|
|
int old = mWhiteBalance; |
|
|
|
|
|
|
|
mWhiteBalance = whiteBalance; |
|
|
|
if (mCameraParameters != null) { |
|
|
|
if (mCameraParameters != null) { |
|
|
|
List<String> flashes = mCameraParameters.getSupportedFlashModes(); |
|
|
|
List<String> supported = mCameraParameters.getSupportedWhiteBalance(); |
|
|
|
String internalFlash = new ConstantMapper.Flash(flash).map(); |
|
|
|
String internal = mMapper.mapWhiteBalance(whiteBalance); |
|
|
|
if (flashes != null && flashes.contains(internalFlash)) { |
|
|
|
if (supported != null && supported.contains(internal)) { |
|
|
|
mCameraParameters.setFlashMode(internalFlash); |
|
|
|
mCameraParameters.setWhiteBalance(internal); |
|
|
|
mFlash = flash; |
|
|
|
mCamera.setParameters(mCameraParameters); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
String currentFlash = new ConstantMapper.Flash(mFlash).map(); |
|
|
|
mWhiteBalance = old; |
|
|
|
if (flashes == null || !flashes.contains(currentFlash)) { |
|
|
|
} |
|
|
|
mCameraParameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); |
|
|
|
|
|
|
|
mFlash = FLASH_OFF; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
void setFlash(@Flash int flash) { |
|
|
|
|
|
|
|
int old = mFlash; |
|
|
|
|
|
|
|
mFlash = flash; |
|
|
|
|
|
|
|
if (mCameraParameters != null) { |
|
|
|
|
|
|
|
List<String> flashes = mCameraParameters.getSupportedFlashModes(); |
|
|
|
|
|
|
|
String internalFlash = mMapper.mapFlash(flash); |
|
|
|
|
|
|
|
if (flashes != null && flashes.contains(internalFlash)) { |
|
|
|
|
|
|
|
mCameraParameters.setFlashMode(internalFlash); |
|
|
|
mCamera.setParameters(mCameraParameters); |
|
|
|
mCamera.setParameters(mCameraParameters); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mFlash = flash; |
|
|
|
mFlash = old; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setFocus(@Focus int focus) { |
|
|
|
void setFocus(@Focus int focus) { |
|
|
|
this.mFocus = focus; |
|
|
|
int old = mFocus; |
|
|
|
|
|
|
|
mFocus = focus; |
|
|
|
switch (focus) { |
|
|
|
switch (focus) { |
|
|
|
case FOCUS_CONTINUOUS: |
|
|
|
case FOCUS_CONTINUOUS: |
|
|
|
if (mCameraParameters != null) { |
|
|
|
if (mCameraParameters != null) { |
|
|
@ -190,17 +200,20 @@ class Camera1 extends CameraImpl { |
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { |
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { |
|
|
|
mCameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); |
|
|
|
mCameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setFocus(FOCUS_OFF); |
|
|
|
mFocus = old; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case FOCUS_TAP: |
|
|
|
case FOCUS_TAP: |
|
|
|
|
|
|
|
case FOCUS_TAP_WITH_MARKER: |
|
|
|
if (mCameraParameters != null) { |
|
|
|
if (mCameraParameters != null) { |
|
|
|
attachFocusTapListener(); |
|
|
|
attachFocusTapListener(); |
|
|
|
final List<String> modes = mCameraParameters.getSupportedFocusModes(); |
|
|
|
final List<String> modes = mCameraParameters.getSupportedFocusModes(); |
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { |
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { |
|
|
|
mCameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); |
|
|
|
mCameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
mFocus = old; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -318,8 +331,8 @@ class Camera1 extends CameraImpl { |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
CameraProperties getCameraProperties() { |
|
|
|
ExtraProperties getExtraProperties() { |
|
|
|
return mCameraProperties; |
|
|
|
return mExtraProperties; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Internal:
|
|
|
|
// Internal:
|
|
|
@ -424,7 +437,7 @@ class Camera1 extends CameraImpl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void collectCameraProperties() { |
|
|
|
private void collectCameraProperties() { |
|
|
|
mCameraProperties = new CameraProperties(mCameraParameters.getVerticalViewAngle(), |
|
|
|
mExtraProperties = new ExtraProperties(mCameraParameters.getVerticalViewAngle(), |
|
|
|
mCameraParameters.getHorizontalViewAngle()); |
|
|
|
mCameraParameters.getHorizontalViewAngle()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|