From d462b8304827a55205e0e54c9a78361fa5107ce9 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Sat, 23 Feb 2019 15:52:41 +0100 Subject: [PATCH] v2.0.0-beta03 (#392) * Fix #377 and update dependencies * Fix #384 * Fix unbindFromSurface bug * Bump version to v2.0.0-beta03 * Update build.gradle --- README.md | 2 +- cameraview/build.gradle | 2 +- .../com/otaliastudios/cameraview/EglCore.java | 19 ++---------- .../com/otaliastudios/cameraview/Camera1.java | 29 ++++++++++++++----- .../cameraview/CameraController.java | 2 +- .../otaliastudios/cameraview/CameraView.java | 1 - demo/build.gradle | 4 +-- demo/src/main/AndroidManifest.xml | 4 +-- docs/_posts/2018-12-20-changelog.md | 9 +++++- docs/_posts/2018-12-20-install.md | 2 +- 10 files changed, 39 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 566d0e9c..01f3ac6b 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 -compile 'com.otaliastudios:cameraview:2.0.0-beta02' +compile 'com.otaliastudios:cameraview:2.0.0-beta03' ``` - Fast & reliable diff --git a/cameraview/build.gradle b/cameraview/build.gradle index aa0d5819..07e871c7 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 = '2.0.0-beta02' +version = '2.0.0-beta03' group = 'com.otaliastudios' //region android dependencies diff --git a/cameraview/src/main/gles/com/otaliastudios/cameraview/EglCore.java b/cameraview/src/main/gles/com/otaliastudios/cameraview/EglCore.java index 2483978d..62f1f6d9 100644 --- a/cameraview/src/main/gles/com/otaliastudios/cameraview/EglCore.java +++ b/cameraview/src/main/gles/com/otaliastudios/cameraview/EglCore.java @@ -137,7 +137,7 @@ final class EglCore { int[] values = new int[1]; EGL14.eglQueryContext(mEGLDisplay, mEGLContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0); - Log.d(TAG, "EGLContext created, client version " + values[0]); + // Log.d(TAG, "EGLContext created, client version " + values[0]); } /** @@ -273,7 +273,7 @@ final class EglCore { public void makeCurrent(EGLSurface eglSurface) { if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { // called makeCurrent() before create? - Log.d(TAG, "NOTE: makeCurrent w/o display"); + // Log.d(TAG, "NOTE: makeCurrent w/o display"); } if (!EGL14.eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext)) { throw new RuntimeException("eglMakeCurrent failed"); @@ -351,21 +351,6 @@ final class EglCore { return mGlVersion; } - /** - * Writes the current display, context, and surface to the log. - */ - public static void logCurrent(String msg) { - EGLDisplay display; - EGLContext context; - EGLSurface surface; - - display = EGL14.eglGetCurrentDisplay(); - context = EGL14.eglGetCurrentContext(); - surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW); - Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context + - ", surface=" + surface); - } - /** * Checks for EGL errors. Throws an exception if an error has been raised. */ diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 72bc6993..7c6f9b52 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -66,7 +66,10 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera }); } - // Preview surface is now available. If camera is open, set up. + /** + * Preview surface is now available. If camera is open, set up. + * At this point we are sure that mPreview is not null. + */ @Override public void onSurfaceAvailable() { LOG.i("onSurfaceAvailable:", "Size is", mPreview.getOutputSurfaceSize()); @@ -80,8 +83,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera }); } - // Preview surface did change its size. Compute a new preview size. - // This requires stopping and restarting the preview. + /** + * Preview surface did change its size. Compute a new preview size. + * This requires stopping and restarting the preview. + * At this point we are sure that mPreview is not null. + */ @Override public void onSurfaceChanged() { LOG.i("onSurfaceChanged, size is", mPreview.getOutputSurfaceSize()); @@ -119,8 +125,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera return isCameraAvailable() && mPreview != null && mPreview.hasSurface() && !mIsBound; } - // The act of binding an "open" camera to a "ready" preview. - // These can happen at different times but we want to end up here. + /** + * The act of binding an "open" camera to a "ready" preview. + * These can happen at different times but we want to end up here. + * At this point we are sure that mPreview is not null. + */ @WorkerThread private void bindToSurface() { LOG.i("bindToSurface:", "Started"); @@ -275,7 +284,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera } if (mCamera != null) { stopPreview(); - unbindFromSurface(); + if (mIsBound) unbindFromSurface(); destroyCamera(); } mCameraOptions = null; @@ -440,8 +449,12 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(mCameraId, info); if (info.canDisableShutterSound) { - mCamera.enableShutterSound(mPlaySounds); - return true; + try { + // this method is documented to throw on some occasions. #377 + return mCamera.enableShutterSound(mPlaySounds); + } catch (RuntimeException exception) { + return false; + } } } if (mPlaySounds) { diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index d6063787..cfedbb9c 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -91,7 +91,7 @@ abstract class CameraController implements mFrameManager = new FrameManager(2, this); } - void setPreview(CameraPreview cameraPreview) { + void setPreview(@NonNull CameraPreview cameraPreview) { mPreview = cameraPreview; mPreview.setSurfaceCallback(this); } diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index f7c979ff..7f2f6213 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -602,7 +602,6 @@ public class CameraView extends FrameLayout implements LifecycleObserver { public void open() { if (!isEnabled()) return; if (mCameraPreview != null) mCameraPreview.onResume(); - if (checkPermissions(getAudio())) { // Update display orientation for current CameraController mOrientationHelper.enable(getContext()); diff --git a/demo/build.gradle b/demo/build.gradle index 51bcb2f1..be25003a 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -23,6 +23,6 @@ android { dependencies { implementation project(':cameraview') - implementation 'androidx.appcompat:appcompat:1.1.0-alpha01' - implementation 'com.google.android.material:material:1.1.0-alpha02' + implementation 'androidx.appcompat:appcompat:1.1.0-alpha02' + implementation 'com.google.android.material:material:1.1.0-alpha03' } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 91853314..15d6c9ea 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -15,9 +15,9 @@ + android:screenOrientation="portrait" + android:hardwareAccelerated="true"> diff --git a/docs/_posts/2018-12-20-changelog.md b/docs/_posts/2018-12-20-changelog.md index 41a4495a..1a924184 100644 --- a/docs/_posts/2018-12-20-changelog.md +++ b/docs/_posts/2018-12-20-changelog.md @@ -8,6 +8,11 @@ order: 3 New versions are released through GitHub, so the reference page is the [GitHub Releases](https://github.com/natario1/CameraView/releases) page. +### v2.0.0-beta03 + +- Fixed a few bugs ([#392][392]) +- Important fixes to video snapshot recording ([#374][374]) + ### v2.0.0-beta02 - Fixed important bugs ([#356][356]) @@ -19,4 +24,6 @@ New versions are released through GitHub, so the reference page is the [GitHub R This is the first beta release. For changes with respect to v1, please take a look at the [migration guide](../extra/v1-migration-guide.html). [356]: https://github.com/natario1/CameraView/pull/356 -[360]: https://github.com/natario1/CameraView/pull/360 \ No newline at end of file +[360]: https://github.com/natario1/CameraView/pull/360 +[374]: https://github.com/natario1/CameraView/pull/374 +[392]: https://github.com/natario1/CameraView/pull/392 \ No newline at end of file diff --git a/docs/_posts/2018-12-20-install.md b/docs/_posts/2018-12-20-install.md index 0683c4cc..917a56e9 100644 --- a/docs/_posts/2018-12-20-install.md +++ b/docs/_posts/2018-12-20-install.md @@ -24,7 +24,7 @@ allprojects { Then simply download the latest version: ```groovy -api 'com.otaliastudios:cameraview:2.0.0-beta02' +api 'com.otaliastudios:cameraview:2.0.0-beta03' ``` No other configuration steps are needed. \ No newline at end of file