Implement Shutter callback. Add GestureAction.TAKE_PICTURE_SNAPSHOT. (#1030)

* include swipe and shutter callback

* Swipe Left and Right callback on CameraListener.
* Shutter event callback on CameraListener.

* Add Gesture Action TakePictureSnapshot

Added a new GestureAction.TAKE_PICTURE_SNAPSHOT that calls takePictureSnapshot() method.

* take_picture_snapshot GestureAction
pull/1040/head
Ezequiel Adrián 4 years ago committed by GitHub
parent 5d10277d7b
commit d89491195c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java
  2. 12
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  3. 17
      cameraview/src/main/java/com/otaliastudios/cameraview/gesture/GestureAction.java
  4. 26
      cameraview/src/main/res/values/attrs.xml

@ -161,4 +161,12 @@ public abstract class CameraListener {
}
}
/**
* Notifies that the shutter event is happening. You can update UI to show some
* trigger effect, so user visually confirms that picture is being taken
* or video recording is about to start.
*/
@UiThread
public void onShutter() {}
}

@ -669,6 +669,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
//noinspection ConstantConditions
switch (action) {
case TAKE_PICTURE_SNAPSHOT:
takePictureSnapshot();
break;
case TAKE_PICTURE:
takePicture();
break;
@ -2228,6 +2232,14 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
if (shouldPlaySound && mPlaySounds) {
playSound(MediaActionSound.SHUTTER_CLICK);
}
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (CameraListener listener : mListeners) {
listener.onShutter();
}
}
});
}
@Override

@ -43,6 +43,15 @@ public enum GestureAction {
*/
TAKE_PICTURE(2, GestureType.ONE_SHOT),
/**
* When triggered, this action will fire a picture snapshot.
* This action can be mapped to one shot gestures:
*
* - {@link Gesture#TAP}
* - {@link Gesture#LONG_TAP}
*/
TAKE_PICTURE_SNAPSHOT(3, GestureType.ONE_SHOT),
/**
* Zoom control, typically assigned to the pinch gesture.
* This action can be mapped to continuous gestures:
@ -51,7 +60,7 @@ public enum GestureAction {
* - {@link Gesture#SCROLL_HORIZONTAL}
* - {@link Gesture#SCROLL_VERTICAL}
*/
ZOOM(3, GestureType.CONTINUOUS),
ZOOM(4, GestureType.CONTINUOUS),
/**
* Exposure correction control.
@ -61,7 +70,7 @@ public enum GestureAction {
* - {@link Gesture#SCROLL_HORIZONTAL}
* - {@link Gesture#SCROLL_VERTICAL}
*/
EXPOSURE_CORRECTION(4, GestureType.CONTINUOUS),
EXPOSURE_CORRECTION(5, GestureType.CONTINUOUS),
/**
* Controls the first parameter of a real-time {@link Filter},
@ -71,7 +80,7 @@ public enum GestureAction {
* - {@link Gesture#SCROLL_HORIZONTAL}
* - {@link Gesture#SCROLL_VERTICAL}
*/
FILTER_CONTROL_1(5, GestureType.CONTINUOUS),
FILTER_CONTROL_1(6, GestureType.CONTINUOUS),
/**
* Controls the second parameter of a real-time {@link Filter},
@ -81,7 +90,7 @@ public enum GestureAction {
* - {@link Gesture#SCROLL_HORIZONTAL}
* - {@link Gesture#SCROLL_VERTICAL}
*/
FILTER_CONTROL_2(6, GestureType.CONTINUOUS);
FILTER_CONTROL_2(7, GestureType.CONTINUOUS);
final static GestureAction DEFAULT_PINCH = NONE;
final static GestureAction DEFAULT_TAP = NONE;

@ -40,36 +40,38 @@
<enum name="none" value="0" />
<enum name="autoFocus" value="1" />
<enum name="takePicture" value="2" />
<enum name="takePictureSnapshot" value="3" />
</attr>
<attr name="cameraGestureLongTap" format="enum">
<enum name="none" value="0" />
<enum name="autoFocus" value="1" />
<enum name="takePicture" value="2" />
<enum name="takePictureSnapshot" value="3" />
</attr>
<attr name="cameraGesturePinch" format="enum">
<enum name="none" value="0" />
<enum name="zoom" value="3" />
<enum name="exposureCorrection" value="4" />
<enum name="filterControl1" value="5" />
<enum name="filterControl2" value="6" />
<enum name="zoom" value="4" />
<enum name="exposureCorrection" value="5" />
<enum name="filterControl1" value="6" />
<enum name="filterControl2" value="7" />
</attr>
<attr name="cameraGestureScrollHorizontal" format="enum">
<enum name="none" value="0" />
<enum name="zoom" value="3" />
<enum name="exposureCorrection" value="4" />
<enum name="filterControl1" value="5" />
<enum name="filterControl2" value="6" />
<enum name="zoom" value="4" />
<enum name="exposureCorrection" value="5" />
<enum name="filterControl1" value="6" />
<enum name="filterControl2" value="7" />
</attr>
<attr name="cameraGestureScrollVertical" format="enum">
<enum name="none" value="0" />
<enum name="zoom" value="3" />
<enum name="exposureCorrection" value="4" />
<enum name="filterControl1" value="5" />
<enum name="filterControl2" value="6" />
<enum name="zoom" value="4" />
<enum name="exposureCorrection" value="5" />
<enum name="filterControl1" value="6" />
<enum name="filterControl2" value="7" />
</attr>
<attr name="cameraEngine" format="enum">

Loading…
Cancel
Save