Removed deprecated classes

pull/1/head
Mattia Iavarone 7 years ago
parent c967eeae68
commit cb53602daf
  1. 33
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraConstants.java
  2. 6
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java
  3. 17
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  4. 17
      cameraview/src/main/options/com/otaliastudios/cameraview/Focus.java
  5. 15
      cameraview/src/main/options/com/otaliastudios/cameraview/Method.java
  6. 15
      cameraview/src/main/options/com/otaliastudios/cameraview/Permissions.java
  7. 15
      cameraview/src/main/options/com/otaliastudios/cameraview/ZoomMode.java
  8. 85
      cameraview/src/main/views/com/otaliastudios/cameraview/FocusMarkerLayout.java
  9. 101
      cameraview/src/main/views/com/otaliastudios/cameraview/PinchToZoomLayout.java
  10. 18
      demo/src/main/java/com/otaliastudios/cameraview/demo/MainActivity.java
  11. 53
      demo/src/main/res/layout/activity_main.xml

@ -6,14 +6,9 @@ public class CameraConstants {
public static final int PERMISSION_REQUEST_CODE = 16; public static final int PERMISSION_REQUEST_CODE = 16;
@Deprecated public static final int GESTURE_ACTION_NONE = 0; @Deprecated public static final int GESTURE_ACTION_NONE = 0;
@Deprecated public static final int GESTURE_ACTION_FOCUS = 1;
@Deprecated public static final int GESTURE_ACTION_FOCUS_WITH_MARKER = 2;
@Deprecated public static final int GESTURE_ACTION_CAPTURE = 3;
@Deprecated public static final int GESTURE_ACTION_ZOOM = 4;
@Deprecated public static final int GESTURE_ACTION_AE_CORRECTION = 5;
@Deprecated public static final int FACING_BACK = 0; @Deprecated public static final int FACING_BACK = 0;
@Deprecated public static final int FACING_FRONT = 1; @Deprecated public static final int FOCUS_CONTINUOUS = 1;
@Deprecated public static final int ZOOM_OFF = 0;
public static final int FLASH_OFF = 0; public static final int FLASH_OFF = 0;
public static final int FLASH_ON = 1; public static final int FLASH_ON = 1;
@ -42,24 +37,20 @@ public class CameraConstants {
public static final int WHITE_BALANCE_DAYLIGHT = 3; public static final int WHITE_BALANCE_DAYLIGHT = 3;
public static final int WHITE_BALANCE_CLOUDY = 4; public static final int WHITE_BALANCE_CLOUDY = 4;
@Deprecated public static final int FOCUS_FIXED = 0;
@Deprecated public static final int FOCUS_CONTINUOUS = 1;
@Deprecated public static final int FOCUS_TAP = 2;
@Deprecated public static final int FOCUS_TAP_WITH_MARKER = 3;
@Deprecated public static final int ZOOM_OFF = 0;
@Deprecated public static final int ZOOM_PINCH = 1;
@Deprecated public static final int CAPTURE_METHOD_STANDARD = 0;
@Deprecated public static final int CAPTURE_METHOD_FRAME = 1;
@Deprecated public static final int PERMISSIONS_VIDEO = 0;
@Deprecated public static final int PERMISSIONS_PICTURE = 1;
static class Defaults { static class Defaults {
// TODO: Move to enum classes
static final int DEFAULT_GESTURE_ACTION_TAP = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_TAP = GESTURE_ACTION_NONE;
// WIP static final int DEFAULT_GESTURE_ACTION_DOUBLE_TAP = GESTURE_ACTION_NONE;
static final int DEFAULT_GESTURE_ACTION_LONG_TAP = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_LONG_TAP = GESTURE_ACTION_NONE;
static final int DEFAULT_GESTURE_ACTION_PINCH = GESTURE_ACTION_NONE; static final int DEFAULT_GESTURE_ACTION_PINCH = GESTURE_ACTION_NONE;
static final int DEFAULT_FACING = FACING_BACK; static final int DEFAULT_FACING = FACING_BACK;
// Deprecated
@Deprecated static final int DEFAULT_FOCUS = FOCUS_CONTINUOUS;
@Deprecated static final int DEFAULT_ZOOM = ZOOM_OFF;
// OK
static final int DEFAULT_FLASH = FLASH_OFF; static final int DEFAULT_FLASH = FLASH_OFF;
static final int DEFAULT_VIDEO_QUALITY = VIDEO_QUALITY_480P; static final int DEFAULT_VIDEO_QUALITY = VIDEO_QUALITY_480P;
static final int DEFAULT_WHITE_BALANCE = WHITE_BALANCE_AUTO; static final int DEFAULT_WHITE_BALANCE = WHITE_BALANCE_AUTO;
@ -68,10 +59,6 @@ public class CameraConstants {
static final int DEFAULT_GRID = GRID_OFF; static final int DEFAULT_GRID = GRID_OFF;
static final boolean DEFAULT_CROP_OUTPUT = false; static final boolean DEFAULT_CROP_OUTPUT = false;
@Deprecated static final int DEFAULT_FOCUS = FOCUS_CONTINUOUS;
@Deprecated static final int DEFAULT_ZOOM = ZOOM_OFF;
@Deprecated static final int DEFAULT_METHOD = CAPTURE_METHOD_STANDARD;
@Deprecated static final int DEFAULT_PERMISSIONS = PERMISSIONS_PICTURE;
} }
} }

@ -13,7 +13,6 @@ abstract class CameraController implements Preview.SurfaceCallback {
protected Facing mFacing; protected Facing mFacing;
@Flash protected int mFlash; @Flash protected int mFlash;
@Focus protected int mFocus;
@VideoQuality protected int mVideoQuality; @VideoQuality protected int mVideoQuality;
@WhiteBalance protected int mWhiteBalance; @WhiteBalance protected int mWhiteBalance;
@SessionType protected int mSessionType; @SessionType protected int mSessionType;
@ -63,11 +62,6 @@ abstract class CameraController implements Preview.SurfaceCallback {
return mFlash; return mFlash;
} }
@Focus
final int getFocus() {
return mFocus;
}
@WhiteBalance @WhiteBalance
final int getWhiteBalance() { final int getWhiteBalance() {
return mWhiteBalance; return mWhiteBalance;

@ -1314,7 +1314,7 @@ public class CameraView extends FrameLayout {
* @param focus no-op * @param focus no-op
*/ */
@Deprecated @Deprecated
public void setFocus(@Focus int focus) { public void setFocus(int focus) {
} }
@ -1324,9 +1324,8 @@ public class CameraView extends FrameLayout {
* @deprecated * @deprecated
*/ */
@Deprecated @Deprecated
@Focus
public int getFocus() { public int getFocus() {
return FOCUS_FIXED; return Defaults.DEFAULT_FOCUS;
} }
@ -1336,7 +1335,7 @@ public class CameraView extends FrameLayout {
* @param method no-op * @param method no-op
*/ */
@Deprecated @Deprecated
public void setCaptureMethod(@Method int method) {} public void setCaptureMethod(int method) {}
/** /**
@ -1345,20 +1344,17 @@ public class CameraView extends FrameLayout {
* @param permissions no-op * @param permissions no-op
*/ */
@Deprecated @Deprecated
public void setPermissionPolicy(@Permissions int permissions) {} public void setPermissionPolicy(int permissions) {}
/** /**
* Sets the zoom mode for the current session. * Sets the zoom mode for the current session.
* *
* @see CameraConstants#ZOOM_OFF
* @see CameraConstants#ZOOM_PINCH
*
* @param zoom no-op * @param zoom no-op
* @deprecated use {@link #mapGesture(Gesture, GestureAction)} to map zoom control to gestures * @deprecated use {@link #mapGesture(Gesture, GestureAction)} to map zoom control to gestures
*/ */
@Deprecated @Deprecated
public void setZoomMode(@ZoomMode int zoom) { public void setZoomMode(int zoom) {
} }
@ -1367,10 +1363,9 @@ public class CameraView extends FrameLayout {
* @return no-op * @return no-op
* @deprecated use {@link #mapGesture(Gesture, GestureAction)} to map zoom control to gestures * @deprecated use {@link #mapGesture(Gesture, GestureAction)} to map zoom control to gestures
*/ */
@ZoomMode
@Deprecated @Deprecated
public int getZoomMode() { public int getZoomMode() {
return ZOOM_OFF; return Defaults.DEFAULT_ZOOM;
} }
} }

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

@ -41,10 +41,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
@BindView(R.id.cropModeRadioGroup) @BindView(R.id.cropModeRadioGroup)
RadioGroup cropModeRadioGroup; RadioGroup cropModeRadioGroup;
// Pinch to zoom:
@BindView(R.id.zoomModeRadioGroup)
RadioGroup zoomModeRadioGroup;
// Video Quality: // Video Quality:
@BindView(R.id.videoQualityRadioGroup) @BindView(R.id.videoQualityRadioGroup)
RadioGroup videoQualityRadioGroup; RadioGroup videoQualityRadioGroup;
@ -100,7 +96,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
heightModeRadioGroup.setOnCheckedChangeListener(heightModeChangedListener); heightModeRadioGroup.setOnCheckedChangeListener(heightModeChangedListener);
videoQualityRadioGroup.setOnCheckedChangeListener(videoQualityChangedListener); videoQualityRadioGroup.setOnCheckedChangeListener(videoQualityChangedListener);
gridModeRadioGroup.setOnCheckedChangeListener(gridModeChangedListener); gridModeRadioGroup.setOnCheckedChangeListener(gridModeChangedListener);
zoomModeRadioGroup.setOnCheckedChangeListener(zoomModeChangedListener);
camera.addOnLayoutChangeListener(this); camera.addOnLayoutChangeListener(this);
camera.addCameraListener(new CameraListener() { camera.addCameraListener(new CameraListener() {
@ -274,19 +269,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLayoutChan
}; };
RadioGroup.OnCheckedChangeListener zoomModeChangedListener = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int zoom = CameraConstants.ZOOM_OFF;
switch (checkedId) {
case R.id.zoomModeOff: zoom = CameraConstants.ZOOM_OFF; break;
case R.id.zoomModePinch: zoom = CameraConstants.ZOOM_PINCH; break;
}
camera.setZoomMode(zoom);
message("Zoom mode changed! Note that pinch-to-zoom won't work well in ScrollViews like here", true);
}
};
@OnClick(R.id.widthUpdate) @OnClick(R.id.widthUpdate)
void widthUpdateClicked() { void widthUpdateClicked() {
if (mCapturingPicture) return; if (mCapturingPicture) return;

@ -197,59 +197,6 @@
</FrameLayout> </FrameLayout>
<!-- Pinch to zoom -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<View
android:layout_width="2.5dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="ZOOM MODE"
android:textColor="@android:color/black"
android:textSize="14sp"
android:textStyle="bold" />
<RadioGroup
android:id="@+id/zoomModeRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:checkedButton="@+id/zoomModeOff"
android:orientation="horizontal">
<RadioButton
android:id="@+id/zoomModeOff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Off" />
<RadioButton
android:id="@+id/zoomModePinch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Pinch to zoom" />
</RadioGroup>
</LinearLayout>
</FrameLayout>
<!-- Width --> <!-- Width -->
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

Loading…
Cancel
Save