diff --git a/README.md b/README.md
index 9cedc12c..07ab1352 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ CameraKit is an easy to use utility to work with the Android Camera APIs. Everyt
- [cameraFlash](#cameraflash)
- [cameraFocus](#camerafocus)
- [cameraCaptureMethod](#cameracapturemethod)
- - [cameraZoom](#camerazoom)
+ - [cameraZoomMode](#camerazoommode)
- [cameraCropOutput](#cameracropoutput)
- [cameraJpegQuality](#camerajpegquality)
- [Permissions Behavior](#permissions-behavior)
@@ -166,7 +166,7 @@ camera.setCameraListener(new CameraListener() {
|[`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`|
+|[`cameraZoomMode`](#camerazoommode)|`setZoom()`|`off` `pinch`|`off`|
|[`cameraPermissionPolicy`](#camerapermissionpolicy)|`setPermissionPolicy()`|`picture` `video`|`picture`|
|[`cameraCropOutput`](#cameracropoutput)|`setCropOutput()`|`true` `false`|`false`|
|[`cameraJpegQuality`](#camerajpegquality)|`setJpegQuality()`|`0 <= n <= 100`|`100`|
@@ -213,7 +213,7 @@ cameraView.setMethod(CameraKit.Constants.CAPTURE_METHOD_STANDARD);
cameraView.setMethod(CameraKit.Constants.CAPTURE_METHOD_FRAME);
```
-### cameraZoom
+### cameraZoomMode
TODO: work in progress. Right now 'off' is the onlly option.
diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
index 25885e47..3c6d9990 100644
--- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
+++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
@@ -54,16 +54,18 @@ class Camera1 extends CameraImpl {
@Flash private int mFlash;
@Focus private int mFocus;
@Method private int mMethod;
- @Zoom private int mZoom;
+ @ZoomMode private int mZoom;
@VideoQuality private int mVideoQuality;
+ private double mLatitude;
+ private double mLongitude;
private Handler mHandler = new Handler();
Camera1(CameraListener callback, PreviewImpl preview) {
super(callback, preview);
- preview.setCallback(new PreviewImpl.OnSurfaceChangedCallback() {
+ preview.setCallback(new PreviewImpl.OnPreviewSurfaceChangedCallback() {
@Override
- public void onSurfaceChanged() {
+ public void onPreviewSurfaceChanged() {
if (mCamera != null) {
setupPreview();
collectCameraSizes();
@@ -121,6 +123,17 @@ class Camera1 extends CameraImpl {
this.mDeviceOrientation = deviceOrientation;
}
+ @Override
+ void setLocation(double latitude, double longitude) {
+ mLatitude = latitude;
+ mLongitude = longitude;
+ if (mCameraParameters != null) {
+ mCameraParameters.setGpsLatitude(latitude);
+ mCameraParameters.setGpsLongitude(longitude);
+ mCamera.setParameters(mCameraParameters);
+ }
+ }
+
@Override
void setFacing(@Facing int facing) {
int internalFacing = new ConstantMapper.Facing(facing).map();
@@ -214,7 +227,7 @@ class Camera1 extends CameraImpl {
}
@Override
- void setZoom(@Zoom int zoom) {
+ void setZoom(@ZoomMode int zoom) {
this.mZoom = zoom;
}
@@ -373,7 +386,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.OnSurfaceChangedCallback} should be called,
+ * But when it does, the {@link PreviewImpl.OnPreviewSurfaceChangedCallback} should be called,
* and this should be refreshed.
*
*
@@ -406,6 +419,7 @@ class Camera1 extends CameraImpl {
// mCameraParameters.setRotation(rotation);
setFocus(mFocus);
setFlash(mFlash);
+ setLocation(mLatitude, mLongitude);
mCamera.setParameters(mCameraParameters);
}
diff --git a/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java b/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java
index 73bec674..92be2aa6 100644
--- a/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java
+++ b/camerakit/src/main/api21/com/flurgle/camerakit/Camera2.java
@@ -35,9 +35,9 @@ class Camera2 extends CameraImpl {
Camera2(CameraListener callback, PreviewImpl preview, Context context) {
super(callback, preview);
- preview.setCallback(new PreviewImpl.OnSurfaceChangedCallback() {
+ preview.setCallback(new PreviewImpl.OnPreviewSurfaceChangedCallback() {
@Override
- public void onSurfaceChanged() {
+ public void onPreviewSurfaceChanged() {
}
});
@@ -65,8 +65,8 @@ class Camera2 extends CameraImpl {
float w = size.getWidth();
float h = size.getHeight();
mCameraPropertyMap.put(cameraId, new CameraProperties(
- (float) Math.toDegrees(2*Math.atan(size.getWidth()/(maxFocus[0]*2))),
- (float) Math.toDegrees(2*Math.atan(size.getHeight()/(maxFocus[0]*2)))
+ (float) Math.toDegrees(2*Math.atan(w/(maxFocus[0]*2))),
+ (float) Math.toDegrees(2*Math.atan(h/(maxFocus[0]*2)))
));
}
}
@@ -155,7 +155,12 @@ class Camera2 extends CameraImpl {
}
@Override
- void setZoom(@Zoom int zoom) {
+ void setZoom(@ZoomMode int zoom) {
+
+ }
+
+ @Override
+ void setLocation(double latitude, double longitude) {
}
diff --git a/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java
index 6bdc0cd3..fe854e4f 100644
--- a/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java
+++ b/camerakit/src/main/base/com/flurgle/camerakit/CameraImpl.java
@@ -22,8 +22,9 @@ abstract class CameraImpl {
abstract void setFlash(@Flash int flash);
abstract void setFocus(@Focus int focus);
abstract void setMethod(@Method int method);
- abstract void setZoom(@Zoom int zoom);
+ abstract void setZoom(@ZoomMode int zoom);
abstract void setVideoQuality(@VideoQuality int videoQuality);
+ abstract void setLocation(double latitude, double longitude);
abstract void captureImage();
abstract void startVideo();
diff --git a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java
index 096e864a..e5f2320f 100644
--- a/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java
+++ b/camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java
@@ -1,18 +1,17 @@
package com.flurgle.camerakit;
import android.graphics.SurfaceTexture;
-import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;
abstract class PreviewImpl {
- interface OnSurfaceChangedCallback {
- void onSurfaceChanged();
+ interface OnPreviewSurfaceChangedCallback {
+ void onPreviewSurfaceChanged();
}
- private OnSurfaceChangedCallback mOnSurfaceChangedCallback;
+ private OnPreviewSurfaceChangedCallback mOnPreviewSurfaceChangedCallback;
// As far as I can see, these are the view/surface dimensions.
// This live in the 'View' orientation.
@@ -23,8 +22,8 @@ abstract class PreviewImpl {
private int mDesiredWidth;
private int mDesiredHeight;
- void setCallback(OnSurfaceChangedCallback callback) {
- mOnSurfaceChangedCallback = callback;
+ void setCallback(OnPreviewSurfaceChangedCallback callback) {
+ mOnPreviewSurfaceChangedCallback = callback;
}
abstract Surface getSurface();
@@ -39,7 +38,7 @@ abstract class PreviewImpl {
abstract boolean isReady();
protected void dispatchSurfaceChanged() {
- mOnSurfaceChangedCallback.onSurfaceChanged();
+ mOnPreviewSurfaceChangedCallback.onPreviewSurfaceChanged();
}
SurfaceHolder getSurfaceHolder() {
@@ -51,8 +50,7 @@ abstract class PreviewImpl {
}
// As far as I can see, these are the view/surface dimensions.
- // This is called by subclasses. 1080, 1794 -- 1080, 1440
-
+ // This is called by subclasses.
protected void setSurfaceSize(int width, int height) {
this.mSurfaceWidth = width;
this.mSurfaceHeight = height;
@@ -60,7 +58,8 @@ abstract class PreviewImpl {
}
// As far as I can see, these are the actual preview dimensions, as set in CameraParameters.
- // This is called by the CameraImpl. 1200, 1600
+ // This is called by the CameraImpl.
+ // These must be alredy rotated, if needed, to be consistent with surface/view sizes.
void setDesiredSize(int width, int height) {
this.mDesiredWidth = width;
this.mDesiredHeight = height;
diff --git a/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java b/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java
index 36d14776..29f66f1d 100644
--- a/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java
+++ b/camerakit/src/main/base/com/flurgle/camerakit/TextureViewPreview.java
@@ -45,7 +45,7 @@ class TextureViewPreview extends PreviewImpl {
@Override
Surface getSurface() {
- return new Surface(mTextureView.getSurfaceTexture());
+ return new Surface(getSurfaceTexture());
}
@Override
@@ -60,7 +60,7 @@ class TextureViewPreview extends PreviewImpl {
@Override
boolean isReady() {
- return mTextureView.getSurfaceTexture() != null;
+ return getSurfaceTexture() != null;
}
@Override
diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
index 6dd8f15c..4fedc6f2 100644
--- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
+++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
@@ -80,7 +80,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
@Flash private int mFlash;
@Focus private int mFocus;
@Method private int mMethod;
- @Zoom private int mZoom;
+ @ZoomMode
+ private int mZoom;
@Permissions private int mPermissions;
@VideoQuality private int mVideoQuality;
private int mJpegQuality;
@@ -113,7 +114,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
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);
+ mZoom = a.getInteger(R.styleable.CameraView_cameraZoomMode, 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);
@@ -355,6 +356,16 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
return mCameraImpl.getCameraProperties();
}
+
+ /**
+ * Set location coordinates to be found later in the jpeg EXIF header
+ * @param latitude current latitude
+ * @param longitude current longitude
+ */
+ public void setLocation(double latitude, double longitude) {
+ mCameraImpl.setLocation(latitude, longitude);
+ }
+
@Facing
public int getFacing() {
return mFacing;
@@ -396,7 +407,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
mCameraImpl.setMethod(mMethod);
}
- public void setZoom(@Zoom int zoom) {
+ public void setZoom(@ZoomMode int zoom) {
this.mZoom = zoom;
mCameraImpl.setZoom(mZoom);
}
diff --git a/camerakit/src/main/res/layout/texture_view.xml b/camerakit/src/main/res/layout/texture_view.xml
index 33a5cdb9..4714b43c 100644
--- a/camerakit/src/main/res/layout/texture_view.xml
+++ b/camerakit/src/main/res/layout/texture_view.xml
@@ -3,6 +3,7 @@
diff --git a/camerakit/src/main/res/values/attrs.xml b/camerakit/src/main/res/values/attrs.xml
index 52604949..ff6fdda3 100644
--- a/camerakit/src/main/res/values/attrs.xml
+++ b/camerakit/src/main/res/values/attrs.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/camerakit/src/main/types/com/flurgle/camerakit/Zoom.java b/camerakit/src/main/types/com/flurgle/camerakit/Zoom.java
deleted file mode 100644
index 57f77116..00000000
--- a/camerakit/src/main/types/com/flurgle/camerakit/Zoom.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.flurgle.camerakit;
-
-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;
-
-@Retention(RetentionPolicy.SOURCE)
-@IntDef({ZOOM_OFF, ZOOM_PINCH})
-public @interface Zoom {
-}