diff --git a/README.md b/README.md index d99ff508..9b7e2c04 100644 --- a/README.md +++ b/README.md @@ -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* - *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. ```java -cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_PICTURE); -cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_VIDEO); +cameraView.setSessionType(CameraConstants.SESSION_TYPE_PICTURE); +cameraView.setSessionType(CameraConstants.SESSION_TYPE_VIDEO); ``` ### cameraFacing @@ -277,8 +277,8 @@ cameraView.setSessionType(CameraKit.Constants.SESSION_TYPE_VIDEO); Which camera to use, either back facing or front facing. ```java -cameraView.setFacing(CameraKit.Constants.FACING_BACK); -cameraView.setFacing(CameraKit.Constants.FACING_FRONT); +cameraView.setFacing(CameraConstants.FACING_BACK); +cameraView.setFacing(CameraConstants.FACING_FRONT); ``` ### cameraFlash @@ -286,10 +286,10 @@ cameraView.setFacing(CameraKit.Constants.FACING_FRONT); Flash mode, either off, on, auto or *torch*. ```java -cameraView.setFlash(CameraKit.Constants.FLASH_OFF); -cameraView.setFlash(CameraKit.Constants.FLASH_ON); -cameraView.setFlash(CameraKit.Constants.FLASH_AUTO); -cameraView.setFlash(CameraKit.Constants.FLASH_TORCH); +cameraView.setFlash(CameraConstants.FLASH_OFF); +cameraView.setFlash(CameraConstants.FLASH_ON); +cameraView.setFlash(CameraConstants.FLASH_AUTO); +cameraView.setFlash(CameraConstants.FLASH_TORCH); ``` ### 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). ```java -cameraView.setFocus(CameraKit.Constants.FOCUS_FIXED); -cameraView.setFocus(CameraKit.Constants.FOCUS_CONTINUOUS); -cameraView.setFocus(CameraKit.Constants.FOCUS_TAP); -cameraView.setFocus(CameraKit.Constants.FOCUS_TAP_WITH_MARKER); +cameraView.setFocus(CameraConstants.FOCUS_FIXED); +cameraView.setFocus(CameraConstants.FOCUS_CONTINUOUS); +cameraView.setFocus(CameraConstants.FOCUS_TAP); +cameraView.setFocus(CameraConstants.FOCUS_TAP_WITH_MARKER); ``` ### 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. ```java -cameraView.setZoomMode(CameraKit.Constants.ZOOM_OFF); -cameraView.setZoomMode(CameraKit.Constants.ZOOM_PINCH); +cameraView.setZoomMode(CameraConstants.ZOOM_OFF); +cameraView.setZoomMode(CameraConstants.ZOOM_PINCH); ``` ### 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. ```java -cameraView.setZoom(CameraKit.Constants.GRID_OFF); -cameraView.setZoom(CameraKit.Constants.GRID_3X3); -cameraView.setZoom(CameraKit.Constants.GRID_4X4); -cameraView.setZoom(CameraKit.Constants.GRID_PHI); +cameraView.setZoom(CameraConstants.GRID_OFF); +cameraView.setZoom(CameraConstants.GRID_3X3); +cameraView.setZoom(CameraConstants.GRID_4X4); +cameraView.setZoom(CameraConstants.GRID_PHI); ``` ### cameraCropOutput @@ -342,13 +342,13 @@ cameraView.setJpegQuality(50); Sets the desired video quality. ```java -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_480P); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_720P); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_1080P); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_2160P); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_LOWEST); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_HIGHEST); -cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_QVGA); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_480P); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_720P); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_1080P); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_2160P); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_LOWEST); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_HIGHEST); +cameraView.setVideoQuality(CameraConstants.VIDEO_QUALITY_QVGA); ``` ### cameraWhiteBalance @@ -356,11 +356,11 @@ cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_QVGA); Sets the desired white balance for the current session. ```java -cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_AUTO); -cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_INCANDESCENT); -cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_FLUORESCENT); -cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_DAYLIGHT); -cameraView.setWhiteBalance(CameraKit.Constants.WHITE_BALANCE_CLOUDY); +cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_AUTO); +cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_INCANDESCENT); +cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_FLUORESCENT); +cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_DAYLIGHT); +cameraView.setWhiteBalance(CameraConstants.WHITE_BALANCE_CLOUDY); ``` ## Permissions behavior diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java index f947c01f..b58b0246 100644 --- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java +++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java @@ -18,15 +18,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_FIXED; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP_WITH_MARKER; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; +import static com.flurgle.camerakit.CameraConstants.FOCUS_CONTINUOUS; +import static com.flurgle.camerakit.CameraConstants.FOCUS_FIXED; +import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP; +import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP_WITH_MARKER; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO; @SuppressWarnings("deprecation") -class Camera1 extends CameraImpl { +class Camera1 extends CameraController { private static final String TAG = Camera1.class.getSimpleName(); @@ -49,14 +49,14 @@ class Camera1 extends CameraImpl { private double mLongitude; private Handler mFocusHandler = new Handler(); - private MapperImpl mMapper = new MapperImpl.Mapper1(); + private Mapper mMapper = new Mapper.Mapper1(); private boolean mIsSetup = false; private boolean mIsCapturingImage = false; private boolean mIsCapturingVideo = false; private final Object mLock = new Object(); - Camera1(CameraView.CameraCallbacks callback, final PreviewImpl preview) { + Camera1(CameraView.CameraCallbacks callback, final Preview preview) { super(callback, preview); } @@ -145,10 +145,10 @@ class Camera1 extends CameraImpl { Camera.Parameters params = mCamera.getParameters(); mExtraProperties = new ExtraProperties(params); mOptions = new CameraOptions(params); - mergeFocus(params, CameraKit.Defaults.DEFAULT_FOCUS); - mergeFlash(params, CameraKit.Defaults.DEFAULT_FLASH); + mergeFocus(params, CameraConstants.Defaults.DEFAULT_FOCUS); + mergeFlash(params, CameraConstants.Defaults.DEFAULT_FLASH); mergeLocation(params, 0d, 0d); - mergeWhiteBalance(params, CameraKit.Defaults.DEFAULT_WHITE_BALANCE); + mergeWhiteBalance(params, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE); params.setRecordingHint(mSessionType == SESSION_TYPE_VIDEO); mCamera.setParameters(params); } @@ -349,7 +349,7 @@ class Camera1 extends CameraImpl { } 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. Size oldSize = mCaptureSize; mCaptureSize = computeCaptureSize(); @@ -485,7 +485,7 @@ class Camera1 extends CameraImpl { * It is meant to be fed to Camera.setDisplayOrientation(). */ private int computeSensorToDisplayOffset() { - if (mFacing == CameraKit.Constants.FACING_FRONT) { + if (mFacing == CameraConstants.FACING_FRONT) { // or: (360 - ((mSensorOffset + mDisplayOffset) % 360)) % 360; return ((mSensorOffset - mDisplayOffset) + 360 + 180) % 360; } else { @@ -499,7 +499,7 @@ class Camera1 extends CameraImpl { * This ignores flipping for facing camera. */ private int computeExifRotation() { - if (mFacing == CameraKit.Constants.FACING_FRONT) { + if (mFacing == CameraConstants.FACING_FRONT) { return (mSensorOffset - mDeviceOrientation + 360) % 360; } else { return (mSensorOffset + mDeviceOrientation) % 360; @@ -511,7 +511,7 @@ class Camera1 extends CameraImpl { * Whether the exif tag should include a 'flip' operation. */ 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. * It is possible that in the first call the preview surface has not already computed its * 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. */ private Size computeCaptureSize() { @@ -612,41 +612,41 @@ class Camera1 extends CameraImpl { @NonNull private CamcorderProfile getCamcorderProfile(@VideoQuality int videoQuality) { switch (videoQuality) { - case CameraKit.Constants.VIDEO_QUALITY_HIGHEST: + case CameraConstants.VIDEO_QUALITY_HIGHEST: 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 && CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) { return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_2160P); } // Don't break. - case CameraKit.Constants.VIDEO_QUALITY_1080P: + case CameraConstants.VIDEO_QUALITY_1080P: if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) { return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_1080P); } // Don't break. - case CameraKit.Constants.VIDEO_QUALITY_720P: + case CameraConstants.VIDEO_QUALITY_720P: if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) { return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_720P); } // Don't break. - case CameraKit.Constants.VIDEO_QUALITY_480P: + case CameraConstants.VIDEO_QUALITY_480P: if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) { return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_480P); } // Don't break. - case CameraKit.Constants.VIDEO_QUALITY_QVGA: + case CameraConstants.VIDEO_QUALITY_QVGA: if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_QVGA)) { return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_QVGA); } // Don't break. - case CameraKit.Constants.VIDEO_QUALITY_LOWEST: + case CameraConstants.VIDEO_QUALITY_LOWEST: default: // Fallback to lowest. return CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_LOW); diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/MapperImpl.java b/camerakit/src/main/api16/com/flurgle/camerakit/Mapper.java similarity index 63% rename from camerakit/src/main/api16/com/flurgle/camerakit/MapperImpl.java rename to camerakit/src/main/api16/com/flurgle/camerakit/Mapper.java index 192a0f33..796ce72b 100644 --- a/camerakit/src/main/api16/com/flurgle/camerakit/MapperImpl.java +++ b/camerakit/src/main/api16/com/flurgle/camerakit/Mapper.java @@ -1,14 +1,9 @@ package com.flurgle.camerakit; -import android.annotation.TargetApi; import android.hardware.Camera; -import android.hardware.camera2.CameraCharacteristics; import android.support.v4.util.SparseArrayCompat; -import android.util.SparseIntArray; -import java.util.Map; - -abstract class MapperImpl { +abstract class Mapper { abstract T mapFlash(@Flash int internalConstant); abstract T mapFacing(@Facing int internalConstant); @@ -19,28 +14,28 @@ abstract class MapperImpl { @WhiteBalance abstract int unmapWhiteBalance(T cameraConstant); @Focus abstract int unmapFocus(T cameraConstant); - static class Mapper1 extends MapperImpl { + static class Mapper1 extends Mapper { private static final SparseArrayCompat FLASH = new SparseArrayCompat<>(); private static final SparseArrayCompat WB = new SparseArrayCompat<>(); private static final SparseArrayCompat FACING = new SparseArrayCompat<>(); private static final SparseArrayCompat FOCUS = new SparseArrayCompat<>(); static { - FLASH.put(CameraKit.Constants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF); - FLASH.put(CameraKit.Constants.FLASH_ON, Camera.Parameters.FLASH_MODE_ON); - FLASH.put(CameraKit.Constants.FLASH_AUTO, Camera.Parameters.FLASH_MODE_AUTO); - FLASH.put(CameraKit.Constants.FLASH_TORCH, Camera.Parameters.FLASH_MODE_TORCH); - FACING.put(CameraKit.Constants.FACING_BACK, Camera.CameraInfo.CAMERA_FACING_BACK); - FACING.put(CameraKit.Constants.FACING_FRONT, Camera.CameraInfo.CAMERA_FACING_FRONT); - WB.put(CameraKit.Constants.WHITE_BALANCE_AUTO, Camera.Parameters.WHITE_BALANCE_AUTO); - WB.put(CameraKit.Constants.WHITE_BALANCE_INCANDESCENT, Camera.Parameters.WHITE_BALANCE_INCANDESCENT); - WB.put(CameraKit.Constants.WHITE_BALANCE_FLUORESCENT, Camera.Parameters.WHITE_BALANCE_FLUORESCENT); - WB.put(CameraKit.Constants.WHITE_BALANCE_DAYLIGHT, Camera.Parameters.WHITE_BALANCE_DAYLIGHT); - WB.put(CameraKit.Constants.WHITE_BALANCE_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); - FOCUS.put(CameraKit.Constants.FOCUS_FIXED, Camera.Parameters.FOCUS_MODE_FIXED); - FOCUS.put(CameraKit.Constants.FOCUS_CONTINUOUS, Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); - FOCUS.put(CameraKit.Constants.FOCUS_TAP, Camera.Parameters.FOCUS_MODE_AUTO); - FOCUS.put(CameraKit.Constants.FOCUS_TAP_WITH_MARKER, Camera.Parameters.FOCUS_MODE_AUTO); + FLASH.put(CameraConstants.FLASH_OFF, Camera.Parameters.FLASH_MODE_OFF); + FLASH.put(CameraConstants.FLASH_ON, Camera.Parameters.FLASH_MODE_ON); + FLASH.put(CameraConstants.FLASH_AUTO, Camera.Parameters.FLASH_MODE_AUTO); + FLASH.put(CameraConstants.FLASH_TORCH, Camera.Parameters.FLASH_MODE_TORCH); + FACING.put(CameraConstants.FACING_BACK, Camera.CameraInfo.CAMERA_FACING_BACK); + FACING.put(CameraConstants.FACING_FRONT, Camera.CameraInfo.CAMERA_FACING_FRONT); + WB.put(CameraConstants.WHITE_BALANCE_AUTO, Camera.Parameters.WHITE_BALANCE_AUTO); + WB.put(CameraConstants.WHITE_BALANCE_INCANDESCENT, Camera.Parameters.WHITE_BALANCE_INCANDESCENT); + 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_CLOUDY, Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); + 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 @@ -85,7 +80,7 @@ abstract class MapperImpl { } } - static class Mapper2 extends MapperImpl { + static class Mapper2 extends Mapper { @Override T mapWhiteBalance(@WhiteBalance int internalConstant) { diff --git a/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java b/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java index 6804628f..498493d4 100644 --- a/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java +++ b/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.TreeSet; @TargetApi(21) -class Camera2 extends CameraImpl { +class Camera2 extends CameraController { private CameraDevice mCamera; private CameraCharacteristics mCameraCharacteristics; @@ -31,7 +31,7 @@ class Camera2 extends CameraImpl { private Size mCaptureSize; private Size mPreviewSize; - private MapperImpl mMapper = new MapperImpl.Mapper2(); + private Mapper mMapper = new Mapper.Mapper2(); private final HashMap 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); mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); diff --git a/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/CameraController.java similarity index 91% rename from camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java rename to camerakit/src/main/base/com/flurgle/camerakit/CameraController.java index 1ae3dd63..7db98d96 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/CameraController.java @@ -2,14 +2,13 @@ package com.flurgle.camerakit; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.view.MotionEvent; import java.io.File; -abstract class CameraImpl implements PreviewImpl.SurfaceCallback { +abstract class CameraController implements Preview.SurfaceCallback { protected final CameraView.CameraCallbacks mCameraCallbacks; - protected final PreviewImpl mPreview; + protected final Preview mPreview; @Facing protected int mFacing; @Flash protected int mFlash; @@ -18,7 +17,7 @@ abstract class CameraImpl implements PreviewImpl.SurfaceCallback { @WhiteBalance protected int mWhiteBalance; @SessionType protected int mSessionType; - CameraImpl(CameraView.CameraCallbacks callback, PreviewImpl preview) { + CameraController(CameraView.CameraCallbacks callback, Preview preview) { mCameraCallbacks = callback; mPreview = preview; mPreview.setSurfaceCallback(this); diff --git a/camerakit/src/main/base/com/flurgle/camerakit/CameraOptions.java b/camerakit/src/main/base/com/flurgle/camerakit/CameraOptions.java index 1c67599b..34cc5e5b 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/CameraOptions.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/CameraOptions.java @@ -24,7 +24,7 @@ public class CameraOptions { CameraOptions(Camera.Parameters params) { List strings; - MapperImpl mapper = new MapperImpl.Mapper1(); + Mapper mapper = new Mapper.Mapper1(); // Facing Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); diff --git a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/Preview.java similarity index 97% rename from camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java rename to camerakit/src/main/base/com/flurgle/camerakit/Preview.java index 60ceb30b..bce15a07 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/Preview.java @@ -7,7 +7,7 @@ import android.view.SurfaceHolder; import android.view.View; import android.view.ViewGroup; -abstract class PreviewImpl { +abstract class Preview { // 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. @@ -27,7 +27,7 @@ abstract class PreviewImpl { private int mDesiredWidth; private int mDesiredHeight; - PreviewImpl(Context context, ViewGroup parent) {} + Preview(Context context, ViewGroup parent) {} abstract Surface getSurface(); abstract View getView(); diff --git a/camerakit/src/main/base/com/flurgle/camerakit/SurfaceViewPreview.java b/camerakit/src/main/base/com/flurgle/camerakit/SurfaceViewPreview.java index af432cc7..81d3ab36 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/SurfaceViewPreview.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/SurfaceViewPreview.java @@ -8,7 +8,7 @@ import android.view.View; import android.view.ViewGroup; // This is not used. -class SurfaceViewPreview extends PreviewImpl { +class SurfaceViewPreview extends Preview { private final SurfaceView mSurfaceView; diff --git a/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java b/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java index 1c74b0cc..702eadc2 100644 --- a/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java +++ b/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java @@ -9,7 +9,7 @@ import android.view.View; import android.view.ViewGroup; @TargetApi(14) -class TextureViewPreview extends PreviewImpl { +class TextureViewPreview extends Preview { private final TextureView mTextureView; private Surface mSurface; diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraConstants.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraConstants.java new file mode 100644 index 00000000..2e29967f --- /dev/null +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraConstants.java @@ -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 + * + * 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; + + } +} diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java deleted file mode 100644 index 7c2d1c6a..00000000 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java +++ /dev/null @@ -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 - * - * 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; - - } - -} diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraUtils.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraUtils.java index d4d9994a..23a29c29 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraUtils.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraUtils.java @@ -40,11 +40,11 @@ public class CameraUtils { * Facing value, so that a session can be started. * * @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 */ 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(); for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { Camera.getCameraInfo(i, cameraInfo); diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index e6c563b8..e50752b1 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -33,14 +33,14 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -import static com.flurgle.camerakit.CameraKit.Constants.FACING_BACK; -import static com.flurgle.camerakit.CameraKit.Constants.FACING_FRONT; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_AUTO; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_ON; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_TORCH; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; +import static com.flurgle.camerakit.CameraConstants.FACING_BACK; +import static com.flurgle.camerakit.CameraConstants.FACING_FRONT; +import static com.flurgle.camerakit.CameraConstants.FLASH_AUTO; +import static com.flurgle.camerakit.CameraConstants.FLASH_OFF; +import static com.flurgle.camerakit.CameraConstants.FLASH_ON; +import static com.flurgle.camerakit.CameraConstants.FLASH_TORCH; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO; import static android.view.View.MeasureSpec.AT_MOST; import static android.view.View.MeasureSpec.EXACTLY; @@ -89,8 +89,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver { private int mDisplayOffset; private CameraCallbacks mCameraCallbacks; private OrientationHelper mOrientationHelper; - private CameraImpl mCameraImpl; - private PreviewImpl mPreviewImpl; + private CameraController mCameraController; + private Preview mPreviewImpl; private Lifecycle mLifecycle; private FocusMarkerLayout mFocusMarkerLayout; @@ -112,21 +112,21 @@ public class CameraView extends FrameLayout implements LifecycleObserver { @SuppressWarnings("WrongConstant") private void init(@NonNull Context context, @Nullable AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0); - int facing = a.getInteger(R.styleable.CameraView_cameraFacing, CameraKit.Defaults.DEFAULT_FACING); - int flash = a.getInteger(R.styleable.CameraView_cameraFlash, CameraKit.Defaults.DEFAULT_FLASH); - int focus = a.getInteger(R.styleable.CameraView_cameraFocus, CameraKit.Defaults.DEFAULT_FOCUS); - int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, CameraKit.Defaults.DEFAULT_SESSION_TYPE); - int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraKit.Defaults.DEFAULT_WHITE_BALANCE); - int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraKit.Defaults.DEFAULT_VIDEO_QUALITY); - int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraKit.Defaults.DEFAULT_GRID); - int zoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, CameraKit.Defaults.DEFAULT_ZOOM); - mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraKit.Defaults.DEFAULT_JPEG_QUALITY); - mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraKit.Defaults.DEFAULT_CROP_OUTPUT); + int facing = a.getInteger(R.styleable.CameraView_cameraFacing, CameraConstants.Defaults.DEFAULT_FACING); + int flash = a.getInteger(R.styleable.CameraView_cameraFlash, CameraConstants.Defaults.DEFAULT_FLASH); + int focus = a.getInteger(R.styleable.CameraView_cameraFocus, CameraConstants.Defaults.DEFAULT_FOCUS); + int sessionType = a.getInteger(R.styleable.CameraView_cameraSessionType, CameraConstants.Defaults.DEFAULT_SESSION_TYPE); + int whiteBalance = a.getInteger(R.styleable.CameraView_cameraWhiteBalance, CameraConstants.Defaults.DEFAULT_WHITE_BALANCE); + int videoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraConstants.Defaults.DEFAULT_VIDEO_QUALITY); + int grid = a.getInteger(R.styleable.CameraView_cameraGrid, CameraConstants.Defaults.DEFAULT_GRID); + int zoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, CameraConstants.Defaults.DEFAULT_ZOOM); + mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraConstants.Defaults.DEFAULT_JPEG_QUALITY); + mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraConstants.Defaults.DEFAULT_CROP_OUTPUT); a.recycle(); mCameraCallbacks = new CameraCallbacks(); mPreviewImpl = new TextureViewPreview(context, this); - mCameraImpl = new Camera1(mCameraCallbacks, mPreviewImpl); + mCameraController = new Camera1(mCameraCallbacks, mPreviewImpl); mFocusMarkerLayout = new FocusMarkerLayout(context); mGridLinesLayout = new GridLinesLayout(context); mPinchToZoomLayout = new PinchToZoomLayout(context); @@ -149,13 +149,13 @@ public class CameraView extends FrameLayout implements LifecycleObserver { @Override public void onDisplayOffsetChanged(int displayOffset) { mDisplayOffset = displayOffset; - mCameraImpl.onDisplayOffset(displayOffset); + mCameraController.onDisplayOffset(displayOffset); mPreviewImpl.onDisplayOffset(displayOffset); } @Override protected void onDeviceOrientationChanged(int deviceOrientation) { - mCameraImpl.onDeviceOrientation(deviceOrientation); + mCameraController.onDeviceOrientation(deviceOrientation); mPreviewImpl.onDeviceOrientation(deviceOrientation); } }; @@ -200,7 +200,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { * aspect ratio. * * 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. * * 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); final int widthValue = MeasureSpec.getSize(widthMeasureSpec); 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 previewHeight = flip ? previewSize.getWidth() : previewSize.getHeight(); @@ -396,7 +396,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { run(new Runnable() { @Override public void run() { - mCameraImpl.start(); + mCameraController.start(); } }); } @@ -467,7 +467,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { return; } mIsStarted = false; - mCameraImpl.stop(); + mCameraController.stop(); } public void destroy() { @@ -486,7 +486,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Nullable public CameraOptions getCameraOptions() { - return mCameraImpl.getCameraOptions(); + return mCameraController.getCameraOptions(); } @@ -497,7 +497,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Nullable 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) { 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. mPinchToZoomLayout.onExternalZoom(zoom); return true; @@ -524,9 +524,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver { /** * Controls the grids to be drawn over the current layout. * - * @see CameraKit.Constants#GRID_OFF - * @see CameraKit.Constants#GRID_3X3 - * @see CameraKit.Constants#GRID_4X4 + * @see CameraConstants#GRID_OFF + * @see CameraConstants#GRID_3X3 + * @see CameraConstants#GRID_4X4 * * @param gridMode desired grid mode */ @@ -552,23 +552,23 @@ public class CameraView extends FrameLayout implements LifecycleObserver { * @param longitude current longitude */ public void setLocation(double latitude, double longitude) { - mCameraImpl.setLocation(latitude, longitude); + mCameraController.setLocation(latitude, longitude); } /** * Sets desired white balance to current camera session. * - * @see CameraKit.Constants#WHITE_BALANCE_AUTO - * @see CameraKit.Constants#WHITE_BALANCE_CLOUDY - * @see CameraKit.Constants#WHITE_BALANCE_DAYLIGHT - * @see CameraKit.Constants#WHITE_BALANCE_FLUORESCENT - * @see CameraKit.Constants#WHITE_BALANCE_INCANDESCENT + * @see CameraConstants#WHITE_BALANCE_AUTO + * @see CameraConstants#WHITE_BALANCE_CLOUDY + * @see CameraConstants#WHITE_BALANCE_DAYLIGHT + * @see CameraConstants#WHITE_BALANCE_FLUORESCENT + * @see CameraConstants#WHITE_BALANCE_INCANDESCENT * * @param whiteBalance desired white balance behavior. */ public void setWhiteBalance(@WhiteBalance int whiteBalance) { - mCameraImpl.setWhiteBalance(whiteBalance); + mCameraController.setWhiteBalance(whiteBalance); } @@ -578,15 +578,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @WhiteBalance public int getWhiteBalance() { - return mCameraImpl.getWhiteBalance(); + return mCameraController.getWhiteBalance(); } /** * Sets which camera sensor should be used. * - * @see CameraKit.Constants#FACING_FRONT - * @see CameraKit.Constants#FACING_BACK + * @see CameraConstants#FACING_FRONT + * @see CameraConstants#FACING_BACK * * @param facing a facing value. */ @@ -594,7 +594,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { run(new Runnable() { @Override public void run() { - mCameraImpl.setFacing(facing); + mCameraController.setFacing(facing); } }); } @@ -606,19 +606,19 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Facing public int getFacing() { - return mCameraImpl.getFacing(); + return mCameraController.getFacing(); } /** - * Toggles the facing value between {@link CameraKit.Constants#FACING_BACK} - * and {@link CameraKit.Constants#FACING_FRONT}. + * Toggles the facing value between {@link CameraConstants#FACING_BACK} + * and {@link CameraConstants#FACING_FRONT}. * * @return the new facing value */ @Facing public int toggleFacing() { - int facing = mCameraImpl.getFacing(); + int facing = mCameraController.getFacing(); switch (facing) { case FACING_BACK: setFacing(FACING_FRONT); @@ -629,22 +629,22 @@ public class CameraView extends FrameLayout implements LifecycleObserver { break; } - return mCameraImpl.getFacing(); + return mCameraController.getFacing(); } /** * Sets the flash mode. * - * @see CameraKit.Constants#FLASH_OFF - * @see CameraKit.Constants#FLASH_ON - * @see CameraKit.Constants#FLASH_AUTO - * @see CameraKit.Constants#FLASH_TORCH + * @see CameraConstants#FLASH_OFF + * @see CameraConstants#FLASH_ON + * @see CameraConstants#FLASH_AUTO + * @see CameraConstants#FLASH_TORCH * @param flash desired flash mode. */ public void setFlash(@Flash int flash) { - mCameraImpl.setFlash(flash); + mCameraController.setFlash(flash); } @@ -654,20 +654,20 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Flash public int getFlash() { - return mCameraImpl.getFlash(); + return mCameraController.getFlash(); } /** - * Toggles the flash mode between {@link CameraKit.Constants#FLASH_OFF}, - * {@link CameraKit.Constants#FLASH_ON}, {@link CameraKit.Constants#FLASH_AUTO} and - * {@link CameraKit.Constants#FOCUS_FIXED}, in this order. + * Toggles the flash mode between {@link CameraConstants#FLASH_OFF}, + * {@link CameraConstants#FLASH_ON}, {@link CameraConstants#FLASH_AUTO} and + * {@link CameraConstants#FOCUS_FIXED}, in this order. * * @return the new flash value */ @Flash public int toggleFlash() { - int flash = mCameraImpl.getFlash(); + int flash = mCameraController.getFlash(); switch (flash) { case FLASH_OFF: setFlash(FLASH_ON); @@ -683,7 +683,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { 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) { 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()"); - mCameraImpl.startFocus(x, y); + mCameraController.startFocus(x, y); } /** * Sets the current focus behavior. * - * @see CameraKit.Constants#FOCUS_CONTINUOUS - * @see CameraKit.Constants#FOCUS_FIXED - * @see CameraKit.Constants#FOCUS_TAP - * @see CameraKit.Constants#FOCUS_TAP_WITH_MARKER + * @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) { // 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); - if (focus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) { - focus = CameraKit.Constants.FOCUS_TAP; + mFocusMarkerLayout.setEnabled(focus == CameraConstants.FOCUS_TAP_WITH_MARKER); + if (focus == CameraConstants.FOCUS_TAP_WITH_MARKER) { + focus = CameraConstants.FOCUS_TAP; } - mCameraImpl.setFocus(focus); + mCameraController.setFocus(focus); } @@ -727,7 +727,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Focus 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 #capturePicture()} will fallback to {@link #captureSnapshot()} * - * @see CameraKit.Constants#SESSION_TYPE_PICTURE - * @see CameraKit.Constants#SESSION_TYPE_VIDEO + * @see CameraConstants#SESSION_TYPE_PICTURE + * @see CameraConstants#SESSION_TYPE_VIDEO * * @param sessionType desired session type. */ @@ -762,11 +762,11 @@ public class CameraView extends FrameLayout implements LifecycleObserver { if (sessionType == getSessionType() || !mIsStarted) { // Check did took place, or will happen on start(). - mCameraImpl.setSessionType(sessionType); + mCameraController.setSessionType(sessionType); } else if (checkPermissions(sessionType)) { // Camera is running. CameraImpl setSessionType will do the trick. - mCameraImpl.setSessionType(sessionType); + mCameraController.setSessionType(sessionType); } else { // This means that the audio permission is being asked. @@ -784,15 +784,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @SessionType public int getSessionType() { - return mCameraImpl.getSessionType(); + return mCameraController.getSessionType(); } /** * Sets the zoom mode for the current session. * - * @see CameraKit.Constants#ZOOM_OFF - * @see CameraKit.Constants#ZOOM_PINCH + * @see CameraConstants#ZOOM_OFF + * @see CameraConstants#ZOOM_PINCH * * @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 sessionType is video, this might trigger a camera restart and a change in preview size. * - * @see CameraKit.Constants#VIDEO_QUALITY_LOWEST - * @see CameraKit.Constants#VIDEO_QUALITY_QVGA - * @see CameraKit.Constants#VIDEO_QUALITY_480P - * @see CameraKit.Constants#VIDEO_QUALITY_720P - * @see CameraKit.Constants#VIDEO_QUALITY_1080P - * @see CameraKit.Constants#VIDEO_QUALITY_2160P - * @see CameraKit.Constants#VIDEO_QUALITY_HIGHEST + * @see CameraConstants#VIDEO_QUALITY_LOWEST + * @see CameraConstants#VIDEO_QUALITY_QVGA + * @see CameraConstants#VIDEO_QUALITY_480P + * @see CameraConstants#VIDEO_QUALITY_720P + * @see CameraConstants#VIDEO_QUALITY_1080P + * @see CameraConstants#VIDEO_QUALITY_2160P + * @see CameraConstants#VIDEO_QUALITY_HIGHEST * * @param videoQuality requested video quality */ public void setVideoQuality(@VideoQuality int videoQuality) { - mCameraImpl.setVideoQuality(videoQuality); + mCameraController.setVideoQuality(videoQuality); } @@ -837,7 +837,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @VideoQuality 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 * 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). * * @see #captureSnapshot() */ public void capturePicture() { - mCameraImpl.capturePicture(); + mCameraController.capturePicture(); } @@ -943,7 +943,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { * @see #capturePicture() */ public void captureSnapshot() { - mCameraImpl.captureSnapshot(); + mCameraController.captureSnapshot(); } @@ -970,7 +970,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { if (file == null) { file = new File(getContext().getExternalFilesDir(null), "video.mp4"); } - if (mCameraImpl.startVideo(file)) { + if (mCameraController.startVideo(file)) { mKeepScreenOn = getKeepScreenOn(); if (!mKeepScreenOn) setKeepScreenOn(true); } @@ -1010,7 +1010,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { * This will fire {@link CameraListener#onVideoTaken(File)}. */ public void stopCapturingVideo() { - mCameraImpl.endVideo(); + mCameraController.endVideo(); if (getKeepScreenOn() != mKeepScreenOn) setKeepScreenOn(mKeepScreenOn); } @@ -1022,7 +1022,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { */ @Nullable 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 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) { ActivityCompat.requestPermissions(activity, permissions.toArray(new String[permissions.size()]), - CameraKit.Constants.PERMISSION_REQUEST_CODE); + CameraConstants.PERMISSION_REQUEST_CODE); } } diff --git a/camerakit/src/main/java/com/flurgle/camerakit/GridLinesLayout.java b/camerakit/src/main/java/com/flurgle/camerakit/GridLinesLayout.java index 54f21e29..0e31f5f7 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/GridLinesLayout.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/GridLinesLayout.java @@ -52,17 +52,17 @@ class GridLinesLayout extends View { private int getLineCount() { switch (gridMode) { - case CameraKit.Constants.GRID_OFF: return 0; - case CameraKit.Constants.GRID_3X3: return 2; - case CameraKit.Constants.GRID_PHI: return 2; - case CameraKit.Constants.GRID_4X4: return 3; + case CameraConstants.GRID_OFF: return 0; + case CameraConstants.GRID_3X3: return 2; + case CameraConstants.GRID_PHI: return 2; + case CameraConstants.GRID_4X4: return 3; } return 0; } private float getLinePosition(int lineNumber) { int lineCount = getLineCount(); - if (gridMode == CameraKit.Constants.GRID_PHI) { + if (gridMode == CameraConstants.GRID_PHI) { // 1 = 2x + GRIx // 1 = x(2+GRI) // x = 1/(2+GRI) diff --git a/camerakit/src/main/java/com/flurgle/camerakit/PinchToZoomLayout.java b/camerakit/src/main/java/com/flurgle/camerakit/PinchToZoomLayout.java index 9117eb54..f4810a9a 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/PinchToZoomLayout.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/PinchToZoomLayout.java @@ -67,7 +67,7 @@ class PinchToZoomLayout extends View { @Override 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. // This is to ensure that the notify flag stays on until the diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Facing.java b/camerakit/src/main/types/com/flurgle/camerakit/Facing.java index 15a555f7..3abc71de 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Facing.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Facing.java @@ -5,8 +5,8 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.FACING_BACK; -import static com.flurgle.camerakit.CameraKit.Constants.FACING_FRONT; +import static com.flurgle.camerakit.CameraConstants.FACING_BACK; +import static com.flurgle.camerakit.CameraConstants.FACING_FRONT; @IntDef({FACING_BACK, FACING_FRONT}) @Retention(RetentionPolicy.SOURCE) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Flash.java b/camerakit/src/main/types/com/flurgle/camerakit/Flash.java index e42800b0..ce2a3120 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Flash.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Flash.java @@ -5,10 +5,10 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_AUTO; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_ON; -import static com.flurgle.camerakit.CameraKit.Constants.FLASH_TORCH; +import static com.flurgle.camerakit.CameraConstants.FLASH_AUTO; +import static com.flurgle.camerakit.CameraConstants.FLASH_OFF; +import static com.flurgle.camerakit.CameraConstants.FLASH_ON; +import static com.flurgle.camerakit.CameraConstants.FLASH_TORCH; @Retention(RetentionPolicy.SOURCE) @IntDef({FLASH_OFF, FLASH_ON, FLASH_AUTO, FLASH_TORCH}) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Focus.java b/camerakit/src/main/types/com/flurgle/camerakit/Focus.java index 84201d15..5e387d40 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Focus.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Focus.java @@ -5,10 +5,10 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_FIXED; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; -import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP_WITH_MARKER; +import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP; +import static com.flurgle.camerakit.CameraConstants.FOCUS_FIXED; +import static com.flurgle.camerakit.CameraConstants.FOCUS_CONTINUOUS; +import static com.flurgle.camerakit.CameraConstants.FOCUS_TAP_WITH_MARKER; @Retention(RetentionPolicy.SOURCE) @IntDef({FOCUS_CONTINUOUS, FOCUS_TAP, FOCUS_FIXED, FOCUS_TAP_WITH_MARKER}) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Grid.java b/camerakit/src/main/types/com/flurgle/camerakit/Grid.java index 037bf220..0961fde1 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Grid.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Grid.java @@ -5,10 +5,10 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.GRID_OFF; -import static com.flurgle.camerakit.CameraKit.Constants.GRID_3X3; -import static com.flurgle.camerakit.CameraKit.Constants.GRID_4X4; -import static com.flurgle.camerakit.CameraKit.Constants.GRID_PHI; +import static com.flurgle.camerakit.CameraConstants.GRID_OFF; +import static com.flurgle.camerakit.CameraConstants.GRID_3X3; +import static com.flurgle.camerakit.CameraConstants.GRID_4X4; +import static com.flurgle.camerakit.CameraConstants.GRID_PHI; @IntDef({GRID_OFF, GRID_3X3, GRID_4X4, GRID_PHI}) @Retention(RetentionPolicy.SOURCE) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Method.java b/camerakit/src/main/types/com/flurgle/camerakit/Method.java index d7afa1a8..b9af1f04 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Method.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Method.java @@ -5,8 +5,8 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; -import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; +import static com.flurgle.camerakit.CameraConstants.CAPTURE_METHOD_STANDARD; +import static com.flurgle.camerakit.CameraConstants.CAPTURE_METHOD_FRAME; @Deprecated @Retention(RetentionPolicy.SOURCE) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Permissions.java b/camerakit/src/main/types/com/flurgle/camerakit/Permissions.java index cabf7160..6b4e4ee5 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Permissions.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Permissions.java @@ -5,8 +5,8 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_PICTURE; -import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_VIDEO; +import static com.flurgle.camerakit.CameraConstants.PERMISSIONS_PICTURE; +import static com.flurgle.camerakit.CameraConstants.PERMISSIONS_VIDEO; @Deprecated @Retention(RetentionPolicy.SOURCE) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/SessionType.java b/camerakit/src/main/types/com/flurgle/camerakit/SessionType.java index ba8907e8..b5a84ed7 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/SessionType.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/SessionType.java @@ -5,8 +5,8 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; -import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_PICTURE; +import static com.flurgle.camerakit.CameraConstants.SESSION_TYPE_VIDEO; @Retention(RetentionPolicy.SOURCE) @IntDef({SESSION_TYPE_PICTURE, SESSION_TYPE_VIDEO}) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/VideoQuality.java b/camerakit/src/main/types/com/flurgle/camerakit/VideoQuality.java index e9709167..3974de1e 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/VideoQuality.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/VideoQuality.java @@ -5,13 +5,13 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_1080P; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_2160P; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_480P; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_720P; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_HIGHEST; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_LOWEST; -import static com.flurgle.camerakit.CameraKit.Constants.VIDEO_QUALITY_QVGA; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_1080P; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_2160P; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_480P; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_720P; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_HIGHEST; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_LOWEST; +import static com.flurgle.camerakit.CameraConstants.VIDEO_QUALITY_QVGA; @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}) diff --git a/camerakit/src/main/types/com/flurgle/camerakit/WhiteBalance.java b/camerakit/src/main/types/com/flurgle/camerakit/WhiteBalance.java index 8bd72097..ebb39c1a 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/WhiteBalance.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/WhiteBalance.java @@ -5,11 +5,11 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_AUTO; -import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_INCANDESCENT; -import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_FLUORESCENT; -import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_DAYLIGHT; -import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_CLOUDY; +import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_AUTO; +import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_INCANDESCENT; +import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_FLUORESCENT; +import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_DAYLIGHT; +import static com.flurgle.camerakit.CameraConstants.WHITE_BALANCE_CLOUDY; @Retention(RetentionPolicy.SOURCE) @IntDef({WHITE_BALANCE_AUTO, WHITE_BALANCE_INCANDESCENT, WHITE_BALANCE_FLUORESCENT, diff --git a/camerakit/src/main/types/com/flurgle/camerakit/ZoomMode.java b/camerakit/src/main/types/com/flurgle/camerakit/ZoomMode.java index 53c38722..a3749dab 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/ZoomMode.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/ZoomMode.java @@ -5,8 +5,8 @@ import android.support.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_OFF; -import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_PINCH; +import static com.flurgle.camerakit.CameraConstants.ZOOM_OFF; +import static com.flurgle.camerakit.CameraConstants.ZOOM_PINCH; @Retention(RetentionPolicy.SOURCE) @IntDef({ZOOM_OFF, ZOOM_PINCH}) diff --git a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java index d532ee70..9c4c89fd 100644 --- a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java +++ b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java @@ -13,7 +13,7 @@ import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; -import com.flurgle.camerakit.CameraKit; +import com.flurgle.camerakit.CameraConstants; import com.flurgle.camerakit.CameraListener; import com.flurgle.camerakit.CameraView; import com.flurgle.camerakit.Size; @@ -158,7 +158,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan @OnClick(R.id.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); return; } @@ -190,11 +190,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan void toggleCamera() { if (mCapturingPicture) return; switch (camera.toggleFacing()) { - case CameraKit.Constants.FACING_BACK: + case CameraConstants.FACING_BACK: message("Switched to back camera!", false); break; - case CameraKit.Constants.FACING_FRONT: + case CameraConstants.FACING_FRONT: message("Switched to front camera!", false); break; } @@ -204,15 +204,15 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan void toggleFlash() { if (mCapturingPicture) return; switch (camera.toggleFlash()) { - case CameraKit.Constants.FLASH_ON: + case CameraConstants.FLASH_ON: message("Flash on!", false); break; - case CameraKit.Constants.FLASH_OFF: + case CameraConstants.FLASH_OFF: message("Flash off!", false); break; - case CameraKit.Constants.FLASH_AUTO: + case CameraConstants.FLASH_AUTO: message("Flash auto!", false); break; } @@ -224,8 +224,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan if (mCapturingPicture) return; camera.setSessionType( checkedId == R.id.sessionTypePicture ? - CameraKit.Constants.SESSION_TYPE_PICTURE : - CameraKit.Constants.SESSION_TYPE_VIDEO + CameraConstants.SESSION_TYPE_PICTURE : + CameraConstants.SESSION_TYPE_VIDEO ); 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 public void onCheckedChanged(RadioGroup group, int checkedId) { if (mCapturingVideo) return; - int videoQuality = CameraKit.Constants.VIDEO_QUALITY_HIGHEST; + int videoQuality = CameraConstants.VIDEO_QUALITY_HIGHEST; switch (checkedId) { - case R.id.videoQualityLowest: videoQuality = CameraKit.Constants.VIDEO_QUALITY_LOWEST; break; - case R.id.videoQualityQvga: videoQuality = CameraKit.Constants.VIDEO_QUALITY_QVGA; break; - case R.id.videoQuality480p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_480P; break; - case R.id.videoQuality720p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_720P; break; - case R.id.videoQuality1080p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_1080P; break; - case R.id.videoQuality2160p: videoQuality = CameraKit.Constants.VIDEO_QUALITY_2160P; break; - case R.id.videoQualityHighest: videoQuality = CameraKit.Constants.VIDEO_QUALITY_HIGHEST; break; + case R.id.videoQualityLowest: videoQuality = CameraConstants.VIDEO_QUALITY_LOWEST; break; + case R.id.videoQualityQvga: videoQuality = CameraConstants.VIDEO_QUALITY_QVGA; break; + case R.id.videoQuality480p: videoQuality = CameraConstants.VIDEO_QUALITY_480P; break; + case R.id.videoQuality720p: videoQuality = CameraConstants.VIDEO_QUALITY_720P; break; + case R.id.videoQuality1080p: videoQuality = CameraConstants.VIDEO_QUALITY_1080P; break; + case R.id.videoQuality2160p: videoQuality = CameraConstants.VIDEO_QUALITY_2160P; break; + case R.id.videoQualityHighest: videoQuality = CameraConstants.VIDEO_QUALITY_HIGHEST; break; } camera.setVideoQuality(videoQuality); message("Video quality changed!", false); @@ -263,12 +263,12 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan RadioGroup.OnCheckedChangeListener gridModeChangedListener = new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { - int grid = CameraKit.Constants.GRID_OFF; + int grid = CameraConstants.GRID_OFF; switch (checkedId) { - case R.id.gridModeOff: grid = CameraKit.Constants.GRID_OFF; break; - case R.id.gridMode3x3: grid = CameraKit.Constants.GRID_3X3; break; - case R.id.gridMode4x4: grid = CameraKit.Constants.GRID_4X4; break; - case R.id.gridModeGolden: grid = CameraKit.Constants.GRID_PHI; break; + case R.id.gridModeOff: grid = CameraConstants.GRID_OFF; break; + case R.id.gridMode3x3: grid = CameraConstants.GRID_3X3; break; + case R.id.gridMode4x4: grid = CameraConstants.GRID_4X4; break; + case R.id.gridModeGolden: grid = CameraConstants.GRID_PHI; break; } camera.setGrid(grid); message("Grid mode changed!", false); @@ -279,10 +279,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan RadioGroup.OnCheckedChangeListener zoomModeChangedListener = new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { - int zoom = CameraKit.Constants.ZOOM_OFF; + int zoom = CameraConstants.ZOOM_OFF; switch (checkedId) { - case R.id.zoomModeOff: zoom = CameraKit.Constants.ZOOM_OFF; break; - case R.id.zoomModePinch: zoom = CameraKit.Constants.ZOOM_PINCH; break; + case R.id.zoomModeOff: zoom = CameraConstants.ZOOM_OFF; break; + case R.id.zoomModePinch: zoom = CameraConstants.ZOOM_PINCH; break; } camera.setZoomMode(zoom); message("Zoom mode changed! Note that pinch-to-zoom won't work well in ScrollViews like here", true); diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml index 252d7984..9bcf8dcf 100644 --- a/demo/src/main/res/values/strings.xml +++ b/demo/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - CameraKit + CameraKit Preview