plugins
plugins copied to clipboard
[camera] Allow logical cameras to use all physical cameras via zoom on android 11+
Cameras in android versions greater than 11 are strongly pushed by the android team to use logical cameras to wrap multiple physical rear cameras into a single "logical camera."
The Flutter camera plugin has an issue where it calculates zoom incorrectly on these cameras and stops the user from being able to change the zoom appropriately to swap between the physical cameras wrapped by the logical camera exposed via the Android API
This change uses the new APIs implemented in Android 11 to correctly calculate zoom, and allow the camera app to swap between all the physical cameras contained within a single Logical camera in android. Users will still see a single Rear cam, but zooming should swap correctly.
Linked to https://github.com/flutter/plugins/pull/6091
Pre-launch Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use
dart format
.) - [x] I signed the CLA.
- [x] The title of the PR starts with the name of the plugin surrounded by square brackets, e.g.
[shared_preferences]
- [x] I listed at least one issue that this PR fixes in the description above.
- [x] I updated
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes. - [x] I updated
CHANGELOG.md
to add a description of the change, following repository CHANGELOG style. - [x] I updated/added relevant documentation (doc comments with
///
). - [x] I added new tests to check the change I am making, or this PR is test-exempt.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
+1 ! This is a high priority necessity for me and it seems that the PR could go on ? If not yet, how can I test this before the PR is merged ? Sorry, not a Flutter veteran so trying to understand how to use the modified package to test the functionality. Thank you !
EDIT : using the following seems to allow me to test the modified plugin, but not sure where to go from there, is there anything to add to the code or is the zoom detection / lens switch automatic ?
dependency_overrides:
camera_android:
git:
dependency: transitive
url: https://github.com/lucasoskorep/plugins.git
ref: feat/allowCameraZoomToUseAllPhysicalCameras
path: packages/camera/camera_android/
camera:
git:
url: https://github.com/lucasoskorep/plugins.git
ref: feat/allowCameraZoomToUseAllPhysicalCameras
path: packages/camera/camera/
+1 ! This is a high priority necessity for me and it seems that the PR could go on ? If not yet, how can I test this before the PR is merged ? Sorry, not a Flutter veteran so trying to understand how to use the modified package to test the functionality. Thank you !
EDIT : using the following seems to allow me to test the modified plugin, but not sure where to go from there, is there anything to add to the code or is the zoom detection / lens switch automatic ?
dependency_overrides: camera_android: git: dependency: transitive url: https://github.com/lucasoskorep/plugins.git ref: feat/allowCameraZoomToUseAllPhysicalCameras path: packages/camera/camera_android/ camera: git: url: https://github.com/lucasoskorep/plugins.git ref: feat/allowCameraZoomToUseAllPhysicalCameras path: packages/camera/camera/
This is the fix I have for my application for now. Still pending @stuartmorgan's final approval though so sit tight for getting it from the main package itself!
As for functionality any android phone with a logical camera hiding multiple physical cameras will just return the correct min and max zoom values with the fix so no code changes outside of potentially how you are guarding min and max zoom values :)
@stuartmorgan thanks for reviewing the PR! Got the requested changes added in and updated the version to +3 in pubspec and changelog.md so this PR would be up to date. Let me know if there is anything else you'd like added and I can get fixes set up for it :)
@stuartmorgan This seems to be ready for another look