mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Increase logging around camera errors, skip toast if context is null.
This commit is contained in:
@@ -403,6 +403,7 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
|
||||
try {
|
||||
return CameraXUtil.toJpeg(image, camera.getCameraLensFacing() == CameraSelector.LENS_FACING_FRONT);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Failed to encode captured image.", e);
|
||||
return null;
|
||||
} finally {
|
||||
image.close();
|
||||
@@ -421,6 +422,7 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
|
||||
|
||||
@Override
|
||||
public void onError(ImageCaptureException exception) {
|
||||
Log.w(TAG, "Failed to capture image", exception);
|
||||
flashHelper.endFlash();
|
||||
controller.onCameraError();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,13 @@ class MediaCaptureFragment : Fragment(R.layout.fragment_container), CameraFragme
|
||||
|
||||
override fun onCameraError() {
|
||||
Log.w(TAG, "Camera Error.")
|
||||
Toast.makeText(requireContext(), R.string.MediaSendActivity_camera_unavailable, Toast.LENGTH_SHORT).show()
|
||||
|
||||
val context = this.context
|
||||
if (context != null) {
|
||||
Toast.makeText(context, R.string.MediaSendActivity_camera_unavailable, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Log.w(TAG, "Could not post toast, fragment not attached to a context.")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onImageCaptured(data: ByteArray, width: Int, height: Int) {
|
||||
|
||||
Reference in New Issue
Block a user