parent
c967eeae68
commit
cb53602daf
@ -1,17 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.support.annotation.IntDef; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
|
||||
import static com.otaliastudios.cameraview.CameraConstants.FOCUS_TAP; |
||||
import static com.otaliastudios.cameraview.CameraConstants.FOCUS_FIXED; |
||||
import static com.otaliastudios.cameraview.CameraConstants.FOCUS_CONTINUOUS; |
||||
import static com.otaliastudios.cameraview.CameraConstants.FOCUS_TAP_WITH_MARKER; |
||||
|
||||
@Retention(RetentionPolicy.SOURCE) |
||||
@IntDef({FOCUS_CONTINUOUS, FOCUS_TAP, FOCUS_FIXED, FOCUS_TAP_WITH_MARKER}) |
||||
@Deprecated |
||||
public @interface Focus { |
||||
} |
@ -1,15 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.support.annotation.IntDef; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
|
||||
import static com.otaliastudios.cameraview.CameraConstants.CAPTURE_METHOD_STANDARD; |
||||
import static com.otaliastudios.cameraview.CameraConstants.CAPTURE_METHOD_FRAME; |
||||
|
||||
@Deprecated |
||||
@Retention(RetentionPolicy.SOURCE) |
||||
@IntDef({CAPTURE_METHOD_STANDARD, CAPTURE_METHOD_FRAME}) |
||||
public @interface Method { |
||||
} |
@ -1,15 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.support.annotation.IntDef; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
|
||||
import static com.otaliastudios.cameraview.CameraConstants.PERMISSIONS_PICTURE; |
||||
import static com.otaliastudios.cameraview.CameraConstants.PERMISSIONS_VIDEO; |
||||
|
||||
@Deprecated |
||||
@Retention(RetentionPolicy.SOURCE) |
||||
@IntDef({PERMISSIONS_VIDEO, PERMISSIONS_PICTURE}) |
||||
public @interface Permissions { |
||||
} |
@ -1,15 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.support.annotation.IntDef; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
|
||||
import static com.otaliastudios.cameraview.CameraConstants.ZOOM_OFF; |
||||
import static com.otaliastudios.cameraview.CameraConstants.ZOOM_PINCH; |
||||
|
||||
@Retention(RetentionPolicy.SOURCE) |
||||
@IntDef({ZOOM_OFF, ZOOM_PINCH}) |
||||
@Deprecated |
||||
public @interface ZoomMode { |
||||
} |
@ -1,85 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.animation.Animator; |
||||
import android.animation.AnimatorListenerAdapter; |
||||
import android.content.Context; |
||||
import android.support.annotation.NonNull; |
||||
import android.support.annotation.Nullable; |
||||
import android.util.AttributeSet; |
||||
import android.view.LayoutInflater; |
||||
import android.view.MotionEvent; |
||||
import android.widget.FrameLayout; |
||||
import android.widget.ImageView; |
||||
|
||||
@Deprecated |
||||
class FocusMarkerLayout extends FrameLayout { |
||||
|
||||
private FrameLayout mFocusMarkerContainer; |
||||
private ImageView mFill; |
||||
private boolean mEnabled; |
||||
|
||||
public FocusMarkerLayout(@NonNull Context context) { |
||||
this(context, null); |
||||
} |
||||
|
||||
public FocusMarkerLayout(@NonNull Context context, @Nullable AttributeSet attrs) { |
||||
super(context, attrs); |
||||
LayoutInflater.from(getContext()).inflate(R.layout.layout_focus_marker, this); |
||||
|
||||
mFocusMarkerContainer = (FrameLayout) findViewById(R.id.focusMarkerContainer); |
||||
mFill = (ImageView) findViewById(R.id.fill); |
||||
mFocusMarkerContainer.setAlpha(0); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onTouchEvent(MotionEvent event) { |
||||
int action = event.getAction(); |
||||
if (action == MotionEvent.ACTION_UP && mEnabled) { |
||||
focus(event.getX(), event.getY()); |
||||
return true; |
||||
} |
||||
return false; // We didn't consume, pass
|
||||
} |
||||
|
||||
public void focus(float mx, float my) { |
||||
int x = (int) (mx - mFocusMarkerContainer.getWidth() / 2); |
||||
int y = (int) (my - mFocusMarkerContainer.getWidth() / 2); |
||||
|
||||
mFocusMarkerContainer.setTranslationX(x); |
||||
mFocusMarkerContainer.setTranslationY(y); |
||||
|
||||
mFocusMarkerContainer.animate().setListener(null).cancel(); |
||||
mFill.animate().setListener(null).cancel(); |
||||
|
||||
mFill.setScaleX(0); |
||||
mFill.setScaleY(0); |
||||
mFill.setAlpha(1f); |
||||
|
||||
mFocusMarkerContainer.setScaleX(1.36f); |
||||
mFocusMarkerContainer.setScaleY(1.36f); |
||||
mFocusMarkerContainer.setAlpha(1f); |
||||
|
||||
mFocusMarkerContainer.animate().scaleX(1).scaleY(1).setStartDelay(0).setDuration(330) |
||||
.setListener(new AnimatorListenerAdapter() { |
||||
@Override |
||||
public void onAnimationEnd(Animator animation) { |
||||
super.onAnimationEnd(animation); |
||||
mFocusMarkerContainer.animate().alpha(0).setStartDelay(750).setDuration(800).setListener(null).start(); |
||||
} |
||||
}).start(); |
||||
|
||||
mFill.animate().scaleX(1).scaleY(1).setDuration(330) |
||||
.setListener(new AnimatorListenerAdapter() { |
||||
@Override |
||||
public void onAnimationEnd(Animator animation) { |
||||
super.onAnimationEnd(animation); |
||||
mFill.animate().alpha(0).setDuration(800).setListener(null).start(); |
||||
} |
||||
}).start(); |
||||
} |
||||
|
||||
|
||||
public void enable(boolean enable) { |
||||
mEnabled = enable; |
||||
} |
||||
} |
@ -1,101 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.content.Context; |
||||
import android.graphics.PointF; |
||||
import android.os.Build; |
||||
import android.support.annotation.NonNull; |
||||
import android.support.annotation.Nullable; |
||||
import android.util.AttributeSet; |
||||
import android.view.MotionEvent; |
||||
import android.view.ScaleGestureDetector; |
||||
import android.view.View; |
||||
|
||||
@Deprecated |
||||
class PinchToZoomLayout extends View { |
||||
|
||||
|
||||
private ScaleGestureDetector mDetector; |
||||
private boolean mNotify; |
||||
private boolean mEnabled; |
||||
@ZoomMode private int mZoomMode; |
||||
private float mZoom = 0; |
||||
private PointF[] mPoints = new PointF[]{ |
||||
new PointF(0, 0), |
||||
new PointF(0, 0) |
||||
}; |
||||
|
||||
public PinchToZoomLayout(@NonNull Context context) { |
||||
this(context, null); |
||||
} |
||||
|
||||
public PinchToZoomLayout(@NonNull Context context, @Nullable AttributeSet attrs) { |
||||
super(context, attrs); |
||||
mDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() { |
||||
@Override |
||||
public boolean onScale(ScaleGestureDetector detector) { |
||||
mNotify = true; |
||||
mZoom += ((detector.getScaleFactor() - 1) * 2); |
||||
if (mZoom < 0) mZoom = 0; |
||||
if (mZoom > 1) mZoom = 1; |
||||
return true; |
||||
} |
||||
}); |
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) { |
||||
mDetector.setQuickScaleEnabled(false); |
||||
} |
||||
} |
||||
|
||||
@ZoomMode |
||||
public int getZoomMode() { |
||||
return mZoomMode; |
||||
} |
||||
|
||||
public void setZoomMode(@ZoomMode int zoomMode) { |
||||
mZoomMode = zoomMode; |
||||
} |
||||
|
||||
public float getZoom() { |
||||
return mZoom; |
||||
} |
||||
|
||||
public void onExternalZoom(float zoom) { |
||||
mZoom = zoom; |
||||
} |
||||
|
||||
public PointF[] getPoints() { |
||||
return mPoints; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onTouchEvent(MotionEvent event) { |
||||
if (mZoomMode != CameraConstants.ZOOM_PINCH) return false; |
||||
if (!mEnabled) return false; |
||||
|
||||
// Reset the mNotify flag on a new gesture.
|
||||
// This is to ensure that the mNotify flag stays on until the
|
||||
// previous gesture ends.
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) { |
||||
mNotify = false; |
||||
} |
||||
|
||||
// Let's see if we detect something. This will call onScale().
|
||||
mDetector.onTouchEvent(event); |
||||
|
||||
// Keep notifying CameraView as long as the gesture goes.
|
||||
if (mNotify) { |
||||
mPoints[0].x = event.getX(0); |
||||
mPoints[0].y = event.getY(0); |
||||
if (event.getPointerCount() > 1) { |
||||
mPoints[1].x = event.getX(1); |
||||
mPoints[1].y = event.getY(1); |
||||
} |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public void enable(boolean enable) { |
||||
mEnabled = enable; |
||||
} |
||||
} |
Loading…
Reference in new issue