Control commit

This commit is contained in:
Captain Arepa 2024-06-07 14:46:56 -04:00
parent bbbe4344fe
commit 6166aed715
2 changed files with 30 additions and 7 deletions

View file

@ -81,11 +81,13 @@ public class SegpassCameraActivity extends AppCompatActivity implements Activity
@Override
public void onPictureTakenSuccess(String base64) {
cameraLayout.showToast("Base64 generated.");
this.finish();
}
@Override
public void onPictureTakenFail(String error) {
cameraLayout.showToast(error);
this.finish();
}
/**
@ -95,6 +97,7 @@ public class SegpassCameraActivity extends AppCompatActivity implements Activity
@Override
public void onCameraInitError(String errorMessage) {
cameraLayout.showToast(errorMessage);
this.finish();
}
/**

View file

@ -92,9 +92,15 @@ public class SegpassCamera {
/**
* Error constants
*/
private static final String ERROR_MSG_CAMERA_ACCESS = "Camera access error.";
private static final String ERROR_MSG_CAMERA_TIMEOUT = "Timeout waiting to lock camera opening.";
private static final String ERROR_MSG_NO_CAMERA_PREVIEW_SIZE = "No compatible picture image sizes found.";
private static final String ERROR_MSG_CAMERA_ACCESS = "Error de acceso a 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_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.";
private static final String ERROR_STATE_MSG_CAMERA_DISABLED = "Error: cámara inhabilitada.";
private static final String ERROR_STATE_MSG_CAMERA_DEVICE = "Error fatal en cámara. Intente reiniciar aplicación o dispositivo.";
private static final String ERROR_STATE_MSG_CAMERA_SERVICE = "Error fatal en cámara. Intente reiniciar dispositivo.";
/**
* ID of the current {@link CameraDevice}.
@ -238,7 +244,23 @@ public class SegpassCamera {
mCameraOpenCloseLock.release();
cameraDevice.close();
mCameraDevice = null;
mActivity.finish();
switch (error) {
case CameraDevice.StateCallback.ERROR_CAMERA_IN_USE:
mCameraCallback.onCameraInitError(ERROR_STATE_MSG_CAMERA_IN_USE);
break;
case CameraDevice.StateCallback.ERROR_MAX_CAMERAS_IN_USE:
mCameraCallback.onCameraInitError(ERROR_STATE_MSG_MAX_CAMERAS_IN_USE);
break;
case CameraDevice.StateCallback.ERROR_CAMERA_DISABLED:
mCameraCallback.onCameraInitError(ERROR_STATE_MSG_CAMERA_DISABLED);
break;
case CameraDevice.StateCallback.ERROR_CAMERA_DEVICE:
mCameraCallback.onCameraInitError(ERROR_STATE_MSG_CAMERA_DEVICE);
break;
case CameraDevice.StateCallback.ERROR_CAMERA_SERVICE:
mCameraCallback.onCameraInitError(ERROR_STATE_MSG_CAMERA_SERVICE);
break;
}
}
};
@ -269,7 +291,6 @@ public class SegpassCamera {
*/
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = reader -> {
mImage = reader.acquireNextImage();
//mBackgroundHandler.post(new ImageSaverUtil(mImage, base64Callback));
};
@ -771,9 +792,8 @@ public class SegpassCamera {
}
public void savePicture() {
// Save the picture and finish activity to go back
// Save the picture. Delegate later actions to the host application.
mBackgroundHandler.post(new ImageSaverUtil(mImage, base64Callback));
mActivity.finish();
}
public void discardPicture() {