diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java index 9f8a71de..c6d9094b 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java @@ -161,4 +161,12 @@ public abstract class CameraListener { } -} \ No newline at end of file + /** + * 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() {} + +} diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 21967289..eb745722 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -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 diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/gesture/GestureAction.java b/cameraview/src/main/java/com/otaliastudios/cameraview/gesture/GestureAction.java index ca86a6c3..63c5152a 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/gesture/GestureAction.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/gesture/GestureAction.java @@ -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; diff --git a/cameraview/src/main/res/values/attrs.xml b/cameraview/src/main/res/values/attrs.xml index fb6bc1b7..9a27f115 100644 --- a/cameraview/src/main/res/values/attrs.xml +++ b/cameraview/src/main/res/values/attrs.xml @@ -40,36 +40,38 @@ + + - - - - + + + + - - - - + + + + - - - - + + + +