From 01af0189aa671d343a5fa7d142e9083f187d2c49 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Sat, 23 Feb 2019 14:21:37 +0100 Subject: [PATCH] Fix #377 and update dependencies --- build.gradle | 2 +- .../com/otaliastudios/cameraview/EglCore.java | 19 ++----------------- .../com/otaliastudios/cameraview/Camera1.java | 8 ++++++-- demo/build.gradle | 4 ++-- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index 78d9e221..964dd2b0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' } 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..6a178681 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -440,8 +440,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/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' }