Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2197235
Fixed video orientation on iOS
BeMacized Dec 30, 2020
5988830
Remove unnecessary check
BeMacized Jan 4, 2021
6bcf07d
Merge branch 'master' into fix/video-photo-preview-rotation
BeMacized Jan 4, 2021
9c4d4ca
Expand platform interface to support reporting device orientation
BeMacized Jan 4, 2021
484e02f
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 4, 2021
ed56fac
Switch to flutter DeviceOrientation enum
BeMacized Jan 4, 2021
1092177
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 4, 2021
07931a7
Fix preview rotation on iOS
BeMacized Jan 4, 2021
abe4360
Fix preview rotation for android
BeMacized Jan 4, 2021
4dcbbf7
Update unit tests
BeMacized Jan 4, 2021
69f752d
Fix rotation on initialise.
BeMacized Jan 4, 2021
fb42049
Keep EXIF data and picture orientation
mvanbeusekom Jan 5, 2021
13b9305
Fix photo capture orientation
mvanbeusekom Jan 5, 2021
eab58fe
Add interface methods for (un)locking the capture orientation.
BeMacized Jan 5, 2021
273d6e0
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
27bba29
Update capture orientation interfaces and add unit tests.
BeMacized Jan 5, 2021
751921a
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
859076f
Made device orientation mandatory for locking capture orientation in …
BeMacized Jan 5, 2021
d13b8ae
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
a8a9d43
Add capture orientation locking (iOS done, Android WIP)
BeMacized Jan 5, 2021
165c1ed
Code format
BeMacized Jan 5, 2021
3e9aad7
Add orientation lock to android implementation
BeMacized Jan 5, 2021
118bd00
Update comment
BeMacized Jan 5, 2021
ef56d9d
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
aa2c392
Maintain preview rotation while recording
BeMacized Jan 5, 2021
0aba73a
Merge branch 'master' into fix/video-photo-preview-rotation-platform-…
BeMacized Jan 5, 2021
0c74a4b
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
0bb07be
Update comment.
BeMacized Jan 5, 2021
5f845fe
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
a2c3fbf
Update changelog and pubspec version
BeMacized Jan 5, 2021
99ddc49
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
BeMacized Jan 5, 2021
9242af0
Updated changelog and pubspec version
BeMacized Jan 5, 2021
1d409b9
Update packages/camera/camera_platform_interface/lib/src/events/devic…
BeMacized Jan 5, 2021
96a739a
Merge branch 'master' into fix/video-photo-preview-rotation-platform-…
mvanbeusekom Jan 6, 2021
3df1a7b
Merge branch 'master' into fix/video-photo-preview-rotation
mvanbeusekom Jan 6, 2021
3a69c94
Merge branch 'fix/video-photo-preview-rotation-platform-interface' in…
mvanbeusekom Jan 6, 2021
5ece84b
Merge with master
mvanbeusekom Jan 6, 2021
e69f746
Fix formatting
mvanbeusekom Jan 6, 2021
1d84bae
Fix deprecation warning
mvanbeusekom Jan 6, 2021
f779fdc
Merge branch 'master' into fix/video-photo-preview-rotation
BeMacized Jan 11, 2021
3ca8eaf
Update platform interface dependency
BeMacized Jan 11, 2021
2aa1b53
Merge branch 'master' into fix/video-photo-preview-rotation
BeMacized Jan 11, 2021
3135953
Rollback update to Android compileSdkVersion 30
mvanbeusekom Jan 13, 2021
fd412a3
Revert "Rollback update to Android compileSdkVersion 30"
mvanbeusekom Jan 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into fix/video-photo-preview-rotation
# Conflicts:
#	packages/camera/camera/CHANGELOG.md
#	packages/camera/camera/android/src/test/java/io/flutter/plugins/camera/DartMessengerTest.java
#	packages/camera/camera/ios/Classes/CameraPlugin.m
#	packages/camera/camera/lib/src/camera_controller.dart
#	packages/camera/camera/pubspec.yaml
#	packages/camera/camera/test/camera_value_test.dart
  • Loading branch information
BeMacized committed Jan 11, 2021
commit 2aa1b53b29946d8b64706693bcc67d665b1552b6
8 changes: 8 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
* Fixed videos & photos saving with the incorrect rotation on iOS.
* BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`.

## 0.6.6

* Adds auto focus support for Android and iOS implementations.

## 0.6.5

* Adds ImageFormat selection for ImageStream and Video(iOS only).

## 0.6.4+5

* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.camera;

import android.app.Activity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.camera;

import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void sendCameraErrorEvent_includesErrorDescriptions() {
}

@Test
public void sendCameraInitializedEvent_includesParams() {
dartMessenger.sendCameraInitializedEvent(0, 0, ExposureMode.auto, true);
public void sendCameraInitializedEvent_includesPreviewSize() {
dartMessenger.sendCameraInitializedEvent(0, 0, ExposureMode.auto, FocusMode.auto, true, true);

List<ByteBuffer> sentMessages = fakeBinaryMessenger.getMessages();
assertEquals(1, sentMessages.size());
Expand Down
70 changes: 62 additions & 8 deletions packages/camera/camera/ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,44 @@ static UIDeviceOrientation getUIDeviceOrientationForString(NSString *orientation
};
}

// Mirrors FocusMode in camera.dart
typedef enum {
FocusModeAuto,
FocusModeLocked,
} FocusMode;

static NSString *getStringForFocusMode(FocusMode mode) {
switch (mode) {
case FocusModeAuto:
return @"auto";
case FocusModeLocked:
return @"locked";
}
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSURLErrorUnknown
userInfo:@{
NSLocalizedDescriptionKey : [NSString
stringWithFormat:@"Unknown string for focus mode"]
}];
@throw error;
}

static FocusMode getFocusModeForString(NSString *mode) {
if ([mode isEqualToString:@"auto"]) {
return FocusModeAuto;
} else if ([mode isEqualToString:@"locked"]) {
return FocusModeLocked;
} else {
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSURLErrorUnknown
userInfo:@{
NSLocalizedDescriptionKey : [NSString
stringWithFormat:@"Unknown focus mode %@", mode]
}];
@throw error;
}
}

// Mirrors ResolutionPreset in camera.dart
typedef enum {
veryLow,
Expand Down Expand Up @@ -328,6 +366,8 @@ - (instancetype)initWithCameraName:(NSString *)cameraName
_dispatchQueue = dispatchQueue;
_captureSession = [[AVCaptureSession alloc] init];
_flashMode = FlashModeAuto;
_exposureMode = ExposureModeAuto;
_focusMode = FocusModeAuto;
_lockedCaptureOrientation = UIDeviceOrientationUnknown;

_captureDevice = [AVCaptureDevice deviceWithUniqueID:cameraName];
Expand Down Expand Up @@ -1316,14 +1356,17 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
(unsigned long)cameraId]
binaryMessenger:_messenger];
_camera.methodChannel = methodChannel;
[methodChannel invokeMethod:@"initialized"
arguments:@{
@"previewWidth" : @(_camera.previewSize.width),
@"previewHeight" : @(_camera.previewSize.height),
@"exposureMode" : getStringForExposureMode([_camera exposureMode]),
@"exposurePointSupported" :
@([_camera.captureDevice isExposurePointOfInterestSupported]),
}];
[methodChannel
invokeMethod:@"initialized"
arguments:@{
@"previewWidth" : @(_camera.previewSize.width),
@"previewHeight" : @(_camera.previewSize.height),
@"exposureMode" : getStringForExposureMode([_camera exposureMode]),
@"focusMode" : getStringForFocusMode([_camera focusMode]),
@"exposurePointSupported" :
@([_camera.captureDevice isExposurePointOfInterestSupported]),
@"focusPointSupported" : @([_camera.captureDevice isFocusPointOfInterestSupported]),
}];
[self sendDeviceOrientation:[UIDevice currentDevice].orientation];
[_camera start];
result(nil);
Expand Down Expand Up @@ -1382,6 +1425,17 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
[_camera lockCaptureOrientationWithResult:result orientation:call.arguments[@"orientation"]];
} else if ([@"unlockCaptureOrientation" isEqualToString:call.method]) {
[_camera unlockCaptureOrientationWithResult:result];
} else if ([@"setFocusMode" isEqualToString:call.method]) {
[_camera setFocusModeWithResult:result mode:call.arguments[@"mode"]];
} else if ([@"setFocusPoint" isEqualToString:call.method]) {
BOOL reset = ((NSNumber *)call.arguments[@"reset"]).boolValue;
double x = 0.5;
double y = 0.5;
if (!reset) {
x = ((NSNumber *)call.arguments[@"x"]).doubleValue;
y = ((NSNumber *)call.arguments[@"y"]).doubleValue;
}
[_camera setFocusPointWithResult:result x:x y:y];
} else {
result(FlutterMethodNotImplemented);
}
Expand Down
41 changes: 41 additions & 0 deletions packages/camera/camera/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CameraValue {
this.exposureMode,
this.focusMode,
this.exposurePointSupported,
this.focusPointSupported,
this.deviceOrientation,
this.lockedCaptureOrientation,
this.recordingOrientation,
Expand All @@ -58,6 +59,7 @@ class CameraValue {
isRecordingPaused: false,
flashMode: FlashMode.auto,
exposurePointSupported: false,
focusPointSupported: false,
deviceOrientation: DeviceOrientation.portraitUp,
);

Expand Down Expand Up @@ -111,6 +113,9 @@ class CameraValue {
/// Whether setting the exposure point is supported.
final bool exposurePointSupported;

/// Whether setting the focus point is supported.
final bool focusPointSupported;

/// The current device orientation.
final DeviceOrientation deviceOrientation;

Expand Down Expand Up @@ -139,6 +144,7 @@ class CameraValue {
ExposureMode exposureMode,
FocusMode focusMode,
bool exposurePointSupported,
bool focusPointSupported,
DeviceOrientation deviceOrientation,
Optional<DeviceOrientation> lockedCaptureOrientation,
Optional<DeviceOrientation> recordingOrientation,
Expand All @@ -156,6 +162,7 @@ class CameraValue {
focusMode: focusMode ?? this.focusMode,
exposurePointSupported:
exposurePointSupported ?? this.exposurePointSupported,
focusPointSupported: focusPointSupported ?? this.focusPointSupported,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
lockedCaptureOrientation: lockedCaptureOrientation == null
? this.lockedCaptureOrientation
Expand All @@ -176,7 +183,9 @@ class CameraValue {
'isStreamingImages: $isStreamingImages, '
'flashMode: $flashMode, '
'exposureMode: $exposureMode, '
'focusMode: $focusMode, '
'exposurePointSupported: $exposurePointSupported, '
'focusPointSupported: $focusPointSupported, '
'deviceOrientation: $deviceOrientation, '
'lockedCaptureOrientation: $lockedCaptureOrientation, '
'recordingOrientation: $recordingOrientation)';
Expand Down Expand Up @@ -769,6 +778,16 @@ class CameraController extends ValueNotifier<CameraValue> {
}
}

/// Sets the focus mode for taking pictures.
Future<void> setFocusMode(FocusMode mode) async {
try {
await CameraPlatform.instance.setFocusMode(_cameraId, mode);
value = value.copyWith(focusMode: mode);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}

/// Unlocks the capture orientation.
Future<void> unlockCaptureOrientation() async {
try {
Expand All @@ -779,6 +798,28 @@ class CameraController extends ValueNotifier<CameraValue> {
}
}

/// Sets the focus point for automatically determining the focus value.
Future<void> setFocusPoint(Offset point) async {
if (point != null &&
(point.dx < 0 || point.dx > 1 || point.dy < 0 || point.dy > 1)) {
throw ArgumentError(
'The values of point should be anywhere between (0,0) and (1,1).');
}
try {
await CameraPlatform.instance.setFocusPoint(
_cameraId,
point == null
? null
: Point<double>(
point.dx,
point.dy,
),
);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}

/// Releases the resources of this camera.
@override
Future<void> dispose() async {
Expand Down
3 changes: 2 additions & 1 deletion packages/camera/camera/test/camera_value_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ void main() {
exposureMode: ExposureMode.auto,
focusMode: FocusMode.auto,
exposurePointSupported: true,
focusPointSupported: true,
deviceOrientation: DeviceOrientation.portraitUp,
lockedCaptureOrientation: DeviceOrientation.portraitUp,
recordingOrientation: DeviceOrientation.portraitUp,
);

expect(cameraValue.toString(),
'CameraValue(isRecordingVideo: false, isInitialized: false, errorDescription: null, previewSize: Size(10.0, 10.0), isStreamingImages: false, flashMode: FlashMode.auto, exposureMode: null, exposurePointSupported: true, deviceOrientation: DeviceOrientation.portraitUp, lockedCaptureOrientation: DeviceOrientation.portraitUp, recordingOrientation: DeviceOrientation.portraitUp)');
'CameraValue(isRecordingVideo: false, isInitialized: false, errorDescription: null, previewSize: Size(10.0, 10.0), isStreamingImages: false, flashMode: FlashMode.auto, exposureMode: ExposureMode.auto, focusMode: FocusMode.auto, exposurePointSupported: true, focusPointSupported: true, deviceOrientation: DeviceOrientation.portraitUp, lockedCaptureOrientation: DeviceOrientation.portraitUp, recordingOrientation: DeviceOrientation.portraitUp)');
});
});
}
You are viewing a condensed version of this merge commit. You can view the full changes here.