diff --git a/.repo/camerakit-android-header.png b/.repo/camerakit-android-header.png deleted file mode 100644 index b12139c3..00000000 Binary files a/.repo/camerakit-android-header.png and /dev/null differ diff --git a/.repo/demo1.png b/.repo/demo1.png deleted file mode 100644 index ee2e9e8a..00000000 Binary files a/.repo/demo1.png and /dev/null differ diff --git a/.repo/demo2.png b/.repo/demo2.png deleted file mode 100644 index e6a51cb7..00000000 Binary files a/.repo/demo2.png and /dev/null differ diff --git a/.repo/demo3.png b/.repo/demo3.png deleted file mode 100644 index 897288b8..00000000 Binary files a/.repo/demo3.png and /dev/null differ diff --git a/.repo/demo4.png b/.repo/demo4.png deleted file mode 100644 index 4dd497a2..00000000 Binary files a/.repo/demo4.png and /dev/null differ diff --git a/.repo/google-play-badge.png b/.repo/google-play-badge.png deleted file mode 100644 index c77b7464..00000000 Binary files a/.repo/google-play-badge.png and /dev/null differ diff --git a/.repo/permissions.gif b/.repo/permissions.gif deleted file mode 100644 index bccf3352..00000000 Binary files a/.repo/permissions.gif and /dev/null differ diff --git a/.repo/sizing.gif b/.repo/sizing.gif deleted file mode 100644 index 7c4a123a..00000000 Binary files a/.repo/sizing.gif and /dev/null differ diff --git a/README.md b/README.md index 7b6b5478..9cedc12c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -*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)* +*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).* -CameraKit is an easy to use utility to work with the Android Camera APIs. Everything at the moment is work in progress. +# CameraKit + +CameraKit is an easy to use utility to work with the Android Camera APIs. Everything at the moment is work in progress, but it works well for pictures at least. ## Table of Contents @@ -10,43 +12,38 @@ CameraKit is an easy to use utility to work with the Android Camera APIs. Everyt - [Usage](#usage) - [Capturing Images](#capturing-images) - [Capturing Video](#capturing-video) + - [Other camera events](#other-camera-events) - [Extra Attributes](#extra-attributes) - - [`ckFacing`](#ckfacing) - - [`ckFlash`](#ckflash) - - [`ckFocus`](#ckfocus) - - [`ckMethod`](#ckmethod) - - [`ckZoom`](#ckzoom) - - [`ckCropOutput`](#ckcropoutput) - - [`ckJpegQuality`](#ckjpegquality) -- [Automatic Permissions Behavior](#automatic-permissions-behavior) + - [cameraFacing](#camerafacing) + - [cameraFlash](#cameraflash) + - [cameraFocus](#camerafocus) + - [cameraCaptureMethod](#cameracapturemethod) + - [cameraZoom](#camerazoom) + - [cameraCropOutput](#cameracropoutput) + - [cameraJpegQuality](#camerajpegquality) +- [Permissions Behavior](#permissions-behavior) - [Dynamic Sizing Behavior](#dynamic-sizing-behavior) - - [`adjustViewBounds`](#adjustviewbounds) -- [Events](#events) -- [Credits](#credits) -- [License](#license) - -## Features - -- Image and video capture seamlessly working with the same preview session. -- Automatic system permission handling. -- Automatic preview scaling. - - Create a `CameraView` of any size (not just presets!). - - Automatic output cropping to match your `CameraView` bounds. -- Multiple capture methods. - - `METHOD_STANDARD`: an image captured normally using the camera APIs. - - `METHOD_STILL`: a freeze frame of the `CameraView` preview (similar to SnapChat and Instagram) for devices with slower cameras. - - **Coming soon:** `METHOD_SPEED`: automatic capture method determination based on measured speed. -- Built-in continuous focus. -- Built-in tap to focus. -- **Coming soon:** Built-in pinch to zoom. + - [Center Crop](#center-crop) + - [Center Inside](#center-inside) + +# Features + +- Image and video capture seamlessly working with the same preview session. (TODO: remove this, use different sessions) +- System permission handling +- Dynamic sizing behavior + - Create a `CameraView` of any size (not just presets!)... + - Or let it adapt to the sensor preview size + - Automatic output cropping to match your `CameraView` bounds +- Multiple capture methods + - `CAPTURE_METHOD_STANDARD`: an image captured normally using the camera APIs. + - `CAPTURE_METHOD_FRAME`: a freeze frame of the `CameraView` preview (similar to SnapChat and Instagram) for devices with slower cameras +- Built-in tap to focus +- TODO: Built-in pinch to zoom ## Setup -Add __CameraKit__ to the dependencies block in your `app` level `build.gradle`: - -```groovy -compile 'com.flurgle:camerakit:0.9.17' -``` +For now, clone the repo and add it to your project. +TODO: publish to bintray. ## Usage @@ -60,7 +57,7 @@ To use CameraKit, simply add a `CameraView` to your layout: android:adjustViewBounds="true" /> ``` -Make sure you override `onResume` and `onPause` in your activity, and make calls respectively to `CameraView.start()` and `CameraView.stop()`. +Make sure you override `onResume`, `onPause` and `onDestroy` in your activity, and call `CameraView.start()`, `stop()` and `destroy()`. ```java @Override @@ -71,8 +68,14 @@ protected void onResume() { @Override protected void onPause() { - cameraView.stop(); super.onPause(); + cameraView.stop(); +} + +@Override +protected void onDestroy() { + super.onDestroy(); + cameraView.destroy(); } ``` @@ -84,9 +87,7 @@ To capture an image just call `CameraView.captureImage()`. Make sure you setup a camera.setCameraListener(new CameraListener() { @Override public void onPictureTaken(byte[] picture) { - super.onPictureTaken(picture); - - // Create a bitmap + // Create a bitmap or a file... Bitmap result = BitmapFactory.decodeByteArray(picture, 0, picture.length); } }); @@ -96,13 +97,14 @@ camera.captureImage(); ### Capturing Video +TODO: test size and orientation stuff. + To capture video just call `CameraView.startRecordingVideo()` to start, and `CameraView.stopRecordingVideo()` to finish. Make sure you setup a `CameraListener` to handle the video callback. ```java camera.setCameraListener(new CameraListener() { @Override public void onVideoTaken(File video) { - super.onVideoTaken(video); // The File parameter is an MP4 file. } }); @@ -116,296 +118,185 @@ camera.postDelayed(new Runnable() { }, 2500); ``` +### Other camera events + +Make sure you can react to different camera events by setting up a `CameraListener` instance. + +```java +camera.setCameraListener(new CameraListener() { + + @Override + public void onCameraOpened() {} + + @Override + public void onCameraClosed() {} + + @Override + public void onPictureTaken(byte[] picture) {} + + @Override + public void onVideoTaken(File video) {} + +}); +``` + + ## Extra Attributes ```xml - ``` -|Attribute|Values|Default Value| -|---------|------|-------------| -|[`ckFacing`](#ckfacing)|[`back`](#back) [`front`](#front)|`back`| -|[`ckFlash`](#ckflash)|[`off`](#off) [`on`](#on) [`auto`](#auto)|`off`| -|[`ckFocus`](#ckfocus)|[`off`](#off-1) [`continuous`](#continuous) [`tap`](#tap)|`continuous`| -|[`ckMethod`](#ckmethod)|[`standard`](#standard) [`still`](#still) [`speed`](#speed)|`standard`| -|[`ckZoom`](#ckzoom)|[`off`](#off-2) [`pinch`](#pinch)|`off`| -|[`ckPermissions`](#ckpermissions)|[`strict`](#strict) [`lazy`](#lazy) [`picture`](#picture`)|`strict`| -|[`ckCropOutput`](#ckcropoutput)|[`true`](#true) [`false`](#false)|`false`| -|[`ckJpegQuality`](#ckjpegquality)|[`0 <= n <= 100`](#ckjpegquality)|`100`| -|[`ckVideoQuality`](#ckvideoquality)|[`max480p`](#max480p) [`max720p`](#max720p) [`max1080p`](#max1080p) [`max2160p`](#max2160p) [`highest`](#highest) [`lowest`](#lowest)|`max480p`| +|XML Attribute|Method|Values|Default Value| +|-------------|------|------|-------------| +|[`cameraFacing`](#camerafacing)|`setFacing()`|`back` `front`|`back`| +|[`cameraFlash`](#cameraflash)|`setFlash()`|`off` `on` `auto` `torch`|`off`| +|[`cameraFocus`](#camerafocus)|`setFocus()`|`off` `continuous` `tap` `tapWithMarker`|`continuous`| +|[`cameraCaptureMethod`](#cameracapturemethod)|`setCaptureMethod()`|`standard` `frame`|`standard`| +|[`cameraZoom`](#camerazoom)|`setZoom()`|`off` `pinch`|`off`| +|[`cameraPermissionPolicy`](#camerapermissionpolicy)|`setPermissionPolicy()`|`picture` `video`|`picture`| +|[`cameraCropOutput`](#cameracropoutput)|`setCropOutput()`|`true` `false`|`false`| +|[`cameraJpegQuality`](#camerajpegquality)|`setJpegQuality()`|`0 <= n <= 100`|`100`| +|[`cameraVideoQuality`](#cameravideoquality)|`setVideoQuality()`|`max480p` `max720p` `max1080p` `max2160p` `highest` `lowest`|`max480p`| -- - - -### `ckFacing` -[`back`](#back) [`front`](#front) +### cameraFacing -#### `back` +Which camera to use, either back facing or front facing. ```java cameraView.setFacing(CameraKit.Constants.FACING_BACK); -``` - -#### `front` - -```java cameraView.setFacing(CameraKit.Constants.FACING_FRONT); ``` -- - - +### cameraFlash -### `ckFlash` -[`off`](#off) [`on`](#on) [`auto`](#auto) [`torch`](#torch) - -#### `off` +Flash mode, either off, on, auto or *torch*. ```java cameraView.setFlash(CameraKit.Constants.FLASH_OFF); -``` - -#### `on` - -```java cameraView.setFlash(CameraKit.Constants.FLASH_ON); -``` - -#### `auto` - -```java cameraView.setFlash(CameraKit.Constants.FLASH_AUTO); -``` - -#### `torch` -```java cameraView.setFlash(CameraKit.Constants.FLASH_TORCH); ``` -- - - - -### `ckFocus` -[`off`](#off-1) [`continuous`](#continuous) [`tap`](#tap) +### cameraFocus -#### `off` +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_OFF); -``` - -#### `continuous` - -```java cameraView.setFocus(CameraKit.Constants.FOCUS_CONTINUOUS); -``` - -#### `tap` - -```java cameraView.setFocus(CameraKit.Constants.FOCUS_TAP); +cameraView.setFocus(CameraKit.Constants.FOCUS_TAP_WITH_MARKER); ``` -- - - - -### `ckMethod` -[`standard`](#standard) [`still`](#still) [`speed`](#speed) +### cameraCaptureMethod -#### `standard` +How to capture pictures, either standard or frame. The frame option lets you capture and save a preview frame, which can be better with slower camera sensors, though the captured image can be blurry or noisy. ```java -cameraView.setMethod(CameraKit.Constants.METHOD_STANDARD); +cameraView.setMethod(CameraKit.Constants.CAPTURE_METHOD_STANDARD); +cameraView.setMethod(CameraKit.Constants.CAPTURE_METHOD_FRAME); ``` -When you use `METHOD_STANDARD` (`camerakit:ckMethod="standard"`), images will be captured using the normal camera API capture method using the shutter. - -#### `still` - -```java -cameraView.setMethod(CameraKit.Constants.METHOD_STILL); -``` - -When you use `METHOD_STILL` (`camerakit:ckMethod="still"`), images will be captured by grabbing a single frame from the preview. This behavior is the same as SnapChat and Instagram. This method has a higher rate of motion blur but can be a better experience for users with slower cameras. - -#### `speed` +### cameraZoom -**Coming soon** - -```java -cameraView.setMethod(CameraKit.Constants.METHOD_SPEED); -``` - -When you use `METHOD_SPEED` (`camerakit:ckMethod="speed"`), images will be captured using both `METHOD_STANDARD` and `METHOD_SPEED`. After 6 image captures the camera will set itself to `METHOD_STANDARD` or `METHOD_STILL` permanently based on whichever is faster. - -- - - - -### `ckZoom` -[`off`](#off-2) [`pinch`](#pinch) - -#### `off` +TODO: work in progress. Right now 'off' is the onlly option. ```java cameraView.setZoom(CameraKit.Constants.ZOOM_OFF); -``` - -#### `pinch` - -```java cameraView.setZoom(CameraKit.Constants.ZOOM_PINCH); ``` -- - - +### cameraPermissionPolicy -### `ckPermissions` -[`strict`](#strict) [`lazy`](#lazy) [`picture`](#picture`) +Either picture or video. This tells the library which permissions should be asked before starting the camera session. In the case of 'picture', we require the camera permissions. In the case of 'video', the record audio permission is asked as well. -#### `strict` - -```java -cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_STRICT); -``` - -#### `lazy` - -```java -cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_LAZY); -``` - -#### `picture` +Please note that, if needed, the latter should be added to your manifest file or the app will crash. ```java cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_PICTURE); +cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_VIDEO); ``` -- - - - -### `ckCropOutput` -[`true`](#true) [`false`](#false) - -#### `true` - -```java -cameraView.setCropOutput(true); -``` - -#### `false` +### cameraCropOutput -```java -cameraView.setCropOutput(false); -``` +Wheter the output file should be cropped to fit the aspect ratio of the preview surface. +This can guarantee consistency between what the user sees and the final output, if you fixed the camera view dimensions. -- - - +### cameraJpegQuality -### `ckJpegQuality` +Sets the JPEG quality of pictures. ```java cameraView.setJpegQuality(100); +cameraView.setJpegQuality(50); ``` -- - - - -### `ckVideoQuality` -[`max480p`](#max480p) [`max720p`](#max720p) [`max1080p`](#max1080p) [`max2160p`](#max2160p) [`lowest`](#lowest) [`highest`](#highest) [`qvga`](#qvga) +### cameraVideoQuality -#### `max480p` +Sets the desired video quality. ```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_480P); -``` - -#### `max720p` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_720P); -``` - -#### `max1080p` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_1080P); -``` - -#### `max2160p` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_2160P); -``` - -#### `lowest` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_LOWEST); -``` - -#### `highest` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_HIGHEST); -``` - -#### `qvga` - -```java cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_QVGA); ``` -- - - - -## Automatic Permissions Behavior +## Permissions behavior -You can handle permissions yourself in whatever way you want, but if you make a call to `CameraView.start()` without the `android.permission.CAMERA` permission, an exception would normally be thrown and your app would crash. +`CameraView` needs two permissions: -With CameraKit, we will automatically prompt for the `android.permission.CAMERA` permission if it's not available. If you want to handle it yourself, just make sure you don't call `CameraView.start()` until you acquire the permissions. +- `android.permission.CAMERA` : required +- `android.permission.RECORD_AUDIO` : required for capturing videos -![Permissions behavior gif](.repo/permissions.gif) +You can handle permissions yourself and then call `CameraView.start()` once they are acquired. If they are not, `CameraView` will request permissions to the user based on the `permissionPolicy` that was set. In that case, you can restart the camera if you have a successful response from `onRequestPermissionResults()`. -## Dynamic Sizing Behavior +## Manifest file -You can setup the `CameraView` dimensions however you want. When your dimensions don't match the aspect ratio of the internal preview surface, the surface will be cropped minimally to fill the view. The behavior is the same as the `android:scaleType="centerCrop"` on an `ImageView`. +The library manifest file is not strict and only asks for camera permissions. This means that: -![Dynamic sizing gif](.repo/sizing.gif) +- If you wish to record videos, you should also add `android.permission.RECORD_AUDIO` to required permissions -### `adjustViewBounds` +```xml + +``` -You can use a mix of a fixed dimension (a set value or `match_parent`) as well as `wrap_content`. When you do this make sure you set `android:adjustViewBounds="true"` on the `CameraView`. +- If you want your app to be installed only on devices that have a camera, you should add: -When you do this the dimension set to `wrap_content` will automatically align with the true aspect ratio of the preview surface. In this case the whole preview will be visible with no cropping. +```xml + +``` -## Events +If you don't request this feature, you can use `CameraKit.hasCameras()` to detect if current device has cameras, and then start the camera view. -Make sure you can react to different camera events by setting up a `CameraListener` instance. - -```java -camera.setCameraListener(new CameraListener() { +## Dynamic Sizing Behavior - @Override - public void onCameraOpened() { - super.onCameraOpened(); - } +### Center crop - @Override - public void onCameraClosed() { - super.onCameraClosed(); - } +You can setup the `CameraView` dimensions as you wish. Default behavior is that if your dimensions don't match the aspect ratio of the internal preview surface, the surface will be cropped to fill the view, just like `android:scaleType="centerCrop"` on an `ImageView`. - @Override - public void onPictureTaken(byte[] picture) { - super.onPictureTaken(picture); - } +### Center inside - @Override - public void onVideoTaken(File video) { - super.onVideoTaken(video); - } +If `android:adjustViewBounds` is set to true the library will try to adapt the view dimension to the chosen preview size. How? All dimensions set to `wrap_content` are streched out to ensure the view holds the whole preview. If both dimensions are `wrap_content`, this is exactly like `android:scaleType="centerInside"` on an `ImageView`. -}); -``` diff --git a/camerakit/src/main/AndroidManifest.xml b/camerakit/src/main/AndroidManifest.xml index 0b5e8472..8667a0e7 100644 --- a/camerakit/src/main/AndroidManifest.xml +++ b/camerakit/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ + android:required="false"/> diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java index 2b28abd2..25885e47 100644 --- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java +++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java @@ -22,8 +22,8 @@ import static com.flurgle.camerakit.CameraKit.Constants.FLASH_OFF; import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_CONTINUOUS; import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_OFF; import static com.flurgle.camerakit.CameraKit.Constants.FOCUS_TAP; -import static com.flurgle.camerakit.CameraKit.Constants.METHOD_STANDARD; -import static com.flurgle.camerakit.CameraKit.Constants.METHOD_STILL; +import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; +import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; @SuppressWarnings("deprecation") class Camera1 extends CameraImpl { @@ -226,7 +226,7 @@ class Camera1 extends CameraImpl { @Override void captureImage() { switch (mMethod) { - case METHOD_STANDARD: + case CAPTURE_METHOD_STANDARD: // Null check required for camera here as is briefly null when View is detached if (!capturingImage && mCamera != null) { // Set boolean to wait for image callback @@ -250,7 +250,7 @@ class Camera1 extends CameraImpl { } break; - case METHOD_STILL: + case CAPTURE_METHOD_FRAME: // TODO: will calculateCaptureRotation work here? It's the only usage. Test... mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback() { @Override diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java index 033ae806..994ea4cb 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java @@ -1,9 +1,17 @@ package com.flurgle.camerakit; -import android.content.res.Resources; +import android.content.Context; +import android.content.pm.PackageManager; public class CameraKit { + public static boolean hasCameras(Context context) { + PackageManager manager = context.getPackageManager(); + // There's also FEATURE_CAMERA_EXTERNAL , should we support it? + return manager.hasSystemFeature(PackageManager.FEATURE_CAMERA) + || manager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT); + } + public static class Constants { public static final int PERMISSION_REQUEST_CODE = 16; @@ -24,9 +32,8 @@ public class CameraKit { public static final int ZOOM_OFF = 0; public static final int ZOOM_PINCH = 1; - public static final int METHOD_STANDARD = 0; - public static final int METHOD_STILL = 1; - public static final int METHOD_SPEED = 2; + public static final int CAPTURE_METHOD_STANDARD = 0; + public static final int CAPTURE_METHOD_FRAME = 1; /** @@ -60,7 +67,7 @@ public class CameraKit { static final int DEFAULT_FLASH = Constants.FLASH_OFF; static final int DEFAULT_FOCUS = Constants.FOCUS_CONTINUOUS; static final int DEFAULT_ZOOM = Constants.ZOOM_OFF; - static final int DEFAULT_METHOD = Constants.METHOD_STANDARD; + static final int DEFAULT_METHOD = Constants.CAPTURE_METHOD_STANDARD; static final int DEFAULT_PERMISSIONS = Constants.PERMISSIONS_PICTURE; static final int DEFAULT_VIDEO_QUALITY = Constants.VIDEO_QUALITY_480P; diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java index 8699bef1..6dd8f15c 100644 --- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java +++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java @@ -11,10 +11,8 @@ import android.content.ContextWrapper; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.TypedArray; -import android.graphics.Color; import android.graphics.Rect; import android.graphics.YuvImage; -import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.os.HandlerThread; import android.support.annotation.NonNull; @@ -41,7 +39,6 @@ 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.METHOD_STANDARD; import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_PICTURE; import static com.flurgle.camerakit.CameraKit.Constants.PERMISSIONS_VIDEO; @@ -112,15 +109,15 @@ public class CameraView extends FrameLayout implements LifecycleObserver { if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0); try { - mFacing = a.getInteger(R.styleable.CameraView_ckFacing, CameraKit.Defaults.DEFAULT_FACING); - mFlash = a.getInteger(R.styleable.CameraView_ckFlash, CameraKit.Defaults.DEFAULT_FLASH); - mFocus = a.getInteger(R.styleable.CameraView_ckFocus, CameraKit.Defaults.DEFAULT_FOCUS); - mMethod = a.getInteger(R.styleable.CameraView_ckMethod, CameraKit.Defaults.DEFAULT_METHOD); - mZoom = a.getInteger(R.styleable.CameraView_ckZoom, CameraKit.Defaults.DEFAULT_ZOOM); - mPermissions = a.getInteger(R.styleable.CameraView_ckPermissions, CameraKit.Defaults.DEFAULT_PERMISSIONS); - mVideoQuality = a.getInteger(R.styleable.CameraView_ckVideoQuality, CameraKit.Defaults.DEFAULT_VIDEO_QUALITY); - mJpegQuality = a.getInteger(R.styleable.CameraView_ckJpegQuality, CameraKit.Defaults.DEFAULT_JPEG_QUALITY); - mCropOutput = a.getBoolean(R.styleable.CameraView_ckCropOutput, CameraKit.Defaults.DEFAULT_CROP_OUTPUT); + mFacing = a.getInteger(R.styleable.CameraView_cameraFacing, CameraKit.Defaults.DEFAULT_FACING); + mFlash = a.getInteger(R.styleable.CameraView_cameraFlash, CameraKit.Defaults.DEFAULT_FLASH); + mFocus = a.getInteger(R.styleable.CameraView_cameraFocus, CameraKit.Defaults.DEFAULT_FOCUS); + mMethod = a.getInteger(R.styleable.CameraView_cameraCaptureMethod, CameraKit.Defaults.DEFAULT_METHOD); + mZoom = a.getInteger(R.styleable.CameraView_cameraZoom, CameraKit.Defaults.DEFAULT_ZOOM); + mPermissions = a.getInteger(R.styleable.CameraView_cameraPermissionPolicy, CameraKit.Defaults.DEFAULT_PERMISSIONS); + mVideoQuality = a.getInteger(R.styleable.CameraView_cameraVideoQuality, CameraKit.Defaults.DEFAULT_VIDEO_QUALITY); + mJpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, CameraKit.Defaults.DEFAULT_JPEG_QUALITY); + mCropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, CameraKit.Defaults.DEFAULT_CROP_OUTPUT); mAdjustViewBounds = a.getBoolean(R.styleable.CameraView_android_adjustViewBounds, CameraKit.Defaults.DEFAULT_ADJUST_VIEW_BOUNDS); } finally { a.recycle(); @@ -136,7 +133,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { setFacing(mFacing); setFlash(mFlash); setFocus(mFocus); - setMethod(mMethod); + setCaptureMethod(mMethod); setZoom(mZoom); setPermissionPolicy(mPermissions); setVideoQuality(mVideoQuality); @@ -394,7 +391,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { mCameraImpl.setFocus(mFocus); } - public void setMethod(@Method int method) { + public void setCaptureMethod(@Method int method) { this.mMethod = method; mCameraImpl.setMethod(mMethod); } diff --git a/camerakit/src/main/res/values/attrs.xml b/camerakit/src/main/res/values/attrs.xml index b079b74f..52604949 100644 --- a/camerakit/src/main/res/values/attrs.xml +++ b/camerakit/src/main/res/values/attrs.xml @@ -3,26 +3,26 @@ - + - + - + - + @@ -30,23 +30,19 @@ - + - - - - + - - - - + + + - + - + @@ -56,7 +52,7 @@ - + diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Method.java b/camerakit/src/main/types/com/flurgle/camerakit/Method.java index ba6d85b1..8c471cca 100644 --- a/camerakit/src/main/types/com/flurgle/camerakit/Method.java +++ b/camerakit/src/main/types/com/flurgle/camerakit/Method.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.METHOD_STANDARD; -import static com.flurgle.camerakit.CameraKit.Constants.METHOD_STILL; +import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_STANDARD; +import static com.flurgle.camerakit.CameraKit.Constants.CAPTURE_METHOD_FRAME; @Retention(RetentionPolicy.SOURCE) -@IntDef({METHOD_STANDARD, METHOD_STILL}) +@IntDef({CAPTURE_METHOD_STANDARD, CAPTURE_METHOD_FRAME}) public @interface Method { }