diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 5f9c3c2a36c4..be0982077530 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.19 + +* Changes target rotation of captured images to current default display rotation to fix captured + photo orientation to upright. + ## 0.6.18+3 * Fixes incorrect camera preview mirroring for front cameras of devices using the Impeller backend. diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 795a87472278..e52435b3b100 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -392,7 +392,8 @@ class AndroidCameraCameraX extends CameraPlatform { // Configure ImageCapture instance. imageCapture = proxy.newImageCapture( resolutionSelector: presetResolutionSelector, - /* use CameraX default target rotation */ targetRotation: null, + /* use CameraX default target rotation */ targetRotation: + await deviceOrientationManager.getDefaultDisplayRotation(), ); // Configure ImageAnalysis instance. @@ -966,9 +967,9 @@ class AndroidCameraCameraX extends CameraPlatform { await imageCapture!.setFlashMode(CameraXFlashMode.off); } - // Set target rotation to default CameraX rotation only if capture - // orientation not locked. - if (!captureOrientationLocked && shouldSetDefaultRotation) { + // Set target rotation to the current default CameraX rotation if + // the capture orientation is not locked. + if (!captureOrientationLocked) { await imageCapture!.setTargetRotation( await deviceOrientationManager.getDefaultDisplayRotation(), ); diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index 0bf7e8a986a5..09d8688b3231 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_android_camerax description: Android implementation of the camera plugin using the CameraX library. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.6.18+3 +version: 0.6.19 environment: sdk: ^3.7.0 diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 6618e45f26f7..6b2535cf437e 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -3488,7 +3488,7 @@ void main() { ); test( - 'takePicture sets ImageCapture target rotation to currrent photo rotation when orientation unlocked', + 'takePicture sets ImageCapture target rotation as expected when orientation locked or unlocked', () async { final AndroidCameraCameraX camera = AndroidCameraCameraX(); final MockImageCapture mockImageCapture = MockImageCapture(); @@ -3531,7 +3531,7 @@ void main() { // Orientation is unlocked and plugin does not need to set default target // rotation manually. await camera.takePicture(cameraId); - verifyNever(mockImageCapture.setTargetRotation(any)); + verify(mockImageCapture.setTargetRotation(defaultTargetRotation)); // Orientation is locked and plugin does not need to set default target // rotation manually.