From 53af0773b9beb0c13842e5d9f47ddb7f66ceacf4 Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Thu, 5 May 2022 10:22:56 +0200 Subject: [PATCH 01/11] return all the possible cameras --- packages/camera/camera/ios/Classes/CameraPlugin.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index c0a3833dcd64..2e3784403ae4 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -100,8 +100,14 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FLTThreadSafeFlutterResult *)result { if ([@"availableCameras" isEqualToString:call.method]) { if (@available(iOS 10.0, *)) { + NSMutableArray *dicscoveryDevices = [NSMutableArray array]; + [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; + [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; + if (@available(iOS 13.0, *)) { + [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ] + discoverySessionWithDeviceTypes:[NSArray arrayWithArray:dicscoveryDevices] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified]; NSArray *devices = discoverySession.devices; From 80abba95469d889657f786ad7062704d247323db Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Thu, 5 May 2022 10:31:52 +0200 Subject: [PATCH 02/11] version update --- packages/camera/camera/CHANGELOG.md | 390 ++++++++++++++-------------- packages/camera/camera/pubspec.yaml | 2 +- 2 files changed, 199 insertions(+), 193 deletions(-) diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md index bf0ccf86a82e..ab8aa193e7aa 100644 --- a/packages/camera/camera/CHANGELOG.md +++ b/packages/camera/camera/CHANGELOG.md @@ -1,280 +1,284 @@ +## 0.9.5 + +- Return all the available cameras on iOS. + ## 0.9.4+22 -* Removes unnecessary imports. -* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors +- Removes unnecessary imports. +- Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings. ## 0.9.4+21 -* Fixes README code samples. +- Fixes README code samples. ## 0.9.4+20 -* Fixes an issue with the orientation of videos recorded in landscape on Android. +- Fixes an issue with the orientation of videos recorded in landscape on Android. ## 0.9.4+19 -* Migrate deprecated Scaffold SnackBar methods to ScaffoldMessenger. +- Migrate deprecated Scaffold SnackBar methods to ScaffoldMessenger. ## 0.9.4+18 -* Fixes a crash in iOS when streaming on low-performance devices. +- Fixes a crash in iOS when streaming on low-performance devices. ## 0.9.4+17 -* Removes obsolete information from README, and adds OS support table. +- Removes obsolete information from README, and adds OS support table. ## 0.9.4+16 -* Fixes a bug resulting in a `CameraAccessException` that prevents image +- Fixes a bug resulting in a `CameraAccessException` that prevents image capture on some Android devices. ## 0.9.4+15 -* Uses dispatch queue for pixel buffer synchronization on iOS. -* Minor iOS internal code cleanup related to queue helper functions. +- Uses dispatch queue for pixel buffer synchronization on iOS. +- Minor iOS internal code cleanup related to queue helper functions. ## 0.9.4+14 -* Restores compatibility with Flutter 2.5 and 2.8. +- Restores compatibility with Flutter 2.5 and 2.8. ## 0.9.4+13 -* Updates iOS camera's photo capture delegate reference on a background queue to prevent potential race conditions, and some related internal code cleanup. +- Updates iOS camera's photo capture delegate reference on a background queue to prevent potential race conditions, and some related internal code cleanup. ## 0.9.4+12 -* Skips unnecessary AppDelegate setup for unit tests on iOS. -* Internal code cleanup for stricter analysis options. +- Skips unnecessary AppDelegate setup for unit tests on iOS. +- Internal code cleanup for stricter analysis options. ## 0.9.4+11 -* Manages iOS camera's orientation-related states on a background queue to prevent potential race conditions. +- Manages iOS camera's orientation-related states on a background queue to prevent potential race conditions. ## 0.9.4+10 -* iOS performance improvement by moving file writing from the main queue to a background IO queue. +- iOS performance improvement by moving file writing from the main queue to a background IO queue. ## 0.9.4+9 -* iOS performance improvement by moving sample buffer handling from the main queue to a background session queue. -* Minor iOS internal code cleanup related to camera class and its delegate. -* Minor iOS internal code cleanup related to resolution preset, video format, focus mode, exposure mode and device orientation. -* Minor iOS internal code cleanup related to flash mode. +- iOS performance improvement by moving sample buffer handling from the main queue to a background session queue. +- Minor iOS internal code cleanup related to camera class and its delegate. +- Minor iOS internal code cleanup related to resolution preset, video format, focus mode, exposure mode and device orientation. +- Minor iOS internal code cleanup related to flash mode. ## 0.9.4+8 -* Fixes a bug where ImageFormatGroup was ignored in `startImageStream` on iOS. +- Fixes a bug where ImageFormatGroup was ignored in `startImageStream` on iOS. ## 0.9.4+7 -* Fixes a crash in iOS when passing null queue pointer into AVFoundation API due to race condition. -* Minor iOS internal code cleanup related to dispatch queue. +- Fixes a crash in iOS when passing null queue pointer into AVFoundation API due to race condition. +- Minor iOS internal code cleanup related to dispatch queue. ## 0.9.4+6 -* Fixes a crash in iOS when using image stream due to calling Flutter engine API on non-main thread. +- Fixes a crash in iOS when using image stream due to calling Flutter engine API on non-main thread. ## 0.9.4+5 -* Fixes bug where calling a method after the camera was closed resulted in a Java `IllegalStateException` exception. -* Fixes integration tests. +- Fixes bug where calling a method after the camera was closed resulted in a Java `IllegalStateException` exception. +- Fixes integration tests. ## 0.9.4+4 -* Change Android compileSdkVersion to 31. -* Remove usages of deprecated Android API `CamcorderProfile`. -* Update gradle version to 7.0.2 on Android. +- Change Android compileSdkVersion to 31. +- Remove usages of deprecated Android API `CamcorderProfile`. +- Update gradle version to 7.0.2 on Android. ## 0.9.4+3 -* Fix registerTexture and result being called on background thread on iOS. +- Fix registerTexture and result being called on background thread on iOS. ## 0.9.4+2 -* Updated package description; -* Refactor unit test on iOS to make it compatible with new restrictions in Xcode 13 which only supports the use of the `XCUIDevice` in Xcode UI tests. +- Updated package description; +- Refactor unit test on iOS to make it compatible with new restrictions in Xcode 13 which only supports the use of the `XCUIDevice` in Xcode UI tests. ## 0.9.4+1 -* Fixed Android implementation throwing IllegalStateException when switching to a different activity. +- Fixed Android implementation throwing IllegalStateException when switching to a different activity. ## 0.9.4 -* Add web support by endorsing `package:camera_web`. +- Add web support by endorsing `package:camera_web`. ## 0.9.3+1 -* Remove iOS 9 availability check around ultra high capture sessions. +- Remove iOS 9 availability check around ultra high capture sessions. ## 0.9.3 -* Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0. +- Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0. ## 0.9.2+2 -* Ensure that setting the exposure offset returns the new offset value on Android. +- 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. +- Fixed camera controller throwing an exception when being replaced in the preview widget. ## 0.9.2 -* Added functions to pause and resume the camera preview. +- Added functions to pause and resume the camera preview. ## 0.9.1+1 -* Replace `device_info` reference with `device_info_plus` in the [README.md](README.md) +- Replace `device_info` reference with `device_info_plus` in the [README.md](README.md) ## 0.9.1 -* Added `lensAperture`, `sensorExposureTime` and `sensorSensitivity` properties to the `CameraImage` dto. +- Added `lensAperture`, `sensorExposureTime` and `sensorSensitivity` properties to the `CameraImage` dto. ## 0.9.0 -* Complete rewrite of Android plugin to fix many capture, focus, flash, orientation and exposure issues. -* Fixed crash when opening front-facing cameras on some legacy android devices like Sony XZ. -* Android Flash mode works with full precapture sequence. -* Updated Android lint settings. +- Complete rewrite of Android plugin to fix many capture, focus, flash, orientation and exposure issues. +- Fixed crash when opening front-facing cameras on some legacy android devices like Sony XZ. +- Android Flash mode works with full precapture sequence. +- Updated Android lint settings. ## 0.8.1+7 -* Fix device orientation sometimes not affecting the camera preview orientation. +- Fix device orientation sometimes not affecting the camera preview orientation. ## 0.8.1+6 -* Remove references to the Android V1 embedding. +- Remove references to the Android V1 embedding. ## 0.8.1+5 -* Make sure the `setFocusPoint` and `setExposurePoint` coordinates work correctly in all orientations on iOS (instead of only in portrait mode). +- Make sure the `setFocusPoint` and `setExposurePoint` coordinates work correctly in all orientations on iOS (instead of only in portrait mode). ## 0.8.1+4 -* Silenced warnings that may occur during build when using a very +- Silenced warnings that may occur during build when using a very recent version of Flutter relating to null safety. ## 0.8.1+3 -* Do not change camera orientation when iOS device is flat. +- Do not change camera orientation when iOS device is flat. ## 0.8.1+2 -* Fix iOS crash when selecting an unsupported FocusMode. +- Fix iOS crash when selecting an unsupported FocusMode. ## 0.8.1+1 -* Migrate maven repository from jcenter to mavenCentral. +- Migrate maven repository from jcenter to mavenCentral. ## 0.8.1 -* Solved a rotation issue on iOS which caused the default preview to be displayed as landscape right instead of portrait. +- Solved a rotation issue on iOS which caused the default preview to be displayed as landscape right instead of portrait. ## 0.8.0 -* Stable null safety release. -* Solved delay when using the zoom feature on iOS. -* Added a timeout to the pre-capture sequence on Android to prevent crashes when the camera cannot get a focus. -* Updates the example code listed in the [README.md](README.md), so it runs without errors when you simply copy/ paste it into a Flutter App. +- Stable null safety release. +- Solved delay when using the zoom feature on iOS. +- Added a timeout to the pre-capture sequence on Android to prevent crashes when the camera cannot get a focus. +- Updates the example code listed in the [README.md](README.md), so it runs without errors when you simply copy/ paste it into a Flutter App. ## 0.7.0+4 -* Fix crash when taking picture with orientation lock +- Fix crash when taking picture with orientation lock ## 0.7.0+3 -* Clockwise rotation of focus point in android +- Clockwise rotation of focus point in android ## 0.7.0+2 -* Fix example reference in README. -* Revert compileSdkVersion back to 29 (from 30) as this is causing problems with add-to-app configurations. +- Fix example reference in README. +- Revert compileSdkVersion back to 29 (from 30) as this is causing problems with add-to-app configurations. ## 0.7.0+1 -* Ensure communication from JAVA to Dart is done on the main UI thread. +- Ensure communication from JAVA to Dart is done on the main UI thread. ## 0.7.0 -* BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`. [(commit)](https://github.com/flutter/plugins/commit/100c7470d4066b1d0f8f7e4ec6d7c943e736f970) - * Added support for capture orientation locking on Android and iOS. - * Fixed camera preview not rotating correctly on Android and iOS. - * Fixed camera preview sometimes appearing stretched on Android and iOS. - * Fixed videos & photos saving with the incorrect rotation on iOS. -* New Features: - * Adds auto focus support for Android and iOS implementations. [(commmit)](https://github.com/flutter/plugins/commit/71a831790220f898bf8120c8a23840ac6e742db5) - * Adds ImageFormat selection for ImageStream and Video(iOS only). [(commit)](https://github.com/flutter/plugins/commit/da1b4638b750a5ff832d7be86a42831c42c6d6c0) -* Bug Fixes: - * Fixes crash when taking a picture on iOS devices without flash. [(commit)](https://github.com/flutter/plugins/commit/831344490984b1feec007afc9c8595d80b6c13f4) - * Make sure the configured zoom scale is copied over to the final capture builder on Android. Fixes the issue where the preview is zoomed but the final picture is not. [(commit)](https://github.com/flutter/plugins/commit/5916f55664e1772a4c3f0c02c5c71fc11e491b76) - * Fixes crash with using inner camera on some Android devices. [(commit)](https://github.com/flutter/plugins/commit/980b674cb4020c1927917426211a87e275346d5e) - * Improved error feedback by differentiating between uninitialized and disposed camera controllers. [(commit)](https://github.com/flutter/plugins/commit/d0b7109f6b00a0eda03506fed2c74cc123ffc6f3) - * Fixes picture captures causing a crash on some Huawei devices. [(commit)](https://github.com/flutter/plugins/commit/6d18db83f00f4861ffe485aba2d1f8aa08845ce6) +- BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`. [(commit)](https://github.com/flutter/plugins/commit/100c7470d4066b1d0f8f7e4ec6d7c943e736f970) + - Added support for capture orientation locking on Android and iOS. + - Fixed camera preview not rotating correctly on Android and iOS. + - Fixed camera preview sometimes appearing stretched on Android and iOS. + - Fixed videos & photos saving with the incorrect rotation on iOS. +- New Features: + - Adds auto focus support for Android and iOS implementations. [(commmit)](https://github.com/flutter/plugins/commit/71a831790220f898bf8120c8a23840ac6e742db5) + - Adds ImageFormat selection for ImageStream and Video(iOS only). [(commit)](https://github.com/flutter/plugins/commit/da1b4638b750a5ff832d7be86a42831c42c6d6c0) +- Bug Fixes: + - Fixes crash when taking a picture on iOS devices without flash. [(commit)](https://github.com/flutter/plugins/commit/831344490984b1feec007afc9c8595d80b6c13f4) + - Make sure the configured zoom scale is copied over to the final capture builder on Android. Fixes the issue where the preview is zoomed but the final picture is not. [(commit)](https://github.com/flutter/plugins/commit/5916f55664e1772a4c3f0c02c5c71fc11e491b76) + - Fixes crash with using inner camera on some Android devices. [(commit)](https://github.com/flutter/plugins/commit/980b674cb4020c1927917426211a87e275346d5e) + - Improved error feedback by differentiating between uninitialized and disposed camera controllers. [(commit)](https://github.com/flutter/plugins/commit/d0b7109f6b00a0eda03506fed2c74cc123ffc6f3) + - Fixes picture captures causing a crash on some Huawei devices. [(commit)](https://github.com/flutter/plugins/commit/6d18db83f00f4861ffe485aba2d1f8aa08845ce6) ## 0.6.4+5 -* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. +- Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. ## 0.6.4+4 -* Set camera auto focus enabled by default. +- Set camera auto focus enabled by default. ## 0.6.4+3 -* Detect if selected camera supports auto focus and act accordingly on Android. This solves a problem where front facing cameras are not capturing the picture because auto focus is not supported. +- Detect if selected camera supports auto focus and act accordingly on Android. This solves a problem where front facing cameras are not capturing the picture because auto focus is not supported. ## 0.6.4+2 -* Set ImageStreamReader listener to null to prevent stale images when streaming images. +- Set ImageStreamReader listener to null to prevent stale images when streaming images. ## 0.6.4+1 -* Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash. +- Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash. ## 0.6.4 -* Adds auto exposure support for Android and iOS implementations. +- Adds auto exposure support for Android and iOS implementations. ## 0.6.3+4 -* Revert previous dependency update: Changed dependency on camera_platform_interface to >=1.04 <1.1.0. +- Revert previous dependency update: Changed dependency on camera_platform_interface to >=1.04 <1.1.0. ## 0.6.3+3 -* Updated dependency on camera_platform_interface to ^1.2.0. +- Updated dependency on camera_platform_interface to ^1.2.0. ## 0.6.3+2 -* Fixes crash on Android which occurs after video recording has stopped just before taking a picture. +- Fixes crash on Android which occurs after video recording has stopped just before taking a picture. ## 0.6.3+1 -* Fixes flash & torch modes not working on some Android devices. +- Fixes flash & torch modes not working on some Android devices. ## 0.6.3 -* Adds torch mode as a flash mode for Android and iOS implementations. +- Adds torch mode as a flash mode for Android and iOS implementations. ## 0.6.2+1 -* Fix the API documentation for the `CameraController.takePicture` method. +- Fix the API documentation for the `CameraController.takePicture` method. ## 0.6.2 -* Add zoom support for Android and iOS implementations. +- Add zoom support for Android and iOS implementations. ## 0.6.1+1 -* Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up. +- Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up. ## 0.6.1 -* Add flash support for Android and iOS implementations. +- Add flash support for Android and iOS implementations. ## 0.6.0+2 -* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) +- Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) ## 0.6.0+1 @@ -285,6 +289,7 @@ Updated README to inform users that iOS 10.0+ is needed for use As part of implementing federated architecture and making the interface compatible with the web this version contains the following **breaking changes**: Method changes in `CameraController`: + - The `takePicture` method no longer accepts the `path` parameter, but instead returns the captured image as an instance of the `XFile` class; - The `startVideoRecording` method no longer accepts the `filePath`. Instead the recorded video is now returned as a `XFile` instance when the `stopVideoRecording` method completes; - The `stopVideoRecording` method now returns the captured video when it completes; @@ -292,251 +297,250 @@ Method changes in `CameraController`: ## 0.5.8+19 -* Update Flutter SDK constraint. +- Update Flutter SDK constraint. ## 0.5.8+18 -* Suppress unchecked warning in Android tests which prevented the tests to compile. +- Suppress unchecked warning in Android tests which prevented the tests to compile. ## 0.5.8+17 -* Added Android 30 support. +- Added Android 30 support. ## 0.5.8+16 -* Moved package to camera/camera subdir, to allow for federated implementations. +- Moved package to camera/camera subdir, to allow for federated implementations. ## 0.5.8+15 -* Added the `debugCheckIsDisposed` method which can be used in debug mode to validate if the `CameraController` class has been disposed. +- Added the `debugCheckIsDisposed` method which can be used in debug mode to validate if the `CameraController` class has been disposed. ## 0.5.8+14 -* Changed the order of the setters for `mediaRecorder` in `MediaRecorderBuilder.java` to make it more readable. +- Changed the order of the setters for `mediaRecorder` in `MediaRecorderBuilder.java` to make it more readable. ## 0.5.8+13 -* Added Dartdocs for all public APIs. +- Added Dartdocs for all public APIs. ## 0.5.8+12 -* Added information of video not working correctly on Android emulators to `README.md`. +- Added information of video not working correctly on Android emulators to `README.md`. ## 0.5.8+11 -* Fix rare nullptr exception on Android. -* Updated README.md with information about handling App lifecycle changes. +- Fix rare nullptr exception on Android. +- Updated README.md with information about handling App lifecycle changes. ## 0.5.8+10 -* Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`. +- Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`. ## 0.5.8+9 -* Update android compileSdkVersion to 29. +- Update android compileSdkVersion to 29. ## 0.5.8+8 -* Fixed garbled audio (in video) by setting audio encoding bitrate. +- Fixed garbled audio (in video) by setting audio encoding bitrate. ## 0.5.8+7 -* Keep handling deprecated Android v1 classes for backward compatibility. +- Keep handling deprecated Android v1 classes for backward compatibility. ## 0.5.8+6 -* Avoiding uses or overrides a deprecated API in CameraPlugin.java. +- Avoiding uses or overrides a deprecated API in CameraPlugin.java. ## 0.5.8+5 -* Fix compilation/availability issues on iOS. +- Fix compilation/availability issues on iOS. ## 0.5.8+4 -* Fixed bug caused by casting a `CameraAccessException` on Android. +- Fixed bug caused by casting a `CameraAccessException` on Android. ## 0.5.8+3 -* Fix bug in usage example in README.md +- Fix bug in usage example in README.md ## 0.5.8+2 -* Post-v2 embedding cleanups. +- Post-v2 embedding cleanups. ## 0.5.8+1 -* Update lower bound of dart dependency to 2.1.0. +- Update lower bound of dart dependency to 2.1.0. ## 0.5.8 -* Remove Android dependencies fallback. -* Require Flutter SDK 1.12.13+hotfix.5 or greater. +- Remove Android dependencies fallback. +- Require Flutter SDK 1.12.13+hotfix.5 or greater. ## 0.5.7+5 -* Replace deprecated `getFlutterEngine` call on Android. +- Replace deprecated `getFlutterEngine` call on Android. ## 0.5.7+4 -* Add `pedantic` to dev_dependency. +- Add `pedantic` to dev_dependency. ## 0.5.7+3 -* Fix an Android crash when permissions are requested multiple times. +- Fix an Android crash when permissions are requested multiple times. ## 0.5.7+2 -* Remove the deprecated `author:` field from pubspec.yaml -* Migrate the plugin to the pubspec platforms manifest. -* Require Flutter SDK 1.10.0 or greater. +- Remove the deprecated `author:` field from pubspec.yaml +- Migrate the plugin to the pubspec platforms manifest. +- Require Flutter SDK 1.10.0 or greater. ## 0.5.7+1 -* Fix example null exception. +- Fix example null exception. ## 0.5.7 -* Fix unawaited futures. +- Fix unawaited futures. ## 0.5.6+4 -* Android: Use CameraDevice.TEMPLATE_RECORD to improve image streaming. +- Android: Use CameraDevice.TEMPLATE_RECORD to improve image streaming. ## 0.5.6+3 -* Remove AndroidX warning. +- Remove AndroidX warning. ## 0.5.6+2 -* Include lifecycle dependency as a compileOnly one on Android to resolve +- Include lifecycle dependency as a compileOnly one on Android to resolve potential version conflicts with other transitive libraries. ## 0.5.6+1 -* Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in `build.gradle` to support apps that has not been migrated to AndroidX. +- Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in `build.gradle` to support apps that has not been migrated to AndroidX. ## 0.5.6 -* Add support for the v2 Android embedding. This shouldn't affect existing +- Add support for the v2 Android embedding. This shouldn't affect existing functionality. ## 0.5.5+1 -* Fix event type check +- Fix event type check ## 0.5.5 -* Define clang modules for iOS. +- Define clang modules for iOS. ## 0.5.4+3 -* Update and migrate iOS example project. +- Update and migrate iOS example project. ## 0.5.4+2 -* Fix Android NullPointerException on devices with only front-facing camera. +- Fix Android NullPointerException on devices with only front-facing camera. ## 0.5.4+1 -* Fix Android pause and resume video crash when executing in APIs below 24. +- Fix Android pause and resume video crash when executing in APIs below 24. ## 0.5.4 -* Add feature to pause and resume video recording. +- Add feature to pause and resume video recording. ## 0.5.3+1 -* Fix too large request code for FragmentActivity users. +- Fix too large request code for FragmentActivity users. ## 0.5.3 -* Added new quality presets. -* Now all quality presets can be used to control image capture quality. +- Added new quality presets. +- Now all quality presets can be used to control image capture quality. ## 0.5.2+2 -* Fix memory leak related to not unregistering stream handler in FlutterEventChannel when disposing camera. +- Fix memory leak related to not unregistering stream handler in FlutterEventChannel when disposing camera. ## 0.5.2+1 -* Fix bug that prevented video recording with audio. +- Fix bug that prevented video recording with audio. ## 0.5.2 -* Added capability to disable audio for the `CameraController`. (e.g. `CameraController(_, _, - enableAudio: false);`) +- Added capability to disable audio for the `CameraController`. (e.g. `CameraController(_, _, enableAudio: false);`) ## 0.5.1 -* Can now be compiled with earlier Android sdks below 21 when -`` has been added to the project -`AndroidManifest.xml`. For sdks below 21, the plugin won't be registered and calls to it will throw -a `MissingPluginException.` +- Can now be compiled with earlier Android sdks below 21 when + `` has been added to the project + `AndroidManifest.xml`. For sdks below 21, the plugin won't be registered and calls to it will throw + a `MissingPluginException.` ## 0.5.0 -* **Breaking Change** This plugin no longer handles closing and opening the camera on Android +- **Breaking Change** This plugin no longer handles closing and opening the camera on Android lifecycle changes. Please use `WidgetsBindingObserver` to control camera resources on lifecycle changes. See example project for example using `WidgetsBindingObserver`. ## 0.4.3+2 -* Bump the minimum Flutter version to 1.2.0. -* Add template type parameter to `invokeMethod` calls. +- Bump the minimum Flutter version to 1.2.0. +- Add template type parameter to `invokeMethod` calls. ## 0.4.3+1 -* Catch additional `Exception`s from Android and throw as `CameraException`s. +- Catch additional `Exception`s from Android and throw as `CameraException`s. ## 0.4.3 -* Add capability to prepare the capture session for video recording on iOS. +- Add capability to prepare the capture session for video recording on iOS. ## 0.4.2 -* Add sensor orientation value to `CameraDescription`. +- Add sensor orientation value to `CameraDescription`. ## 0.4.1 -* Camera methods are ran in a background thread on iOS. +- Camera methods are ran in a background thread on iOS. ## 0.4.0+3 -* Fixed a crash when the plugin is registered by a background FlutterView. +- Fixed a crash when the plugin is registered by a background FlutterView. ## 0.4.0+2 -* Fix orientation of captured photos when camera is used for the first time on Android. +- Fix orientation of captured photos when camera is used for the first time on Android. ## 0.4.0+1 -* Remove categories. +- Remove categories. ## 0.4.0 -* **Breaking Change** Change iOS image stream format to `ImageFormatGroup.bgra8888` from +- **Breaking Change** Change iOS image stream format to `ImageFormatGroup.bgra8888` from `ImageFormatGroup.yuv420`. ## 0.3.0+4 -* Fixed bug causing black screen on some Android devices. +- Fixed bug causing black screen on some Android devices. ## 0.3.0+3 -* Log a more detailed warning at build time about the previous AndroidX +- Log a more detailed warning at build time about the previous AndroidX migration. ## 0.3.0+2 -* Fix issue with calculating iOS image orientation in certain edge cases. +- Fix issue with calculating iOS image orientation in certain edge cases. ## 0.3.0+1 -* Remove initial method call invocation from static camera method. +- Remove initial method call invocation from static camera method. ## 0.3.0 -* **Breaking change**. Migrate from the deprecated original Android Support +- **Breaking change**. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to [also migrate](https://developer.android.com/jetpack/androidx/migrate) if they're @@ -544,94 +548,96 @@ a `MissingPluginException.` ## 0.2.9+1 -* Fix a crash when failing to start preview. +- Fix a crash when failing to start preview. ## 0.2.9 -* Save photo orientation data on iOS. +- Save photo orientation data on iOS. ## 0.2.8 -* Add access to the image stream from Dart. -* Use `cameraController.startImageStream(listener)` to process the images. +- Add access to the image stream from Dart. +- Use `cameraController.startImageStream(listener)` to process the images. ## 0.2.7 -* Fix issue with crash when the physical device's orientation is unknown. +- Fix issue with crash when the physical device's orientation is unknown. ## 0.2.6 -* Update the camera to use the physical device's orientation instead of the UI +- Update the camera to use the physical device's orientation instead of the UI orientation on Android. ## 0.2.5 -* Fix preview and video size with satisfying conditions of multiple outputs. +- Fix preview and video size with satisfying conditions of multiple outputs. ## 0.2.4 -* Unregister the activity lifecycle callbacks when disposing the camera. +- Unregister the activity lifecycle callbacks when disposing the camera. ## 0.2.3 -* Added path_provider and video_player as dev dependencies because the example uses them. -* Updated example path_provider version to get Dart 2 support. +- Added path_provider and video_player as dev dependencies because the example uses them. +- Updated example path_provider version to get Dart 2 support. ## 0.2.2 -* iOS image capture is done in high quality (full camera size) +- iOS image capture is done in high quality (full camera size) ## 0.2.1 -* Updated Gradle tooling to match Android Studio 3.1.2. +- Updated Gradle tooling to match Android Studio 3.1.2. ## 0.2.0 -* Added support for video recording. -* Changed the example app to add video recording. +- Added support for video recording. +- Changed the example app to add video recording. A lot of **breaking changes** in this version: Getter changes: - - Removed `isStarted` - - Renamed `initialized` to `isInitialized` - - Added `isRecordingVideo` + +- Removed `isStarted` +- Renamed `initialized` to `isInitialized` +- Added `isRecordingVideo` Method changes: - - Renamed `capture` to `takePicture` - - Removed `start` (the preview starts automatically when `initialize` is called) - - Added `startVideoRecording(String filePath)` - - Removed `stop` (the preview stops automatically when `dispose` is called) - - Added `stopVideoRecording` + +- Renamed `capture` to `takePicture` +- Removed `start` (the preview starts automatically when `initialize` is called) +- Added `startVideoRecording(String filePath)` +- Removed `stop` (the preview stops automatically when `dispose` is called) +- Added `stopVideoRecording` ## 0.1.2 -* Fix Dart 2 runtime errors. +- Fix Dart 2 runtime errors. ## 0.1.1 -* Fix Dart 2 runtime error. +- Fix Dart 2 runtime error. ## 0.1.0 -* **Breaking change**. Set SDK constraints to match the Flutter beta release. +- **Breaking change**. Set SDK constraints to match the Flutter beta release. ## 0.0.4 -* Revert regression of `CameraController.capture()` introduced in v. 0.0.3. +- Revert regression of `CameraController.capture()` introduced in v. 0.0.3. ## 0.0.3 -* Improved resource cleanup on Android. Avoids crash on Activity restart. -* Made the Future returned by `CameraController.dispose()` and `CameraController.capture()` actually complete on +- Improved resource cleanup on Android. Avoids crash on Activity restart. +- Made the Future returned by `CameraController.dispose()` and `CameraController.capture()` actually complete on Android. ## 0.0.2 -* Simplified and upgraded Android project template to Android SDK 27. -* Moved Android package to io.flutter.plugins. -* Fixed warnings from the Dart 2.0 analyzer. +- Simplified and upgraded Android project template to Android SDK 27. +- Moved Android package to io.flutter.plugins. +- Fixed warnings from the Dart 2.0 analyzer. ## 0.0.1 -* Initial release +- Initial release diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index fde6663844c2..59cde43dd66a 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing Dart. repository: https://github.com/flutter/plugins/tree/main/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.4+22 +version: 0.9.5 environment: sdk: ">=2.14.0 <3.0.0" From efb576c538540b6f960500a154ca908bbec6a02c Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Thu, 5 May 2022 10:44:22 +0200 Subject: [PATCH 03/11] fix formatting --- packages/camera/camera/ios/Classes/CameraPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index 2e3784403ae4..40a6fbd47595 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -104,7 +104,7 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; if (@available(iOS 13.0, *)) { - [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithArray:dicscoveryDevices] From 6ba4bd8b8dacb05a0100f951a41b299976dd5383 Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Fri, 6 May 2022 18:47:40 +0200 Subject: [PATCH 04/11] add available cameras test --- .../ios/Runner.xcodeproj/project.pbxproj | 6 +- .../ios/RunnerTests/AvailableCamerasTest.m | 135 ++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m diff --git a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj index 37f56d0ed52e..4e53e91afdb2 100644 --- a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -15,6 +15,7 @@ 25C3919135C3D981E6F800D0 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1944D8072499F3B5E7653D44 /* libPods-RunnerTests.a */; }; 334733EA2668111C00DCC49E /* CameraOrientationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 03BB767226653ABE00CE5A93 /* CameraOrientationTests.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 43ED1537282570DE00EB00DE /* AvailableCamerasTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 43ED1536282570DE00EB00DE /* AvailableCamerasTest.m */; }; 788A065A27B0E02900533D74 /* StreamingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 788A065927B0E02900533D74 /* StreamingTest.m */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; @@ -70,6 +71,7 @@ 14AE82C910C2A12F2ECB2094 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 1944D8072499F3B5E7653D44 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 43ED1536282570DE00EB00DE /* AvailableCamerasTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AvailableCamerasTest.m; sourceTree = ""; }; 59848A7CA98C1FADF8840207 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 788A065927B0E02900533D74 /* StreamingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StreamingTest.m; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -145,6 +147,7 @@ E032F24F279F5E94009E9028 /* CameraCaptureSessionQueueRaceConditionTests.m */, E0F95E3C27A32AB900699390 /* CameraPropertiesTests.m */, 788A065927B0E02900533D74 /* StreamingTest.m */, + 43ED1536282570DE00EB00DE /* AvailableCamerasTest.m */, ); path = RunnerTests; sourceTree = ""; @@ -415,6 +418,7 @@ E487C86026D686A10034AC92 /* CameraPreviewPauseTests.m in Sources */, E071CF7427B31DE4006EF3BA /* FLTCamSampleBufferTests.m in Sources */, E04F108627A87CA600573D0C /* FLTSavePhotoDelegateTests.m in Sources */, + 43ED1537282570DE00EB00DE /* AvailableCamerasTest.m in Sources */, F6EE622F2710A6FC00905E4A /* MockFLTThreadSafeFlutterResult.m in Sources */, E0CDBAC227CD9729002561D9 /* CameraTestUtils.m in Sources */, 334733EA2668111C00DCC49E /* CameraOrientationTests.m in Sources */, diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m new file mode 100644 index 000000000000..9fe039eb61a5 --- /dev/null +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -0,0 +1,135 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import camera; +@import camera.Test; +@import XCTest; +@import AVFoundation; +#import +#import "MockFLTThreadSafeFlutterResult.h" + +@interface AVCaptureDeviceMock : AVCaptureDevice + +@end + +@implementation AVCaptureDeviceMock { + NSString *_mockId; + AVCaptureDevicePosition _mockPosition; +} +- (AVCaptureDevicePosition)position { + return _mockPosition; +} +- (NSString *)uniqueID { + return _mockId; +} +-(id)initWithId:(NSString *)localId position:(AVCaptureDevicePosition)localPosition { + _mockId = localId; + _mockPosition = localPosition; + return self; +} + +@end + +@interface AvailableCamerasTest : XCTestCase +@end + +@implementation AvailableCamerasTest + + +- (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { + CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; + XCTestExpectation *expectation = + [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; + + // iPhone 13 Cameras: + id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" position:AVCaptureDevicePositionBack]; + id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" position:AVCaptureDevicePositionFront]; + id ultraWideCamera = [[AVCaptureDeviceMock alloc] initWithId:@"2" position:AVCaptureDevicePositionBack]; + id telephotoCamera = [[AVCaptureDeviceMock alloc] initWithId:@"3" position:AVCaptureDevicePositionBack]; + + NSMutableArray *requiredTypes = [NSMutableArray array]; + [requiredTypes addObjectsFromArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInTelephotoCamera]]; + if (@available(iOS 13.0, *)) { + [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } + + id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); + OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) + .andReturn(discoverySessionMock); + + NSMutableArray *cameras =[NSMutableArray array]; + [cameras addObjectsFromArray:@[wideAngleCamera, frontFacingCamera, telephotoCamera]]; + if (@available(iOS 13.0, *)) { + [cameras addObject:ultraWideCamera]; + } + OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); + + + MockFLTThreadSafeFlutterResult *resultObject = + [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; + + // Set up method call + FlutterMethodCall *call = [FlutterMethodCall + methodCallWithMethodName:@"availableCameras" + arguments:nil + ]; + + [camera handleMethodCallAsync:call result:resultObject]; + + // Verify the result + NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; + if (@available(iOS 13.0, *)) { + XCTAssertTrue([dictionaryResult count] == 4); + } + else { + XCTAssertTrue([dictionaryResult count] == 3); + } + +} +- (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { + CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; + XCTestExpectation *expectation = + [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; + + // iPhone 8 Cameras: + id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" position:AVCaptureDevicePositionBack]; + id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" position:AVCaptureDevicePositionFront]; + + NSMutableArray *requiredTypes = [NSMutableArray array]; + [requiredTypes addObjectsFromArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInTelephotoCamera]]; + if (@available(iOS 13.0, *)) { + [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } + + id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); + OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) + .andReturn(discoverySessionMock); + + NSMutableArray *cameras =[NSMutableArray array]; + [cameras addObjectsFromArray:@[wideAngleCamera, frontFacingCamera]]; + OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); + + + MockFLTThreadSafeFlutterResult *resultObject = + [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; + + // Set up method call + FlutterMethodCall *call = [FlutterMethodCall + methodCallWithMethodName:@"availableCameras" + arguments:nil + ]; + + [camera handleMethodCallAsync:call result:resultObject]; + + // Verify the result + NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; + XCTAssertTrue([dictionaryResult count] == 2); + +} + +@end From 1a6417e97089534a8060261b047bf3a3082e349c Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Fri, 6 May 2022 18:50:58 +0200 Subject: [PATCH 05/11] fix format --- .../ios/RunnerTests/AvailableCamerasTest.m | 200 +++++++++--------- 1 file changed, 101 insertions(+), 99 deletions(-) diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m index 9fe039eb61a5..abd8b1d06d6d 100644 --- a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -14,19 +14,19 @@ @interface AVCaptureDeviceMock : AVCaptureDevice @end @implementation AVCaptureDeviceMock { - NSString *_mockId; - AVCaptureDevicePosition _mockPosition; + NSString *_mockId; + AVCaptureDevicePosition _mockPosition; } - (AVCaptureDevicePosition)position { - return _mockPosition; + return _mockPosition; } - (NSString *)uniqueID { - return _mockId; + return _mockId; } --(id)initWithId:(NSString *)localId position:(AVCaptureDevicePosition)localPosition { - _mockId = localId; - _mockPosition = localPosition; - return self; +- (id)initWithId:(NSString *)localId position:(AVCaptureDevicePosition)localPosition { + _mockId = localId; + _mockPosition = localPosition; + return self; } @end @@ -36,100 +36,102 @@ @interface AvailableCamerasTest : XCTestCase @implementation AvailableCamerasTest - - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { - CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; - XCTestExpectation *expectation = - [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; - - // iPhone 13 Cameras: - id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" position:AVCaptureDevicePositionBack]; - id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" position:AVCaptureDevicePositionFront]; - id ultraWideCamera = [[AVCaptureDeviceMock alloc] initWithId:@"2" position:AVCaptureDevicePositionBack]; - id telephotoCamera = [[AVCaptureDeviceMock alloc] initWithId:@"3" position:AVCaptureDevicePositionBack]; - - NSMutableArray *requiredTypes = [NSMutableArray array]; - [requiredTypes addObjectsFromArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInTelephotoCamera]]; - if (@available(iOS 13.0, *)) { - [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; - } - - id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); - OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]) - .andReturn(discoverySessionMock); - - NSMutableArray *cameras =[NSMutableArray array]; - [cameras addObjectsFromArray:@[wideAngleCamera, frontFacingCamera, telephotoCamera]]; - if (@available(iOS 13.0, *)) { - [cameras addObject:ultraWideCamera]; - } - OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); - - - MockFLTThreadSafeFlutterResult *resultObject = - [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; - - // Set up method call - FlutterMethodCall *call = [FlutterMethodCall - methodCallWithMethodName:@"availableCameras" - arguments:nil - ]; - - [camera handleMethodCallAsync:call result:resultObject]; - - // Verify the result - NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; - if (@available(iOS 13.0, *)) { - XCTAssertTrue([dictionaryResult count] == 4); - } - else { - XCTAssertTrue([dictionaryResult count] == 3); - } - + CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; + XCTestExpectation *expectation = + [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; + + // iPhone 13 Cameras: + id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" + position:AVCaptureDevicePositionBack]; + id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" + position:AVCaptureDevicePositionFront]; + id ultraWideCamera = [[AVCaptureDeviceMock alloc] initWithId:@"2" + position:AVCaptureDevicePositionBack]; + id telephotoCamera = [[AVCaptureDeviceMock alloc] initWithId:@"3" + position:AVCaptureDevicePositionBack]; + + NSMutableArray *requiredTypes = [NSMutableArray array]; + [requiredTypes addObjectsFromArray:@[ + AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera + ]]; + if (@available(iOS 13.0, *)) { + [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } + + id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); + OCMStub([discoverySessionMock + discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) + .andReturn(discoverySessionMock); + + NSMutableArray *cameras = [NSMutableArray array]; + [cameras addObjectsFromArray:@[ wideAngleCamera, frontFacingCamera, telephotoCamera ]]; + if (@available(iOS 13.0, *)) { + [cameras addObject:ultraWideCamera]; + } + OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); + + MockFLTThreadSafeFlutterResult *resultObject = + [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; + + // Set up method call + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras" + arguments:nil]; + + [camera handleMethodCallAsync:call result:resultObject]; + + // Verify the result + NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; + if (@available(iOS 13.0, *)) { + XCTAssertTrue([dictionaryResult count] == 4); + } else { + XCTAssertTrue([dictionaryResult count] == 3); + } } - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { - CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; - XCTestExpectation *expectation = - [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; - - // iPhone 8 Cameras: - id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" position:AVCaptureDevicePositionBack]; - id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" position:AVCaptureDevicePositionFront]; - - NSMutableArray *requiredTypes = [NSMutableArray array]; - [requiredTypes addObjectsFromArray:@[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInTelephotoCamera]]; - if (@available(iOS 13.0, *)) { - [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; - } - - id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); - OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]) - .andReturn(discoverySessionMock); - - NSMutableArray *cameras =[NSMutableArray array]; - [cameras addObjectsFromArray:@[wideAngleCamera, frontFacingCamera]]; - OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); - - - MockFLTThreadSafeFlutterResult *resultObject = - [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; - - // Set up method call - FlutterMethodCall *call = [FlutterMethodCall - methodCallWithMethodName:@"availableCameras" - arguments:nil - ]; - - [camera handleMethodCallAsync:call result:resultObject]; - - // Verify the result - NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; - XCTAssertTrue([dictionaryResult count] == 2); - + CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil]; + XCTestExpectation *expectation = + [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; + + // iPhone 8 Cameras: + id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" + position:AVCaptureDevicePositionBack]; + id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" + position:AVCaptureDevicePositionFront]; + + NSMutableArray *requiredTypes = [NSMutableArray array]; + [requiredTypes addObjectsFromArray:@[ + AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera + ]]; + if (@available(iOS 13.0, *)) { + [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } + + id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); + OCMStub([discoverySessionMock + discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) + .andReturn(discoverySessionMock); + + NSMutableArray *cameras = [NSMutableArray array]; + [cameras addObjectsFromArray:@[ wideAngleCamera, frontFacingCamera ]]; + OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]); + + MockFLTThreadSafeFlutterResult *resultObject = + [[MockFLTThreadSafeFlutterResult alloc] initWithExpectation:expectation]; + + // Set up method call + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras" + arguments:nil]; + + [camera handleMethodCallAsync:call result:resultObject]; + + // Verify the result + NSDictionary *dictionaryResult = (NSDictionary *)resultObject.receivedResult; + XCTAssertTrue([dictionaryResult count] == 2); } @end From 1ca465740c70cff91f3e8d330682010592cda06a Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Mon, 9 May 2022 11:06:02 +0200 Subject: [PATCH 06/11] remove unnecessary NSArray conversion --- .../example/ios/RunnerTests/AvailableCamerasTest.m | 14 ++++++-------- packages/camera/camera/ios/Classes/CameraPlugin.m | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m index abd8b1d06d6d..17cdd4579343 100644 --- a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -60,10 +60,9 @@ - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { } id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); - OCMStub([discoverySessionMock - discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]) + OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:requiredTypes + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) .andReturn(discoverySessionMock); NSMutableArray *cameras = [NSMutableArray array]; @@ -110,10 +109,9 @@ - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { } id discoverySessionMock = OCMClassMock([AVCaptureDeviceDiscoverySession class]); - OCMStub([discoverySessionMock - discoverySessionWithDeviceTypes:[NSArray arrayWithArray:requiredTypes] - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]) + OCMStub([discoverySessionMock discoverySessionWithDeviceTypes:requiredTypes + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]) .andReturn(discoverySessionMock); NSMutableArray *cameras = [NSMutableArray array]; diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index 40a6fbd47595..d6ac7be2f708 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -107,7 +107,7 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:[NSArray arrayWithArray:dicscoveryDevices] + discoverySessionWithDeviceTypes:dicscoveryDevices mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified]; NSArray *devices = discoverySession.devices; From 630f4892f159e1f0f470bfaddca38ccd60de40f8 Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Mon, 9 May 2022 19:06:54 +0200 Subject: [PATCH 07/11] remove AVCaptureDeviceMock --- .../ios/RunnerTests/AvailableCamerasTest.m | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m index 17cdd4579343..eeeef449d6b5 100644 --- a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -9,28 +9,6 @@ #import #import "MockFLTThreadSafeFlutterResult.h" -@interface AVCaptureDeviceMock : AVCaptureDevice - -@end - -@implementation AVCaptureDeviceMock { - NSString *_mockId; - AVCaptureDevicePosition _mockPosition; -} -- (AVCaptureDevicePosition)position { - return _mockPosition; -} -- (NSString *)uniqueID { - return _mockId; -} -- (id)initWithId:(NSString *)localId position:(AVCaptureDevicePosition)localPosition { - _mockId = localId; - _mockPosition = localPosition; - return self; -} - -@end - @interface AvailableCamerasTest : XCTestCase @end @@ -42,14 +20,21 @@ - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; // iPhone 13 Cameras: - id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" - position:AVCaptureDevicePositionBack]; - id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" - position:AVCaptureDevicePositionFront]; - id ultraWideCamera = [[AVCaptureDeviceMock alloc] initWithId:@"2" - position:AVCaptureDevicePositionBack]; - id telephotoCamera = [[AVCaptureDeviceMock alloc] initWithId:@"3" - position:AVCaptureDevicePositionBack]; + AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([wideAngleCamera uniqueID]).andReturn(@"0"); + OCMStub([wideAngleCamera position]).andReturn(AVCaptureDevicePositionBack); + + AVCaptureDevice *frontFacingCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); + OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); + + AVCaptureDevice *ultraWideCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([ultraWideCamera uniqueID]).andReturn(@"2"); + OCMStub([ultraWideCamera position]).andReturn(AVCaptureDevicePositionBack); + + AVCaptureDevice *telephotoCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([telephotoCamera uniqueID]).andReturn(@"3"); + OCMStub([telephotoCamera position]).andReturn(AVCaptureDevicePositionBack); NSMutableArray *requiredTypes = [NSMutableArray array]; [requiredTypes addObjectsFromArray:@[ @@ -95,10 +80,13 @@ - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { [[XCTestExpectation alloc] initWithDescription:@"Result finished"]; // iPhone 8 Cameras: - id wideAngleCamera = [[AVCaptureDeviceMock alloc] initWithId:@"0" - position:AVCaptureDevicePositionBack]; - id frontFacingCamera = [[AVCaptureDeviceMock alloc] initWithId:@"1" - position:AVCaptureDevicePositionFront]; + AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([wideAngleCamera uniqueID]).andReturn(@"0"); + OCMStub([wideAngleCamera position]).andReturn(AVCaptureDevicePositionBack); + + AVCaptureDevice *frontFacingCamera = OCMClassMock([AVCaptureDevice class]); + OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); + OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); NSMutableArray *requiredTypes = [NSMutableArray array]; [requiredTypes addObjectsFromArray:@[ From 6a270ad6c6e33324ad3b7d9e23b6b1d3be48f8b1 Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Tue, 10 May 2022 09:18:30 +0200 Subject: [PATCH 08/11] fix typo --- packages/camera/camera/ios/Classes/CameraPlugin.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index d6ac7be2f708..27f77b16b71e 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -100,14 +100,14 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FLTThreadSafeFlutterResult *)result { if ([@"availableCameras" isEqualToString:call.method]) { if (@available(iOS 10.0, *)) { - NSMutableArray *dicscoveryDevices = [NSMutableArray array]; - [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; - [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; + NSMutableArray *discoveryDevices = [NSMutableArray array]; + [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; + [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; if (@available(iOS 13.0, *)) { - [dicscoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:dicscoveryDevices + discoverySessionWithDeviceTypes:discoveryDevices mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified]; NSArray *devices = discoverySession.devices; From f851e6f9c7b2c64a54718a0c1348e20a52dcf36d Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Tue, 10 May 2022 09:29:39 +0200 Subject: [PATCH 09/11] fix changelog formatting --- packages/camera/camera/CHANGELOG.md | 388 ++++++++++++++-------------- 1 file changed, 193 insertions(+), 195 deletions(-) diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md index ab8aa193e7aa..c2aa03de18ed 100644 --- a/packages/camera/camera/CHANGELOG.md +++ b/packages/camera/camera/CHANGELOG.md @@ -1,284 +1,284 @@ ## 0.9.5 -- Return all the available cameras on iOS. +* Return all the available cameras on iOS. ## 0.9.4+22 -- Removes unnecessary imports. -- Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors +* Removes unnecessary imports. +* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings. ## 0.9.4+21 -- Fixes README code samples. +* Fixes README code samples. ## 0.9.4+20 -- Fixes an issue with the orientation of videos recorded in landscape on Android. +* Fixes an issue with the orientation of videos recorded in landscape on Android. ## 0.9.4+19 -- Migrate deprecated Scaffold SnackBar methods to ScaffoldMessenger. +* Migrate deprecated Scaffold SnackBar methods to ScaffoldMessenger. ## 0.9.4+18 -- Fixes a crash in iOS when streaming on low-performance devices. +* Fixes a crash in iOS when streaming on low-performance devices. ## 0.9.4+17 -- Removes obsolete information from README, and adds OS support table. +* Removes obsolete information from README, and adds OS support table. ## 0.9.4+16 -- Fixes a bug resulting in a `CameraAccessException` that prevents image +* Fixes a bug resulting in a `CameraAccessException` that prevents image capture on some Android devices. ## 0.9.4+15 -- Uses dispatch queue for pixel buffer synchronization on iOS. -- Minor iOS internal code cleanup related to queue helper functions. +* Uses dispatch queue for pixel buffer synchronization on iOS. +* Minor iOS internal code cleanup related to queue helper functions. ## 0.9.4+14 -- Restores compatibility with Flutter 2.5 and 2.8. +* Restores compatibility with Flutter 2.5 and 2.8. ## 0.9.4+13 -- Updates iOS camera's photo capture delegate reference on a background queue to prevent potential race conditions, and some related internal code cleanup. +* Updates iOS camera's photo capture delegate reference on a background queue to prevent potential race conditions, and some related internal code cleanup. ## 0.9.4+12 -- Skips unnecessary AppDelegate setup for unit tests on iOS. -- Internal code cleanup for stricter analysis options. +* Skips unnecessary AppDelegate setup for unit tests on iOS. +* Internal code cleanup for stricter analysis options. ## 0.9.4+11 -- Manages iOS camera's orientation-related states on a background queue to prevent potential race conditions. +* Manages iOS camera's orientation-related states on a background queue to prevent potential race conditions. ## 0.9.4+10 -- iOS performance improvement by moving file writing from the main queue to a background IO queue. +* iOS performance improvement by moving file writing from the main queue to a background IO queue. ## 0.9.4+9 -- iOS performance improvement by moving sample buffer handling from the main queue to a background session queue. -- Minor iOS internal code cleanup related to camera class and its delegate. -- Minor iOS internal code cleanup related to resolution preset, video format, focus mode, exposure mode and device orientation. -- Minor iOS internal code cleanup related to flash mode. +* iOS performance improvement by moving sample buffer handling from the main queue to a background session queue. +* Minor iOS internal code cleanup related to camera class and its delegate. +* Minor iOS internal code cleanup related to resolution preset, video format, focus mode, exposure mode and device orientation. +* Minor iOS internal code cleanup related to flash mode. ## 0.9.4+8 -- Fixes a bug where ImageFormatGroup was ignored in `startImageStream` on iOS. +* Fixes a bug where ImageFormatGroup was ignored in `startImageStream` on iOS. ## 0.9.4+7 -- Fixes a crash in iOS when passing null queue pointer into AVFoundation API due to race condition. -- Minor iOS internal code cleanup related to dispatch queue. +* Fixes a crash in iOS when passing null queue pointer into AVFoundation API due to race condition. +* Minor iOS internal code cleanup related to dispatch queue. ## 0.9.4+6 -- Fixes a crash in iOS when using image stream due to calling Flutter engine API on non-main thread. +* Fixes a crash in iOS when using image stream due to calling Flutter engine API on non-main thread. ## 0.9.4+5 -- Fixes bug where calling a method after the camera was closed resulted in a Java `IllegalStateException` exception. -- Fixes integration tests. +* Fixes bug where calling a method after the camera was closed resulted in a Java `IllegalStateException` exception. +* Fixes integration tests. ## 0.9.4+4 -- Change Android compileSdkVersion to 31. -- Remove usages of deprecated Android API `CamcorderProfile`. -- Update gradle version to 7.0.2 on Android. +* Change Android compileSdkVersion to 31. +* Remove usages of deprecated Android API `CamcorderProfile`. +* Update gradle version to 7.0.2 on Android. ## 0.9.4+3 -- Fix registerTexture and result being called on background thread on iOS. +* Fix registerTexture and result being called on background thread on iOS. ## 0.9.4+2 -- Updated package description; -- Refactor unit test on iOS to make it compatible with new restrictions in Xcode 13 which only supports the use of the `XCUIDevice` in Xcode UI tests. +* Updated package description; +* Refactor unit test on iOS to make it compatible with new restrictions in Xcode 13 which only supports the use of the `XCUIDevice` in Xcode UI tests. ## 0.9.4+1 -- Fixed Android implementation throwing IllegalStateException when switching to a different activity. +* Fixed Android implementation throwing IllegalStateException when switching to a different activity. ## 0.9.4 -- Add web support by endorsing `package:camera_web`. +* Add web support by endorsing `package:camera_web`. ## 0.9.3+1 -- Remove iOS 9 availability check around ultra high capture sessions. +* Remove iOS 9 availability check around ultra high capture sessions. ## 0.9.3 -- Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0. +* Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0. ## 0.9.2+2 -- Ensure that setting the exposure offset returns the new offset value on Android. +* 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. +* Fixed camera controller throwing an exception when being replaced in the preview widget. ## 0.9.2 -- Added functions to pause and resume the camera preview. +* Added functions to pause and resume the camera preview. ## 0.9.1+1 -- Replace `device_info` reference with `device_info_plus` in the [README.md](README.md) +* Replace `device_info` reference with `device_info_plus` in the [README.md](README.md) ## 0.9.1 -- Added `lensAperture`, `sensorExposureTime` and `sensorSensitivity` properties to the `CameraImage` dto. +* Added `lensAperture`, `sensorExposureTime` and `sensorSensitivity` properties to the `CameraImage` dto. ## 0.9.0 -- Complete rewrite of Android plugin to fix many capture, focus, flash, orientation and exposure issues. -- Fixed crash when opening front-facing cameras on some legacy android devices like Sony XZ. -- Android Flash mode works with full precapture sequence. -- Updated Android lint settings. +* Complete rewrite of Android plugin to fix many capture, focus, flash, orientation and exposure issues. +* Fixed crash when opening front-facing cameras on some legacy android devices like Sony XZ. +* Android Flash mode works with full precapture sequence. +* Updated Android lint settings. ## 0.8.1+7 -- Fix device orientation sometimes not affecting the camera preview orientation. +* Fix device orientation sometimes not affecting the camera preview orientation. ## 0.8.1+6 -- Remove references to the Android V1 embedding. +* Remove references to the Android V1 embedding. ## 0.8.1+5 -- Make sure the `setFocusPoint` and `setExposurePoint` coordinates work correctly in all orientations on iOS (instead of only in portrait mode). +* Make sure the `setFocusPoint` and `setExposurePoint` coordinates work correctly in all orientations on iOS (instead of only in portrait mode). ## 0.8.1+4 -- Silenced warnings that may occur during build when using a very +* Silenced warnings that may occur during build when using a very recent version of Flutter relating to null safety. ## 0.8.1+3 -- Do not change camera orientation when iOS device is flat. +* Do not change camera orientation when iOS device is flat. ## 0.8.1+2 -- Fix iOS crash when selecting an unsupported FocusMode. +* Fix iOS crash when selecting an unsupported FocusMode. ## 0.8.1+1 -- Migrate maven repository from jcenter to mavenCentral. +* Migrate maven repository from jcenter to mavenCentral. ## 0.8.1 -- Solved a rotation issue on iOS which caused the default preview to be displayed as landscape right instead of portrait. +* Solved a rotation issue on iOS which caused the default preview to be displayed as landscape right instead of portrait. ## 0.8.0 -- Stable null safety release. -- Solved delay when using the zoom feature on iOS. -- Added a timeout to the pre-capture sequence on Android to prevent crashes when the camera cannot get a focus. -- Updates the example code listed in the [README.md](README.md), so it runs without errors when you simply copy/ paste it into a Flutter App. +* Stable null safety release. +* Solved delay when using the zoom feature on iOS. +* Added a timeout to the pre-capture sequence on Android to prevent crashes when the camera cannot get a focus. +* Updates the example code listed in the [README.md](README.md), so it runs without errors when you simply copy/ paste it into a Flutter App. ## 0.7.0+4 -- Fix crash when taking picture with orientation lock +* Fix crash when taking picture with orientation lock ## 0.7.0+3 -- Clockwise rotation of focus point in android +* Clockwise rotation of focus point in android ## 0.7.0+2 -- Fix example reference in README. -- Revert compileSdkVersion back to 29 (from 30) as this is causing problems with add-to-app configurations. +* Fix example reference in README. +* Revert compileSdkVersion back to 29 (from 30) as this is causing problems with add-to-app configurations. ## 0.7.0+1 -- Ensure communication from JAVA to Dart is done on the main UI thread. +* Ensure communication from JAVA to Dart is done on the main UI thread. ## 0.7.0 -- BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`. [(commit)](https://github.com/flutter/plugins/commit/100c7470d4066b1d0f8f7e4ec6d7c943e736f970) - - Added support for capture orientation locking on Android and iOS. - - Fixed camera preview not rotating correctly on Android and iOS. - - Fixed camera preview sometimes appearing stretched on Android and iOS. - - Fixed videos & photos saving with the incorrect rotation on iOS. -- New Features: - - Adds auto focus support for Android and iOS implementations. [(commmit)](https://github.com/flutter/plugins/commit/71a831790220f898bf8120c8a23840ac6e742db5) - - Adds ImageFormat selection for ImageStream and Video(iOS only). [(commit)](https://github.com/flutter/plugins/commit/da1b4638b750a5ff832d7be86a42831c42c6d6c0) -- Bug Fixes: - - Fixes crash when taking a picture on iOS devices without flash. [(commit)](https://github.com/flutter/plugins/commit/831344490984b1feec007afc9c8595d80b6c13f4) - - Make sure the configured zoom scale is copied over to the final capture builder on Android. Fixes the issue where the preview is zoomed but the final picture is not. [(commit)](https://github.com/flutter/plugins/commit/5916f55664e1772a4c3f0c02c5c71fc11e491b76) - - Fixes crash with using inner camera on some Android devices. [(commit)](https://github.com/flutter/plugins/commit/980b674cb4020c1927917426211a87e275346d5e) - - Improved error feedback by differentiating between uninitialized and disposed camera controllers. [(commit)](https://github.com/flutter/plugins/commit/d0b7109f6b00a0eda03506fed2c74cc123ffc6f3) - - Fixes picture captures causing a crash on some Huawei devices. [(commit)](https://github.com/flutter/plugins/commit/6d18db83f00f4861ffe485aba2d1f8aa08845ce6) +* BREAKING CHANGE: `CameraValue.aspectRatio` now returns `width / height` rather than `height / width`. [(commit)](https://github.com/flutter/plugins/commit/100c7470d4066b1d0f8f7e4ec6d7c943e736f970) + * Added support for capture orientation locking on Android and iOS. + * Fixed camera preview not rotating correctly on Android and iOS. + * Fixed camera preview sometimes appearing stretched on Android and iOS. + * Fixed videos & photos saving with the incorrect rotation on iOS. +* New Features: + * Adds auto focus support for Android and iOS implementations. [(commmit)](https://github.com/flutter/plugins/commit/71a831790220f898bf8120c8a23840ac6e742db5) + * Adds ImageFormat selection for ImageStream and Video(iOS only). [(commit)](https://github.com/flutter/plugins/commit/da1b4638b750a5ff832d7be86a42831c42c6d6c0) +* Bug Fixes: + * Fixes crash when taking a picture on iOS devices without flash. [(commit)](https://github.com/flutter/plugins/commit/831344490984b1feec007afc9c8595d80b6c13f4) + * Make sure the configured zoom scale is copied over to the final capture builder on Android. Fixes the issue where the preview is zoomed but the final picture is not. [(commit)](https://github.com/flutter/plugins/commit/5916f55664e1772a4c3f0c02c5c71fc11e491b76) + * Fixes crash with using inner camera on some Android devices. [(commit)](https://github.com/flutter/plugins/commit/980b674cb4020c1927917426211a87e275346d5e) + * Improved error feedback by differentiating between uninitialized and disposed camera controllers. [(commit)](https://github.com/flutter/plugins/commit/d0b7109f6b00a0eda03506fed2c74cc123ffc6f3) + * Fixes picture captures causing a crash on some Huawei devices. [(commit)](https://github.com/flutter/plugins/commit/6d18db83f00f4861ffe485aba2d1f8aa08845ce6) ## 0.6.4+5 -- Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. +* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. ## 0.6.4+4 -- Set camera auto focus enabled by default. +* Set camera auto focus enabled by default. ## 0.6.4+3 -- Detect if selected camera supports auto focus and act accordingly on Android. This solves a problem where front facing cameras are not capturing the picture because auto focus is not supported. +* Detect if selected camera supports auto focus and act accordingly on Android. This solves a problem where front facing cameras are not capturing the picture because auto focus is not supported. ## 0.6.4+2 -- Set ImageStreamReader listener to null to prevent stale images when streaming images. +* Set ImageStreamReader listener to null to prevent stale images when streaming images. ## 0.6.4+1 -- Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash. +* Added closeCaptureSession() to stopVideoRecording in Camera.java to fix an Android 6 crash. ## 0.6.4 -- Adds auto exposure support for Android and iOS implementations. +* Adds auto exposure support for Android and iOS implementations. ## 0.6.3+4 -- Revert previous dependency update: Changed dependency on camera_platform_interface to >=1.04 <1.1.0. +* Revert previous dependency update: Changed dependency on camera_platform_interface to >=1.04 <1.1.0. ## 0.6.3+3 -- Updated dependency on camera_platform_interface to ^1.2.0. +* Updated dependency on camera_platform_interface to ^1.2.0. ## 0.6.3+2 -- Fixes crash on Android which occurs after video recording has stopped just before taking a picture. +* Fixes crash on Android which occurs after video recording has stopped just before taking a picture. ## 0.6.3+1 -- Fixes flash & torch modes not working on some Android devices. +* Fixes flash & torch modes not working on some Android devices. ## 0.6.3 -- Adds torch mode as a flash mode for Android and iOS implementations. +* Adds torch mode as a flash mode for Android and iOS implementations. ## 0.6.2+1 -- Fix the API documentation for the `CameraController.takePicture` method. +* Fix the API documentation for the `CameraController.takePicture` method. ## 0.6.2 -- Add zoom support for Android and iOS implementations. +* Add zoom support for Android and iOS implementations. ## 0.6.1+1 -- Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up. +* Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up. ## 0.6.1 -- Add flash support for Android and iOS implementations. +* Add flash support for Android and iOS implementations. ## 0.6.0+2 -- Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) +* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276)) ## 0.6.0+1 @@ -289,7 +289,6 @@ Updated README to inform users that iOS 10.0+ is needed for use As part of implementing federated architecture and making the interface compatible with the web this version contains the following **breaking changes**: Method changes in `CameraController`: - - The `takePicture` method no longer accepts the `path` parameter, but instead returns the captured image as an instance of the `XFile` class; - The `startVideoRecording` method no longer accepts the `filePath`. Instead the recorded video is now returned as a `XFile` instance when the `stopVideoRecording` method completes; - The `stopVideoRecording` method now returns the captured video when it completes; @@ -297,250 +296,251 @@ Method changes in `CameraController`: ## 0.5.8+19 -- Update Flutter SDK constraint. +* Update Flutter SDK constraint. ## 0.5.8+18 -- Suppress unchecked warning in Android tests which prevented the tests to compile. +* Suppress unchecked warning in Android tests which prevented the tests to compile. ## 0.5.8+17 -- Added Android 30 support. +* Added Android 30 support. ## 0.5.8+16 -- Moved package to camera/camera subdir, to allow for federated implementations. +* Moved package to camera/camera subdir, to allow for federated implementations. ## 0.5.8+15 -- Added the `debugCheckIsDisposed` method which can be used in debug mode to validate if the `CameraController` class has been disposed. +* Added the `debugCheckIsDisposed` method which can be used in debug mode to validate if the `CameraController` class has been disposed. ## 0.5.8+14 -- Changed the order of the setters for `mediaRecorder` in `MediaRecorderBuilder.java` to make it more readable. +* Changed the order of the setters for `mediaRecorder` in `MediaRecorderBuilder.java` to make it more readable. ## 0.5.8+13 -- Added Dartdocs for all public APIs. +* Added Dartdocs for all public APIs. ## 0.5.8+12 -- Added information of video not working correctly on Android emulators to `README.md`. +* Added information of video not working correctly on Android emulators to `README.md`. ## 0.5.8+11 -- Fix rare nullptr exception on Android. -- Updated README.md with information about handling App lifecycle changes. +* Fix rare nullptr exception on Android. +* Updated README.md with information about handling App lifecycle changes. ## 0.5.8+10 -- Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`. +* Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`. ## 0.5.8+9 -- Update android compileSdkVersion to 29. +* Update android compileSdkVersion to 29. ## 0.5.8+8 -- Fixed garbled audio (in video) by setting audio encoding bitrate. +* Fixed garbled audio (in video) by setting audio encoding bitrate. ## 0.5.8+7 -- Keep handling deprecated Android v1 classes for backward compatibility. +* Keep handling deprecated Android v1 classes for backward compatibility. ## 0.5.8+6 -- Avoiding uses or overrides a deprecated API in CameraPlugin.java. +* Avoiding uses or overrides a deprecated API in CameraPlugin.java. ## 0.5.8+5 -- Fix compilation/availability issues on iOS. +* Fix compilation/availability issues on iOS. ## 0.5.8+4 -- Fixed bug caused by casting a `CameraAccessException` on Android. +* Fixed bug caused by casting a `CameraAccessException` on Android. ## 0.5.8+3 -- Fix bug in usage example in README.md +* Fix bug in usage example in README.md ## 0.5.8+2 -- Post-v2 embedding cleanups. +* Post-v2 embedding cleanups. ## 0.5.8+1 -- Update lower bound of dart dependency to 2.1.0. +* Update lower bound of dart dependency to 2.1.0. ## 0.5.8 -- Remove Android dependencies fallback. -- Require Flutter SDK 1.12.13+hotfix.5 or greater. +* Remove Android dependencies fallback. +* Require Flutter SDK 1.12.13+hotfix.5 or greater. ## 0.5.7+5 -- Replace deprecated `getFlutterEngine` call on Android. +* Replace deprecated `getFlutterEngine` call on Android. ## 0.5.7+4 -- Add `pedantic` to dev_dependency. +* Add `pedantic` to dev_dependency. ## 0.5.7+3 -- Fix an Android crash when permissions are requested multiple times. +* Fix an Android crash when permissions are requested multiple times. ## 0.5.7+2 -- Remove the deprecated `author:` field from pubspec.yaml -- Migrate the plugin to the pubspec platforms manifest. -- Require Flutter SDK 1.10.0 or greater. +* Remove the deprecated `author:` field from pubspec.yaml +* Migrate the plugin to the pubspec platforms manifest. +* Require Flutter SDK 1.10.0 or greater. ## 0.5.7+1 -- Fix example null exception. +* Fix example null exception. ## 0.5.7 -- Fix unawaited futures. +* Fix unawaited futures. ## 0.5.6+4 -- Android: Use CameraDevice.TEMPLATE_RECORD to improve image streaming. +* Android: Use CameraDevice.TEMPLATE_RECORD to improve image streaming. ## 0.5.6+3 -- Remove AndroidX warning. +* Remove AndroidX warning. ## 0.5.6+2 -- Include lifecycle dependency as a compileOnly one on Android to resolve +* Include lifecycle dependency as a compileOnly one on Android to resolve potential version conflicts with other transitive libraries. ## 0.5.6+1 -- Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in `build.gradle` to support apps that has not been migrated to AndroidX. +* Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in `build.gradle` to support apps that has not been migrated to AndroidX. ## 0.5.6 -- Add support for the v2 Android embedding. This shouldn't affect existing +* Add support for the v2 Android embedding. This shouldn't affect existing functionality. ## 0.5.5+1 -- Fix event type check +* Fix event type check ## 0.5.5 -- Define clang modules for iOS. +* Define clang modules for iOS. ## 0.5.4+3 -- Update and migrate iOS example project. +* Update and migrate iOS example project. ## 0.5.4+2 -- Fix Android NullPointerException on devices with only front-facing camera. +* Fix Android NullPointerException on devices with only front-facing camera. ## 0.5.4+1 -- Fix Android pause and resume video crash when executing in APIs below 24. +* Fix Android pause and resume video crash when executing in APIs below 24. ## 0.5.4 -- Add feature to pause and resume video recording. +* Add feature to pause and resume video recording. ## 0.5.3+1 -- Fix too large request code for FragmentActivity users. +* Fix too large request code for FragmentActivity users. ## 0.5.3 -- Added new quality presets. -- Now all quality presets can be used to control image capture quality. +* Added new quality presets. +* Now all quality presets can be used to control image capture quality. ## 0.5.2+2 -- Fix memory leak related to not unregistering stream handler in FlutterEventChannel when disposing camera. +* Fix memory leak related to not unregistering stream handler in FlutterEventChannel when disposing camera. ## 0.5.2+1 -- Fix bug that prevented video recording with audio. +* Fix bug that prevented video recording with audio. ## 0.5.2 -- Added capability to disable audio for the `CameraController`. (e.g. `CameraController(_, _, enableAudio: false);`) +* Added capability to disable audio for the `CameraController`. (e.g. `CameraController(_, _, + enableAudio: false);`) ## 0.5.1 -- Can now be compiled with earlier Android sdks below 21 when - `` has been added to the project - `AndroidManifest.xml`. For sdks below 21, the plugin won't be registered and calls to it will throw - a `MissingPluginException.` +* Can now be compiled with earlier Android sdks below 21 when +`` has been added to the project +`AndroidManifest.xml`. For sdks below 21, the plugin won't be registered and calls to it will throw +a `MissingPluginException.` ## 0.5.0 -- **Breaking Change** This plugin no longer handles closing and opening the camera on Android +* **Breaking Change** This plugin no longer handles closing and opening the camera on Android lifecycle changes. Please use `WidgetsBindingObserver` to control camera resources on lifecycle changes. See example project for example using `WidgetsBindingObserver`. ## 0.4.3+2 -- Bump the minimum Flutter version to 1.2.0. -- Add template type parameter to `invokeMethod` calls. +* Bump the minimum Flutter version to 1.2.0. +* Add template type parameter to `invokeMethod` calls. ## 0.4.3+1 -- Catch additional `Exception`s from Android and throw as `CameraException`s. +* Catch additional `Exception`s from Android and throw as `CameraException`s. ## 0.4.3 -- Add capability to prepare the capture session for video recording on iOS. +* Add capability to prepare the capture session for video recording on iOS. ## 0.4.2 -- Add sensor orientation value to `CameraDescription`. +* Add sensor orientation value to `CameraDescription`. ## 0.4.1 -- Camera methods are ran in a background thread on iOS. +* Camera methods are ran in a background thread on iOS. ## 0.4.0+3 -- Fixed a crash when the plugin is registered by a background FlutterView. +* Fixed a crash when the plugin is registered by a background FlutterView. ## 0.4.0+2 -- Fix orientation of captured photos when camera is used for the first time on Android. +* Fix orientation of captured photos when camera is used for the first time on Android. ## 0.4.0+1 -- Remove categories. +* Remove categories. ## 0.4.0 -- **Breaking Change** Change iOS image stream format to `ImageFormatGroup.bgra8888` from +* **Breaking Change** Change iOS image stream format to `ImageFormatGroup.bgra8888` from `ImageFormatGroup.yuv420`. ## 0.3.0+4 -- Fixed bug causing black screen on some Android devices. +* Fixed bug causing black screen on some Android devices. ## 0.3.0+3 -- Log a more detailed warning at build time about the previous AndroidX +* Log a more detailed warning at build time about the previous AndroidX migration. ## 0.3.0+2 -- Fix issue with calculating iOS image orientation in certain edge cases. +* Fix issue with calculating iOS image orientation in certain edge cases. ## 0.3.0+1 -- Remove initial method call invocation from static camera method. +* Remove initial method call invocation from static camera method. ## 0.3.0 -- **Breaking change**. Migrate from the deprecated original Android Support +* **Breaking change**. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to [also migrate](https://developer.android.com/jetpack/androidx/migrate) if they're @@ -548,96 +548,94 @@ Method changes in `CameraController`: ## 0.2.9+1 -- Fix a crash when failing to start preview. +* Fix a crash when failing to start preview. ## 0.2.9 -- Save photo orientation data on iOS. +* Save photo orientation data on iOS. ## 0.2.8 -- Add access to the image stream from Dart. -- Use `cameraController.startImageStream(listener)` to process the images. +* Add access to the image stream from Dart. +* Use `cameraController.startImageStream(listener)` to process the images. ## 0.2.7 -- Fix issue with crash when the physical device's orientation is unknown. +* Fix issue with crash when the physical device's orientation is unknown. ## 0.2.6 -- Update the camera to use the physical device's orientation instead of the UI +* Update the camera to use the physical device's orientation instead of the UI orientation on Android. ## 0.2.5 -- Fix preview and video size with satisfying conditions of multiple outputs. +* Fix preview and video size with satisfying conditions of multiple outputs. ## 0.2.4 -- Unregister the activity lifecycle callbacks when disposing the camera. +* Unregister the activity lifecycle callbacks when disposing the camera. ## 0.2.3 -- Added path_provider and video_player as dev dependencies because the example uses them. -- Updated example path_provider version to get Dart 2 support. +* Added path_provider and video_player as dev dependencies because the example uses them. +* Updated example path_provider version to get Dart 2 support. ## 0.2.2 -- iOS image capture is done in high quality (full camera size) +* iOS image capture is done in high quality (full camera size) ## 0.2.1 -- Updated Gradle tooling to match Android Studio 3.1.2. +* Updated Gradle tooling to match Android Studio 3.1.2. ## 0.2.0 -- Added support for video recording. -- Changed the example app to add video recording. +* Added support for video recording. +* Changed the example app to add video recording. A lot of **breaking changes** in this version: Getter changes: - -- Removed `isStarted` -- Renamed `initialized` to `isInitialized` -- Added `isRecordingVideo` + - Removed `isStarted` + - Renamed `initialized` to `isInitialized` + - Added `isRecordingVideo` Method changes: - -- Renamed `capture` to `takePicture` -- Removed `start` (the preview starts automatically when `initialize` is called) -- Added `startVideoRecording(String filePath)` -- Removed `stop` (the preview stops automatically when `dispose` is called) -- Added `stopVideoRecording` + - Renamed `capture` to `takePicture` + - Removed `start` (the preview starts automatically when `initialize` is called) + - Added `startVideoRecording(String filePath)` + - Removed `stop` (the preview stops automatically when `dispose` is called) + - Added `stopVideoRecording` ## 0.1.2 -- Fix Dart 2 runtime errors. +* Fix Dart 2 runtime errors. ## 0.1.1 -- Fix Dart 2 runtime error. +* Fix Dart 2 runtime error. ## 0.1.0 -- **Breaking change**. Set SDK constraints to match the Flutter beta release. +* **Breaking change**. Set SDK constraints to match the Flutter beta release. ## 0.0.4 -- Revert regression of `CameraController.capture()` introduced in v. 0.0.3. +* Revert regression of `CameraController.capture()` introduced in v. 0.0.3. ## 0.0.3 -- Improved resource cleanup on Android. Avoids crash on Activity restart. -- Made the Future returned by `CameraController.dispose()` and `CameraController.capture()` actually complete on +* Improved resource cleanup on Android. Avoids crash on Activity restart. +* Made the Future returned by `CameraController.dispose()` and `CameraController.capture()` actually complete on Android. ## 0.0.2 -- Simplified and upgraded Android project template to Android SDK 27. -- Moved Android package to io.flutter.plugins. -- Fixed warnings from the Dart 2.0 analyzer. +* Simplified and upgraded Android project template to Android SDK 27. +* Moved Android package to io.flutter.plugins. +* Fixed warnings from the Dart 2.0 analyzer. ## 0.0.1 -- Initial release +* Initial release From d2a096ebf1d99bf8d139c32c77e5bf4ebd0f9c0a Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Mon, 16 May 2022 09:55:11 +0200 Subject: [PATCH 10/11] add initial camera device enums right to mutable array --- .../example/ios/RunnerTests/AvailableCamerasTest.m | 10 ++-------- packages/camera/camera/ios/Classes/CameraPlugin.m | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m index eeeef449d6b5..8672a5f00abf 100644 --- a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -36,10 +36,7 @@ - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { OCMStub([telephotoCamera uniqueID]).andReturn(@"3"); OCMStub([telephotoCamera position]).andReturn(AVCaptureDevicePositionBack); - NSMutableArray *requiredTypes = [NSMutableArray array]; - [requiredTypes addObjectsFromArray:@[ - AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera - ]]; + NSMutableArray *requiredTypes = [@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera] mutableCopy]; if (@available(iOS 13.0, *)) { [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } @@ -88,10 +85,7 @@ - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); - NSMutableArray *requiredTypes = [NSMutableArray array]; - [requiredTypes addObjectsFromArray:@[ - AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera - ]]; + NSMutableArray *requiredTypes = [@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera] mutableCopy]; if (@available(iOS 13.0, *)) { [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index d4c537628d2f..f404fc5edfc6 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -101,9 +101,7 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FLTThreadSafeFlutterResult *)result { if ([@"availableCameras" isEqualToString:call.method]) { if (@available(iOS 10.0, *)) { - NSMutableArray *discoveryDevices = [NSMutableArray array]; - [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; - [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; + NSMutableArray *discoveryDevices = [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] mutableCopy]; if (@available(iOS 13.0, *)) { [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } From df37438a8cee2a3284173ca9d0cb116d318a480e Mon Sep 17 00:00:00 2001 From: Martin Georgiu Date: Mon, 16 May 2022 10:03:32 +0200 Subject: [PATCH 11/11] fix formatting --- .../camera/example/ios/RunnerTests/AvailableCamerasTest.m | 8 ++++++-- packages/camera/camera/ios/Classes/CameraPlugin.m | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m index 8672a5f00abf..2caac0a03891 100644 --- a/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m +++ b/packages/camera/camera/example/ios/RunnerTests/AvailableCamerasTest.m @@ -36,7 +36,9 @@ - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone { OCMStub([telephotoCamera uniqueID]).andReturn(@"3"); OCMStub([telephotoCamera position]).andReturn(AVCaptureDevicePositionBack); - NSMutableArray *requiredTypes = [@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera] mutableCopy]; + NSMutableArray *requiredTypes = + [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] + mutableCopy]; if (@available(iOS 13.0, *)) { [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } @@ -85,7 +87,9 @@ - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone { OCMStub([frontFacingCamera uniqueID]).andReturn(@"1"); OCMStub([frontFacingCamera position]).andReturn(AVCaptureDevicePositionFront); - NSMutableArray *requiredTypes = [@[AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera] mutableCopy]; + NSMutableArray *requiredTypes = + [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] + mutableCopy]; if (@available(iOS 13.0, *)) { [requiredTypes addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; } diff --git a/packages/camera/camera/ios/Classes/CameraPlugin.m b/packages/camera/camera/ios/Classes/CameraPlugin.m index f404fc5edfc6..29e9460a89b6 100644 --- a/packages/camera/camera/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera/ios/Classes/CameraPlugin.m @@ -101,7 +101,9 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FLTThreadSafeFlutterResult *)result { if ([@"availableCameras" isEqualToString:call.method]) { if (@available(iOS 10.0, *)) { - NSMutableArray *discoveryDevices = [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] mutableCopy]; + NSMutableArray *discoveryDevices = + [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] + mutableCopy]; if (@available(iOS 13.0, *)) { [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; }