-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Add CameraInfo class and clean CameraX plugin #6345
Conversation
| */ | ||
| public CameraAndroidCameraxPlugin() {} | ||
|
|
||
| void setUp(BinaryMessenger binaryMessenger, Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context is not currently being used I noticed but I will need it in a follow up PR as per: https://github.com/flutter/plugins/pull/6307/files#diff-f037f7d2d2a92c6e1b775e086f9da043c0a77dfbb1209c63adf41b0b70899ed2R27-R40
bparrishMines
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good. Added some comments for my first pass through.
|
|
||
| dependencies { | ||
| // CameraX core library using the camera2 implementation must use same version number. | ||
| def camerax_version = "1.2.0-alpha04" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cirrus warning is complaining that this is not version 1.2.0-beta01. Is there a reason you chose this version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the latest at the time I wrote it. I'll change it to the latest!
.../camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java
Outdated
Show resolved
Hide resolved
.../camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/example/android/app/build.gradle
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/camera_info.dart
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/test/camera_info_test.dart
Outdated
Show resolved
Hide resolved
Co-authored-by: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Co-authored-by: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
...droid_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoFlutterApiImpl.java
Show resolved
Hide resolved
.../camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java
Outdated
Show resolved
Hide resolved
| # | ||
| # For details regarding fonts from package dependencies, | ||
| # see https://flutter.dev/custom-fonts/#from-packages | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think you're right. I wonder why this is indicating that a newline doesn't exist.
packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart
Show resolved
Hide resolved
|
|
||
| void setUp(BinaryMessenger binaryMessenger, Context context) { | ||
| // Set up instance manager. | ||
| instanceManager = InstanceManager.open(identifier -> {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callback method should call
new JavaObjectFlutterApi(binaryMessenger).dispose(identifier, reply -> {});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies -- you commented on this before and I meant to ask you about it, but I see what you're saying now!
| ) | ||
| @HostApi(dartHostTestHandler: 'TestJavaObjectHostApi') | ||
| abstract class JavaObjectHostApi { | ||
| void dispose(int instanceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit(optional): the term identifier has personally worked better for us than instanceId. (since instanceId is close to instance.). We changed the term starting in the iOS implementation of the webview_flutter plugin.
bparrishMines
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're also missing the JavaObjectHostApiImpl.java and its setup?
|
|
||
| /// Global instance of [InstanceManager]. | ||
| static final InstanceManager globalInstanceManager = InstanceManager( | ||
| onWeakReferenceRemoved: (_) {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
onWeakReferenceRemoved: (int identifier) {
JavaObjectHostApiImpl().dispose(identifier);
},There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right! Thanks for pointing that out!
bparrishMines
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a last nit
| .dispose(identifier, reply -> {}); | ||
| }); | ||
|
|
||
| // Set up Host APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing GeneratedCameraXLibrary.JavaObjectHostApi.setup(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Ok I think I'm getting the pattern!
Adds
CameraInfoclass wrapper to CameraX plugin and removes unnecessary code/refactors some code to prepare for the implementation ofavailableCameras().Part of flutter/flutter#111125.
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.