From c3e3d43b28286402664cc4faf077d09af5951e8a Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Wed, 30 May 2018 16:30:35 +0200 Subject: [PATCH 1/4] Bump version (#222) * Bump version * update jacoco --- CHANGELOG.md | 12 ++++++++++++ README.md | 2 +- build.gradle | 4 ++-- cameraview/build.gradle | 6 +++--- .../cameraview/ScrollGestureLayout.java | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fcabb3d..27166b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### v1.5.1 + +- Bug: byte array length for Frames was incorrect thanks to [@ssakhavi][ssakhavi] ([#205][205]) +- Bug: gestures were crashing in some conditions ([#222][222]) +- Bug: import correctly the ExifInterface library ([#222][222]) +- Updated dependencies thanks to [@caleb-allen][caleb-allen] ([#190][190]) + ## v1.5.0 - New: set encoder for video recordings with `cameraVideoCodec` ([#174][174]) @@ -80,6 +87,8 @@ https://github.com/natario1/CameraView/compare/v1.2.3...v1.3.0 [RobertoMorelos]: https://github.com/RobertoMorelos [RocketRider]: https://github.com/RocketRider [xp-vit]: https://github.com/xp-vit +[caleb-allen]: https://github.com/caleb-allen +[ssakhavi]: https://github.com/ssakhavi [73]: https://github.com/natario1/CameraView/pull/73 [80]: https://github.com/natario1/CameraView/pull/80 @@ -104,3 +113,6 @@ https://github.com/natario1/CameraView/compare/v1.2.3...v1.3.0 [172]: https://github.com/natario1/CameraView/pull/172 [173]: https://github.com/natario1/CameraView/pull/173 [174]: https://github.com/natario1/CameraView/pull/174 +[190]: https://github.com/natario1/CameraView/pull/190 +[205]: https://github.com/natario1/CameraView/pull/205 +[222]: https://github.com/natario1/CameraView/pull/222 diff --git a/README.md b/README.md index a4ec4dfa..031e3140 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ addressing most of the common issues and needs, and still leaving you with flexi See [CHANGELOG](https://github.com/natario1/CameraView/blob/master/CHANGELOG.md). ```groovy -compile 'com.otaliastudios:cameraview:1.5.0' +compile 'com.otaliastudios:cameraview:1.5.1' ``` Make sure your project repositories include the `jcenter()`: diff --git a/build.gradle b/build.gradle index 4ef0d0af..129a0ad0 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.2.0-alpha15' // https://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en // https://www.theguardian.com/technology/developer-blog/2016/dec/06/how-to-publish-an-android-library-a-mysterious-conversation classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' @@ -25,7 +25,7 @@ allprojects { ext { compileSdkVersion = 27 buildToolsVersion = "27.0.3" - supportLibVersion = '27.1.0' + supportLibVersion = '27.1.1' minSdkVersion = 15 targetSdkVersion = 27 } diff --git a/cameraview/build.gradle b/cameraview/build.gradle index 7ace1dd9..4882e0ac 100644 --- a/cameraview/build.gradle +++ b/cameraview/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // Required by bintray -version = '1.5.0' +version = '1.5.1' group = 'com.otaliastudios' //region android dependencies @@ -48,7 +48,7 @@ dependencies { androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - implementation "com.android.support:exifinterface:$supportLibVersion" + api "com.android.support:exifinterface:$supportLibVersion" implementation "com.android.support:support-annotations:$supportLibVersion" } @@ -178,7 +178,7 @@ apply plugin: 'jacoco' def reportsDirectory = "$buildDir/reports/" jacoco { - toolVersion = "0.7.4+" + toolVersion = "0.8.1" reportsDir = file(reportsDirectory) } diff --git a/cameraview/src/main/views/com/otaliastudios/cameraview/ScrollGestureLayout.java b/cameraview/src/main/views/com/otaliastudios/cameraview/ScrollGestureLayout.java index f8e3b17a..23a2fc46 100644 --- a/cameraview/src/main/views/com/otaliastudios/cameraview/ScrollGestureLayout.java +++ b/cameraview/src/main/views/com/otaliastudios/cameraview/ScrollGestureLayout.java @@ -29,6 +29,7 @@ class ScrollGestureLayout extends GestureLayout { public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { boolean horizontal; LOG.i("onScroll:", "distanceX="+distanceX, "distanceY="+distanceY); + if (e1 == null || e2 == null) return false; // Got some crashes about this. 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 // stick to it for the whole gesture. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bb725f70..3facb3bd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip From 819638862fce349018506d7d2b0b92d284036e43 Mon Sep 17 00:00:00 2001 From: Josh Burton Date: Fri, 1 Jun 2018 12:18:52 +1200 Subject: [PATCH 2/4] Provides synchronous version of decodeBitmap (#224) * Provides synchronous version of decodeBitmap and adds annotation to make it clear this should run on a worker thread Closes #221 * Tidies up decodeBitmap javadoc --- .../otaliastudios/cameraview/CameraUtils.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/cameraview/src/main/utils/com/otaliastudios/cameraview/CameraUtils.java b/cameraview/src/main/utils/com/otaliastudios/cameraview/CameraUtils.java index a81870f7..dd7a74e2 100644 --- a/cameraview/src/main/utils/com/otaliastudios/cameraview/CameraUtils.java +++ b/cameraview/src/main/utils/com/otaliastudios/cameraview/CameraUtils.java @@ -8,6 +8,7 @@ import android.graphics.Matrix; import android.hardware.Camera; import android.os.Handler; import android.support.annotation.UiThread; +import android.support.annotation.WorkerThread; import android.support.media.ExifInterface; import java.io.ByteArrayInputStream; @@ -55,6 +56,19 @@ public class CameraUtils { } + /** + * Decodes an input byte array and outputs a Bitmap that is ready to be displayed. + * The difference with {@link android.graphics.BitmapFactory#decodeByteArray(byte[], int, int)} + * is that this cares about orientation, reading it from the EXIF header. + * + * @param source a JPEG byte array + */ + @SuppressWarnings("WeakerAccess") + @WorkerThread + public static void decodeBitmap(final byte[] source) { + decodeBitmap(source, Integer.MAX_VALUE, Integer.MAX_VALUE); + } + /** * Decodes an input byte array and outputs a Bitmap that is ready to be displayed. * The difference with {@link android.graphics.BitmapFactory#decodeByteArray(byte[], int, int)} @@ -100,9 +114,21 @@ public class CameraUtils { } + /** + * Decodes an input byte array and outputs a Bitmap that is ready to be displayed. + * The difference with {@link android.graphics.BitmapFactory#decodeByteArray(byte[], int, int)} + * is that this cares about orientation, reading it from the EXIF header. + * + * The image is also downscaled taking care of the maxWidth and maxHeight arguments. + * + * @param source a JPEG byte array + * @param maxWidth the max allowed width + * @param maxHeight the max allowed height + */ // TODO ignores flipping @SuppressWarnings({"SuspiciousNameCombination", "WeakerAccess"}) - /* for tests */ static Bitmap decodeBitmap(byte[] source, int maxWidth, int maxHeight) { + @WorkerThread + public static Bitmap decodeBitmap(byte[] source, int maxWidth, int maxHeight) { if (maxWidth <= 0) maxWidth = Integer.MAX_VALUE; if (maxHeight <= 0) maxHeight = Integer.MAX_VALUE; int orientation; From c113933b60cd2919cb1ad3340c303386dab31e9a Mon Sep 17 00:00:00 2001 From: MatFl Date: Sat, 28 Jul 2018 03:32:22 +0200 Subject: [PATCH 3/4] Prevent context leak through SystemSensorManager (#245) --- .../utils/com/otaliastudios/cameraview/OrientationHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java b/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java index 99c2cb17..8006d095 100644 --- a/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java +++ b/cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java @@ -22,7 +22,7 @@ class OrientationHelper { OrientationHelper(Context context, @NonNull Callback callback) { mCallback = callback; - mListener = new OrientationEventListener(context, SensorManager.SENSOR_DELAY_NORMAL) { + mListener = new OrientationEventListener(context.getApplicationContext(), SensorManager.SENSOR_DELAY_NORMAL) { @Override public void onOrientationChanged(int orientation) { @@ -72,4 +72,4 @@ class OrientationHelper { int getDisplayOffset() { return mDisplayOffset; } -} \ No newline at end of file +} From 4c6a8db0c398b6334e47b41c226660a9c7d0fffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wo=C5=9B?= Date: Tue, 31 Jul 2018 03:25:10 +0200 Subject: [PATCH 4/4] Fix README selector example (#248) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 031e3140..a78546d7 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ to just square sizes: ```java SizeSelector width = SizeSelectors.minWidth(1000); -SizeSelector height = SizeSelectors.minWidth(2000); +SizeSelector height = SizeSelectors.minHeight(2000); SizeSelector dimensions = SizeSelectors.and(width, height); // Matches sizes bigger than 1000x2000. SizeSelector ratio = SizeSelectors.aspectRatio(AspectRatio.of(1, 1), 0); // Matches 1:1 sizes.