Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Ensure setExposureOffset returns new value on Android (#4301)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Sep 2, 2021
1 parent bafc4ee commit 5d1ed48
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.2+2

* Ensure that setting the exposure offset returns the new offset value on Android.

## 0.9.2+1

* Fixed camera controller throwing an exception when being replaced in the preview widget.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ public void setExposureOffset(@NonNull final Result result, double offset) {
exposureOffsetFeature.updateBuilder(previewRequestBuilder);

refreshPreviewCaptureSession(
() -> result.success(null),
() -> result.success(exposureOffsetFeature.getValue()),
(code, message) ->
result.error("setExposureOffsetFailed", "Could not set exposure offset.", null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,13 @@ public void setExposureOffset_shouldUpdateExposureOffsetFeature() {
mockCameraFeatureFactory.createExposureOffsetFeature(mockCameraProperties);
MethodChannel.Result mockResult = mock(MethodChannel.Result.class);

when(mockExposureOffsetFeature.getValue()).thenReturn(1.0);

camera.setExposureOffset(mockResult, 1.0);

verify(mockExposureOffsetFeature, times(1)).setValue(1.0);
verify(mockResult, never()).error(any(), any(), any());
verify(mockResult, times(1)).success(null);
verify(mockResult, times(1)).success(1.0);
}

@Test
Expand Down
7 changes: 7 additions & 0 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
onSetExposureModeButtonPressed(ExposureMode.locked)
: null,
),
TextButton(
child: Text('RESET OFFSET'),
style: styleLocked,
onPressed: controller != null
? () => controller!.setExposureOffset(0.0)
: null,
),
],
),
Center(
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for getting information about and controlling the
and streaming image buffers to dart.
repository: https://github.com/flutter/plugins/tree/master/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.2+1
version: 0.9.2+2

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 5d1ed48

Please sign in to comment.