Class name refactoring

pull/1/head
Mattia Iavarone 7 years ago
parent 033872d0a6
commit f14f866c96
  1. 62
      README.md
  2. 48
      camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
  3. 41
      camerakit/src/main/api16/com/flurgle/camerakit/Mapper.java
  4. 6
      camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java
  5. 7
      camerakit/src/main/base/com/flurgle/camerakit/CameraController.java
  6. 2
      camerakit/src/main/base/com/flurgle/camerakit/CameraOptions.java
  7. 4
      camerakit/src/main/base/com/flurgle/camerakit/Preview.java
  8. 2
      camerakit/src/main/base/com/flurgle/camerakit/SurfaceViewPreview.java
  9. 2
      camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java
  10. 92
      camerakit/src/main/java/com/flurgle/camerakit/CameraConstants.java
  11. 92
      camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java
  12. 4
      camerakit/src/main/java/com/flurgle/camerakit/CameraUtils.java
  13. 188
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
  14. 10
      camerakit/src/main/java/com/flurgle/camerakit/GridLinesLayout.java
  15. 2
      camerakit/src/main/java/com/flurgle/camerakit/PinchToZoomLayout.java
  16. 4
      camerakit/src/main/types/com/flurgle/camerakit/Facing.java
  17. 8
      camerakit/src/main/types/com/flurgle/camerakit/Flash.java
  18. 8
      camerakit/src/main/types/com/flurgle/camerakit/Focus.java
  19. 8
      camerakit/src/main/types/com/flurgle/camerakit/Grid.java
  20. 4
      camerakit/src/main/types/com/flurgle/camerakit/Method.java
  21. 4
      camerakit/src/main/types/com/flurgle/camerakit/Permissions.java
  22. 4
      camerakit/src/main/types/com/flurgle/camerakit/SessionType.java
  23. 14
      camerakit/src/main/types/com/flurgle/camerakit/VideoQuality.java
  24. 10
      camerakit/src/main/types/com/flurgle/camerakit/WhiteBalance.java
  25. 4
      camerakit/src/main/types/com/flurgle/camerakit/ZoomMode.java
  26. 50
      demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java
  27. 2
      demo/src/main/res/values/strings.xml

@ -1,5 +1,5 @@
*A fork of [Dylan McIntyre's CameraKit-Android library](https://github.com/gogopop/CameraKit-Android), originally a fork of [Google's CameraView library](https://github.com/google/cameraview). The CameraKit-Android at this point has been completely rewritten and refactored:* *A fork of [Dylan McIntyre's CameraKit-Android library](https://github.com/gogopop/CameraKit-Android), originally a fork of [Google's CameraView library](https://github.com/google/cameraview). The library at this point has been completely rewritten and refactored:*
- lots *of serious bugs fixed* - lots *of serious bugs fixed*
- *decent orientation support for both pictures and videos* - *decent orientation support for both pictures and videos*
@ -268,8 +268,8 @@ What to capture - either picture or video. This has a couple of consequences:
- Permission behavior: when requesting a `video` session, the record audio permission will be requested. If this is needed, the audio permission should be added to your manifest or the app will crash. - Permission behavior: when requesting a `video` session, the record audio permission will be requested. If this is needed, the audio permission should be added to your manifest or the app will crash.
```java ```java
cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_PICTURE); cameraView.setSessionType(CameraConstants.SESSION_TYPE_PICTURE);
cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_VIDEO); cameraView.setSessionType(CameraConstants.SESSION_TYPE_VIDEO);
``` ```
### cameraFacing ### cameraFacing
@ -277,8 +277,8 @@ cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_VIDEO);
Which camera to use, either back facing or front facing. Which camera to use, either back facing or front facing.
```java ```java
cameraView.setFacing(CameraKit.Constants.FACING_BACK); cameraView.setFacing(CameraConstants.FACING_BACK);
cameraView.setFacing(CameraKit.Constants.FACING_FRONT); cameraView.setFacing(CameraConstants.FACING_FRONT);
``` ```
### cameraFlash ### cameraFlash
@ -286,10 +286,10 @@ cameraView.setFacing(CameraKit.Constants.FACING_FRONT);
Flash mode, either off, on, auto or *torch*. Flash mode, either off, on, auto or *torch*.
```java ```java
cameraView.setFlash(CameraKit.Constants.FLASH_OFF); cameraView.setFlash(CameraConstants.FLASH_OFF);
cameraView.setFlash(CameraKit.Constants.FLASH_ON); cameraView.setFlash(CameraConstants.FLASH_ON);
cameraView.setFlash(CameraKit.Constants.FLASH_AUTO); cameraView.setFlash(CameraConstants.FLASH_AUTO);
cameraView.setFlash(CameraKit.Constants.FLASH_TORCH); cameraView.setFlash(CameraConstants.FLASH_TORCH);
``` ```
### cameraFocus ### cameraFocus
@ -297,10 +297,10 @@ cameraView.setFlash(CameraKit.Constants.FLASH_TORCH);
Focus behavior. Can be off, continuous (camera continuously tries to adapt its focus), tap (focus is driven by the user tap) and tapWithMarker (a marker is drawn on screen to indicate focusing). Focus behavior. Can be off, continuous (camera continuously tries to adapt its focus), tap (focus is driven by the user tap) and tapWithMarker (a marker is drawn on screen to indicate focusing).
```java ```java
cameraView.setFocus(CameraKit.Constants.FOCUS_FIXED); cameraView.setFocus(CameraConstants.FOCUS_FIXED);
cameraView.setFocus(CameraKit.Constants.FOCUS_CONTINUOUS); cameraView.setFocus(CameraConstants.FOCUS_CONTINUOUS);
cameraView.setFocus(CameraKit.Constants.FOCUS_TAP); cameraView.setFocus(CameraConstants.FOCUS_TAP);
cameraView.setFocus(CameraKit.Constants.FOCUS_TAP_WITH_MARKER); cameraView.setFocus(CameraConstants.FOCUS_TAP_WITH_MARKER);
``` ```
### cameraZoomMode ### cameraZoomMode
@ -308,8 +308,8 @@ cameraView.setFocus(CameraKit.Constants.FOCUS_TAP_WITH_MARKER);
Lets you enable built-in pinch-to-zoom behavior. This means that the camera will capture two-finger gestures and move the zoom value accordingly. Nothing is drawn on screen, but you can listen to `onZoomChanged` in your camera listener. Lets you enable built-in pinch-to-zoom behavior. This means that the camera will capture two-finger gestures and move the zoom value accordingly. Nothing is drawn on screen, but you can listen to `onZoomChanged` in your camera listener.
```java ```java
cameraView.setZoomMode(CameraKit.Constants.ZOOM_OFF); cameraView.setZoomMode(CameraConstants.ZOOM_OFF);
cameraView.setZoomMode(CameraKit.Constants.ZOOM_PINCH); cameraView.setZoomMode(CameraConstants.ZOOM_PINCH);
``` ```
### cameraGrid ### cameraGrid
@ -317,10 +317,10 @@ cameraView.setZoomMode(CameraKit.Constants.ZOOM_PINCH);
Lets you draw grids over the camera preview. Supported values are `off`, `grid3x3` and `grid4x4` for regular grids, and `phi` for a grid based on the golden ratio constant, often used in photography. Lets you draw grids over the camera preview. Supported values are `off`, `grid3x3` and `grid4x4` for regular grids, and `phi` for a grid based on the golden ratio constant, often used in photography.
```java ```java
cameraView.setZoom(CameraKit.Constants.GRID_OFF); cameraView.setZoom(CameraConstants.GRID_OFF);
cameraView.setZoom(CameraKit.Constants.GRID_3X3); cameraView.setZoom(CameraConstants.GRID_3X3);
cameraView.setZoom(CameraKit.Constants.GRID_4X4); cameraView.setZoom(CameraConstants.GRID_4X4);
cameraView.setZoom(CameraKit.Constants.GRID_PHI); cameraView.setZoom(CameraConstants.GRID_PHI);
``` ```
### cameraCropOutput ### cameraCropOutput
@ -342,13 +342,13 @@ cameraView.setJpegQuality(50);
Sets the desired video quality. Sets the desired video quality.
```java ```java
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_480P); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_480P);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_720P); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_720P);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_1080P); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_1080P);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_2160P); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_2160P);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_LOWEST); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_LOWEST);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_HIGHEST); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_HIGHEST);
cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_QVGA); cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_QVGA);
``` ```
### cameraWhiteBalance ### cameraWhiteBalance
@ -356,11 +356,11 @@ cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_QVGA);
Sets the desired white balance for the current session. Sets the desired white balance for the current session.
```java ```java
cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_AUTO); cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_AUTO);
cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_INCANDESCENT); cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_INCANDESCENT);
cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_FLUORESCENT); cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_FLUORESCENT);
cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_DAYLIGHT); cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_DAYLIGHT);
cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_CLOUDY); cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_CLOUDY);
``` ```
## Permissions behavior ## Permissions behavior

@ -18,15 +18,15 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; import static com.flurgle.camerakit.CameraConstants.FOCUS_CONTINUOUS;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_FIXED; import static com.flurgle.camerakit.CameraConstants.FOCUS_FIXED;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP_WITH_MARKER; import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP_WITH_MARKER;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
class Camera1 extends CameraImpl { class Camera1 extends CameraController {
private static final String TAG = Camera1.class.getSimpleName(); private static final String TAG = Camera1.class.getSimpleName();
@ -49,14 +49,14 @@ class Camera1 extends CameraImpl {
private double mLongitude; private double mLongitude;
private Handler mFocusHandler = new Handler(); private Handler mFocusHandler = new Handler();
private MapperImpl mMapper = new MapperImpl.Mapper1(); private Mapper mMapper = new Mapper.Mapper1();
private boolean mIsSetup = false; private boolean mIsSetup = false;
private boolean mIsCapturingImage = false; private boolean mIsCapturingImage = false;
private boolean mIsCapturingVideo = false; private boolean mIsCapturingVideo = false;
private final Object mLock = new Object(); private final Object mLock = new Object();
Camera1(CameraView.CameraCallbacks callback, final PreviewImpl preview) { Camera1(CameraView.CameraCallbacks callback, final Preview preview) {
super(callback, preview); super(callback, preview);
} }
@ -145,10 +145,10 @@ class Camera1 extends CameraImpl {
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, CameraKit.Defaults.DEFAULT_FOCUS); mergeFocus(params, CameraConstants.Defaults.DEFAULT_FOCUS);
mergeFlash(params, CameraKit.Defaults.DEFAULT_FLASH); mergeFlash(params, CameraConstants.Defaults.DEFAULT_FLASH);
mergeLocation(params, 0d, 0d); mergeLocation(params, 0d, 0d);
mergeWhiteBalance(params, CameraKit.Defaults.DEFAULT_WHITE_BALANCE); mergeWhiteBalance(params, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE);
params.setRecordingHint(mSessionType == SESSION_TYPE_VIDEO); params.setRecordingHint(mSessionType == SESSION_TYPE_VIDEO);
mCamera.setParameters(params); mCamera.setParameters(params);
} }
@ -349,7 +349,7 @@ class Camera1 extends CameraImpl {
} }
mVideoQuality = videoQuality; mVideoQuality = videoQuality;
if (isCameraOpened() && mSessionType == CameraKit.Constants.SESSION_TYPE_VIDEO) { if (isCameraOpened() && mSessionType == CameraConstants.SESSION_TYPE_VIDEO) {
// Change capture size to a size that fits the video aspect ratio. // Change capture size to a size that fits the video aspect ratio.
Size oldSize = mCaptureSize; Size oldSize = mCaptureSize;
mCaptureSize = computeCaptureSize(); mCaptureSize = computeCaptureSize();
@ -485,7 +485,7 @@ class Camera1 extends CameraImpl {
* It is meant to be fed to Camera.setDisplayOrientation(). * It is meant to be fed to Camera.setDisplayOrientation().
*/ */
private int computeSensorToDisplayOffset() { private int computeSensorToDisplayOffset() {
if (mFacing == CameraKit.Constants.FACING_FRONT) { if (mFacing == CameraConstants.FACING_FRONT) {
// or: (360 - ((mSensorOffset + mDisplayOffset) % 360)) % 360; // or: (360 - ((mSensorOffset + mDisplayOffset) % 360)) % 360;
return ((mSensorOffset - mDisplayOffset) + 360 + 180) % 360; return ((mSensorOffset - mDisplayOffset) + 360 + 180) % 360;
} else { } else {
@ -499,7 +499,7 @@ class Camera1 extends CameraImpl {
* This ignores flipping for facing camera. * This ignores flipping for facing camera.
*/ */
private int computeExifRotation() { private int computeExifRotation() {
if (mFacing == CameraKit.Constants.FACING_FRONT) { if (mFacing == CameraConstants.FACING_FRONT) {
return (mSensorOffset - mDeviceOrientation + 360) % 360; return (mSensorOffset - mDeviceOrientation + 360) % 360;
} else { } else {
return (mSensorOffset + mDeviceOrientation) % 360; return (mSensorOffset + mDeviceOrientation) % 360;
@ -511,7 +511,7 @@ class Camera1 extends CameraImpl {
* Whether the exif tag should include a 'flip' operation. * Whether the exif tag should include a 'flip' operation.
*/ */
private boolean computeExifFlip() { private boolean computeExifFlip() {
return mFacing == CameraKit.Constants.FACING_FRONT; return mFacing == CameraConstants.FACING_FRONT;
} }
@ -519,7 +519,7 @@ class Camera1 extends CameraImpl {
* This is called either on cameraView.start(), or when the underlying surface changes. * This is called either on cameraView.start(), or when the underlying surface changes.
* It is possible that in the first call the preview surface has not already computed its * It is possible that in the first call the preview surface has not already computed its
* dimensions. * dimensions.
* But when it does, the {@link PreviewImpl.SurfaceCallback} should be called, * But when it does, the {@link Preview.SurfaceCallback} should be called,
* and this should be refreshed. * and this should be refreshed.
*/ */
private Size computeCaptureSize() { private Size computeCaptureSize() {
@ -612,41 +612,41 @@ class Camera1 extends CameraImpl {
@NonNull @NonNull
private CamcorderProfile getCamcorderProfile(@VideoQuality int videoQuality) { private CamcorderProfile getCamcorderProfile(@VideoQuality int videoQuality) {
switch (videoQuality) { switch (videoQuality) {
case CameraKit.Constants.VIDEO_QUALITY_HIGHEST: case CameraConstants.VIDEO_QUALITY_HIGHEST:
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH);
case CameraKit.Constants.VIDEO_QUALITY_2160P: case CameraConstants.VIDEO_QUALITY_2160P:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) { CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) {
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_2160P); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_2160P);
} }
// Don't break. // Don't break.
case CameraKit.Constants.VIDEO_QUALITY_1080P: case CameraConstants.VIDEO_QUALITY_1080P:
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) { if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) {
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_1080P); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_1080P);
} }
// Don't break. // Don't break.
case CameraKit.Constants.VIDEO_QUALITY_720P: case CameraConstants.VIDEO_QUALITY_720P:
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) { if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) {
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_720P); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_720P);
} }
// Don't break. // Don't break.
case CameraKit.Constants.VIDEO_QUALITY_480P: case CameraConstants.VIDEO_QUALITY_480P:
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) { if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) {
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_480P); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_480P);
} }
// Don't break. // Don't break.
case CameraKit.Constants.VIDEO_QUALITY_QVGA: case CameraConstants.VIDEO_QUALITY_QVGA:
if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_QVGA)) { if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_QVGA)) {
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_QVGA); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_QVGA);
} }
// Don't break. // Don't break.
case CameraKit.Constants.VIDEO_QUALITY_LOWEST: case CameraConstants.VIDEO_QUALITY_LOWEST:
default: default:
// Fallback to lowest. // Fallback to lowest.
return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_LOW); return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_LOW);

@ -1,14 +1,9 @@
package com.flurgle.camerakit; package com.flurgle.camerakit;
import android.annotation.TargetApi;
import android.hardware.Camera; import android.hardware.Camera;
import android.hardware.camera2.CameraCharacteristics;
import android.support.v4.util.SparseArrayCompat; import android.support.v4.util.SparseArrayCompat;
import android.util.SparseIntArray;
import java.util.Map; abstract class Mapper {
abstract class MapperImpl {
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);
@ -19,28 +14,28 @@ abstract class MapperImpl {
@WhiteBalance abstract <T> int unmapWhiteBalance(T cameraConstant); @WhiteBalance abstract <T> int unmapWhiteBalance(T cameraConstant);
@Focus abstract <T> int unmapFocus(T cameraConstant); @Focus abstract <T> int unmapFocus(T cameraConstant);
static class Mapper1 extends MapperImpl { static class Mapper1 extends Mapper {
private static final SparseArrayCompat<String> FLASH = new SparseArrayCompat<>(); private static final SparseArrayCompat<String> FLASH = new SparseArrayCompat<>();
private static final SparseArrayCompat<String> WB = new SparseArrayCompat<>(); private static final SparseArrayCompat<String> WB = new SparseArrayCompat<>();
private static final SparseArrayCompat<Integer> FACING = new SparseArrayCompat<>(); private static final SparseArrayCompat<Integer> FACING = new SparseArrayCompat<>();
private static final SparseArrayCompat<String> FOCUS = new SparseArrayCompat<>(); private static final SparseArrayCompat<String> FOCUS = new SparseArrayCompat<>();
static { static {
FLASH.put(CameraKit.Constants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF); FLASH.put(CameraConstants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF);
FLASH.put(CameraKit.Constants.FLASH_ON, Camera.Parameters.FLASH_MODE_ON); FLASH.put(CameraConstants.FLASH_ON, Camera.Parameters.FLASH_MODE_ON);
FLASH.put(CameraKit.Constants.FLASH_AUTO, Camera.Parameters.FLASH_MODE_AUTO); FLASH.put(CameraConstants.FLASH_AUTO, Camera.Parameters.FLASH_MODE_AUTO);
FLASH.put(CameraKit.Constants.FLASH_TORCH, Camera.Parameters.FLASH_MODE_TORCH); FLASH.put(CameraConstants.FLASH_TORCH, Camera.Parameters.FLASH_MODE_TORCH);
FACING.put(CameraKit.Constants.FACING_BACK, Camera.CameraInfo.CAMERA_FACING_BACK); FACING.put(CameraConstants.FACING_BACK, Camera.CameraInfo.CAMERA_FACING_BACK);
FACING.put(CameraKit.Constants.FACING_FRONT, Camera.CameraInfo.CAMERA_FACING_FRONT); FACING.put(CameraConstants.FACING_FRONT, Camera.CameraInfo.CAMERA_FACING_FRONT);
WB.put(CameraKit.Constants.WHITE_BALANCE_AUTO, Camera.Parameters.WHITE_BALANCE_AUTO); WB.put(CameraConstants.WHITE_BALANCE_AUTO, Camera.Parameters.WHITE_BALANCE_AUTO);
WB.put(CameraKit.Constants.WHITE_BALANCE_INCANDESCENT, Camera.Parameters.WHITE_BALANCE_INCANDESCENT); WB.put(CameraConstants.WHITE_BALANCE_INCANDESCENT, Camera.Parameters.WHITE_BALANCE_INCANDESCENT);
WB.put(CameraKit.Constants.WHITE_BALANCE_FLUORESCENT, Camera.Parameters.WHITE_BALANCE_FLUORESCENT); WB.put(CameraConstants.WHITE_BALANCE_FLUORESCENT, Camera.Parameters.WHITE_BALANCE_FLUORESCENT);
WB.put(CameraKit.Constants.WHITE_BALANCE_DAYLIGHT, Camera.Parameters.WHITE_BALANCE_DAYLIGHT); WB.put(CameraConstants.WHITE_BALANCE_DAYLIGHT, Camera.Parameters.WHITE_BALANCE_DAYLIGHT);
WB.put(CameraKit.Constants.WHITE_BALANCE_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); WB.put(CameraConstants.WHITE_BALANCE_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
FOCUS.put(CameraKit.Constants.FOCUS_FIXED, Camera.Parameters.FOCUS_MODE_FIXED); FOCUS.put(CameraConstants.FOCUS_FIXED, Camera.Parameters.FOCUS_MODE_FIXED);
FOCUS.put(CameraKit.Constants.FOCUS_CONTINUOUS, Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); FOCUS.put(CameraConstants.FOCUS_CONTINUOUS, Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
FOCUS.put(CameraKit.Constants.FOCUS_TAP, Camera.Parameters.FOCUS_MODE_AUTO); FOCUS.put(CameraConstants.FOCUS_TAP, Camera.Parameters.FOCUS_MODE_AUTO);
FOCUS.put(CameraKit.Constants.FOCUS_TAP_WITH_MARKER, Camera.Parameters.FOCUS_MODE_AUTO); FOCUS.put(CameraConstants.FOCUS_TAP_WITH_MARKER, Camera.Parameters.FOCUS_MODE_AUTO);
} }
@Override @Override
@ -85,7 +80,7 @@ abstract class MapperImpl {
} }
} }
static class Mapper2 extends MapperImpl { static class Mapper2 extends Mapper {
@Override @Override
<T> T mapWhiteBalance(@WhiteBalance int internalConstant) { <T> T mapWhiteBalance(@WhiteBalance int internalConstant) {

@ -19,7 +19,7 @@ import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
@TargetApi(21) @TargetApi(21)
class Camera2 extends CameraImpl { class Camera2 extends CameraController {
private CameraDevice mCamera; private CameraDevice mCamera;
private CameraCharacteristics mCameraCharacteristics; private CameraCharacteristics mCameraCharacteristics;
@ -31,7 +31,7 @@ class Camera2 extends CameraImpl {
private Size mCaptureSize; private Size mCaptureSize;
private Size mPreviewSize; private Size mPreviewSize;
private MapperImpl mMapper = new MapperImpl.Mapper2(); private Mapper mMapper = new Mapper.Mapper2();
private final HashMap<String, ExtraProperties> mExtraPropertiesMap = new HashMap<>(); private final HashMap<String, ExtraProperties> mExtraPropertiesMap = new HashMap<>();
@ -50,7 +50,7 @@ class Camera2 extends CameraImpl {
} }
Camera2(CameraView.CameraCallbacks callback, PreviewImpl preview, Context context) { Camera2(CameraView.CameraCallbacks callback, Preview preview, Context context) {
super(callback, preview); super(callback, preview);
mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);

@ -2,14 +2,13 @@ package com.flurgle.camerakit;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.MotionEvent;
import java.io.File; import java.io.File;
abstract class CameraImpl implements PreviewImpl.SurfaceCallback { abstract class CameraController implements Preview.SurfaceCallback {
protected final CameraView.CameraCallbacks mCameraCallbacks; protected final CameraView.CameraCallbacks mCameraCallbacks;
protected final PreviewImpl mPreview; protected final Preview mPreview;
@Facing protected int mFacing; @Facing protected int mFacing;
@Flash protected int mFlash; @Flash protected int mFlash;
@ -18,7 +17,7 @@ abstract class CameraImpl implements PreviewImpl.SurfaceCallback {
@WhiteBalance protected int mWhiteBalance; @WhiteBalance protected int mWhiteBalance;
@SessionType protected int mSessionType; @SessionType protected int mSessionType;
CameraImpl(CameraView.CameraCallbacks callback, PreviewImpl preview) { CameraController(CameraView.CameraCallbacks callback, Preview preview) {
mCameraCallbacks = callback; mCameraCallbacks = callback;
mPreview = preview; mPreview = preview;
mPreview.setSurfaceCallback(this); mPreview.setSurfaceCallback(this);

@ -24,7 +24,7 @@ public class CameraOptions {
CameraOptions(Camera.Parameters params) { CameraOptions(Camera.Parameters params) {
List<String> strings; List<String> strings;
MapperImpl mapper = new MapperImpl.Mapper1(); Mapper mapper = new Mapper.Mapper1();
// Facing // Facing
Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.CameraInfo cameraInfo = new Camera.CameraInfo();

@ -7,7 +7,7 @@ import android.view.SurfaceHolder;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
abstract class PreviewImpl { abstract class Preview {
// This is used to notify CameraImpl to recompute its camera Preview size. // This is used to notify CameraImpl to recompute its camera Preview size.
// After that, CameraView will need a new layout pass to adapt to the Preview size. // After that, CameraView will need a new layout pass to adapt to the Preview size.
@ -27,7 +27,7 @@ abstract class PreviewImpl {
private int mDesiredWidth; private int mDesiredWidth;
private int mDesiredHeight; private int mDesiredHeight;
PreviewImpl(Context context, ViewGroup parent) {} Preview(Context context, ViewGroup parent) {}
abstract Surface getSurface(); abstract Surface getSurface();
abstract View getView(); abstract View getView();

@ -8,7 +8,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
// This is not used. // This is not used.
class SurfaceViewPreview extends PreviewImpl { class SurfaceViewPreview extends Preview {
private final SurfaceView mSurfaceView; private final SurfaceView mSurfaceView;

@ -9,7 +9,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@TargetApi(14) @TargetApi(14)
class TextureViewPreview extends PreviewImpl { class TextureViewPreview extends Preview {
private final TextureView mTextureView; private final TextureView mTextureView;
private Surface mSurface; private Surface mSurface;

@ -0,0 +1,92 @@
package com.flurgle.camerakit;
/**
* Created by Mattia on 06/08/17.
*/
public class CameraConstants {
public static final int PERMISSION_REQUEST_CODE = 16;
public static final int FACING_BACK = 0;
public static final int FACING_FRONT = 1;
public static final int FLASH_OFF = 0;
public static final int FLASH_ON = 1;
public static final int FLASH_AUTO = 2;
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 ZOOM_OFF = 0;
public static final int ZOOM_PINCH = 1;
public static final int GRID_OFF = 0;
public static final int GRID_3X3 = 1;
public static final int GRID_4X4 = 2;
public static final int GRID_PHI = 3;
public static final int SESSION_TYPE_PICTURE = 0;
public static final int SESSION_TYPE_VIDEO = 1;
@Deprecated
public static final int CAPTURE_METHOD_STANDARD = 0;
@Deprecated
public static final int CAPTURE_METHOD_FRAME = 1;
/**
* This means the app will be requesting Camera and Audio permissions on Marshmallow+.
* With this configuration, it is mandatory that the developer adds
* <uses-permission android:name="android.permission.RECORD_AUDIO" />
* to its manifest, or the app will crash.
*
* @deprecated this does nothing.
*/
@Deprecated
public static final int PERMISSIONS_VIDEO = 0;
/**
* This means the app will be requesting the Camera permissions on Marshmallow+.
* On older APIs, this is not important, since the Camera permission is already
* declared in the manifest by the library.
*
* @deprecated this does nothing.
*/
@Deprecated
public static final int PERMISSIONS_PICTURE = 1;
public static final int VIDEO_QUALITY_480P = 0;
public static final int VIDEO_QUALITY_720P = 1;
public static final int VIDEO_QUALITY_1080P = 2;
public static final int VIDEO_QUALITY_2160P = 3;
public static final int VIDEO_QUALITY_HIGHEST = 4;
public static final int VIDEO_QUALITY_LOWEST = 5;
public static final int VIDEO_QUALITY_QVGA = 6;
public static final int WHITE_BALANCE_AUTO = 0;
public static final int WHITE_BALANCE_INCANDESCENT = 1;
public static final int WHITE_BALANCE_FLUORESCENT = 2;
public static final int WHITE_BALANCE_DAYLIGHT = 3;
public static final int WHITE_BALANCE_CLOUDY = 4;
static class Defaults {
static final int DEFAULT_FACING = FACING_BACK;
static final int DEFAULT_FLASH = FLASH_OFF;
static final int DEFAULT_FOCUS = FOCUS_CONTINUOUS;
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_WHITE_BALANCE = WHITE_BALANCE_AUTO;
static final int DEFAULT_SESSION_TYPE = SESSION_TYPE_PICTURE;
static final int DEFAULT_JPEG_QUALITY = 100;
static final int DEFAULT_GRID = GRID_OFF;
static final boolean DEFAULT_CROP_OUTPUT = false;
}
}

@ -1,92 +0,0 @@
package com.flurgle.camerakit;
import android.content.Context;
import android.content.pm.PackageManager;
public class CameraKit {
public static class Constants {
public static final int PERMISSION_REQUEST_CODE = 16;
public static final int FACING_BACK = 0;
public static final int FACING_FRONT = 1;
public static final int FLASH_OFF = 0;
public static final int FLASH_ON = 1;
public static final int FLASH_AUTO = 2;
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 ZOOM_OFF = 0;
public static final int ZOOM_PINCH = 1;
public static final int GRID_OFF = 0;
public static final int GRID_3X3 = 1;
public static final int GRID_4X4 = 2;
public static final int GRID_PHI = 3;
public static final int SESSION_TYPE_PICTURE = 0;
public static final int SESSION_TYPE_VIDEO = 1;
@Deprecated public static final int CAPTURE_METHOD_STANDARD = 0;
@Deprecated public static final int CAPTURE_METHOD_FRAME = 1;
/**
* This means the app will be requesting Camera and Audio permissions on Marshmallow+.
* With this configuration, it is mandatory that the developer adds
* <uses-permission android:name="android.permission.RECORD_AUDIO" />
* to its manifest, or the app will crash.
*
* @deprecated this does nothing.
*/
@Deprecated public static final int PERMISSIONS_VIDEO = 0;
/**
* This means the app will be requesting the Camera permissions on Marshmallow+.
* On older APIs, this is not important, since the Camera permission is already
* declared in the manifest by the library.
*
* @deprecated this does nothing.
*/
@Deprecated public static final int PERMISSIONS_PICTURE = 1;
public static final int VIDEO_QUALITY_480P = 0;
public static final int VIDEO_QUALITY_720P = 1;
public static final int VIDEO_QUALITY_1080P = 2;
public static final int VIDEO_QUALITY_2160P = 3;
public static final int VIDEO_QUALITY_HIGHEST = 4;
public static final int VIDEO_QUALITY_LOWEST = 5;
public static final int VIDEO_QUALITY_QVGA = 6;
public static final int WHITE_BALANCE_AUTO = 0;
public static final int WHITE_BALANCE_INCANDESCENT = 1;
public static final int WHITE_BALANCE_FLUORESCENT = 2;
public static final int WHITE_BALANCE_DAYLIGHT = 3;
public static final int WHITE_BALANCE_CLOUDY = 4;
}
static class Defaults {
static final int DEFAULT_FACING = Constants.FACING_BACK;
static final int DEFAULT_FLASH = Constants.FLASH_OFF;
static final int DEFAULT_FOCUS = Constants.FOCUS_CONTINUOUS;
static final int DEFAULT_ZOOM = Constants.ZOOM_OFF;
@Deprecated static final int DEFAULT_METHOD = Constants.CAPTURE_METHOD_STANDARD;
@Deprecated static final int DEFAULT_PERMISSIONS = Constants.PERMISSIONS_PICTURE;
static final int DEFAULT_VIDEO_QUALITY = Constants.VIDEO_QUALITY_480P;
static final int DEFAULT_WHITE_BALANCE = Constants.WHITE_BALANCE_AUTO;
static final int DEFAULT_SESSION_TYPE = Constants.SESSION_TYPE_PICTURE;
static final int DEFAULT_JPEG_QUALITY = 100;
static final int DEFAULT_GRID = Constants.GRID_OFF;
static final boolean DEFAULT_CROP_OUTPUT = false;
}
}

@ -40,11 +40,11 @@ public class CameraUtils {
* Facing value, so that a session can be started. * Facing value, so that a session can be started.
* *
* @param context a valid context * @param context a valid context
* @param facing either {@link CameraKit.Constants#FACING_BACK} or {@link CameraKit.Constants#FACING_FRONT} * @param facing either {@link CameraConstants#FACING_BACK} or {@link CameraConstants#FACING_FRONT}
* @return true if such sensor exists * @return true if such sensor exists
*/ */
public static boolean hasCameraFacing(Context context, @Facing int facing) { public static boolean hasCameraFacing(Context context, @Facing int facing) {
int internal = new MapperImpl.Mapper1().mapFacing(facing); int internal = new Mapper.Mapper1().mapFacing(facing);
Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) {
Camera.getCameraInfo(i, cameraInfo); Camera.getCameraInfo(i, cameraInfo);

@ -33,14 +33,14 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.flurgle.camerakit.CameraKit.Constants.FACING_BACK; import static com.flurgle.camerakit.CameraConstants.FACING_BACK;
import static com.flurgle.camerakit.CameraKit.Constants.FACING_FRONT; import static com.flurgle.camerakit.CameraConstants.FACING_FRONT;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_AUTO; import static com.flurgle.camerakit.CameraConstants.FLASH_AUTO;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; import static com.flurgle.camerakit.CameraConstants.FLASH_OFF;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_ON; import static com.flurgle.camerakit.CameraConstants.FLASH_ON;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_TORCH; import static com.flurgle.camerakit.CameraConstants.FLASH_TORCH;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO;
import static android.view.View.MeasureSpec.AT_MOST; import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.EXACTLY;
@ -89,8 +89,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
private int mDisplayOffset; private int mDisplayOffset;
private CameraCallbacks mCameraCallbacks; private CameraCallbacks mCameraCallbacks;
private OrientationHelper mOrientationHelper; private OrientationHelper mOrientationHelper;
private CameraImpl mCameraImpl; private CameraController mCameraController;
private PreviewImpl mPreviewImpl; private Preview mPreviewImpl;
private Lifecycle mLifecycle; private Lifecycle mLifecycle;
private FocusMarkerLayout mFocusMarkerLayout; private FocusMarkerLayout mFocusMarkerLayout;
@ -112,21 +112,21 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
@SuppressWarnings("WrongConstant") @SuppressWarnings("WrongConstant")
private void init(@NonNull Context context, @Nullable AttributeSet attrs) { private void init(@NonNull Context context, @Nullable AttributeSet attrs) {
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, CameraKit.Defaults.DEFAULT_FACING); int facing = a.getInteger(R.styleable.CameraView_cameraFacing, CameraConstants.Defaults.DEFAULT_FACING);
int flash = a.getInteger(R.styleable.CameraView_cameraFlash, CameraKit.Defaults.DEFAULT_FLASH); int flash = a.getInteger(R.styleable.CameraView_cameraFlash, CameraConstants.Defaults.DEFAULT_FLASH);
int focus = a.getInteger(R.styleable.CameraView_cameraFocus, CameraKit.Defaults.DEFAULT_FOCUS); int focus = a.getInteger(R.styleable.CameraView_cameraFocus, CameraConstants.Defaults.DEFAULT_FOCUS);
int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, CameraKit.Defaults.DEFAULT_SESSION_TYPE); int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, CameraConstants.Defaults.DEFAULT_SESSION_TYPE);
int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraKit.Defaults.DEFAULT_WHITE_BALANCE); int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE);
int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraKit.Defaults.DEFAULT_VIDEO_QUALITY); int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraConstants.Defaults.DEFAULT_VIDEO_QUALITY);
int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraKit.Defaults.DEFAULT_GRID); int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraConstants.Defaults.DEFAULT_GRID);
int zoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, CameraKit.Defaults.DEFAULT_ZOOM); int zoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, CameraConstants.Defaults.DEFAULT_ZOOM);
mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraKit.Defaults.DEFAULT_JPEG_QUALITY); mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraConstants.Defaults.DEFAULT_JPEG_QUALITY);
mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraKit.Defaults.DEFAULT_CROP_OUTPUT); mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraConstants.Defaults.DEFAULT_CROP_OUTPUT);
a.recycle(); a.recycle();
mCameraCallbacks = new CameraCallbacks(); mCameraCallbacks = new CameraCallbacks();
mPreviewImpl = new TextureViewPreview(context, this); mPreviewImpl = new TextureViewPreview(context, this);
mCameraImpl = new Camera1(mCameraCallbacks, mPreviewImpl); mCameraController = new Camera1(mCameraCallbacks, mPreviewImpl);
mFocusMarkerLayout = new FocusMarkerLayout(context); mFocusMarkerLayout = new FocusMarkerLayout(context);
mGridLinesLayout = new GridLinesLayout(context); mGridLinesLayout = new GridLinesLayout(context);
mPinchToZoomLayout = new PinchToZoomLayout(context); mPinchToZoomLayout = new PinchToZoomLayout(context);
@ -149,13 +149,13 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
@Override @Override
public void onDisplayOffsetChanged(int displayOffset) { public void onDisplayOffsetChanged(int displayOffset) {
mDisplayOffset = displayOffset; mDisplayOffset = displayOffset;
mCameraImpl.onDisplayOffset(displayOffset); mCameraController.onDisplayOffset(displayOffset);
mPreviewImpl.onDisplayOffset(displayOffset); mPreviewImpl.onDisplayOffset(displayOffset);
} }
@Override @Override
protected void onDeviceOrientationChanged(int deviceOrientation) { protected void onDeviceOrientationChanged(int deviceOrientation) {
mCameraImpl.onDeviceOrientation(deviceOrientation); mCameraController.onDeviceOrientation(deviceOrientation);
mPreviewImpl.onDeviceOrientation(deviceOrientation); mPreviewImpl.onDeviceOrientation(deviceOrientation);
} }
}; };
@ -200,7 +200,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* aspect ratio. * aspect ratio.
* *
* When both dimensions are MATCH_PARENT, CameraView will fill its * When both dimensions are MATCH_PARENT, CameraView will fill its
* parent no matter the preview. Thanks to what happens in {@link PreviewImpl}, this acts like * parent no matter the preview. Thanks to what happens in {@link Preview}, this acts like
* a CENTER CROP scale type. * a CENTER CROP scale type.
* *
* When both dimensions are WRAP_CONTENT, CameraView will take the biggest dimensions that * When both dimensions are WRAP_CONTENT, CameraView will take the biggest dimensions that
@ -220,7 +220,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec);
final int widthValue = MeasureSpec.getSize(widthMeasureSpec); final int widthValue = MeasureSpec.getSize(widthMeasureSpec);
final int heightValue = MeasureSpec.getSize(heightMeasureSpec); final int heightValue = MeasureSpec.getSize(heightMeasureSpec);
final boolean flip = mCameraImpl.shouldFlipSizes(); final boolean flip = mCameraController.shouldFlipSizes();
final float previewWidth = flip ? previewSize.getHeight() : previewSize.getWidth(); final float previewWidth = flip ? previewSize.getHeight() : previewSize.getWidth();
final float previewHeight = flip ? previewSize.getWidth() : previewSize.getHeight(); final float previewHeight = flip ? previewSize.getWidth() : previewSize.getHeight();
@ -396,7 +396,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
run(new Runnable() { run(new Runnable() {
@Override @Override
public void run() { public void run() {
mCameraImpl.start(); mCameraController.start();
} }
}); });
} }
@ -467,7 +467,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
return; return;
} }
mIsStarted = false; mIsStarted = false;
mCameraImpl.stop(); mCameraController.stop();
} }
public void destroy() { public void destroy() {
@ -486,7 +486,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Nullable @Nullable
public CameraOptions getCameraOptions() { public CameraOptions getCameraOptions() {
return mCameraImpl.getCameraOptions(); return mCameraController.getCameraOptions();
} }
@ -497,7 +497,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Nullable @Nullable
public ExtraProperties getExtraProperties() { public ExtraProperties getExtraProperties() {
return mCameraImpl.getExtraProperties(); return mCameraController.getExtraProperties();
} }
@ -512,7 +512,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
if (zoom < 0 || zoom > 1) { if (zoom < 0 || zoom > 1) {
throw new IllegalArgumentException("Zoom value should be >= 0 and <= 1"); throw new IllegalArgumentException("Zoom value should be >= 0 and <= 1");
} }
if (mCameraImpl.setZoom(zoom)) { if (mCameraController.setZoom(zoom)) {
// Notify PinchToZoomLayout, just in case the call came from outside. // Notify PinchToZoomLayout, just in case the call came from outside.
mPinchToZoomLayout.onExternalZoom(zoom); mPinchToZoomLayout.onExternalZoom(zoom);
return true; return true;
@ -524,9 +524,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
/** /**
* Controls the grids to be drawn over the current layout. * Controls the grids to be drawn over the current layout.
* *
* @see CameraKit.Constants#GRID_OFF * @see CameraConstants#GRID_OFF
* @see CameraKit.Constants#GRID_3X3 * @see CameraConstants#GRID_3X3
* @see CameraKit.Constants#GRID_4X4 * @see CameraConstants#GRID_4X4
* *
* @param gridMode desired grid mode * @param gridMode desired grid mode
*/ */
@ -552,23 +552,23 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* @param longitude current longitude * @param longitude current longitude
*/ */
public void setLocation(double latitude, double longitude) { public void setLocation(double latitude, double longitude) {
mCameraImpl.setLocation(latitude, longitude); mCameraController.setLocation(latitude, longitude);
} }
/** /**
* Sets desired white balance to current camera session. * Sets desired white balance to current camera session.
* *
* @see CameraKit.Constants#WHITE_BALANCE_AUTO * @see CameraConstants#WHITE_BALANCE_AUTO
* @see CameraKit.Constants#WHITE_BALANCE_CLOUDY * @see CameraConstants#WHITE_BALANCE_CLOUDY
* @see CameraKit.Constants#WHITE_BALANCE_DAYLIGHT * @see CameraConstants#WHITE_BALANCE_DAYLIGHT
* @see CameraKit.Constants#WHITE_BALANCE_FLUORESCENT * @see CameraConstants#WHITE_BALANCE_FLUORESCENT
* @see CameraKit.Constants#WHITE_BALANCE_INCANDESCENT * @see CameraConstants#WHITE_BALANCE_INCANDESCENT
* *
* @param whiteBalance desired white balance behavior. * @param whiteBalance desired white balance behavior.
*/ */
public void setWhiteBalance(@WhiteBalance int whiteBalance) { public void setWhiteBalance(@WhiteBalance int whiteBalance) {
mCameraImpl.setWhiteBalance(whiteBalance); mCameraController.setWhiteBalance(whiteBalance);
} }
@ -578,15 +578,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@WhiteBalance @WhiteBalance
public int getWhiteBalance() { public int getWhiteBalance() {
return mCameraImpl.getWhiteBalance(); return mCameraController.getWhiteBalance();
} }
/** /**
* Sets which camera sensor should be used. * Sets which camera sensor should be used.
* *
* @see CameraKit.Constants#FACING_FRONT * @see CameraConstants#FACING_FRONT
* @see CameraKit.Constants#FACING_BACK * @see CameraConstants#FACING_BACK
* *
* @param facing a facing value. * @param facing a facing value.
*/ */
@ -594,7 +594,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
run(new Runnable() { run(new Runnable() {
@Override @Override
public void run() { public void run() {
mCameraImpl.setFacing(facing); mCameraController.setFacing(facing);
} }
}); });
} }
@ -606,19 +606,19 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Facing @Facing
public int getFacing() { public int getFacing() {
return mCameraImpl.getFacing(); return mCameraController.getFacing();
} }
/** /**
* Toggles the facing value between {@link CameraKit.Constants#FACING_BACK} * Toggles the facing value between {@link CameraConstants#FACING_BACK}
* and {@link CameraKit.Constants#FACING_FRONT}. * and {@link CameraConstants#FACING_FRONT}.
* *
* @return the new facing value * @return the new facing value
*/ */
@Facing @Facing
public int toggleFacing() { public int toggleFacing() {
int facing = mCameraImpl.getFacing(); int facing = mCameraController.getFacing();
switch (facing) { switch (facing) {
case FACING_BACK: case FACING_BACK:
setFacing(FACING_FRONT); setFacing(FACING_FRONT);
@ -629,22 +629,22 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
break; break;
} }
return mCameraImpl.getFacing(); return mCameraController.getFacing();
} }
/** /**
* Sets the flash mode. * Sets the flash mode.
* *
* @see CameraKit.Constants#FLASH_OFF * @see CameraConstants#FLASH_OFF
* @see CameraKit.Constants#FLASH_ON * @see CameraConstants#FLASH_ON
* @see CameraKit.Constants#FLASH_AUTO * @see CameraConstants#FLASH_AUTO
* @see CameraKit.Constants#FLASH_TORCH * @see CameraConstants#FLASH_TORCH
* @param flash desired flash mode. * @param flash desired flash mode.
*/ */
public void setFlash(@Flash int flash) { public void setFlash(@Flash int flash) {
mCameraImpl.setFlash(flash); mCameraController.setFlash(flash);
} }
@ -654,20 +654,20 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Flash @Flash
public int getFlash() { public int getFlash() {
return mCameraImpl.getFlash(); return mCameraController.getFlash();
} }
/** /**
* Toggles the flash mode between {@link CameraKit.Constants#FLASH_OFF}, * Toggles the flash mode between {@link CameraConstants#FLASH_OFF},
* {@link CameraKit.Constants#FLASH_ON}, {@link CameraKit.Constants#FLASH_AUTO} and * {@link CameraConstants#FLASH_ON}, {@link CameraConstants#FLASH_AUTO} and
* {@link CameraKit.Constants#FOCUS_FIXED}, in this order. * {@link CameraConstants#FOCUS_FIXED}, in this order.
* *
* @return the new flash value * @return the new flash value
*/ */
@Flash @Flash
public int toggleFlash() { public int toggleFlash() {
int flash = mCameraImpl.getFlash(); int flash = mCameraController.getFlash();
switch (flash) { switch (flash) {
case FLASH_OFF: case FLASH_OFF:
setFlash(FLASH_ON); setFlash(FLASH_ON);
@ -683,7 +683,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
break; break;
} }
return mCameraImpl.getFlash(); return mCameraController.getFlash();
} }
@ -697,27 +697,27 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
public void startFocus(float x, float y) { public void startFocus(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()");
mCameraImpl.startFocus(x, y); mCameraController.startFocus(x, y);
} }
/** /**
* Sets the current focus behavior. * Sets the current focus behavior.
* *
* @see CameraKit.Constants#FOCUS_CONTINUOUS * @see CameraConstants#FOCUS_CONTINUOUS
* @see CameraKit.Constants#FOCUS_FIXED * @see CameraConstants#FOCUS_FIXED
* @see CameraKit.Constants#FOCUS_TAP * @see CameraConstants#FOCUS_TAP
* @see CameraKit.Constants#FOCUS_TAP_WITH_MARKER * @see CameraConstants#FOCUS_TAP_WITH_MARKER
* @param focus a Focus value. * @param focus a Focus value.
*/ */
public void setFocus(@Focus int focus) { public void setFocus(@Focus int focus) {
// TODO we are not sure this focus is supported at this point, yet we enable the layout! // TODO we are not sure this focus is supported at this point, yet we enable the layout!
mFocusMarkerLayout.setEnabled(focus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER); mFocusMarkerLayout.setEnabled(focus == CameraConstants.FOCUS_TAP_WITH_MARKER);
if (focus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) { if (focus == CameraConstants.FOCUS_TAP_WITH_MARKER) {
focus = CameraKit.Constants.FOCUS_TAP; focus = CameraConstants.FOCUS_TAP;
} }
mCameraImpl.setFocus(focus); mCameraController.setFocus(focus);
} }
@ -727,7 +727,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Focus @Focus
public int getFocus() { public int getFocus() {
return mCameraImpl.getFocus(); return mCameraController.getFocus();
} }
@ -753,8 +753,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* - {@link #startCapturingVideo(File)} will not throw any exception * - {@link #startCapturingVideo(File)} will not throw any exception
* - {@link #capturePicture()} will fallback to {@link #captureSnapshot()} * - {@link #capturePicture()} will fallback to {@link #captureSnapshot()}
* *
* @see CameraKit.Constants#SESSION_TYPE_PICTURE * @see CameraConstants#SESSION_TYPE_PICTURE
* @see CameraKit.Constants#SESSION_TYPE_VIDEO * @see CameraConstants#SESSION_TYPE_VIDEO
* *
* @param sessionType desired session type. * @param sessionType desired session type.
*/ */
@ -762,11 +762,11 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
if (sessionType == getSessionType() || !mIsStarted) { if (sessionType == getSessionType() || !mIsStarted) {
// Check did took place, or will happen on start(). // Check did took place, or will happen on start().
mCameraImpl.setSessionType(sessionType); mCameraController.setSessionType(sessionType);
} else if (checkPermissions(sessionType)) { } else if (checkPermissions(sessionType)) {
// Camera is running. CameraImpl setSessionType will do the trick. // Camera is running. CameraImpl setSessionType will do the trick.
mCameraImpl.setSessionType(sessionType); mCameraController.setSessionType(sessionType);
} else { } else {
// This means that the audio permission is being asked. // This means that the audio permission is being asked.
@ -784,15 +784,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@SessionType @SessionType
public int getSessionType() { public int getSessionType() {
return mCameraImpl.getSessionType(); return mCameraController.getSessionType();
} }
/** /**
* Sets the zoom mode for the current session. * Sets the zoom mode for the current session.
* *
* @see CameraKit.Constants#ZOOM_OFF * @see CameraConstants#ZOOM_OFF
* @see CameraKit.Constants#ZOOM_PINCH * @see CameraConstants#ZOOM_PINCH
* *
* @param zoom the zoom mode * @param zoom the zoom mode
*/ */
@ -816,18 +816,18 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* 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.
* If sessionType is video, this might trigger a camera restart and a change in preview size. * If sessionType is video, this might trigger a camera restart and a change in preview size.
* *
* @see CameraKit.Constants#VIDEO_QUALITY_LOWEST * @see CameraConstants#VIDEO_QUALITY_LOWEST
* @see CameraKit.Constants#VIDEO_QUALITY_QVGA * @see CameraConstants#VIDEO_QUALITY_QVGA
* @see CameraKit.Constants#VIDEO_QUALITY_480P * @see CameraConstants#VIDEO_QUALITY_480P
* @see CameraKit.Constants#VIDEO_QUALITY_720P * @see CameraConstants#VIDEO_QUALITY_720P
* @see CameraKit.Constants#VIDEO_QUALITY_1080P * @see CameraConstants#VIDEO_QUALITY_1080P
* @see CameraKit.Constants#VIDEO_QUALITY_2160P * @see CameraConstants#VIDEO_QUALITY_2160P
* @see CameraKit.Constants#VIDEO_QUALITY_HIGHEST * @see CameraConstants#VIDEO_QUALITY_HIGHEST
* *
* @param videoQuality requested video quality * @param videoQuality requested video quality
*/ */
public void setVideoQuality(@VideoQuality int videoQuality) { public void setVideoQuality(@VideoQuality int videoQuality) {
mCameraImpl.setVideoQuality(videoQuality); mCameraController.setVideoQuality(videoQuality);
} }
@ -837,7 +837,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@VideoQuality @VideoQuality
public int getVideoQuality() { public int getVideoQuality() {
return mCameraImpl.getVideoQuality(); return mCameraController.getVideoQuality();
} }
@ -922,13 +922,13 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* This will trigger {@link CameraListener#onPictureTaken(byte[])} if a listener * This will trigger {@link CameraListener#onPictureTaken(byte[])} if a listener
* was registered. * was registered.
* *
* Note that if sessionType is {@link CameraKit.Constants#SESSION_TYPE_VIDEO}, this * Note that if sessionType is {@link CameraConstants#SESSION_TYPE_VIDEO}, this
* might fall back to {@link #captureSnapshot()} (that is, we might capture a preview frame). * might fall back to {@link #captureSnapshot()} (that is, we might capture a preview frame).
* *
* @see #captureSnapshot() * @see #captureSnapshot()
*/ */
public void capturePicture() { public void capturePicture() {
mCameraImpl.capturePicture(); mCameraController.capturePicture();
} }
@ -943,7 +943,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* @see #capturePicture() * @see #capturePicture()
*/ */
public void captureSnapshot() { public void captureSnapshot() {
mCameraImpl.captureSnapshot(); mCameraController.captureSnapshot();
} }
@ -970,7 +970,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
if (file == null) { if (file == null) {
file = new File(getContext().getExternalFilesDir(null), "video.mp4"); file = new File(getContext().getExternalFilesDir(null), "video.mp4");
} }
if (mCameraImpl.startVideo(file)) { if (mCameraController.startVideo(file)) {
mKeepScreenOn = getKeepScreenOn(); mKeepScreenOn = getKeepScreenOn();
if (!mKeepScreenOn) setKeepScreenOn(true); if (!mKeepScreenOn) setKeepScreenOn(true);
} }
@ -1010,7 +1010,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* This will fire {@link CameraListener#onVideoTaken(File)}. * This will fire {@link CameraListener#onVideoTaken(File)}.
*/ */
public void stopCapturingVideo() { public void stopCapturingVideo() {
mCameraImpl.endVideo(); mCameraController.endVideo();
if (getKeepScreenOn() != mKeepScreenOn) setKeepScreenOn(mKeepScreenOn); if (getKeepScreenOn() != mKeepScreenOn) setKeepScreenOn(mKeepScreenOn);
} }
@ -1022,7 +1022,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Nullable @Nullable
public Size getPreviewSize() { public Size getPreviewSize() {
return mCameraImpl != null ? mCameraImpl.getPreviewSize() : null; return mCameraController != null ? mCameraController.getPreviewSize() : null;
} }
@ -1033,7 +1033,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*/ */
@Nullable @Nullable
public Size getCaptureSize() { public Size getCaptureSize() {
return mCameraImpl != null ? mCameraImpl.getCaptureSize() : null; return mCameraController != null ? mCameraController.getCaptureSize() : null;
} }
@ -1065,7 +1065,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
if (activity != null) { if (activity != null) {
ActivityCompat.requestPermissions(activity, ActivityCompat.requestPermissions(activity,
permissions.toArray(new String[permissions.size()]), permissions.toArray(new String[permissions.size()]),
CameraKit.Constants.PERMISSION_REQUEST_CODE); CameraConstants.PERMISSION_REQUEST_CODE);
} }
} }

@ -52,17 +52,17 @@ class GridLinesLayout extends View {
private int getLineCount() { private int getLineCount() {
switch (gridMode) { switch (gridMode) {
case CameraKit.Constants.GRID_OFF: return 0; case CameraConstants.GRID_OFF: return 0;
case CameraKit.Constants.GRID_3X3: return 2; case CameraConstants.GRID_3X3: return 2;
case CameraKit.Constants.GRID_PHI: return 2; case CameraConstants.GRID_PHI: return 2;
case CameraKit.Constants.GRID_4X4: return 3; case CameraConstants.GRID_4X4: return 3;
} }
return 0; return 0;
} }
private float getLinePosition(int lineNumber) { private float getLinePosition(int lineNumber) {
int lineCount = getLineCount(); int lineCount = getLineCount();
if (gridMode == CameraKit.Constants.GRID_PHI) { if (gridMode == CameraConstants.GRID_PHI) {
// 1 = 2x + GRIx // 1 = 2x + GRIx
// 1 = x(2+GRI) // 1 = x(2+GRI)
// x = 1/(2+GRI) // x = 1/(2+GRI)

@ -67,7 +67,7 @@ class PinchToZoomLayout extends View {
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (mZoomMode != CameraKit.Constants.ZOOM_PINCH) return false; if (mZoomMode != CameraConstants.ZOOM_PINCH) return false;
// Reset the notify flag on a new gesture. // Reset the notify flag on a new gesture.
// This is to ensure that the notify flag stays on until the // This is to ensure that the notify flag stays on until the

@ -5,8 +5,8 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.FACING_BACK; import static com.flurgle.camerakit.CameraConstants.FACING_BACK;
import static com.flurgle.camerakit.CameraKit.Constants.FACING_FRONT; import static com.flurgle.camerakit.CameraConstants.FACING_FRONT;
@IntDef({FACING_BACK, FACING_FRONT}) @IntDef({FACING_BACK, FACING_FRONT})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)

@ -5,10 +5,10 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_AUTO; import static com.flurgle.camerakit.CameraConstants.FLASH_AUTO;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; import static com.flurgle.camerakit.CameraConstants.FLASH_OFF;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_ON; import static com.flurgle.camerakit.CameraConstants.FLASH_ON;
import static com.flurgle.camerakit.CameraKit.Constants.FLASH_TORCH; import static com.flurgle.camerakit.CameraConstants.FLASH_TORCH;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({FLASH_OFF, FLASH_ON, FLASH_AUTO, FLASH_TORCH}) @IntDef({FLASH_OFF, FLASH_ON, FLASH_AUTO, FLASH_TORCH})

@ -5,10 +5,10 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_FIXED; import static com.flurgle.camerakit.CameraConstants.FOCUS_FIXED;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; import static com.flurgle.camerakit.CameraConstants.FOCUS_CONTINUOUS;
import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP_WITH_MARKER; import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP_WITH_MARKER;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({FOCUS_CONTINUOUS, FOCUS_TAP, FOCUS_FIXED, FOCUS_TAP_WITH_MARKER}) @IntDef({FOCUS_CONTINUOUS, FOCUS_TAP, FOCUS_FIXED, FOCUS_TAP_WITH_MARKER})

@ -5,10 +5,10 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.GRID_OFF; import static com.flurgle.camerakit.CameraConstants.GRID_OFF;
import static com.flurgle.camerakit.CameraKit.Constants.GRID_3X3; import static com.flurgle.camerakit.CameraConstants.GRID_3X3;
import static com.flurgle.camerakit.CameraKit.Constants.GRID_4X4; import static com.flurgle.camerakit.CameraConstants.GRID_4X4;
import static com.flurgle.camerakit.CameraKit.Constants.GRID_PHI; import static com.flurgle.camerakit.CameraConstants.GRID_PHI;
@IntDef({GRID_OFF, GRID_3X3, GRID_4X4, GRID_PHI}) @IntDef({GRID_OFF, GRID_3X3, GRID_4X4, GRID_PHI})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)

@ -5,8 +5,8 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; import static com.flurgle.camerakit.CameraConstants.CAPTURE_METHOD_STANDARD;
import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; import static com.flurgle.camerakit.CameraConstants.CAPTURE_METHOD_FRAME;
@Deprecated @Deprecated
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)

@ -5,8 +5,8 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_PICTURE; import static com.flurgle.camerakit.CameraConstants.PERMISSIONS_PICTURE;
import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_VIDEO; import static com.flurgle.camerakit.CameraConstants.PERMISSIONS_VIDEO;
@Deprecated @Deprecated
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)

@ -5,8 +5,8 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE;
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({SESSION_TYPE_PICTURE, SESSION_TYPE_VIDEO}) @IntDef({SESSION_TYPE_PICTURE, SESSION_TYPE_VIDEO})

@ -5,13 +5,13 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_1080P; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_1080P;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_2160P; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_2160P;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_480P; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_480P;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_720P; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_720P;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_HIGHEST; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_HIGHEST;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_LOWEST; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_LOWEST;
import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_QVGA; import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_QVGA;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({VIDEO_QUALITY_QVGA, VIDEO_QUALITY_480P, VIDEO_QUALITY_720P, VIDEO_QUALITY_1080P, VIDEO_QUALITY_2160P, VIDEO_QUALITY_HIGHEST, VIDEO_QUALITY_LOWEST}) @IntDef({VIDEO_QUALITY_QVGA, VIDEO_QUALITY_480P, VIDEO_QUALITY_720P, VIDEO_QUALITY_1080P, VIDEO_QUALITY_2160P, VIDEO_QUALITY_HIGHEST, VIDEO_QUALITY_LOWEST})

@ -5,11 +5,11 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_AUTO; import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_AUTO;
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_INCANDESCENT; import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_INCANDESCENT;
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_FLUORESCENT; import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_FLUORESCENT;
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_DAYLIGHT; import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_DAYLIGHT;
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_CLOUDY; import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_CLOUDY;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({WHITE_BALANCE_AUTO, WHITE_BALANCE_INCANDESCENT, WHITE_BALANCE_FLUORESCENT, @IntDef({WHITE_BALANCE_AUTO, WHITE_BALANCE_INCANDESCENT, WHITE_BALANCE_FLUORESCENT,

@ -5,8 +5,8 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_OFF; import static com.flurgle.camerakit.CameraConstants.ZOOM_OFF;
import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_PINCH; import static com.flurgle.camerakit.CameraConstants.ZOOM_PINCH;
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({ZOOM_OFF, ZOOM_PINCH}) @IntDef({ZOOM_OFF, ZOOM_PINCH})

@ -13,7 +13,7 @@ import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.flurgle.camerakit.CameraKit; import com.flurgle.camerakit.CameraConstants;
import com.flurgle.camerakit.CameraListener; import com.flurgle.camerakit.CameraListener;
import com.flurgle.camerakit.CameraView; import com.flurgle.camerakit.CameraView;
import com.flurgle.camerakit.Size; import com.flurgle.camerakit.Size;
@ -158,7 +158,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
@OnClick(R.id.captureVideo) @OnClick(R.id.captureVideo)
void captureVideo() { void captureVideo() {
if (camera.getSessionType() != CameraKit.Constants.SESSION_TYPE_VIDEO) { if (camera.getSessionType() != CameraConstants.SESSION_TYPE_VIDEO) {
message("Can't record video while session type is 'picture'.", false); message("Can't record video while session type is 'picture'.", false);
return; return;
} }
@ -190,11 +190,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
void toggleCamera() { void toggleCamera() {
if (mCapturingPicture) return; if (mCapturingPicture) return;
switch (camera.toggleFacing()) { switch (camera.toggleFacing()) {
case CameraKit.Constants.FACING_BACK: case CameraConstants.FACING_BACK:
message("Switched to back camera!", false); message("Switched to back camera!", false);
break; break;
case CameraKit.Constants.FACING_FRONT: case CameraConstants.FACING_FRONT:
message("Switched to front camera!", false); message("Switched to front camera!", false);
break; break;
} }
@ -204,15 +204,15 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
void toggleFlash() { void toggleFlash() {
if (mCapturingPicture) return; if (mCapturingPicture) return;
switch (camera.toggleFlash()) { switch (camera.toggleFlash()) {
case CameraKit.Constants.FLASH_ON: case CameraConstants.FLASH_ON:
message("Flash on!", false); message("Flash on!", false);
break; break;
case CameraKit.Constants.FLASH_OFF: case CameraConstants.FLASH_OFF:
message("Flash off!", false); message("Flash off!", false);
break; break;
case CameraKit.Constants.FLASH_AUTO: case CameraConstants.FLASH_AUTO:
message("Flash auto!", false); message("Flash auto!", false);
break; break;
} }
@ -224,8 +224,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
if (mCapturingPicture) return; if (mCapturingPicture) return;
camera.setSessionType( camera.setSessionType(
checkedId == R.id.sessionTypePicture ? checkedId == R.id.sessionTypePicture ?
CameraKit.Constants.SESSION_TYPE_PICTURE : CameraConstants.SESSION_TYPE_PICTURE :
CameraKit.Constants.SESSION_TYPE_VIDEO CameraConstants.SESSION_TYPE_VIDEO
); );
message("Session type set to" + (checkedId == R.id.sessionTypePicture ? " picture!" : " video!"), true); message("Session type set to" + (checkedId == R.id.sessionTypePicture ? " picture!" : " video!"), true);
} }
@ -244,15 +244,15 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
if (mCapturingVideo) return; if (mCapturingVideo) return;
int videoQuality = CameraKit.Constants.VIDEO_QUALITY_HIGHEST; int videoQuality = CameraConstants.VIDEO_QUALITY_HIGHEST;
switch (checkedId) { switch (checkedId) {
case R.id.videoQualityLowest: videoQuality = CameraKit.Constants.VIDEO_QUALITY_LOWEST; break; case R.id.videoQualityLowest: videoQuality = CameraConstants.VIDEO_QUALITY_LOWEST; break;
case R.id.videoQualityQvga: videoQuality = CameraKit.Constants.VIDEO_QUALITY_QVGA; break; case R.id.videoQualityQvga: videoQuality = CameraConstants.VIDEO_QUALITY_QVGA; break;
case R.id.videoQuality480p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_480P; break; case R.id.videoQuality480p: videoQuality = CameraConstants.VIDEO_QUALITY_480P; break;
case R.id.videoQuality720p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_720P; break; case R.id.videoQuality720p: videoQuality = CameraConstants.VIDEO_QUALITY_720P; break;
case R.id.videoQuality1080p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_1080P; break; case R.id.videoQuality1080p: videoQuality = CameraConstants.VIDEO_QUALITY_1080P; break;
case R.id.videoQuality2160p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_2160P; break; case R.id.videoQuality2160p: videoQuality = CameraConstants.VIDEO_QUALITY_2160P; break;
case R.id.videoQualityHighest: videoQuality = CameraKit.Constants.VIDEO_QUALITY_HIGHEST; break; case R.id.videoQualityHighest: videoQuality = CameraConstants.VIDEO_QUALITY_HIGHEST; break;
} }
camera.setVideoQuality(videoQuality); camera.setVideoQuality(videoQuality);
message("Video quality changed!", false); message("Video quality changed!", false);
@ -263,12 +263,12 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
RadioGroup.OnCheckedChangeListener gridModeChangedListener = new RadioGroup.OnCheckedChangeListener() { RadioGroup.OnCheckedChangeListener gridModeChangedListener = new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
int grid = CameraKit.Constants.GRID_OFF; int grid = CameraConstants.GRID_OFF;
switch (checkedId) { switch (checkedId) {
case R.id.gridModeOff: grid = CameraKit.Constants.GRID_OFF; break; case R.id.gridModeOff: grid = CameraConstants.GRID_OFF; break;
case R.id.gridMode3x3: grid = CameraKit.Constants.GRID_3X3; break; case R.id.gridMode3x3: grid = CameraConstants.GRID_3X3; break;
case R.id.gridMode4x4: grid = CameraKit.Constants.GRID_4X4; break; case R.id.gridMode4x4: grid = CameraConstants.GRID_4X4; break;
case R.id.gridModeGolden: grid = CameraKit.Constants.GRID_PHI; break; case R.id.gridModeGolden: grid = CameraConstants.GRID_PHI; break;
} }
camera.setGrid(grid); camera.setGrid(grid);
message("Grid mode changed!", false); message("Grid mode changed!", false);
@ -279,10 +279,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
RadioGroup.OnCheckedChangeListener zoomModeChangedListener = new RadioGroup.OnCheckedChangeListener() { RadioGroup.OnCheckedChangeListener zoomModeChangedListener = new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
int zoom = CameraKit.Constants.ZOOM_OFF; int zoom = CameraConstants.ZOOM_OFF;
switch (checkedId) { switch (checkedId) {
case R.id.zoomModeOff: zoom = CameraKit.Constants.ZOOM_OFF; break; case R.id.zoomModeOff: zoom = CameraConstants.ZOOM_OFF; break;
case R.id.zoomModePinch: zoom = CameraKit.Constants.ZOOM_PINCH; break; case R.id.zoomModePinch: zoom = CameraConstants.ZOOM_PINCH; break;
} }
camera.setZoomMode(zoom); camera.setZoomMode(zoom);
message("Zoom mode changed! Note that pinch-to-zoom won't work well in ScrollViews like here", true); message("Zoom mode changed! Note that pinch-to-zoom won't work well in ScrollViews like here", true);

@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">CameraKit</string> <string name="app_name">CameraKit Preview</string>
</resources> </resources>

Loading…
Cancel
Save