Merge remote-tracking branch 'origin/master'

pull/10/head
Mattia Iavarone 8 years ago
commit a58374c34f
  1. 2
      README.md
  2. 2
      cameraview/build.gradle
  3. 27
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  4. 8
      cameraview/src/main/views/com/otaliastudios/cameraview/ScrollGestureLayout.java

@ -7,7 +7,7 @@
CameraView is a well documented, high-level library that makes capturing pictures and videos easy, addressing most of the common issues and needs, and still leaving you with flexibility where needed. CameraView is a well documented, high-level library that makes capturing pictures and videos easy, addressing most of the common issues and needs, and still leaving you with flexibility where needed.
```groovy ```groovy
compile 'com.otaliastudios:cameraview:1.1.3' compile 'com.otaliastudios:cameraview:1.1.4'
``` ```
<p> <p>

@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'
// Required by bintray // Required by bintray
version = '1.1.3' version = '1.1.4'
group = 'com.otaliastudios' group = 'com.otaliastudios'
android { android {

@ -250,7 +250,7 @@ public class CameraView extends FrameLayout {
final float previewHeight = flip ? previewSize.getWidth() : previewSize.getHeight(); final float previewHeight = flip ? previewSize.getWidth() : previewSize.getHeight();
// If MATCH_PARENT is interpreted as AT_MOST, transform to EXACTLY // If MATCH_PARENT is interpreted as AT_MOST, transform to EXACTLY
// to be consistent with our semantics. // to be consistent with our semantics (and our docs).
final ViewGroup.LayoutParams lp = getLayoutParams(); final ViewGroup.LayoutParams lp = getLayoutParams();
if (widthMode == AT_MOST && lp.width == MATCH_PARENT) widthMode = EXACTLY; if (widthMode == AT_MOST && lp.width == MATCH_PARENT) widthMode = EXACTLY;
if (heightMode == AT_MOST && lp.height == MATCH_PARENT) heightMode = EXACTLY; if (heightMode == AT_MOST && lp.height == MATCH_PARENT) heightMode = EXACTLY;
@ -262,7 +262,7 @@ public class CameraView extends FrameLayout {
// If we have fixed dimensions (either 300dp or MATCH_PARENT), there's nothing we should do, // If we have fixed dimensions (either 300dp or MATCH_PARENT), there's nothing we should do,
// other than respect it. The preview will eventually be cropped at the sides (by PreviewImpl scaling) // other than respect it. The preview will eventually be cropped at the sides (by PreviewImpl scaling)
// except the case in which these fixed dimensions somehow fit exactly the preview aspect ratio. // except the case in which these fixed dimensions manage to fit exactly the preview aspect ratio.
if (widthMode == EXACTLY && heightMode == EXACTLY) { if (widthMode == EXACTLY && heightMode == EXACTLY) {
Log.e(TAG, "onMeasure, both are MATCH_PARENT or fixed value. We adapt. This means CROP_INSIDE. " + Log.e(TAG, "onMeasure, both are MATCH_PARENT or fixed value. We adapt. This means CROP_INSIDE. " +
"(" + widthValue + "x" + heightValue + ")"); "(" + widthValue + "x" + heightValue + ")");
@ -273,17 +273,20 @@ public class CameraView extends FrameLayout {
// If both dimensions are free, with no limits, then our size will be exactly the // If both dimensions are free, with no limits, then our size will be exactly the
// preview size. This can happen rarely, for example in scrollable containers. // preview size. This can happen rarely, for example in scrollable containers.
if (widthMode == UNSPECIFIED && heightMode == UNSPECIFIED) { if (widthMode == UNSPECIFIED && heightMode == UNSPECIFIED) {
Log.e(TAG, "onMeasure, both are completely free. We respect that and extend to the whole preview size. " + Log.e(TAG, "onMeasure, both are completely free. " +
"We respect that and extend to the whole preview size. " +
"(" + previewWidth + "x" + previewHeight + ")"); "(" + previewWidth + "x" + previewHeight + ")");
super.onMeasure(MeasureSpec.makeMeasureSpec((int) previewWidth, EXACTLY), super.onMeasure(
MeasureSpec.makeMeasureSpec((int) previewWidth, EXACTLY),
MeasureSpec.makeMeasureSpec((int) previewHeight, EXACTLY)); MeasureSpec.makeMeasureSpec((int) previewHeight, EXACTLY));
return; return;
} }
// It sure now that at least one dimension can be determined (either because EXACTLY or AT_MOST). // It's sure now that at least one dimension can be determined (either because EXACTLY or AT_MOST).
// This starts to seem a pleasant situation. // This starts to seem a pleasant situation.
// If one of the dimension is completely free, take the other and fit the ratio. // If one of the dimension is completely free (e.g. in a scrollable container),
// take the other and fit the ratio.
// One of the two might be AT_MOST, but we use the value anyway. // One of the two might be AT_MOST, but we use the value anyway.
float ratio = previewHeight / previewWidth; float ratio = previewHeight / previewWidth;
if (widthMode == UNSPECIFIED || heightMode == UNSPECIFIED) { if (widthMode == UNSPECIFIED || heightMode == UNSPECIFIED) {
@ -326,7 +329,7 @@ public class CameraView extends FrameLayout {
// Last case, AT_MOST and AT_MOST. Here we can SURELY fit the aspect ratio by filling one // Last case, AT_MOST and AT_MOST. Here we can SURELY fit the aspect ratio by filling one
// dimension and adapting the other. // dimension and adapting the other.
int height, width; int height, width;
float atMostRatio = heightValue / widthValue; float atMostRatio = (float) heightValue / (float) widthValue;
if (atMostRatio >= ratio) { if (atMostRatio >= ratio) {
// We must reduce height. // We must reduce height.
width = widthValue; width = widthValue;
@ -412,13 +415,13 @@ public class CameraView extends FrameLayout {
// Pass to our own GestureLayouts // Pass to our own GestureLayouts
CameraOptions options = mCameraController.getCameraOptions(); // Non null CameraOptions options = mCameraController.getCameraOptions(); // Non null
if (mPinchGestureLayout.onTouchEvent(event)) { if (mPinchGestureLayout.onTouchEvent(event)) {
Log.e(TAG, "pinch!"); // Log.e(TAG, "pinch!");
onGesture(mPinchGestureLayout, options); onGesture(mPinchGestureLayout, options);
} else if (mScrollGestureLayout.onTouchEvent(event)) { } else if (mScrollGestureLayout.onTouchEvent(event)) {
Log.e(TAG, "scroll!"); // Log.e(TAG, "scroll!");
onGesture(mScrollGestureLayout, options); onGesture(mScrollGestureLayout, options);
} else if (mTapGestureLayout.onTouchEvent(event)) { } else if (mTapGestureLayout.onTouchEvent(event)) {
Log.e(TAG, "tap!"); // Log.e(TAG, "tap!");
onGesture(mTapGestureLayout, options); onGesture(mTapGestureLayout, options);
} }
return true; return true;
@ -1249,8 +1252,8 @@ public class CameraView extends FrameLayout {
int w = consistentWithView ? getWidth() : getHeight(); int w = consistentWithView ? getWidth() : getHeight();
int h = consistentWithView ? getHeight() : getWidth(); int h = consistentWithView ? getHeight() : getWidth();
AspectRatio targetRatio = AspectRatio.of(w, h); AspectRatio targetRatio = AspectRatio.of(w, h);
Log.e(TAG, "is Consistent? " + consistentWithView); // Log.e(TAG, "is Consistent? " + consistentWithView);
Log.e(TAG, "viewWidth? " + getWidth() + ", viewHeight? " + getHeight()); // Log.e(TAG, "viewWidth? " + getWidth() + ", viewHeight? " + getHeight());
jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality); jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality);
} }
dispatchOnPictureTaken(jpeg2); dispatchOnPictureTaken(jpeg2);

@ -33,7 +33,7 @@ class ScrollGestureLayout extends GestureLayout {
@Override @Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
boolean horizontal; boolean horizontal;
Log.e("ScrollGestureLayout", "onScroll, distanceX="+distanceX+", distanceY="+distanceY); // Log.e("ScrollGestureLayout", "onScroll, distanceX="+distanceX+", distanceY="+distanceY);
if (e1.getX() != mPoints[0].x || e1.getY() != mPoints[0].y) { if (e1.getX() != mPoints[0].x || e1.getY() != mPoints[0].y) {
// First step. We choose now if it's a vertical or horizontal scroll, and // First step. We choose now if it's a vertical or horizontal scroll, and
// stick to it for the whole gesture. // stick to it for the whole gesture.
@ -46,7 +46,7 @@ class ScrollGestureLayout extends GestureLayout {
} }
mPoints[1].set(e2.getX(), e2.getY()); mPoints[1].set(e2.getX(), e2.getY());
mDistance = horizontal ? (distanceX / getWidth()) : (distanceY / getHeight()); mDistance = horizontal ? (distanceX / getWidth()) : (distanceY / getHeight());
mDistance = -mDistance; // they are provided inverted. mDistance = horizontal ? -mDistance : mDistance; // When vertical, up = positive
mNotify = true; mNotify = true;
return true; return true;
} }
@ -71,7 +71,7 @@ class ScrollGestureLayout extends GestureLayout {
mDetector.onTouchEvent(event); mDetector.onTouchEvent(event);
// Keep notifying CameraView as long as the gesture goes. // Keep notifying CameraView as long as the gesture goes.
if (mNotify) Log.e("ScrollGestureLayout", "notifying a gesture "+mType.name()); // if (mNotify) Log.e("ScrollGestureLayout", "notifying a gesture "+mType.name());
return mNotify; return mNotify;
} }
@ -91,7 +91,7 @@ class ScrollGestureLayout extends GestureLayout {
float newValue = currValue + delta; float newValue = currValue + delta;
if (newValue < minValue) newValue = minValue; if (newValue < minValue) newValue = minValue;
if (newValue > maxValue) newValue = maxValue; if (newValue > maxValue) newValue = maxValue;
Log.e("ScrollGestureLayout", "curr="+currValue+", min="+minValue+", max="+maxValue+", out="+newValue); // Log.e("ScrollGestureLayout", "curr="+currValue+", min="+minValue+", max="+maxValue+", out="+newValue);
return newValue; return newValue;
} }

Loading…
Cancel
Save