Removed FOCUS useless stuff. We default to the best focus mode.

pull/1/head
Mattia Iavarone 7 years ago
parent b7f2152fc5
commit 59fba7b80f
  1. 61
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  2. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera2.java
  3. 36
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraConstants.java
  4. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java
  5. 23
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraOptions.java
  6. 153
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  7. 28
      cameraview/src/main/java/com/otaliastudios/cameraview/Mapper.java
  8. 52
      cameraview/src/main/res/values/attrs.xml

@ -146,7 +146,7 @@ class Camera1 extends CameraController {
Camera.Parameters params = mCamera.getParameters(); Camera.Parameters params = mCamera.getParameters();
mExtraProperties = new ExtraProperties(params); mExtraProperties = new ExtraProperties(params);
mOptions = new CameraOptions(params); mOptions = new CameraOptions(params);
mergeFocus(params, CameraConstants.Defaults.DEFAULT_FOCUS); applyDefaultFocus(params);
mergeFlash(params, CameraConstants.Defaults.DEFAULT_FLASH); mergeFlash(params, CameraConstants.Defaults.DEFAULT_FLASH);
mergeLocation(params, 0d, 0d); mergeLocation(params, 0d, 0d);
mergeWhiteBalance(params, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE); mergeWhiteBalance(params, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE);
@ -297,49 +297,30 @@ class Camera1 extends CameraController {
} }
@Override // Choose the best default focus, based on session type.
void setFocus(@Focus int focus) { private void applyDefaultFocus(Camera.Parameters params) {
int old = mFocus; List<String> modes = params.getSupportedFocusModes();
mFocus = focus;
if (isCameraOpened()) {
synchronized (mLock) {
Camera.Parameters params = mCamera.getParameters();
if (mergeFocus(params, old)) mCamera.setParameters(params);
}
}
}
private boolean mergeFocus(Camera.Parameters params, @Focus int oldFocus) { if (mSessionType == SESSION_TYPE_VIDEO &&
if (!mOptions.getSupportedFocus().contains(mFocus)) { modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
mFocus = oldFocus; params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
return false; return;
} }
switch (mFocus) { if (modes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
case FOCUS_CONTINUOUS: params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
params.setFocusMode((String) mMapper.mapFocus(FOCUS_CONTINUOUS)); return;
return true; }
case FOCUS_TAP:
case FOCUS_TAP_WITH_MARKER:
// We are sure camera supports auto focus.
// Now we must just find a fallback, because FOCUS_AUTO is used only on tap.
if (mOptions.getSupportedFocus().contains(FOCUS_CONTINUOUS)) {
params.setFocusMode((String) mMapper.mapFocus(FOCUS_CONTINUOUS));
return true;
}
// Don't break.
case FOCUS_FIXED: if (modes.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {
if (mOptions.getSupportedFocus().contains(FOCUS_FIXED)) { params.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
params.setFocusMode((String) mMapper.mapFocus(FOCUS_FIXED)); return;
return true;
}
} }
mFocus = oldFocus; if (modes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) {
return false; params.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED);
return;
}
} }
@ -706,7 +687,7 @@ class Camera1 extends CameraController {
int maxAE = params.getMaxNumMeteringAreas(); int maxAE = params.getMaxNumMeteringAreas();
if (maxAF > 0) params.setFocusAreas(maxAF > 1 ? meteringAreas2 : meteringAreas1); if (maxAF > 0) params.setFocusAreas(maxAF > 1 ? meteringAreas2 : meteringAreas1);
if (maxAE > 0) params.setMeteringAreas(maxAE > 1 ? meteringAreas2 : meteringAreas1); if (maxAE > 0) params.setMeteringAreas(maxAE > 1 ? meteringAreas2 : meteringAreas1);
params.setFocusMode((String) mMapper.mapFocus(FOCUS_TAP)); // auto params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
mCamera.setParameters(params); mCamera.setParameters(params);
mCameraCallbacks.dispatchOnFocusStart(gesture, p); mCameraCallbacks.dispatchOnFocusStart(gesture, p);
// TODO this is not guaranteed to be called... Fix. // TODO this is not guaranteed to be called... Fix.
@ -734,7 +715,7 @@ class Camera1 extends CameraController {
Camera.Parameters params = mCamera.getParameters(); Camera.Parameters params = mCamera.getParameters();
params.setFocusAreas(null); params.setFocusAreas(null);
params.setMeteringAreas(null); params.setMeteringAreas(null);
mergeFocus(params, mFocus); // Revert to internal focus (CONTINUOUS_PICTURE if present). applyDefaultFocus(params); // Revert to internal focus.
mCamera.setParameters(params); mCamera.setParameters(params);
} }
} }

@ -142,11 +142,6 @@ class Camera2 extends CameraController {
} }
@Override
void setFocus(@Focus int focus) {
}
@Override @Override
void setSessionType(@SessionType int sessionType) { void setSessionType(@SessionType int sessionType) {

@ -20,11 +20,6 @@ public class CameraConstants {
public static final int FLASH_AUTO = 2; public static final int FLASH_AUTO = 2;
public static final int FLASH_TORCH = 3; public static final int FLASH_TORCH = 3;
public static final int FOCUS_FIXED = 0;
public static final int FOCUS_CONTINUOUS = 1;
public static final int FOCUS_TAP = 2;
public static final int FOCUS_TAP_WITH_MARKER = 3;
public static final int GRID_OFF = 0; public static final int GRID_OFF = 0;
public static final int GRID_3X3 = 1; public static final int GRID_3X3 = 1;
public static final int GRID_4X4 = 2; public static final int GRID_4X4 = 2;
@ -33,15 +28,6 @@ public class CameraConstants {
public static final int SESSION_TYPE_PICTURE = 0; public static final int SESSION_TYPE_PICTURE = 0;
public static final int SESSION_TYPE_VIDEO = 1; public static final int SESSION_TYPE_VIDEO = 1;
@Deprecated public static final int ZOOM_OFF = 0;
@Deprecated public static final int ZOOM_PINCH = 1;
@Deprecated public static final int CAPTURE_METHOD_STANDARD = 0;
@Deprecated public static final int CAPTURE_METHOD_FRAME = 1;
@Deprecated public static final int PERMISSIONS_VIDEO = 0;
@Deprecated public static final int PERMISSIONS_PICTURE = 1;
public static final int VIDEO_QUALITY_480P = 0; public static final int VIDEO_QUALITY_480P = 0;
public static final int VIDEO_QUALITY_720P = 1; public static final int VIDEO_QUALITY_720P = 1;
public static final int VIDEO_QUALITY_1080P = 2; public static final int VIDEO_QUALITY_1080P = 2;
@ -56,20 +42,25 @@ public class CameraConstants {
public static final int WHITE_BALANCE_DAYLIGHT = 3; public static final int WHITE_BALANCE_DAYLIGHT = 3;
public static final int WHITE_BALANCE_CLOUDY = 4; public static final int WHITE_BALANCE_CLOUDY = 4;
@Deprecated public static final int FOCUS_FIXED = 0;
@Deprecated public static final int FOCUS_CONTINUOUS = 1;
@Deprecated public static final int FOCUS_TAP = 2;
@Deprecated public static final int FOCUS_TAP_WITH_MARKER = 3;
@Deprecated public static final int ZOOM_OFF = 0;
@Deprecated public static final int ZOOM_PINCH = 1;
@Deprecated public static final int CAPTURE_METHOD_STANDARD = 0;
@Deprecated public static final int CAPTURE_METHOD_FRAME = 1;
@Deprecated public static final int PERMISSIONS_VIDEO = 0;
@Deprecated public static final int PERMISSIONS_PICTURE = 1;
static class Defaults { static class Defaults {
static final int DEFAULT_GESTURE_ACTION_TAP = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_TAP = GESTURE_ACTION_NONE;
// static final int DEFAULT_GESTURE_ACTION_DOUBLE_TAP = GESTURE_ACTION_NONE; // WIP static final int DEFAULT_GESTURE_ACTION_DOUBLE_TAP = GESTURE_ACTION_NONE;
static final int DEFAULT_GESTURE_ACTION_LONG_TAP = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_LONG_TAP = GESTURE_ACTION_NONE;
static final int DEFAULT_GESTURE_ACTION_PINCH = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_PINCH = GESTURE_ACTION_NONE;
static final int DEFAULT_FACING = FACING_BACK; static final int DEFAULT_FACING = FACING_BACK;
static final int DEFAULT_FLASH = FLASH_OFF; static final int DEFAULT_FLASH = FLASH_OFF;
static final int DEFAULT_FOCUS = FOCUS_CONTINUOUS;
@Deprecated static final int DEFAULT_ZOOM = ZOOM_OFF;
@Deprecated static final int DEFAULT_METHOD = CAPTURE_METHOD_STANDARD;
@Deprecated static final int DEFAULT_PERMISSIONS = PERMISSIONS_PICTURE;
static final int DEFAULT_VIDEO_QUALITY = VIDEO_QUALITY_480P; static final int DEFAULT_VIDEO_QUALITY = VIDEO_QUALITY_480P;
static final int DEFAULT_WHITE_BALANCE = WHITE_BALANCE_AUTO; static final int DEFAULT_WHITE_BALANCE = WHITE_BALANCE_AUTO;
static final int DEFAULT_SESSION_TYPE = SESSION_TYPE_PICTURE; static final int DEFAULT_SESSION_TYPE = SESSION_TYPE_PICTURE;
@ -77,5 +68,10 @@ public class CameraConstants {
static final int DEFAULT_GRID = GRID_OFF; static final int DEFAULT_GRID = GRID_OFF;
static final boolean DEFAULT_CROP_OUTPUT = false; static final boolean DEFAULT_CROP_OUTPUT = false;
@Deprecated static final int DEFAULT_FOCUS = FOCUS_CONTINUOUS;
@Deprecated static final int DEFAULT_ZOOM = ZOOM_OFF;
@Deprecated static final int DEFAULT_METHOD = CAPTURE_METHOD_STANDARD;
@Deprecated static final int DEFAULT_PERMISSIONS = PERMISSIONS_PICTURE;
} }
} }

@ -34,7 +34,6 @@ abstract class CameraController implements Preview.SurfaceCallback {
abstract boolean setExposureCorrection(float EVvalue); abstract boolean setExposureCorrection(float EVvalue);
abstract void setFacing(@Facing int facing); abstract void setFacing(@Facing int facing);
abstract void setFlash(@Flash int flash); abstract void setFlash(@Flash int flash);
abstract void setFocus(@Focus int focus);
abstract void setVideoQuality(@VideoQuality int videoQuality); abstract void setVideoQuality(@VideoQuality int videoQuality);
abstract void setWhiteBalance(@WhiteBalance int whiteBalance); abstract void setWhiteBalance(@WhiteBalance int whiteBalance);
abstract void setSessionType(@SessionType int sessionType); abstract void setSessionType(@SessionType int sessionType);

@ -18,7 +18,6 @@ public class CameraOptions {
private Set<Integer> supportedWhiteBalance = new HashSet<>(5); private Set<Integer> supportedWhiteBalance = new HashSet<>(5);
private Set<Integer> supportedFacing = new HashSet<>(2); private Set<Integer> supportedFacing = new HashSet<>(2);
private Set<Integer> supportedFlash = new HashSet<>(4); private Set<Integer> supportedFlash = new HashSet<>(4);
@Deprecated private Set<Integer> supportedFocus = new HashSet<>(4);
private boolean zoomSupported; private boolean zoomSupported;
private boolean videoSnapshotSupported; private boolean videoSnapshotSupported;
@ -60,13 +59,6 @@ public class CameraOptions {
} }
} }
// Focus
strings = params.getSupportedFocusModes(); // Never null.
for (String string : strings) {
Integer value = mapper.unmapFocus(string);
if (value != null) supportedFocus.add(value);
}
zoomSupported = params.isZoomSupported(); zoomSupported = params.isZoomSupported();
videoSnapshotSupported = params.isVideoSnapshotSupported(); videoSnapshotSupported = params.isVideoSnapshotSupported();
autoFocusSupported = params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO); autoFocusSupported = params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO);
@ -129,21 +121,6 @@ public class CameraOptions {
} }
/**
* Set of supported focus values.
*
* @see CameraConstants#FOCUS_FIXED
* @see CameraConstants#FOCUS_CONTINUOUS
* @see CameraConstants#FOCUS_TAP
* @see CameraConstants#FOCUS_TAP_WITH_MARKER
* @return a set of supported values.
*/
@NonNull
public Set<Integer> getSupportedFocus() {
return supportedFocus;
}
/** /**
* Whether zoom is supported. If this is false, pinch-to-zoom * Whether zoom is supported. If this is false, pinch-to-zoom
* will not work and {@link CameraView#setZoom(float)} will have no effect. * will not work and {@link CameraView#setZoom(float)} will have no effect.

@ -98,7 +98,6 @@ public class CameraView extends FrameLayout {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0);
int facing = a.getInteger(R.styleable.CameraView_cameraFacing, Defaults.DEFAULT_FACING); int facing = a.getInteger(R.styleable.CameraView_cameraFacing, Defaults.DEFAULT_FACING);
int flash = a.getInteger(R.styleable.CameraView_cameraFlash, Defaults.DEFAULT_FLASH); int flash = a.getInteger(R.styleable.CameraView_cameraFlash, Defaults.DEFAULT_FLASH);
int focus = a.getInteger(R.styleable.CameraView_cameraFocus, Defaults.DEFAULT_FOCUS);
int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, Defaults.DEFAULT_SESSION_TYPE); int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, Defaults.DEFAULT_SESSION_TYPE);
int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, Defaults.DEFAULT_WHITE_BALANCE); int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, Defaults.DEFAULT_WHITE_BALANCE);
int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, Defaults.DEFAULT_VIDEO_QUALITY); int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, Defaults.DEFAULT_VIDEO_QUALITY);
@ -124,7 +123,6 @@ public class CameraView extends FrameLayout {
mIsStarted = false; mIsStarted = false;
setFacing(facing); setFacing(facing);
setFlash(flash); setFlash(flash);
setFocus(focus);
setSessionType(sessionType); setSessionType(sessionType);
setVideoQuality(videoQuality); setVideoQuality(videoQuality);
setWhiteBalance(whiteBalance); setWhiteBalance(whiteBalance);
@ -169,6 +167,10 @@ public class CameraView extends FrameLayout {
} }
// Smart measuring behavior
// ------------------------
private String ms(int mode) { private String ms(int mode) {
switch (mode) { switch (mode) {
case AT_MOST: return "AT_MOST"; case AT_MOST: return "AT_MOST";
@ -305,6 +307,10 @@ public class CameraView extends FrameLayout {
} }
// Gesture APIs and touch control
// ------------------------------
/** /**
* Maps a {@link Gesture} to a certain gesture action. * Maps a {@link Gesture} to a certain gesture action.
* For example, you can assign zoom control to the pinch gesture by just calling: * For example, you can assign zoom control to the pinch gesture by just calling:
@ -406,6 +412,10 @@ public class CameraView extends FrameLayout {
} }
// Lifecycle APIs
// --------------
/** /**
* Returns whether the camera has started showing its preview. * Returns whether the camera has started showing its preview.
* @return whether the camera has started * @return whether the camera has started
@ -520,6 +530,10 @@ public class CameraView extends FrameLayout {
} }
// Public APIs for parameters and controls
// ---------------------------------------
/** /**
* Returns a {@link CameraOptions} instance holding supported options for this camera * Returns a {@link CameraOptions} instance holding supported options for this camera
* session. This might change over time. It's better to hold a reference from * session. This might change over time. It's better to hold a reference from
@ -763,54 +777,13 @@ public class CameraView extends FrameLayout {
* @param x should be >= 0 and <= getWidth() * @param x should be >= 0 and <= getWidth()
* @param y should be >= 0 and <= getHeight() * @param y should be >= 0 and <= getHeight()
*/ */
public void startFocus(float x, float y) { public void startAutoFocus(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.startAutoFocus(null, new PointF(x, y)); mCameraController.startAutoFocus(null, new PointF(x, y));
} }
/**
* Sets the current focus behavior.
*
* @see CameraConstants#FOCUS_CONTINUOUS
* @see CameraConstants#FOCUS_FIXED
* @see CameraConstants#FOCUS_TAP
* @see CameraConstants#FOCUS_TAP_WITH_MARKER
* @param focus a Focus value.
*/
public void setFocus(@Focus int focus) {
mCameraController.setFocus(focus);
}
/**
* Gets the current focus behavior.
* @return a focus behavior
*/
@Focus
public int getFocus() {
return mCameraController.getFocus();
}
/**
* This does nothing.
* @deprecated
*/
@Deprecated
public void setCaptureMethod(@Method int method) {}
/**
* This does nothing.
* @deprecated
*/
@Deprecated
public void setPermissionPolicy(@Permissions int permissions) {}
/** /**
* Set the current session type to either picture or video. * Set the current session type to either picture or video.
* When sessionType is video, * When sessionType is video,
@ -852,30 +825,6 @@ public class CameraView extends FrameLayout {
} }
/**
* Sets the zoom mode for the current session.
*
* @see CameraConstants#ZOOM_OFF
* @see CameraConstants#ZOOM_PINCH
*
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures
*/
@Deprecated
public void setZoomMode(@ZoomMode int zoom) {
}
/**
* Gets the current zoom mode.
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures
*/
@ZoomMode
@Deprecated
public int getZoomMode() {
return ZOOM_OFF;
}
/** /**
* Sets video recording quality. This is not guaranteed to be supported by current device. * Sets video recording quality. This is not guaranteed to be supported by current device.
* If it's not, a lower quality will be chosen, until a supported one is found. * If it's not, a lower quality will be chosen, until a supported one is found.
@ -1135,6 +1084,11 @@ public class CameraView extends FrameLayout {
} }
} }
// Callbacks and dispatch
// ----------------------
class CameraCallbacks { class CameraCallbacks {
private ArrayList<CameraListener> mListeners; private ArrayList<CameraListener> mListeners;
@ -1334,4 +1288,67 @@ public class CameraView extends FrameLayout {
} }
// Deprecated stuff
// ----------------
/**
* This does nothing.
* @deprecated
*/
@Deprecated
public void setFocus(@Focus int focus) {
}
/**
* This does nothing.
* @deprecated
*/
@Deprecated
@Focus
public int getFocus() {
return FOCUS_FIXED;
}
/**
* This does nothing.
* @deprecated
*/
@Deprecated
public void setCaptureMethod(@Method int method) {}
/**
* This does nothing.
* @deprecated
*/
@Deprecated
public void setPermissionPolicy(@Permissions int permissions) {}
/**
* Sets the zoom mode for the current session.
*
* @see CameraConstants#ZOOM_OFF
* @see CameraConstants#ZOOM_PINCH
*
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures
*/
@Deprecated
public void setZoomMode(@ZoomMode int zoom) {
}
/**
* Gets the current zoom mode.
* @deprecated use {@link #mapGesture(Gesture, int)} to map zoom control to gestures
*/
@ZoomMode
@Deprecated
public int getZoomMode() {
return ZOOM_OFF;
}
} }

@ -10,17 +10,14 @@ abstract class Mapper {
abstract <T> T mapFlash(@Flash int internalConstant); abstract <T> T mapFlash(@Flash int internalConstant);
abstract <T> T mapFacing(@Facing int internalConstant); abstract <T> T mapFacing(@Facing int internalConstant);
abstract <T> T mapWhiteBalance(@WhiteBalance int internalConstant); abstract <T> T mapWhiteBalance(@WhiteBalance int internalConstant);
abstract <T> T mapFocus(@Focus int internalConstant);
@Flash abstract <T> Integer unmapFlash(T cameraConstant); @Flash abstract <T> Integer unmapFlash(T cameraConstant);
@Facing abstract <T> Integer unmapFacing(T cameraConstant); @Facing abstract <T> Integer unmapFacing(T cameraConstant);
@WhiteBalance abstract <T> Integer unmapWhiteBalance(T cameraConstant); @WhiteBalance abstract <T> Integer unmapWhiteBalance(T cameraConstant);
@Focus abstract <T> Integer unmapFocus(T cameraConstant);
static class Mapper1 extends Mapper { static class Mapper1 extends Mapper {
private static final HashMap<Integer, String> FLASH = new HashMap<>(); private static final HashMap<Integer, String> FLASH = new HashMap<>();
private static final HashMap<Integer, String> WB = new HashMap<>(); private static final HashMap<Integer, String> WB = new HashMap<>();
private static final HashMap<Integer, Integer> FACING = new HashMap<>(); private static final HashMap<Integer, Integer> FACING = new HashMap<>();
private static final HashMap<Integer, String> FOCUS = new HashMap<>();
static { static {
FLASH.put(CameraConstants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF); FLASH.put(CameraConstants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF);
@ -34,11 +31,6 @@ abstract class Mapper {
WB.put(CameraConstants.WHITE_BALANCE_FLUORESCENT, Camera.Parameters.WHITE_BALANCE_FLUORESCENT); WB.put(CameraConstants.WHITE_BALANCE_FLUORESCENT, Camera.Parameters.WHITE_BALANCE_FLUORESCENT);
WB.put(CameraConstants.WHITE_BALANCE_DAYLIGHT, Camera.Parameters.WHITE_BALANCE_DAYLIGHT); WB.put(CameraConstants.WHITE_BALANCE_DAYLIGHT, Camera.Parameters.WHITE_BALANCE_DAYLIGHT);
WB.put(CameraConstants.WHITE_BALANCE_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); WB.put(CameraConstants.WHITE_BALANCE_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
// TODO FOCUS_MODE_FIXED is rarely supported.
FOCUS.put(CameraConstants.FOCUS_FIXED, Camera.Parameters.FOCUS_MODE_FIXED);
FOCUS.put(CameraConstants.FOCUS_CONTINUOUS, Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
FOCUS.put(CameraConstants.FOCUS_TAP, Camera.Parameters.FOCUS_MODE_AUTO);
FOCUS.put(CameraConstants.FOCUS_TAP_WITH_MARKER, Camera.Parameters.FOCUS_MODE_AUTO);
} }
@Override @Override
@ -56,11 +48,6 @@ abstract class Mapper {
return (T) WB.get(internalConstant); return (T) WB.get(internalConstant);
} }
@Override
<T> T mapFocus(@Focus int internalConstant) {
return (T) FOCUS.get(internalConstant);
}
private Integer reverseLookup(HashMap<Integer, ?> map, Object object) { private Integer reverseLookup(HashMap<Integer, ?> map, Object object) {
for (int value : map.keySet()) { for (int value : map.keySet()) {
if (map.get(value).equals(object)) { if (map.get(value).equals(object)) {
@ -84,12 +71,6 @@ abstract class Mapper {
<T> Integer unmapWhiteBalance(T cameraConstant) { <T> Integer unmapWhiteBalance(T cameraConstant) {
return reverseLookup(WB, cameraConstant); return reverseLookup(WB, cameraConstant);
} }
// This will ignore FOCUS_TAP_WITH_MARKER but it's fine
@Override
<T> Integer unmapFocus(T cameraConstant) {
return reverseLookup(FOCUS, cameraConstant);
}
} }
static class Mapper2 extends Mapper { static class Mapper2 extends Mapper {
@ -124,15 +105,6 @@ abstract class Mapper {
return 0; return 0;
} }
@Override
<T> T mapFocus(@Focus int internalConstant) {
return null;
}
@Override
<T> Integer unmapFocus(T cameraConstant) {
return 0;
}
} }
} }

@ -1,16 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<declare-styleable name="CameraView"> <declare-styleable name="CameraView">
<!-- WIP attr name="cameraGestureDoubleTap" format="enum">
<attr name="cameraGestureTap" format="enum">
<enum name="none" value="0" /> <enum name="none" value="0" />
<enum name="focus" value="1" /> <enum name="focus" value="1" />
<enum name="focusWithMarker" value="2" /> <enum name="focusWithMarker" value="2" />
<enum name="capture" value="3" /> <enum name="capture" value="3" />
</attr> </attr-->
<attr name="cameraGestureDoubleTap" format="enum"> <attr name="cameraGestureTap" format="enum">
<enum name="none" value="0" /> <enum name="none" value="0" />
<enum name="focus" value="1" /> <enum name="focus" value="1" />
<enum name="focusWithMarker" value="2" /> <enum name="focusWithMarker" value="2" />
@ -29,7 +27,6 @@
<enum name="aeCorrection" value="5" /> <enum name="aeCorrection" value="5" />
</attr> </attr>
<attr name="cameraFacing" format="enum"> <attr name="cameraFacing" format="enum">
<enum name="back" value="0" /> <enum name="back" value="0" />
<enum name="front" value="1" /> <enum name="front" value="1" />
@ -42,13 +39,6 @@
<enum name="torch" value="3" /> <enum name="torch" value="3" />
</attr> </attr>
<attr name="cameraFocus" format="enum">
<enum name="fixed" value="0" />
<enum name="continuous" value="1" />
<enum name="tap" value="2" />
<enum name="tapWithMarker" value="3" />
</attr>
<attr name="cameraWhiteBalance" format="enum"> <attr name="cameraWhiteBalance" format="enum">
<enum name="auto" value="0" /> <enum name="auto" value="0" />
<enum name="incandescent" value="1" /> <enum name="incandescent" value="1" />
@ -57,11 +47,6 @@
<enum name="cloudy" value="4" /> <enum name="cloudy" value="4" />
</attr> </attr>
<attr name="cameraZoomMode" format="enum">
<enum name="off" value="0" />
<enum name="pinch" value="1" />
</attr>
<attr name="cameraGrid" format="enum"> <attr name="cameraGrid" format="enum">
<enum name="off" value="0" /> <enum name="off" value="0" />
<enum name="grid3x3" value="1" /> <enum name="grid3x3" value="1" />
@ -69,21 +54,11 @@
<enum name="phi" value="3" /> <enum name="phi" value="3" />
</attr> </attr>
<attr name="cameraCaptureMethod" format="enum">
<enum name="standard" value="0" />
<enum name="frame" value="1" />
</attr>
<attr name="cameraSessionType" format="enum"> <attr name="cameraSessionType" format="enum">
<enum name="picture" value="0" /> <enum name="picture" value="0" />
<enum name="video" value="1" /> <enum name="video" value="1" />
</attr> </attr>
<attr name="cameraPermissionPolicy" format="enum">
<enum name="video" value="0" />
<enum name="picture" value="1" />
</attr>
<attr name="cameraJpegQuality" format="integer" /> <attr name="cameraJpegQuality" format="integer" />
<attr name="cameraVideoQuality" format="enum"> <attr name="cameraVideoQuality" format="enum">
@ -98,6 +73,27 @@
<attr name="cameraCropOutput" format="boolean" /> <attr name="cameraCropOutput" format="boolean" />
<!-- deprecated attr name="cameraZoomMode" format="enum">
<enum name="off" value="0" />
<enum name="pinch" value="1" />
</attr -->
<!-- deprecated attr name="cameraCaptureMethod" format="enum">
<enum name="standard" value="0" />
<enum name="frame" value="1" />
</attr -->
<!-- deprecated attr name="cameraPermissionPolicy" format="enum">
<enum name="video" value="0" />
<enum name="picture" value="1" />
</attr -->
<!-- deprecated attr name="cameraFocus" format="enum">
<enum name="fixed" value="0" />
<enum name="continuous" value="1" />
<enum name="tap" value="2" />
<enum name="tapWithMarker" value="3" />
</attr -->
</declare-styleable> </declare-styleable>
</resources> </resources>
Loading…
Cancel
Save