From a2190734681c473d7a8fac0388281b69768436b1 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Thu, 28 Jan 2021 22:42:04 +0100 Subject: [PATCH] Release v2.7.0 (#1040) * Release v2.7.0 * Improve docs --- .github/workflows/build.yml | 1 + README.md | 2 +- build.gradle.kts | 10 +++++----- cameraview/build.gradle.kts | 18 ++++++++--------- .../cameraview/CameraViewCallbacksTest.java | 8 +++++++- .../cameraview/CameraListener.java | 9 +++++---- .../otaliastudios/cameraview/CameraView.java | 4 ++-- .../cameraview/engine/CameraBaseEngine.java | 5 +---- .../cameraview/engine/CameraEngine.java | 2 +- docs/_about/changelog.md | 20 +++++++++++++++++++ docs/_config.yml | 2 +- docs/_docs/capturing-media.md | 5 +++++ docs/_docs/gestures.md | 9 +++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- 14 files changed, 64 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37fb81c3..395539b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - main pull_request: jobs: ANDROID_BASE_CHECKS: diff --git a/README.md b/README.md index 7f8997d3..c3aee6ec 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ CameraView is a well documented, high-level library that makes capturing picture addressing most of the common issues and needs, and still leaving you with flexibility where needed. ```groovy -api 'com.otaliastudios:cameraview:2.6.4' +api 'com.otaliastudios:cameraview:2.7.0' ``` - Fast & reliable diff --git a/build.gradle.kts b/build.gradle.kts index 5b73b143..de358275 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,8 @@ buildscript { extra["minSdkVersion"] = 15 - extra["compileSdkVersion"] = 29 - extra["targetSdkVersion"] = 29 + extra["compileSdkVersion"] = 30 + extra["targetSdkVersion"] = 30 repositories { google() @@ -12,9 +12,9 @@ buildscript { } dependencies { - classpath("com.android.tools.build:gradle:4.0.1") - classpath("com.otaliastudios.tools:publisher:0.3.3") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") + classpath("com.android.tools.build:gradle:4.1.2") + classpath("io.deepmedia.tools:publisher:0.4.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21") } } diff --git a/cameraview/build.gradle.kts b/cameraview/build.gradle.kts index 3f24f095..f1e0ac8b 100644 --- a/cameraview/build.gradle.kts +++ b/cameraview/build.gradle.kts @@ -1,10 +1,10 @@ -import com.otaliastudios.tools.publisher.common.License -import com.otaliastudios.tools.publisher.common.Release +import io.deepmedia.tools.publisher.common.License +import io.deepmedia.tools.publisher.common.Release plugins { id("com.android.library") id("kotlin-android") - id("com.otaliastudios.tools.publisher") + id("io.deepmedia.tools.publisher") id("jacoco") } @@ -14,7 +14,7 @@ android { setMinSdkVersion(property("minSdkVersion") as Int) setTargetSdkVersion(property("targetSdkVersion") as Int) versionCode = 1 - versionName = "2.6.4" + versionName = "2.7.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArgument("filter", "" + "com.otaliastudios.cameraview.tools.SdkExcludeFilter," + @@ -30,11 +30,11 @@ dependencies { androidTestImplementation("androidx.test:runner:1.3.0") androidTestImplementation("androidx.test:rules:1.3.0") - androidTestImplementation("androidx.test.ext:junit:1.1.1") + androidTestImplementation("androidx.test.ext:junit:1.1.2") androidTestImplementation("org.mockito:mockito-android:2.28.2") androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") - api("androidx.exifinterface:exifinterface:1.2.0") + api("androidx.exifinterface:exifinterface:1.3.2") api("androidx.lifecycle:lifecycle-common:2.2.0") api("com.google.android.gms:play-services-tasks:17.2.0") implementation("androidx.annotation:annotation:1.1.0") @@ -52,8 +52,8 @@ publisher { project.url = "https://github.com/natario1/CameraView" project.addLicense(License.APACHE_2_0) bintray { - release.setSources(Release.SOURCES_AUTO) - release.setDocs(Release.DOCS_AUTO) + release.sources = Release.SOURCES_AUTO + release.docs = Release.DOCS_AUTO auth.user = "BINTRAY_USER" auth.key = "BINTRAY_KEY" auth.repo = "BINTRAY_REPO" @@ -97,7 +97,7 @@ jacoco { toolVersion = "0.8.5" } tasks.register("computeCoverage", JacocoReport::class) { dependsOn("compileDebugSources") // Compile sources, needed below executionData.from(fileTree(coverageInputDir)) - sourceDirectories.from(android.sourceSets["main"].java.sourceFiles) + sourceDirectories.from(android.sourceSets["main"].java.srcDirs) additionalSourceDirs.from("$buildDir/generated/source/buildConfig/debug") additionalSourceDirs.from("$buildDir/generated/source/r/debug") classDirectories.from(fileTree("$buildDir/intermediates/javac/debug") { diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java index 6439ee01..a63e2b54 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java @@ -248,7 +248,13 @@ public class CameraViewCallbacksTest extends BaseTest { verify(listener, times(1)).onOrientationChanged(anyInt()); } - // TODO: test onShutter, here or elsewhere + @Test + public void testOnShutter() { + doEndOp(op, true).when(listener).onPictureShutter(); + camera.mCameraCallbacks.dispatchOnPictureShutter(true); + assertNotNull(op.await(DELAY)); + verify(listener, times(1)).onPictureShutter(); + } @Test public void testCameraError() { diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java index c6d9094b..34161eea 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java @@ -162,11 +162,12 @@ public abstract class CameraListener { } /** - * Notifies that the shutter event is happening. You can update UI to show some - * trigger effect, so user visually confirms that picture is being taken - * or video recording is about to start. + * Notifies that the picture capture has started. Can be used to update the UI for visual + * confirmation or sound effects. */ @UiThread - public void onShutter() {} + public void onPictureShutter() { + + } } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index eb745722..f3fd9de8 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -2228,7 +2228,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { } @Override - public void onShutter(boolean shouldPlaySound) { + public void dispatchOnPictureShutter(boolean shouldPlaySound) { if (shouldPlaySound && mPlaySounds) { playSound(MediaActionSound.SHUTTER_CLICK); } @@ -2236,7 +2236,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { @Override public void run() { for (CameraListener listener : mListeners) { - listener.onShutter(); + listener.onPictureShutter(); } } }); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java index 07e3c231..98749d4e 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java @@ -1,7 +1,5 @@ package com.otaliastudios.cameraview.engine; -import android.graphics.PointF; -import android.graphics.RectF; import android.location.Location; import androidx.annotation.CallSuper; @@ -28,7 +26,6 @@ import com.otaliastudios.cameraview.engine.offset.Angles; import com.otaliastudios.cameraview.engine.offset.Reference; import com.otaliastudios.cameraview.engine.orchestrator.CameraState; import com.otaliastudios.cameraview.frame.FrameManager; -import com.otaliastudios.cameraview.gesture.Gesture; import com.otaliastudios.cameraview.overlay.Overlay; import com.otaliastudios.cameraview.picture.PictureRecorder; import com.otaliastudios.cameraview.preview.CameraPreview; @@ -556,7 +553,7 @@ public abstract class CameraBaseEngine extends CameraEngine { @Override public void onPictureShutter(boolean didPlaySound) { - getCallback().onShutter(!didPlaySound); + getCallback().dispatchOnPictureShutter(!didPlaySound); } @Override diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java index e695b61c..0614789d 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java @@ -116,7 +116,7 @@ public abstract class CameraEngine implements void dispatchOnCameraOpened(@NonNull CameraOptions options); void dispatchOnCameraClosed(); void onCameraPreviewStreamSizeChanged(); - void onShutter(boolean shouldPlaySound); + void dispatchOnPictureShutter(boolean shouldPlaySound); void dispatchOnVideoTaken(@NonNull VideoResult.Stub stub); void dispatchOnPictureTaken(@NonNull PictureResult.Stub stub); void dispatchOnFocusStart(@Nullable Gesture trigger, @NonNull PointF where); diff --git a/docs/_about/changelog.md b/docs/_about/changelog.md index 56614f3c..859313c9 100644 --- a/docs/_about/changelog.md +++ b/docs/_about/changelog.md @@ -9,6 +9,18 @@ New versions are released through GitHub, so the reference page is the [GitHub R > Starting from 2.4.0, you can now [support development](https://github.com/sponsors/natario1) through the GitHub Sponsors program. Companies can share a tiny part of their revenue and get private support hours in return. Thanks! +##### v2.7.0 + +- New: onPictureShutter() callback when taking pictures, thanks to [@EzequielAdrianM][EzequielAdrianM] ([#1030][1030]) +- New: GestureAction.TAKE_PICTURE_SNAPSHOT lets you take snapshots on gesture, thanks to [@EzequielAdrianM][EzequielAdrianM] ([#1030][1030]) +- Improvement: try-catch internal exception when takePicture fails, thanks to [@michaelspecht][michaelspecht] ([#1024][1024]) +- Improvement: log errors when file writing fails, thanks to [@bwt][bwt] ([#960][960]) +- Fix: Avoid preview deadlocks ([#1020][1020]) +- Fix: Workaround for messed-up preview on Pixel 4 ([#1020][1020]) +- Fix: Avoid internal StackOverflow errors ([#992][992]) + + + ##### v2.6.4 - Fix: Fix many small bugs ([#953][953]) @@ -322,6 +334,7 @@ This is the last release before v2. [aartikov]: https://github.com/aartikov [athornz]: https://github.com/athornz +[bwt]: https://github.com/bwt [v-gar]: https://github.com/v-gar [andrewmunn]: https://github.com/andrewmunn [chaitanyaraghav]: https://github.com/chaitanyaraghav @@ -344,6 +357,8 @@ This is the last release before v2. [hualong-shen]: https://github.com/hualong-shen [EverydayPineapple]: https://github.com/EverydayPineapple [jeffreyfjohnson]: https://github.com/jeffreyfjohnson +[michaelspecht]: https://github.com/michaelspecht +[EzequielAdrianM]: https://github.com/EzequielAdrianM [73]: https://github.com/natario1/CameraView/pull/73 @@ -442,3 +457,8 @@ This is the last release before v2. [877]: https://github.com/natario1/CameraView/pull/877 [897]: https://github.com/natario1/CameraView/pull/897 [953]: https://github.com/natario1/CameraView/pull/953 +[960]: https://github.com/natario1/CameraView/pull/960 +[992]: https://github.com/natario1/CameraView/pull/992 +[1020]: https://github.com/natario1/CameraView/pull/1020 +[1024]: https://github.com/natario1/CameraView/pull/1024 +[1030]: https://github.com/natario1/CameraView/pull/1030 diff --git a/docs/_config.yml b/docs/_config.yml index 1662d58b..17f87a18 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -12,7 +12,7 @@ google_analytics_id: 'UA-155077779-1' google_site_verification: '4x49i17ABIrSvUl52SeL0-t0341aTnWWaC62-FYCRT4' github: [metadata] # TODO What's this? github_repo: CameraView -github_version: 2.6.4 +github_version: 2.7.0 github_branch: master baseurl: '/CameraView' # Keep as an empty string if served up at the root collections: diff --git a/docs/_docs/capturing-media.md b/docs/_docs/capturing-media.md index fdde9828..94c573d6 100644 --- a/docs/_docs/capturing-media.md +++ b/docs/_docs/capturing-media.md @@ -68,6 +68,11 @@ This is allowed at the following conditions: ```java camera.addCameraListener(new CameraListener() { + + @Override + public void onPictureShutter() { + // Picture capture started! + } @Override public void onPictureTaken(@NonNull PictureResult result) { diff --git a/docs/_docs/gestures.md b/docs/_docs/gestures.md index 961367d6..fb8212f7 100644 --- a/docs/_docs/gestures.md +++ b/docs/_docs/gestures.md @@ -24,8 +24,8 @@ Simple as that. There are two things to be noted: |Gesture|Description|Can be mapped to| |-------------|-----------|----------------| |`PINCH`|Pinch gesture, typically assigned to the zoom control.|`ZOOM` `EXPOSURE_CORRECTION` `FILTER_CONTROL_1` `FILTER_CONTROL_2` `NONE`| -|`TAP`|Single tap gesture, typically assigned to the focus control.|`AUTO_FOCUS` `TAKE_PICTURE` `NONE`| -|`LONG_TAP`|Long tap gesture.|`AUTO_FOCUS` `TAKE_PICTURE` `NONE`| +|`TAP`|Single tap gesture, typically assigned to the focus control.|`AUTO_FOCUS` `TAKE_PICTURE` `TAKE_PICTURE_SNAPSHOT` `NONE`| +|`LONG_TAP`|Long tap gesture.|`AUTO_FOCUS` `TAKE_PICTURE` `TAKE_PICTURE_SNAPSHOT` `NONE`| |`SCROLL_HORIZONTAL`|Horizontal movement gesture.|`ZOOM` `EXPOSURE_CORRECTION` `FILTER_CONTROL_1` `FILTER_CONTROL_2` `NONE`| |`SCROLL_VERTICAL`|Vertical movement gesture.|`ZOOM` `EXPOSURE_CORRECTION` `FILTER_CONTROL_1` `FILTER_CONTROL_2` `NONE`| @@ -38,6 +38,7 @@ Looking at this from the other side: |`NONE`|Disables this gesture.|`TAP` `LONG_TAP` `PINCH` `SCROLL_HORIZONTAL` `SCROLL_VERTICAL`| |`AUTO_FOCUS`|Launches a [touch metering operation](metering#touch-metering) on the finger position.|`TAP` `LONG_TAP`| |`TAKE_PICTURE`|Takes a picture using [takePicture](capturing-media).|`TAP` `LONG_TAP`| +|`TAKE_PICTURE_SNAPSHOT`|Takes a picture using [takePictureSnapshot](capturing-media).|`TAP` `LONG_TAP`| |`ZOOM`|[Zooms](controls#zoom) in or out.|`PINCH` `SCROLL_HORIZONTAL` `SCROLL_VERTICAL`| |`EXPOSURE_CORRECTION`|Controls the [exposure correction](metering#exposure-correction).|`PINCH` `SCROLL_HORIZONTAL` `SCROLL_VERTICAL`| |`FILTER_CONTROL_1`|Controls the first parameter (if any) of a [real-time filter](filters).|`PINCH` `SCROLL_HORIZONTAL` `SCROLL_VERTICAL`| @@ -48,8 +49,8 @@ Looking at this from the other side: ```xml ``` diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d7bac4aa..6c82b158 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-6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip