From 315784df5c4e62430399198665e6bb007bdee118 Mon Sep 17 00:00:00 2001 From: Craig Neuwirt Date: Fri, 5 Apr 2019 08:24:06 -0500 Subject: [PATCH] Added cameraAutoFocusResetDelay xml attribute and associated documentation --- .../otaliastudios/cameraview/CameraView.java | 14 ++++++++------ cameraview/src/main/res/values/attrs.xml | 2 ++ docs/_posts/2018-12-20-more-features.md | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 33643f12..5c796e02 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -114,6 +114,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { int videoMaxDuration = a.getInteger(R.styleable.CameraView_cameraVideoMaxDuration, 0); int videoBitRate = a.getInteger(R.styleable.CameraView_cameraVideoBitRate, 0); int audioBitRate = a.getInteger(R.styleable.CameraView_cameraAudioBitRate, 0); + long autoFocusResetDelay = (long) a.getFloat(R.styleable.CameraView_cameraAutoFocusResetDelay, DEFAULT_AUTOFOCUS_RESET_DELAY_MILLIS); // Picture size selector List pictureConstraints = new ArrayList<>(3); @@ -220,6 +221,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { setVideoMaxSize(videoMaxSize); setVideoMaxDuration(videoMaxDuration); setVideoBitRate(videoBitRate); + setAutoFocusResetDelay(autoFocusResetDelay); // Apply gestures mapGesture(Gesture.TAP, tapGesture); @@ -1051,14 +1053,14 @@ public class CameraView extends FrameLayout implements LifecycleObserver { /** - * the current delay in milliseconds to reset the focus after an autofocus process. + * Sets the current delay in milliseconds to reset the focus after an autofocus process. * - * @param cameraAutoFocusResetDelayMillis desired delay (in milliseconds). If the delay - * is less than or equal to 0 or equal to Long.MAX_VALUE, - * the autofocus will not be reset. + * @param delayMillis desired delay (in milliseconds). If the delay + * is less than or equal to 0 or equal to Long.MAX_VALUE, + * the autofocus will not be reset. */ - public void setAutoFocusResetDelay(long cameraAutoFocusResetDelayMillis) { - mCameraController.setAutoFocusResetDelay(cameraAutoFocusResetDelayMillis); + public void setAutoFocusResetDelay(long delayMillis) { + mCameraController.setAutoFocusResetDelay(delayMillis); } /** diff --git a/cameraview/src/main/res/values/attrs.xml b/cameraview/src/main/res/values/attrs.xml index 5ea86273..7fa4dd0f 100644 --- a/cameraview/src/main/res/values/attrs.xml +++ b/cameraview/src/main/res/values/attrs.xml @@ -124,5 +124,7 @@ + + \ No newline at end of file diff --git a/docs/_posts/2018-12-20-more-features.md b/docs/_posts/2018-12-20-more-features.md index a971f84a..3252699a 100644 --- a/docs/_posts/2018-12-20-more-features.md +++ b/docs/_posts/2018-12-20-more-features.md @@ -15,7 +15,8 @@ disqus: 1 + app:cameraGridColor="@color/black" + app:cameraAutoFocusResetDelay="0"/> ``` ##### cameraPlaySounds @@ -56,6 +57,20 @@ cameraView.setGridColor(Color.WHITE); cameraView.setGridColor(Color.BLACK); ``` +##### cameraAutoFocusResetDelay + +Lets you control how an auto-focus operation is reset after completed. +Setting a value <= 0 or == Long.MAX_VALUE will not reset the auto-focus. +This is useful for low end devices that have slow auto-focus capabilities. +Defaults to 3 seconds. + +```java +cameraView.cameraAutoFocusResetDelay(1000); // 1 second +cameraView.cameraAutoFocusResetDelay(0); // NO reset +cameraView.cameraAutoFocusResetDelay(-1); // NO reset +cameraView.cameraAutoFocusResetDelay(Long.MAX_VALUE); // NO reset + + ### UI Orientation Within a Camera app, it's common to rotate buttons and other UI elements as the device is tilted around.