From 3bc6d96ac36e8efec83b3a5b7461f0b51a71c308 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 17 Nov 2017 14:48:18 +0100 Subject: [PATCH] Add base Control class, add easy setters and CameraOptions APIs (#105) --- .../cameraview/CameraOptions1Test.java | 76 +++++++++++------- .../cameraview/CameraViewTest.java | 45 ++++------- .../cameraview/CameraListener.java | 4 +- .../cameraview/CameraOptions.java | 77 ++++++++++--------- .../otaliastudios/cameraview/CameraView.java | 31 +++++++- .../com/otaliastudios/cameraview/Audio.java | 2 +- .../com/otaliastudios/cameraview/Control.java | 8 ++ .../com/otaliastudios/cameraview/Facing.java | 2 +- .../com/otaliastudios/cameraview/Flash.java | 2 +- .../com/otaliastudios/cameraview/Grid.java | 2 +- .../com/otaliastudios/cameraview/Hdr.java | 2 +- .../otaliastudios/cameraview/SessionType.java | 2 +- .../cameraview/VideoQuality.java | 2 +- .../cameraview/WhiteBalance.java | 2 +- .../cameraview/demo/Control.java | 35 ++++----- 15 files changed, 168 insertions(+), 124 deletions(-) create mode 100644 cameraview/src/main/options/com/otaliastudios/cameraview/Control.java diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraOptions1Test.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraOptions1Test.java index 402a47da..b240c7aa 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraOptions1Test.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraOptions1Test.java @@ -9,6 +9,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -109,25 +110,6 @@ public class CameraOptions1Test extends BaseTest { } } - @Test - public void testFacing() { - Set supported = new HashSet<>(); - Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); - for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { - Camera.getCameraInfo(i, cameraInfo); - supported.add(cameraInfo.facing); - } - - CameraOptions o = new CameraOptions(mock(Camera.Parameters.class), false); - Mapper m = new Mapper.Mapper1(); - Set s = o.getSupportedFacing(); - assertEquals(o.getSupportedFacing().size(), supported.size()); - for (Facing facing : s) { - assertTrue(supported.contains(m.map(facing))); - assertTrue(o.supports(facing)); - } - } - @Test public void testGestureActions() { Camera.Parameters params = mock(Camera.Parameters.class); @@ -145,6 +127,41 @@ public class CameraOptions1Test extends BaseTest { assertFalse(o.supports(GestureAction.EXPOSURE_CORRECTION)); } + @Test + public void testAlwaysSupportedControls() { + // Grid, VideoQuality, SessionType and Audio are always supported. + Camera.Parameters params = mock(Camera.Parameters.class); + CameraOptions o = new CameraOptions(params, false); + + Collection grids = o.getSupportedControls(Grid.class); + Collection video = o.getSupportedControls(VideoQuality.class); + Collection sessions = o.getSupportedControls(SessionType.class); + Collection