Constants refactor, readme changes

pull/1/head
Mattia Iavarone 7 years ago
parent df77e95967
commit f644bfdfef
  1. BIN
      .repo/camerakit-android-header.png
  2. BIN
      .repo/demo1.png
  3. BIN
      .repo/demo2.png
  4. BIN
      .repo/demo3.png
  5. BIN
      .repo/demo4.png
  6. BIN
      .repo/google-play-badge.png
  7. BIN
      .repo/permissions.gif
  8. BIN
      .repo/sizing.gif
  9. 377
      README.md
  10. 2
      camerakit/src/main/AndroidManifest.xml
  11. 8
      camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
  12. 17
      camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java
  13. 25
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
  14. 28
      camerakit/src/main/res/values/attrs.xml
  15. 6
      camerakit/src/main/types/com/flurgle/camerakit/Method.java

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 MiB

@ -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
<com.flurgle.camerakit.CameraView xmlns:camerakit="http://schemas.android.com/apk/res-auto"
<com.flurgle.camerakit.CameraView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
camerakit:ckFacing="back"
camerakit:ckFlash="off"
camerakit:ckFocus="continuous"
camerakit:ckMethod="standard"
camerakit:ckZoom="pinch"
camerakit:ckPermissions="strict"
camerakit:ckCropOutput="true"
camerakit:ckJpegQuality="100"
camerakit:ckVideoQuality="480p"
app:cameraFacing="back"
app:cameraFlash="off"
app:cameraFocus="continuous"
app:cameraCaptureMethod="standard"
app:cameraZoom="pinch"
app:cameraPermissionPolicy="strict"
app:cameraCropOutput="true"
app:cameraJpegQuality="100"
app:cameraVideoQuality="480p"
android:adjustViewBounds="true" />
```
|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
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
```
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
<uses-feature
android:name="android.hardware.camera"
android:required="true"/>
```
## 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`.
});
```

@ -9,7 +9,7 @@
<uses-feature
android:name="android.hardware.camera"
android:required="true"/>
android:required="false"/>
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false"/>

@ -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

@ -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;

@ -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);
}

@ -3,26 +3,26 @@
<declare-styleable name="CameraView">
<attr name="ckFacing" format="enum">
<attr name="cameraFacing" format="enum">
<enum name="back" value="0" />
<enum name="front" value="1" />
</attr>
<attr name="ckFlash" format="enum">
<attr name="cameraFlash" format="enum">
<enum name="off" value="0" />
<enum name="on" value="1" />
<enum name="auto" value="2" />
<enum name="torch" value="3" />
</attr>
<attr name="ckFocus" format="enum">
<attr name="cameraFocus" format="enum">
<enum name="off" value="0" />
<enum name="continuous" value="1" />
<enum name="tap" value="2" />
<enum name="tapWithMarker" value="3" />
</attr>
<attr name="ckZoom" format="enum">
<attr name="cameraZoom" format="enum">
<enum name="off" value="0" />
<!-- TODO: Set to unique value when feature added -->
@ -30,23 +30,19 @@
</attr>
<attr name="ckMethod" format="enum">
<attr name="cameraCaptureMethod" format="enum">
<enum name="standard" value="0" />
<enum name="still" value="1" />
<!-- TODO: Set to unique value when feature added -->
<enum name="speed" value="0" />
<enum name="frame" value="1" />
</attr>
<attr name="ckPermissions" format="enum">
<enum name="strict" value="0" />
<enum name="lazy" value="1" />
<enum name="picture" value="2" />
<attr name="cameraPermissionPolicy" format="enum">
<enum name="video" value="0" />
<enum name="picture" value="1" />
</attr>
<attr name="ckJpegQuality" format="integer" />
<attr name="cameraJpegQuality" format="integer" />
<attr name="ckVideoQuality" format="enum">
<attr name="cameraVideoQuality" format="enum">
<enum name="max480p" value="0" />
<enum name="max720p" value="1" />
<enum name="max1080p" value="2" />
@ -56,7 +52,7 @@
<enum name="qvga" value="6" />
</attr>
<attr name="ckCropOutput" format="boolean" />
<attr name="cameraCropOutput" format="boolean" />
<attr name="android:adjustViewBounds" />

@ -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 {
}

Loading…
Cancel
Save