-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[camerax] Implement onCameraClosing #3419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
6125eca
Recreating image capture impl from flutter/plugins
camsim99 5be1371
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 b2fce3d
Fix integration tesT
camsim99 ed62a9a
Merge branch 'main' into camx_imgcap
camsim99 2e3027b
Analyzer pt 2
camsim99 fbd3fe5
Merge branch 'camx_imgcap' of github.com:camsim99/packages into camx_…
camsim99 dfa477e
Personal cleanup
camsim99 a651b92
Add initialization of controller
camsim99 884fd6c
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 d5f8b91
Modify some docs
camsim99 060b7e5
Address review
camsim99 ff50c70
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 fe6f1fc
Fix analyze
camsim99 e2643ae
Update packages/camera/camera_android_camerax/android/src/main/java/i…
camsim99 b7194f7
Update packages/camera/camera_android_camerax/lib/src/image_capture.dart
camsim99 dadc230
Start addressing review
camsim99 d15e1d4
Finish addressing review
camsim99 6dc2b77
Fix analyze
camsim99 f826b62
Generate mocks on stable
camsim99 0f7f29a
Fix/add tests
camsim99 1e9739b
Add isBound dart test
camsim99 9ba20d0
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 5bf6b17
Start dev
camsim99 5e58b2c
Add cameraClosing impl
camsim99 4c8c94d
Add tests
camsim99 6a0de08
Implement occ with camera state
camsim99 d3ed3e7
Reimplement with live camera state
camsim99 d1c684f
Start adding tests
camsim99 c04d8c1
Add java tests
camsim99 b2322d2
Formatting
camsim99 3545aec
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 e1f5bdb
Fix flutter analyze
camsim99 2d3409b
Fix analyze
camsim99 1f40f47
Review
camsim99 6c9b04e
Fix tests, review 2
camsim99 6c6cbb4
review 3
camsim99 a0ea3c5
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 06c1545
fix analyze
camsim99 681a117
Fix cast
camsim99 1143a03
generate mocks on stable
camsim99 d431511
Formatting
camsim99 ab3c085
Add missing tests
camsim99 631f972
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 70c817a
Fix analyze
camsim99 426b438
Bump camerax version
camsim99 2bc4877
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 0fcf7c6
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 6c49bd9
Formatting
camsim99 b9daeb1
pair programming w/maurice
camsim99 3345878
Fixing plugin
camsim99 9f6646f
Current status
camsim99 265eb1e
Remove print statements
camsim99 bfc4b5e
Add print
camsim99 4f3c342
remove comments
camsim99 e3c7a5b
Review 2
camsim99 f341f7f
Fixing tests
camsim99 0d4b021
Fix tests, format
camsim99 ca3bd9e
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 540ee98
Fix test
camsim99 debcd3a
Fix camera test
camsim99 a79ee62
Start addressing review
camsim99 438f592
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 c44fc06
Address review, remove cast
camsim99 83aea10
Fix java tests
camsim99 5f435e8
Fix dart tests
camsim99 581af94
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 828a04040e111e5eec07056e82037a930f5fd5a2 | ||
| 66fa4c5d301c5093cb4403b39e3d61f604b96d90 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...x/android/src/main/java/io/flutter/plugins/camerax/CameraStateErrorFlutterApiWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // 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. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.VisibleForTesting; | ||
| import androidx.camera.core.CameraState; | ||
| import io.flutter.plugin.common.BinaryMessenger; | ||
| import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateErrorFlutterApi; | ||
|
|
||
| /** | ||
| * Flutter API implementation for {@link CameraStateError}. | ||
| * | ||
| * <p>This class may handle adding native instances that are attached to a Dart instance or passing | ||
| * arguments of callbacks methods to a Dart instance. | ||
| */ | ||
| public class CameraStateErrorFlutterApiWrapper { | ||
| private final BinaryMessenger binaryMessenger; | ||
| private final InstanceManager instanceManager; | ||
| private CameraStateErrorFlutterApi cameraStateErrorFlutterApi; | ||
|
|
||
| /** | ||
| * Constructs a {@link CameraStateErrorFlutterApiWrapper}. | ||
| * | ||
| * @param binaryMessenger used to communicate with Dart over asynchronous messages | ||
| * @param instanceManager maintains instances stored to communicate with attached Dart objects | ||
| */ | ||
| public CameraStateErrorFlutterApiWrapper( | ||
| @NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) { | ||
| this.binaryMessenger = binaryMessenger; | ||
| this.instanceManager = instanceManager; | ||
| cameraStateErrorFlutterApi = new CameraStateErrorFlutterApi(binaryMessenger); | ||
| } | ||
|
|
||
| /** | ||
| * Stores the {@link CameraStateError} instance and notifies Dart to create and store a new {@link | ||
| * CameraStateError} instance that is attached to this one. If {@code instance} has already been | ||
| * added, this method does nothing. | ||
| */ | ||
camsim99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public void create( | ||
| @NonNull CameraState.StateError instance, | ||
| @NonNull Long code, | ||
| @NonNull CameraStateErrorFlutterApi.Reply<Void> callback) { | ||
reidbaker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!instanceManager.containsInstance(instance)) { | ||
| cameraStateErrorFlutterApi.create( | ||
| instanceManager.addHostCreatedInstance(instance), code, callback); | ||
| } | ||
| } | ||
|
|
||
| /** Sets the Flutter API used to send messages to Dart. */ | ||
| @VisibleForTesting | ||
| void setApi(@NonNull CameraStateErrorFlutterApi api) { | ||
| this.cameraStateErrorFlutterApi = api; | ||
| } | ||
| } | ||
101 changes: 101 additions & 0 deletions
101
...amerax/android/src/main/java/io/flutter/plugins/camerax/CameraStateFlutterApiWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // 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. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import androidx.annotation.VisibleForTesting; | ||
| import androidx.camera.core.CameraState; | ||
| import io.flutter.plugin.common.BinaryMessenger; | ||
| import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateFlutterApi; | ||
| import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateType; | ||
| import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateTypeData; | ||
|
|
||
| /** | ||
| * Flutter API implementation for {@link CameraState}. | ||
| * | ||
| * <p>This class may handle adding native instances that are attached to a Dart instance or passing | ||
| * arguments of callbacks methods to a Dart instance. | ||
| */ | ||
| public class CameraStateFlutterApiWrapper { | ||
| private final BinaryMessenger binaryMessenger; | ||
| private final InstanceManager instanceManager; | ||
| private CameraStateFlutterApi cameraStateFlutterApi; | ||
|
|
||
| /** | ||
| * Constructs a {@link CameraStateFlutterApiWrapper}. | ||
| * | ||
| * @param binaryMessenger used to communicate with Dart over asynchronous messages | ||
| * @param instanceManager maintains instances stored to communicate with attached Dart objects | ||
| */ | ||
| public CameraStateFlutterApiWrapper( | ||
| @NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) { | ||
| this.binaryMessenger = binaryMessenger; | ||
| this.instanceManager = instanceManager; | ||
| cameraStateFlutterApi = new CameraStateFlutterApi(binaryMessenger); | ||
| } | ||
|
|
||
| /** | ||
| * Stores the {@link CameraState} instance and notifies Dart to create and store a new {@link | ||
| * CameraState} instance that is attached to this one. If {@code instance} has already been added, | ||
| * this method does nothing. | ||
| */ | ||
| public void create( | ||
camsim99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @NonNull CameraState instance, | ||
| @NonNull CameraStateType type, | ||
| @Nullable CameraState.StateError error, | ||
| @NonNull CameraStateFlutterApi.Reply<Void> callback) { | ||
| if (instanceManager.containsInstance(instance)) { | ||
| return; | ||
| } | ||
|
|
||
| if (error != null) { | ||
| // We need to create a CameraStateError if there is a problem with the current camera | ||
| // state to send to the Dart side. | ||
| new CameraStateErrorFlutterApiWrapper(binaryMessenger, instanceManager) | ||
| .create(error, Long.valueOf(error.getCode()), reply -> {}); | ||
| } | ||
|
|
||
| cameraStateFlutterApi.create( | ||
| instanceManager.addHostCreatedInstance(instance), | ||
| new CameraStateTypeData.Builder().setValue(type).build(), | ||
| instanceManager.getIdentifierForStrongReference(error), | ||
| callback); | ||
| } | ||
|
|
||
| /** Convert CameraX CameraState.Type to CameraStateType that the Dart side understands. */ | ||
| public static CameraStateType getCameraStateType(@NonNull CameraState.Type type) { | ||
| CameraStateType cameraStateType = null; | ||
| switch (type) { | ||
| case CLOSED: | ||
| cameraStateType = CameraStateType.CLOSED; | ||
| break; | ||
| case CLOSING: | ||
| cameraStateType = CameraStateType.CLOSING; | ||
| break; | ||
| case OPEN: | ||
| cameraStateType = CameraStateType.OPEN; | ||
| break; | ||
| case OPENING: | ||
| cameraStateType = CameraStateType.OPENING; | ||
| break; | ||
| case PENDING_OPEN: | ||
| cameraStateType = CameraStateType.PENDING_OPEN; | ||
| break; | ||
| } | ||
|
|
||
| if (cameraStateType == null) { | ||
| throw new IllegalArgumentException( | ||
| "The CameraState.Type passed to this method was not recognized."); | ||
| } | ||
| return cameraStateType; | ||
| } | ||
|
|
||
| /** Sets the Flutter API used to send messages to Dart. */ | ||
| @VisibleForTesting | ||
| void setApi(@NonNull CameraStateFlutterApi api) { | ||
| this.cameraStateFlutterApi = api; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.