diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
index 68d747b6..3b6a0d5c 100644
--- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
+++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
@@ -8,6 +8,7 @@ import android.media.MediaRecorder;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
+import android.widget.Toast;
import java.io.File;
import java.io.IOException;
@@ -444,7 +445,6 @@ public class Camera1 extends CameraImpl {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (mCamera != null) {
-
Camera.Parameters parameters = mCamera.getParameters();
if (parameters.getMaxNumMeteringAreas() > 0) {
Rect rect = calculateFocusArea(event.getX(), event.getY());
diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java
index 1eb6afd3..1268f701 100644
--- a/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java
+++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraKit.java
@@ -29,6 +29,7 @@ public class CameraKit {
public static final int FOCUS_OFF = 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;
diff --git a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
index 184ac2f9..6bc33083 100644
--- a/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
+++ b/camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
@@ -16,6 +16,8 @@ import android.support.v4.hardware.display.DisplayManagerCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.Display;
+import android.view.MotionEvent;
+import android.view.View;
import android.widget.FrameLayout;
import java.io.ByteArrayOutputStream;
@@ -100,6 +102,21 @@ public class CameraView extends FrameLayout {
mPreviewImpl.setDisplayOrientation(displayOrientation);
}
};
+
+ final FocusMarkerLayout focusMarkerLayout = new FocusMarkerLayout(getContext());
+ addView(focusMarkerLayout);
+ focusMarkerLayout.setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent motionEvent) {
+ int action = motionEvent.getAction();
+ if (motionEvent.getAction() == MotionEvent.ACTION_UP && mFocus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) {
+ focusMarkerLayout.focus(motionEvent.getX(), motionEvent.getY());
+ }
+
+ mPreviewImpl.getView().dispatchTouchEvent(motionEvent);
+ return true;
+ }
+ });
}
@Override
@@ -187,6 +204,11 @@ public class CameraView extends FrameLayout {
public void setFocus(@Focus int focus) {
this.mFocus = focus;
+ if (this.mFocus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) {
+ mCameraImpl.setFocus(CameraKit.Constants.FOCUS_TAP);
+ return;
+ }
+
mCameraImpl.setFocus(mFocus);
}
diff --git a/demo/src/main/java/com/flurgle/camerakit/demo/FocusMarkerLayout.java b/camerakit/src/main/java/com/flurgle/camerakit/FocusMarkerLayout.java
similarity index 97%
rename from demo/src/main/java/com/flurgle/camerakit/demo/FocusMarkerLayout.java
rename to camerakit/src/main/java/com/flurgle/camerakit/FocusMarkerLayout.java
index 0d695f3d..0c45a5b4 100644
--- a/demo/src/main/java/com/flurgle/camerakit/demo/FocusMarkerLayout.java
+++ b/camerakit/src/main/java/com/flurgle/camerakit/FocusMarkerLayout.java
@@ -1,4 +1,4 @@
-package com.flurgle.camerakit.demo;
+package com.flurgle.camerakit;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -16,7 +16,7 @@ public class FocusMarkerLayout extends FrameLayout {
private ImageView mFill;
public FocusMarkerLayout(@NonNull Context context) {
- super(context, null);
+ this(context, null);
}
public FocusMarkerLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
diff --git a/demo/src/main/res/drawable/focus_marker_fill.xml b/camerakit/src/main/res/drawable/focus_marker_fill.xml
similarity index 100%
rename from demo/src/main/res/drawable/focus_marker_fill.xml
rename to camerakit/src/main/res/drawable/focus_marker_fill.xml
diff --git a/demo/src/main/res/drawable/focus_marker_outline.xml b/camerakit/src/main/res/drawable/focus_marker_outline.xml
similarity index 100%
rename from demo/src/main/res/drawable/focus_marker_outline.xml
rename to camerakit/src/main/res/drawable/focus_marker_outline.xml
diff --git a/demo/src/main/res/layout/layout_focus_marker.xml b/camerakit/src/main/res/layout/layout_focus_marker.xml
similarity index 100%
rename from demo/src/main/res/layout/layout_focus_marker.xml
rename to camerakit/src/main/res/layout/layout_focus_marker.xml
diff --git a/camerakit/src/main/res/values/attrs.xml b/camerakit/src/main/res/values/attrs.xml
index a962c7ee..77eecd99 100644
--- a/camerakit/src/main/res/values/attrs.xml
+++ b/camerakit/src/main/res/values/attrs.xml
@@ -17,9 +17,8 @@
-
-
+
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 612c2c62..f8f35610 100644
--- a/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java
+++ b/demo/src/main/java/com/flurgle/camerakit/demo/MainActivity.java
@@ -5,7 +5,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -24,7 +23,6 @@ import java.io.File;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
-import butterknife.OnTouch;
public class MainActivity extends AppCompatActivity implements View.OnLayoutChangeListener {
@@ -34,9 +32,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
@BindView(R.id.camera)
CameraView camera;
- @BindView(R.id.focusMarker)
- FocusMarkerLayout focusMarker;
-
// Capture Mode:
@BindView(R.id.captureModeRadioGroup)
@@ -313,10 +308,4 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
camera.removeOnLayoutChangeListener(this);
}
- @OnTouch(R.id.focusMarker)
- boolean onTouchCamera(View view, MotionEvent motionEvent) {
- focusMarker.focus(motionEvent.getX(), motionEvent.getY());
- return false;
- }
-
}
diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml
index 56335cf3..c18d3c42 100644
--- a/demo/src/main/res/layout/activity_main.xml
+++ b/demo/src/main/res/layout/activity_main.xml
@@ -26,19 +26,10 @@
app:ckCropOutput="false"
app:ckFacing="back"
app:ckFlash="off"
- app:ckFocus="tap"
+ app:ckFocus="tapWithMarker"
app:ckJpegQuality="100"
app:ckMethod="standard" />
-
-