Added cameraAutoFocusResetDelay xml attribute and associated documentation

pull/435/head
Craig Neuwirt 6 years ago
parent be8e609358
commit 315784df5c
  1. 14
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  2. 2
      cameraview/src/main/res/values/attrs.xml
  3. 17
      docs/_posts/2018-12-20-more-features.md

@ -114,6 +114,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
int videoMaxDuration = a.getInteger(R.styleable.CameraView_cameraVideoMaxDuration, 0); int videoMaxDuration = a.getInteger(R.styleable.CameraView_cameraVideoMaxDuration, 0);
int videoBitRate = a.getInteger(R.styleable.CameraView_cameraVideoBitRate, 0); int videoBitRate = a.getInteger(R.styleable.CameraView_cameraVideoBitRate, 0);
int audioBitRate = a.getInteger(R.styleable.CameraView_cameraAudioBitRate, 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 // Picture size selector
List<SizeSelector> pictureConstraints = new ArrayList<>(3); List<SizeSelector> pictureConstraints = new ArrayList<>(3);
@ -220,6 +221,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
setVideoMaxSize(videoMaxSize); setVideoMaxSize(videoMaxSize);
setVideoMaxDuration(videoMaxDuration); setVideoMaxDuration(videoMaxDuration);
setVideoBitRate(videoBitRate); setVideoBitRate(videoBitRate);
setAutoFocusResetDelay(autoFocusResetDelay);
// Apply gestures // Apply gestures
mapGesture(Gesture.TAP, tapGesture); 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 * @param delayMillis desired delay (in milliseconds). If the delay
* is less than or equal to 0 or equal to Long.MAX_VALUE, * is less than or equal to 0 or equal to Long.MAX_VALUE,
* the autofocus will not be reset. * the autofocus will not be reset.
*/ */
public void setAutoFocusResetDelay(long cameraAutoFocusResetDelayMillis) { public void setAutoFocusResetDelay(long delayMillis) {
mCameraController.setAutoFocusResetDelay(cameraAutoFocusResetDelayMillis); mCameraController.setAutoFocusResetDelay(delayMillis);
} }
/** /**

@ -124,5 +124,7 @@
<attr name="cameraExperimental" format="boolean" /> <attr name="cameraExperimental" format="boolean" />
<attr name="cameraAutoFocusResetDelay" format="float"/>
</declare-styleable> </declare-styleable>
</resources> </resources>

@ -15,7 +15,8 @@ disqus: 1
<com.otaliastudios.cameraview.CameraView <com.otaliastudios.cameraview.CameraView
app:cameraPlaySounds="true|false" app:cameraPlaySounds="true|false"
app:cameraGrid="off|draw3x3|draw4x4|drawPhi" app:cameraGrid="off|draw3x3|draw4x4|drawPhi"
app:cameraGridColor="@color/black"/> app:cameraGridColor="@color/black"
app:cameraAutoFocusResetDelay="0"/>
``` ```
##### cameraPlaySounds ##### cameraPlaySounds
@ -56,6 +57,20 @@ cameraView.setGridColor(Color.WHITE);
cameraView.setGridColor(Color.BLACK); 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 ### UI Orientation
Within a Camera app, it's common to rotate buttons and other UI elements as the device is tilted around. Within a Camera app, it's common to rotate buttons and other UI elements as the device is tilted around.

Loading…
Cancel
Save