|
|
@ -31,6 +31,7 @@ import android.widget.FrameLayout; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import static com.otaliastudios.cameraview.CameraConstants.FACING_BACK; |
|
|
|
import static com.otaliastudios.cameraview.CameraConstants.FACING_BACK; |
|
|
@ -61,6 +62,11 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
|
|
|
* } |
|
|
|
* } |
|
|
|
* } |
|
|
|
* } |
|
|
|
* </pre> |
|
|
|
* </pre> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* TODO: docs for gestures |
|
|
|
|
|
|
|
* TODO: README for gestures |
|
|
|
|
|
|
|
* TODO: deprecate setFocus, CONTINUOUS should be the default |
|
|
|
|
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
|
|
|
|
|
|
|
@ -92,12 +98,17 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
private Preview mPreviewImpl; |
|
|
|
private Preview mPreviewImpl; |
|
|
|
|
|
|
|
|
|
|
|
private Lifecycle mLifecycle; |
|
|
|
private Lifecycle mLifecycle; |
|
|
|
private FocusMarkerLayout mFocusMarkerLayout; |
|
|
|
|
|
|
|
private GridLinesLayout mGridLinesLayout; |
|
|
|
private GridLinesLayout mGridLinesLayout; |
|
|
|
private PinchToZoomLayout mPinchToZoomLayout; |
|
|
|
private PinchGestureLayout mPinchGestureLayout; |
|
|
|
|
|
|
|
private TapGestureLayout mTapGestureLayout; |
|
|
|
private boolean mIsStarted; |
|
|
|
private boolean mIsStarted; |
|
|
|
private boolean mKeepScreenOn; |
|
|
|
private boolean mKeepScreenOn; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private float mZoomValue; |
|
|
|
|
|
|
|
private float mExposureCorrectionValue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private HashMap<Gesture, Integer> mGestureMap = new HashMap<>(4); |
|
|
|
|
|
|
|
|
|
|
|
public CameraView(@NonNull Context context) { |
|
|
|
public CameraView(@NonNull Context context) { |
|
|
|
super(context, null); |
|
|
|
super(context, null); |
|
|
|
init(context, null); |
|
|
|
init(context, null); |
|
|
@ -118,30 +129,36 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE); |
|
|
|
int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE); |
|
|
|
int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraConstants.Defaults.DEFAULT_VIDEO_QUALITY); |
|
|
|
int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraConstants.Defaults.DEFAULT_VIDEO_QUALITY); |
|
|
|
int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraConstants.Defaults.DEFAULT_GRID); |
|
|
|
int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraConstants.Defaults.DEFAULT_GRID); |
|
|
|
int zoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, CameraConstants.Defaults.DEFAULT_ZOOM); |
|
|
|
|
|
|
|
mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraConstants.Defaults.DEFAULT_JPEG_QUALITY); |
|
|
|
mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraConstants.Defaults.DEFAULT_JPEG_QUALITY); |
|
|
|
mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraConstants.Defaults.DEFAULT_CROP_OUTPUT); |
|
|
|
mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraConstants.Defaults.DEFAULT_CROP_OUTPUT); |
|
|
|
|
|
|
|
int tapGesture = a.getInteger(R.styleable.CameraView_cameraGestureTap, CameraConstants.Defaults.DEFAULT_GESTURE_ACTION_TAP); |
|
|
|
|
|
|
|
// int doubleTapGesture = a.getInteger(R.styleable.CameraView_cameraGestureDoubleTap, CameraConstants.Defaults.DEFAULT_GESTURE_ACTION_DOUBLE_TAP);
|
|
|
|
|
|
|
|
int longTapGesture = a.getInteger(R.styleable.CameraView_cameraGestureLongTap, CameraConstants.Defaults.DEFAULT_GESTURE_ACTION_LONG_TAP); |
|
|
|
|
|
|
|
int pinchGesture = a.getInteger(R.styleable.CameraView_cameraGesturePinch, CameraConstants.Defaults.DEFAULT_GESTURE_ACTION_PINCH); |
|
|
|
a.recycle(); |
|
|
|
a.recycle(); |
|
|
|
|
|
|
|
|
|
|
|
mCameraCallbacks = new CameraCallbacks(); |
|
|
|
mCameraCallbacks = new CameraCallbacks(); |
|
|
|
mPreviewImpl = new TextureViewPreview(context, this); |
|
|
|
mPreviewImpl = new TextureViewPreview(context, this); |
|
|
|
mCameraController = new Camera1(mCameraCallbacks, mPreviewImpl); |
|
|
|
mCameraController = new Camera1(mCameraCallbacks, mPreviewImpl); |
|
|
|
mFocusMarkerLayout = new FocusMarkerLayout(context); |
|
|
|
|
|
|
|
mGridLinesLayout = new GridLinesLayout(context); |
|
|
|
mGridLinesLayout = new GridLinesLayout(context); |
|
|
|
mPinchToZoomLayout = new PinchToZoomLayout(context); |
|
|
|
mPinchGestureLayout = new PinchGestureLayout(context); |
|
|
|
addView(mFocusMarkerLayout); |
|
|
|
mTapGestureLayout = new TapGestureLayout(context); |
|
|
|
addView(mGridLinesLayout); |
|
|
|
addView(mGridLinesLayout); |
|
|
|
addView(mPinchToZoomLayout); |
|
|
|
addView(mPinchGestureLayout); |
|
|
|
|
|
|
|
addView(mTapGestureLayout); |
|
|
|
|
|
|
|
|
|
|
|
mIsStarted = false; |
|
|
|
mIsStarted = false; |
|
|
|
setFacing(facing); |
|
|
|
setFacing(facing); |
|
|
|
setFlash(flash); |
|
|
|
setFlash(flash); |
|
|
|
setFocus(focus); |
|
|
|
setFocus(focus); |
|
|
|
setSessionType(sessionType); |
|
|
|
setSessionType(sessionType); |
|
|
|
setZoomMode(zoom); |
|
|
|
|
|
|
|
setVideoQuality(videoQuality); |
|
|
|
setVideoQuality(videoQuality); |
|
|
|
setWhiteBalance(whiteBalance); |
|
|
|
setWhiteBalance(whiteBalance); |
|
|
|
setGrid(grid); |
|
|
|
setGrid(grid); |
|
|
|
|
|
|
|
mapGesture(Gesture.TAP, tapGesture); |
|
|
|
|
|
|
|
// mapGesture(Gesture.DOUBLE_TAP, doubleTapGesture);
|
|
|
|
|
|
|
|
mapGesture(Gesture.LONG_TAP, longTapGesture); |
|
|
|
|
|
|
|
mapGesture(Gesture.PINCH, pinchGesture); |
|
|
|
|
|
|
|
|
|
|
|
if (!isInEditMode()) { |
|
|
|
if (!isInEditMode()) { |
|
|
|
mOrientationHelper = new OrientationHelper(context) { |
|
|
|
mOrientationHelper = new OrientationHelper(context) { |
|
|
@ -315,6 +332,52 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Maps a {@link Gesture} to a certain gesture action. |
|
|
|
|
|
|
|
* For example, you can assign zoom control to the pinch gesture by just calling: |
|
|
|
|
|
|
|
* <code> |
|
|
|
|
|
|
|
* cameraView.mapGesture(Gesture.PINCH, CameraConstants.GESTURE_ACTION_ZOOM); |
|
|
|
|
|
|
|
* </code> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Not all actions can be assigned to a certain gesture. For example, zoom control can't be |
|
|
|
|
|
|
|
* assigned to the Gesture.TAP gesture. Look at {@link Gesture} to know more. |
|
|
|
|
|
|
|
* This method returns false if they are not assignable. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param gesture which gesture to map |
|
|
|
|
|
|
|
* @param action which action should be assigned |
|
|
|
|
|
|
|
* @return true if this action could be assigned to this gesture |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean mapGesture(@NonNull Gesture gesture, @GestureAction int action) { |
|
|
|
|
|
|
|
if (gesture.isAssignableTo(action)) { |
|
|
|
|
|
|
|
mGestureMap.put(gesture, action); |
|
|
|
|
|
|
|
switch (gesture) { |
|
|
|
|
|
|
|
case PINCH: |
|
|
|
|
|
|
|
mPinchGestureLayout.enable(mGestureMap.get(Gesture.PINCH) != CameraConstants.GESTURE_ACTION_NONE); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TAP: |
|
|
|
|
|
|
|
// case DOUBLE_TAP:
|
|
|
|
|
|
|
|
case LONG_TAP: |
|
|
|
|
|
|
|
mTapGestureLayout.enable(mGestureMap.get(Gesture.TAP) != CameraConstants.GESTURE_ACTION_NONE || |
|
|
|
|
|
|
|
// mGestureMap.get(Gesture.DOUBLE_TAP) != CameraConstants.GESTURE_ACTION_NONE ||
|
|
|
|
|
|
|
|
mGestureMap.get(Gesture.LONG_TAP) != CameraConstants.GESTURE_ACTION_NONE); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapGesture(gesture, CameraConstants.GESTURE_ACTION_NONE); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Clears any action mapped to the given gesture. |
|
|
|
|
|
|
|
* @param gesture which gesture to clear |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void clearGesture(@NonNull Gesture gesture) { |
|
|
|
|
|
|
|
mGestureMap.put(gesture, CameraConstants.GESTURE_ACTION_NONE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) { |
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) { |
|
|
|
return true; // Steal our own events.
|
|
|
|
return true; // Steal our own events.
|
|
|
@ -323,25 +386,48 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onTouchEvent(MotionEvent event) { |
|
|
|
public boolean onTouchEvent(MotionEvent event) { |
|
|
|
// Enable/Disable what needs to be enabled/disabled (because CameraOptions is involved).
|
|
|
|
if (!mCameraController.isCameraOpened()) return true; |
|
|
|
// Pinch-to-zoom actually does not need it because it won't draw anything either way.
|
|
|
|
|
|
|
|
// Grid-lines does not need it because grid modes are always supported.
|
|
|
|
CameraOptions options = mCameraController.getCameraOptions(); // Non null
|
|
|
|
// Why don't we do it just once? Because shit happens when setFocus() is called before camera open.
|
|
|
|
if (mPinchGestureLayout.onTouchEvent(event)) { |
|
|
|
// We don't know if focus is supported at that point.
|
|
|
|
int action = mGestureMap.get(Gesture.PINCH); |
|
|
|
CameraOptions options = mCameraController.getCameraOptions(); |
|
|
|
// This currently can be zoom or AE.
|
|
|
|
mFocusMarkerLayout.enable(mCameraController.getFocus() == CameraConstants.FOCUS_TAP_WITH_MARKER); |
|
|
|
// Camera can either support these or not.
|
|
|
|
mPinchToZoomLayout.enable(options != null && options.isZoomSupported()); |
|
|
|
if (action == CameraConstants.GESTURE_ACTION_ZOOM) { |
|
|
|
|
|
|
|
float oldValue = mZoomValue; |
|
|
|
// Pinch to zoom gesture...
|
|
|
|
float newValue = mPinchGestureLayout.scaleValue(oldValue, 0, 1); |
|
|
|
if (mPinchToZoomLayout.onTouchEvent(event)) { |
|
|
|
PointF[] points = mPinchGestureLayout.getPoints(); |
|
|
|
float zoom = mPinchToZoomLayout.getZoom(); |
|
|
|
if (mCameraController.setZoom(newValue)) { |
|
|
|
PointF[] fingers = mPinchToZoomLayout.getPoints(); |
|
|
|
mZoomValue = newValue; |
|
|
|
mCameraController.setZoom(zoom); // <- We know this is successful, due to mPinchToZoomLayout.enable() above.
|
|
|
|
mCameraCallbacks.dispatchOnZoomChanged(newValue, points); |
|
|
|
mCameraCallbacks.dispatchOnZoomChanged(zoom, fingers); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Focus gesture...
|
|
|
|
} else if (action == CameraConstants.GESTURE_ACTION_AE_CORRECTION) { |
|
|
|
} else if (mFocusMarkerLayout.onTouchEvent(event)) { |
|
|
|
float oldValue = mExposureCorrectionValue; |
|
|
|
startFocus(event.getX(), event.getY()); |
|
|
|
float minValue = options.getExposureCorrectionMinValue(); |
|
|
|
|
|
|
|
float maxValue = options.getExposureCorrectionMaxValue(); |
|
|
|
|
|
|
|
float newValue = mPinchGestureLayout.scaleValue(oldValue, minValue, maxValue); |
|
|
|
|
|
|
|
PointF[] points = mPinchGestureLayout.getPoints(); |
|
|
|
|
|
|
|
float[] bounds = new float[]{minValue, maxValue}; |
|
|
|
|
|
|
|
if (mCameraController.setExposureCorrection(newValue)) { |
|
|
|
|
|
|
|
mExposureCorrectionValue = newValue; |
|
|
|
|
|
|
|
mCameraCallbacks.dispatchOnExposureCorrectionChanged(newValue, bounds, points); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (mTapGestureLayout.onTouchEvent(event)) { |
|
|
|
|
|
|
|
Gesture gesture = mTapGestureLayout.getGestureType(); |
|
|
|
|
|
|
|
int action = mGestureMap.get(gesture); |
|
|
|
|
|
|
|
// This currently can be capture, focus or focusWithMaker.
|
|
|
|
|
|
|
|
// Camera can either support these or not.
|
|
|
|
|
|
|
|
if (action == CameraConstants.GESTURE_ACTION_CAPTURE) { |
|
|
|
|
|
|
|
capturePicture(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (action == CameraConstants.GESTURE_ACTION_FOCUS || |
|
|
|
|
|
|
|
action == CameraConstants.GESTURE_ACTION_FOCUS_WITH_MARKER) { |
|
|
|
|
|
|
|
PointF point = mTapGestureLayout.getPoint(); |
|
|
|
|
|
|
|
mCameraController.startAutoFocus(gesture, point); // This will call onFocusStart and onFocusEnd
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -424,7 +510,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
cameraCheck = PackageManager.PERMISSION_GRANTED; |
|
|
|
cameraCheck = PackageManager.PERMISSION_GRANTED; |
|
|
|
audioCheck = PackageManager.PERMISSION_GRANTED; |
|
|
|
audioCheck = PackageManager.PERMISSION_GRANTED; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
//noinspection all
|
|
|
|
cameraCheck = getContext().checkSelfPermission(Manifest.permission.CAMERA); |
|
|
|
cameraCheck = getContext().checkSelfPermission(Manifest.permission.CAMERA); |
|
|
|
|
|
|
|
//noinspection all
|
|
|
|
audioCheck = getContext().checkSelfPermission(Manifest.permission.RECORD_AUDIO); |
|
|
|
audioCheck = getContext().checkSelfPermission(Manifest.permission.RECORD_AUDIO); |
|
|
|
} |
|
|
|
} |
|
|
|
switch (sessionType) { |
|
|
|
switch (sessionType) { |
|
|
@ -530,7 +618,16 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
* @param EVvalue exposure correction value. |
|
|
|
* @param EVvalue exposure correction value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setExposureCorrection(float EVvalue) { |
|
|
|
public void setExposureCorrection(float EVvalue) { |
|
|
|
mCameraController.setExposureCorrection(EVvalue); |
|
|
|
CameraOptions options = getCameraOptions(); |
|
|
|
|
|
|
|
if (options != null) { |
|
|
|
|
|
|
|
float min = options.getExposureCorrectionMinValue(); |
|
|
|
|
|
|
|
float max = options.getExposureCorrectionMaxValue(); |
|
|
|
|
|
|
|
if (EVvalue < min) EVvalue = min; |
|
|
|
|
|
|
|
if (EVvalue > max) EVvalue = max; |
|
|
|
|
|
|
|
if (mCameraController.setExposureCorrection(EVvalue)) { |
|
|
|
|
|
|
|
mExposureCorrectionValue = EVvalue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -540,15 +637,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
* This will have no effect if called before the camera is opened. |
|
|
|
* This will have no effect if called before the camera is opened. |
|
|
|
* |
|
|
|
* |
|
|
|
* Zoom value should be >= 0 and <= 1, where 1 will be the maximum available zoom. |
|
|
|
* Zoom value should be >= 0 and <= 1, where 1 will be the maximum available zoom. |
|
|
|
|
|
|
|
* If it's not, it will be capped. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param zoom value in [0,1] |
|
|
|
* @param zoom value in [0,1] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setZoom(float zoom) { |
|
|
|
public void setZoom(float zoom) { |
|
|
|
if (zoom < 0 || zoom > 1) { |
|
|
|
if (zoom < 0) zoom = 0; |
|
|
|
throw new IllegalArgumentException("Zoom value should be >= 0 and <= 1"); |
|
|
|
if (zoom > 1) zoom = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (mCameraController.setZoom(zoom)) { |
|
|
|
if (mCameraController.setZoom(zoom)) { |
|
|
|
mPinchToZoomLayout.onExternalZoom(zoom); // Notify PinchToZoomLayout
|
|
|
|
mZoomValue = zoom; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -729,7 +826,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
public void startFocus(float x, float y) { |
|
|
|
public void startFocus(float x, float y) { |
|
|
|
if (x < 0 || x > getWidth()) throw new IllegalArgumentException("x should be >= 0 and <= getWidth()"); |
|
|
|
if (x < 0 || x > getWidth()) throw new IllegalArgumentException("x should be >= 0 and <= getWidth()"); |
|
|
|
if (y < 0 || y > getHeight()) throw new IllegalArgumentException("y should be >= 0 and <= getHeight()"); |
|
|
|
if (y < 0 || y > getHeight()) throw new IllegalArgumentException("y should be >= 0 and <= getHeight()"); |
|
|
|
mCameraController.startFocus(x, y); |
|
|
|
mCameraController.startAutoFocus(null, new PointF(x, y)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -821,20 +918,21 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
* @see CameraConstants#ZOOM_OFF |
|
|
|
* @see CameraConstants#ZOOM_OFF |
|
|
|
* @see CameraConstants#ZOOM_PINCH |
|
|
|
* @see CameraConstants#ZOOM_PINCH |
|
|
|
* |
|
|
|
* |
|
|
|
* @param zoom the zoom mode |
|
|
|
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void setZoomMode(@ZoomMode int zoom) { |
|
|
|
public void setZoomMode(@ZoomMode int zoom) { |
|
|
|
mPinchToZoomLayout.setZoomMode(zoom); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the current zoom mode. |
|
|
|
* Gets the current zoom mode. |
|
|
|
* @return the current zoom mode |
|
|
|
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ZoomMode |
|
|
|
@ZoomMode |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public int getZoomMode() { |
|
|
|
public int getZoomMode() { |
|
|
|
return mPinchToZoomLayout.getZoomMode(); |
|
|
|
return CameraConstants.ZOOM_OFF; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1221,36 +1319,59 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void dispatchOnFocusStart(final float x, final float y) { |
|
|
|
public void dispatchOnFocusStart(@Nullable final Gesture gesture, final PointF point) { |
|
|
|
|
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
if (gesture != null && mGestureMap.get(gesture) == CameraConstants.GESTURE_ACTION_FOCUS_WITH_MARKER) { |
|
|
|
|
|
|
|
mTapGestureLayout.onFocusStart(point); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
|
|
|
|
listener.onFocusStart(point); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void dispatchOnFocusEnd(@Nullable final Gesture gesture, final boolean success, |
|
|
|
|
|
|
|
final PointF point) { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
|
|
|
|
if (gesture != null && mGestureMap.get(gesture) == CameraConstants.GESTURE_ACTION_FOCUS_WITH_MARKER) { |
|
|
|
|
|
|
|
mTapGestureLayout.onFocusEnd(success); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
listener.onFocusStart(x, y); |
|
|
|
listener.onFocusEnd(success, point); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void dispatchOnFocusEnd(final boolean success, final float x, final float y) { |
|
|
|
public void dispatchOnZoomChanged(final float newValue, final PointF[] fingers) { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
listener.onFocusEnd(success, x, y); |
|
|
|
listener.onZoomChanged(newValue, new float[]{0, 1}, fingers); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void dispatchOnZoomChanged(final float zoom, final PointF[] fingers) { |
|
|
|
public void dispatchOnExposureCorrectionChanged(final float newValue, |
|
|
|
|
|
|
|
final float[] bounds, |
|
|
|
|
|
|
|
final PointF[] fingers) { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
uiHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
for (CameraListener listener : mListeners) { |
|
|
|
listener.onZoomChanged(zoom, fingers); |
|
|
|
listener.onExposureCorrectionChanged(newValue, bounds, fingers); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|