From 03f8358d67ba5ffdc6319673e2b83d2ceb81ae78 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 2 Mar 2018 22:37:09 +0100 Subject: [PATCH] Remove ExtraProprties --- README.md | 3 +- .../cameraview/ExtraProperties1Test.java | 32 --------------- .../com/otaliastudios/cameraview/Camera1.java | 1 - .../cameraview/CameraController.java | 6 --- .../otaliastudios/cameraview/CameraView.java | 11 ------ .../cameraview/ExtraProperties.java | 39 ------------------- .../cameraview/SizeSelectors.java | 0 7 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 cameraview/src/androidTest/java/com/otaliastudios/cameraview/ExtraProperties1Test.java delete mode 100644 cameraview/src/main/java/com/otaliastudios/cameraview/ExtraProperties.java rename cameraview/src/main/{java => utils}/com/otaliastudios/cameraview/SizeSelectors.java (100%) diff --git a/README.md b/README.md index 9a61aa93..c9dccd57 100644 --- a/README.md +++ b/README.md @@ -623,7 +623,6 @@ Other APIs not mentioned above are provided, and are well documented and comment |`getGestureAction(Gesture)`|Returns the action currently mapped to the given gesture.| |`clearGesture(Gesture)`|Clears any action mapped to the given gesture.| |`getCameraOptions()`|If camera was started, returns non-null object with information about what is supported.| -|`getExtraProperties()`|If camera was started, returns non-null object with extra information about the camera sensor. Not very useful at the moment.| |`setZoom(float)`, `getZoom()`|Sets a zoom value, where 0 means camera zoomed out and 1 means zoomed in. No-op if zoom is not supported, or camera not started.| |`setExposureCorrection(float)`, `getExposureCorrection()`|Sets exposure compensation EV value, in camera stops. No-op if this is not supported. Should be between the bounds returned by CameraOptions.| |`toggleFacing()`|Toggles the facing value between `Facing.FRONT` and `Facing.BACK`.| @@ -635,7 +634,7 @@ Other APIs not mentioned above are provided, and are well documented and comment |`getSnapshotSize()`|Returns `getPreviewSize()`, since a snapshot is a preview frame.| |`getPictureSize()`|Returns the size of the output picture. The aspect ratio is consistent with `getPreviewSize()`.| -Take also a look at public methods in `CameraUtils`, `CameraOptions`, `ExtraProperties`. +Take also a look at public methods in `CameraUtils`, `CameraOptions`. ## Permissions behavior diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/ExtraProperties1Test.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/ExtraProperties1Test.java deleted file mode 100644 index 02e497ca..00000000 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/ExtraProperties1Test.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.otaliastudios.cameraview; - - -import android.annotation.TargetApi; -import android.hardware.Camera; -import android.hardware.camera2.CameraCharacteristics; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; -import android.util.SizeF; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; - -import static org.mockito.Mockito.*; -import static org.junit.Assert.*; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class ExtraProperties1Test extends BaseTest { - - @Test - public void testConstructor1() { - Camera.Parameters params = mock(Camera.Parameters.class); - when(params.getVerticalViewAngle()).thenReturn(10f); - when(params.getHorizontalViewAngle()).thenReturn(5f); - ExtraProperties e = new ExtraProperties(params); - assertEquals(e.getVerticalViewingAngle(), 10f, 0f); - assertEquals(e.getHorizontalViewingAngle(), 5f, 0f); - } - -} diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 4e04b586..d6181fbd 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -180,7 +180,6 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera // Set parameters that might have been set before the camera was opened. LOG.i("onStart:", "Applying default parameters."); Camera.Parameters params = mCamera.getParameters(); - mExtraProperties = new ExtraProperties(params); mCameraOptions = new CameraOptions(params, shouldFlipSizes()); applyDefaultFocus(params); mergeFlash(params, Flash.DEFAULT); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index 7d30c621..168c641e 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -49,7 +49,6 @@ abstract class CameraController implements protected boolean mPlaySounds; protected int mCameraId; - protected ExtraProperties mExtraProperties; protected CameraOptions mCameraOptions; protected Mapper mMapper; protected FrameManager mFrameManager; @@ -341,11 +340,6 @@ abstract class CameraController implements //region final getters - @Nullable - final ExtraProperties getExtraProperties() { - return mExtraProperties; - } - @Nullable final CameraOptions getCameraOptions() { return mCameraOptions; diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index c6e61819..b6eade39 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -687,17 +687,6 @@ public class CameraView extends FrameLayout implements LifecycleObserver { } - /** - * If present, returns a collection of extra properties from the current camera - * session. - * @return an ExtraProperties object. - */ - @Nullable - public ExtraProperties getExtraProperties() { - return mCameraController.getExtraProperties(); - } - - /** * Sets exposure adjustment, in EV stops. A positive value will mean brighter picture. * diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/ExtraProperties.java b/cameraview/src/main/java/com/otaliastudios/cameraview/ExtraProperties.java deleted file mode 100644 index 4ec5778a..00000000 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/ExtraProperties.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.otaliastudios.cameraview; - - -import android.annotation.TargetApi; -import android.hardware.Camera; -import android.hardware.camera2.CameraCharacteristics; -import android.util.Log; -import android.util.SizeF; - -/** - * Simple pojo containing various camera properties. - */ -@SuppressWarnings("deprecation") -public class ExtraProperties { - - private float verticalViewingAngle; - private float horizontalViewingAngle; - - ExtraProperties(Camera.Parameters params) { - verticalViewingAngle = params.getVerticalViewAngle(); - horizontalViewingAngle = params.getHorizontalViewAngle(); - } - - @TargetApi(21) - ExtraProperties(CameraCharacteristics chars) { - float[] maxFocus = chars.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS); - SizeF size = chars.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE); - verticalViewingAngle = (float) Math.toDegrees(2 * Math.atan(size.getWidth() / (maxFocus[0] * 2))); - horizontalViewingAngle = (float) Math.toDegrees(2 * Math.atan(size.getHeight() / (maxFocus[0] * 2))); - } - - public float getHorizontalViewingAngle() { - return horizontalViewingAngle; - } - - public float getVerticalViewingAngle() { - return verticalViewingAngle; - } -} diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/SizeSelectors.java b/cameraview/src/main/utils/com/otaliastudios/cameraview/SizeSelectors.java similarity index 100% rename from cameraview/src/main/java/com/otaliastudios/cameraview/SizeSelectors.java rename to cameraview/src/main/utils/com/otaliastudios/cameraview/SizeSelectors.java