diff --git a/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java b/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java index d1287cc..03229df 100644 --- a/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java +++ b/app/src/main/java/com/example/cameraxtestappjava/segpass/SegpassCamera.java @@ -5,7 +5,6 @@ import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.graphics.Bitmap; import android.graphics.ImageFormat; import android.graphics.Matrix; import android.graphics.Point; @@ -93,8 +92,11 @@ public class SegpassCamera { * Error constants */ private static final String ERROR_MSG_CAMERA_ACCESS = "Error de acceso a cámara."; + private static final String ERROR_MSG_CAMERA_RUNTIME = "Error en ejecución de cámara."; + private static final String ERROR_MSG_CAMERA_CONFIG_FAILED = "Error en configuración de cámara."; private static final String ERROR_MSG_CAMERA_TIMEOUT = "Tiempo de espera para bloqueo de cámara excedido."; private static final String ERROR_MSG_NO_CAMERA_PREVIEW_SIZE = "No se encontraron tamaños de imagen compatible."; + private static final String ERROR_MSG_NO_CAMERA_CONFIGURATION_FOUND = "Error: no se encontró configuración de cámara"; private static final String ERROR_STATE_MSG_CAMERA_IN_USE = "Error: cámara en uso por otro proceso."; private static final String ERROR_STATE_MSG_MAX_CAMERAS_IN_USE = "Error: máximo número de camaras en uso."; @@ -152,11 +154,6 @@ public class SegpassCamera { */ private Image mImage; - /** - * The bitmap to be shown in the preview to be accepted or discarded - */ - private Bitmap mBitmap; - /** * {@link CaptureRequest.Builder} for the camera preview */ @@ -436,10 +433,10 @@ public class SegpassCamera { } } catch (CameraAccessException e) { Log.e(TAG, "CameraAccessException@setUpCameraOutputs(): " + e.getMessage()); - mCameraCallback.onCameraInitError(e.getMessage()); + mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS); } catch (NullPointerException e) { Log.e(TAG, "NullPointerException@setUpCameraOutputs(): " + e.getMessage()); - mCameraCallback.onCameraInitError(e.getMessage()); + mCameraCallback.onCameraInitError(ERROR_MSG_NO_CAMERA_CONFIGURATION_FOUND); } } @@ -582,10 +579,11 @@ public class SegpassCamera { manager.openCamera(mCameraId, mStateCallback, mBackgroundHandler); } catch (CameraAccessException e) { Log.e(TAG, "CameraAccessException@openCamera(): " + e.getMessage()); - mCameraCallback.onCameraInitError(e.getMessage()); + mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS); } catch (InterruptedException e) { - mBackgroundThread.interrupt(); Log.e(TAG, "InterruptedException@openCamera(): " + e.getMessage()); + mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_RUNTIME); + mBackgroundThread.interrupt(); } } @@ -654,14 +652,14 @@ public class SegpassCamera { null, mBackgroundHandler); } catch (CameraAccessException e) { Log.e(TAG, "onConfigured(): " + e.getMessage()); - mCameraCallback.onCameraInitError(e.getMessage()); + mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_ACCESS); } } @Override public void onConfigureFailed( @NonNull CameraCaptureSession cameraCaptureSession) { - mCameraCallback.onCameraInitError("Camera capture session failed."); + mCameraCallback.onCameraInitError(ERROR_MSG_CAMERA_CONFIG_FAILED); } }, null ); @@ -754,16 +752,7 @@ public class SegpassCamera { @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { super.onCaptureCompleted(session, request, result); - /*if (mBase64Value != null) { - Log.i(TAG, "onCaptureCompleted@takePicture(): sending Base64 result on callback... "); - mCameraCallback.onPictureTakenSuccess(mBase64Value); - } else { - Log.e(TAG, "onCaptureCompleted@takePicture(): error saving picture, base64 value is null."); - mCameraCallback.onPictureTakenFailError("Error saving picture..."); - } - Log.d(TAG, "Recreating camera preview..."); - createCameraPreviewSession(); // This is called if the picture is discarded*/ - //mPictureSavedListener.onPicturePreview(); + // No code needed here, events are handled separately. } };