Skip to content

Commit f23a97c

Browse files
bparrishMinesnick-llewellyn
authored andcommitted
[camera_android_camerax] Updates internal API wrapper to use ProxyApis (flutter#8618)
Also Fixes flutter/flutter#164132 by passing a `TestInstanceManager` when needed.
1 parent 136c8de commit f23a97c

File tree

292 files changed

+32682
-33772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+32682
-33772
lines changed

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.15
2+
3+
* Updates internal API wrapper to use ProxyApis.
4+
15
## 0.6.14+1
26

37
* Updates compileSdk 34 to flutter.compileSdkVersion.

packages/camera/camera_android_camerax/android/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ group 'io.flutter.plugins.camerax'
22
version '1.0'
33

44
buildscript {
5+
ext.kotlin_version = '1.9.10'
56
repositories {
67
google()
78
mavenCentral()
89
}
910

1011
dependencies {
1112
classpath 'com.android.tools.build:gradle:8.5.0'
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1214
}
1315
}
1416

@@ -20,6 +22,7 @@ rootProject.allprojects {
2022
}
2123

2224
apply plugin: 'com.android.library'
25+
apply plugin: 'kotlin-android'
2326

2427
android {
2528
namespace 'io.flutter.plugins.camerax'
@@ -31,6 +34,11 @@ android {
3134
targetCompatibility JavaVersion.VERSION_11
3235
}
3336

37+
kotlinOptions {
38+
// This must match the Java version provided in compileOptions.
39+
jvmTarget = '11'
40+
}
41+
3442
defaultConfig {
3543
// Many of the CameraX APIs require API 21.
3644
minSdkVersion 21
@@ -65,7 +73,8 @@ dependencies {
6573
implementation "androidx.camera:camera-video:${camerax_version}"
6674
implementation 'com.google.guava:guava:33.4.0-android'
6775
testImplementation 'junit:junit:4.13.2'
68-
testImplementation 'org.mockito:mockito-inline:5.0.0'
76+
testImplementation "org.mockito:mockito-core:5.15.2"
77+
testImplementation 'org.mockito:mockito-inline:5.1.0'
6978
testImplementation 'androidx.test:core:1.4.0'
7079
testImplementation 'org.robolectric:robolectric:4.10.3'
7180
}

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/AnalyzerFlutterApiImpl.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/AnalyzerHostApiImpl.java

Lines changed: 0 additions & 119 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.camerax;
6+
7+
import androidx.annotation.NonNull;
8+
import androidx.camera.core.ImageAnalysis.Analyzer;
9+
import java.util.Objects;
10+
11+
/**
12+
* ProxyApi implementation for {@link Analyzer}. This class may handle instantiating native object
13+
* instances that are attached to a Dart instance or handle method calls on the associated native
14+
* class or an instance of that class.
15+
*/
16+
class AnalyzerProxyApi extends PigeonApiAnalyzer {
17+
AnalyzerProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) {
18+
super(pigeonRegistrar);
19+
}
20+
21+
@NonNull
22+
@Override
23+
public ProxyApiRegistrar getPigeonRegistrar() {
24+
return (ProxyApiRegistrar) super.getPigeonRegistrar();
25+
}
26+
27+
/** Implementation of {@link Analyzer} that passes arguments of callback methods to Dart. */
28+
static class AnalyzerImpl implements Analyzer {
29+
final AnalyzerProxyApi api;
30+
31+
AnalyzerImpl(@NonNull AnalyzerProxyApi api) {
32+
this.api = api;
33+
}
34+
35+
@Override
36+
public void analyze(@NonNull androidx.camera.core.ImageProxy image) {
37+
api.getPigeonRegistrar()
38+
.runOnMainThread(
39+
new ProxyApiRegistrar.FlutterMethodRunnable() {
40+
@Override
41+
public void run() {
42+
api.analyze(
43+
AnalyzerImpl.this,
44+
image,
45+
ResultCompat.asCompatCallback(
46+
result -> {
47+
if (result.isFailure()) {
48+
onFailure(
49+
"Analyzer.analyze",
50+
Objects.requireNonNull(result.exceptionOrNull()));
51+
}
52+
return null;
53+
}));
54+
}
55+
});
56+
}
57+
}
58+
59+
@NonNull
60+
@Override
61+
public Analyzer pigeon_defaultConstructor() {
62+
return new AnalyzerImpl(this);
63+
}
64+
}

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/AspectRatioStrategyHostApiImpl.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)