Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
* Implements image streaming.
* Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves.
* Implements retrieval of camera information.
* Updates README with plugin overview.
46 changes: 46 additions & 0 deletions packages/camera/camera_android_camerax/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing to camera\_android\_camerax

## Plugin structure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker but I think this should start with an overview of the architecture @bparrishMines designed. Maybe linking the design doc or if not that then a 1 paragraph summary describing the structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one!


The `camera_platform_interface` implementation is located at
`lib/src/android_camera_camerax.dart`, and it is implemented using Dart classes that
are wrapped versions of native Android Java classes.

In `lib/src/`, you will find all of the Dart-wrapped native classes that the plugin
currently uses in its implementation. Each of these classes uses an `InstanceManager`
(implementation in `instance_manager.dart`) to manage objects that are created by
the plugin implementation that map to objects of the same type created on the native
side. This plugin uses [`pigeon`][1] to generate the communication layer between Flutter
and native Android code, so each of these Dart-wrapped classes also have Host API and
Flutter API implementations, as needed. The communication interface is defined in
the `pigeons/camerax_library.dart` file. After editing the communication interface,
regenerate the communication layer by running
`dart run pigeon --input pigeons/camerax_library.dart` from the plugin root.

On the native side in `android/src/main/java/io/flutter/plugins/camerax/`, you'll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider saying java/kotlin or android. Native means enough different things to different people that we should minimize the usage when a more accurate word choice is available.

find the Host API and Flutter API implementations of the same classes wrapped with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be helpful to articulate what host api and Flutter api mean in this context of native (or java ;) code.

Dart in `lib/src/`. These implementations call directly to the classes that they
are wrapping in the CameraX library or other Android libraries. The objects created
in the native code map to objects created on the Dart side, and thus, are also
managed by an `InstanceManager` (implementation in `InstanceManager.java`).

If you need to access any Android classes to contribute to this plugin, you should
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what this line through 30 is saying but I think it mixes architecture and instructions in a way that muddles what the author should use. If the architecture philosophy is include above then I think this can be shortened to "If CameraX or other Android classes do not have a duplicately named implementation in lib/src then follow the for more detail on how to add them.

search in `lib/src/` for any Dart-wrapped classes you may need. If any classes that
you need are not wrapped or you need to access any methods not wrapped in a class,
you must take the additional steps to wrap them to maintain the structure of this plugin.

For more information on the approach of wrapping native libraries for plugins, please
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having read though this I think a bunch of the information only makes sense after understanding the architecture. A plain english version should be at the top along with a link to the design document.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and @bparrishMines to help people ask questions and spread this pattern or even just write about it you should come up with a unique name for the pattern.

see the [design document][2]. For more information on contributing packages in general,
check out our [contribution guide][3].

## Testing

Besides [`pigeon`][1], this plugin also uses [`mockito`][4] to generate mock objects for
testing purposes. To generate the mock objects, run
`dart run build_runner build --delete-conflicting-outputs`.


[1]: https://pub.dev/packages/pigeon
[2]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg
[3]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md
[4]: https://pub.dev/packages/mockito
65 changes: 63 additions & 2 deletions packages/camera/camera_android_camerax/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
# camera_android_camerax
# camera\_android\_camerax

An implementation of the camera plugin on Android using CameraX.
An Android implementation of [`camera`][1] that uses the [CameraX library][2].

*Note*: This package is under development.
See [missing features and limitations](#missing-features-and-limitations).

## Usage

This package is [non-endorsed][3]; the endorsed Android implementation of `camera`
is [`camera_android`][4]. To use this implementation of the plugin instead of
`camera_android`, you will need to specify it in your `pubsepc.yaml` file as a
dependency in addition to `camera`:

```yaml
dependencies:
# ...along with your other dependencies
camera: ^0.10.4
camera_android_camerax: ^0.5.0
```

## Missing features and limitations

### Resolution configuration \[[Issue #120462][120462]\]

Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and
`onCameraResolutionChanged` is unimplemented.

### Locking/Unlocking capture orientation \[[Issue #125915][125915]\]

`lockCaptureOrientation` & `unLockCaptureOrientation` are unimplemented.

### Flash mode configuration \[[Issue #120715][120715]\]

`setFlashMode` is unimplemented.

### Exposure mode, point, & offset configuration \[[Issue #120468][120468]\]

`setExposureMode`, `setExposurePoint`, & `setExposureOffset` are unimplemented.

### Focus mode & point configuration \[[Issue #120467][120467]\]

`setFocusMode` & `setFocusPoint` are unimplemented.

### Zoom configuration \[[Issue #125371][125371]\]

`setZoomLevel` is unimplemented.

## Contributing

For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CONTRIBUTING.md).

<!-- Links -->

[1]: https://pub.dev/packages/camera
[2]: https://developer.android.com/training/camerax
[3]: https://docs.flutter.dev/packages-and-plugins/developing-packages#non-endorsed-federated-plugin
[4]: https://pub.dev/packages/camera_android
[120462]: https://github.com/flutter/flutter/issues/120462
[125915]: https://github.com/flutter/flutter/issues/125915
[120715]: https://github.com/flutter/flutter/issues/120715
[120468]: https://github.com/flutter/flutter/issues/120468
[120467]: https://github.com/flutter/flutter/issues/120467
[125371]: https://github.com/flutter/flutter/issues/125371