diff --git a/fast_barcode_scanner/.fvmrc b/fast_barcode_scanner/.fvmrc new file mode 100644 index 00000000..906bbb34 --- /dev/null +++ b/fast_barcode_scanner/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.24.3" +} \ No newline at end of file diff --git a/fast_barcode_scanner/.gitignore b/fast_barcode_scanner/.gitignore index e9dc58d3..19909647 100644 --- a/fast_barcode_scanner/.gitignore +++ b/fast_barcode_scanner/.gitignore @@ -5,3 +5,6 @@ .pub/ build/ + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/fast_barcode_scanner/.metadata b/fast_barcode_scanner/.metadata index ccb634bb..5d1b501d 100644 --- a/fast_barcode_scanner/.metadata +++ b/fast_barcode_scanner/.metadata @@ -1,10 +1,33 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: 8af6b2f038c1172e61d418869363a28dffec3cb4 + revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 channel: stable project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: android + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: ios + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/fast_barcode_scanner/.vscode/settings.json b/fast_barcode_scanner/.vscode/settings.json new file mode 100644 index 00000000..965328da --- /dev/null +++ b/fast_barcode_scanner/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dart.flutterSdkPath": ".fvm/versions/3.24.3" +} \ No newline at end of file diff --git a/fast_barcode_scanner/CHANGELOG.md b/fast_barcode_scanner/CHANGELOG.md index 4622a6bb..7f3b3c1b 100644 --- a/fast_barcode_scanner/CHANGELOG.md +++ b/fast_barcode_scanner/CHANGELOG.md @@ -1,3 +1,12 @@ +## 2.0.1 + +- Updating Flutter dependencies to version 3 +- Updating Dart SDK used to version 3.3.4 +- Updating Kotlin version 1.9.23 +- Downgrading Gradle to version 7.4 +- Updating CameraX to version 1.3.4 +- Updating MLKit to version 17.2.0 + ## 2.0.0-dev.2 - Analyze still images from binary or native image pickers on iOS and Android diff --git a/fast_barcode_scanner/analysis_options.yaml b/fast_barcode_scanner/analysis_options.yaml index a3be6b82..e69de29b 100644 --- a/fast_barcode_scanner/analysis_options.yaml +++ b/fast_barcode_scanner/analysis_options.yaml @@ -1 +0,0 @@ -include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/fast_barcode_scanner/android/.gitignore b/fast_barcode_scanner/android/.gitignore index c6cbe562..161bdcda 100644 --- a/fast_barcode_scanner/android/.gitignore +++ b/fast_barcode_scanner/android/.gitignore @@ -6,3 +6,4 @@ .DS_Store /build /captures +.cxx diff --git a/fast_barcode_scanner/android/build.gradle b/fast_barcode_scanner/android/build.gradle index f34c7408..6f03e937 100644 --- a/fast_barcode_scanner/android/build.gradle +++ b/fast_barcode_scanner/android/build.gradle @@ -2,19 +2,19 @@ group 'com.jhoogstraat.fast_barcode_scanner' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.5.30' + ext.kotlin_version = '1.9.23' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.2' + classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } -rootProject.allprojects { +allprojects { repositories { google() mavenCentral() @@ -25,23 +25,55 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 31 + if (project.android.hasProperty("namespace")) { + namespace 'com.jhoogstraat.fast_barcode_scanner' + } + + compileSdk 34 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' + test.java.srcDirs += 'src/test/kotlin' } defaultConfig { - minSdkVersion 21 + minSdk 21 } -} -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + dependencies { + testImplementation 'org.jetbrains.kotlin:kotlin-test' + testImplementation 'org.mockito:mockito-core:5.0.0' + + def camerax_version = "1.3.4" + def mlkit_version = "17.2.0" + implementation "androidx.camera:camera-camera2:$camerax_version" + implementation "androidx.camera:camera-lifecycle:$camerax_version" + implementation "com.google.mlkit:barcode-scanning:$mlkit_version" + } + + testOptions { + unitTests.all { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true + } + } + } +} - def camerax_version = "1.1.0-alpha10" - def mlkit_version = "17.0.0" - implementation "androidx.camera:camera-camera2:$camerax_version" - implementation "androidx.camera:camera-lifecycle:$camerax_version" - implementation "com.google.mlkit:barcode-scanning:$mlkit_version" +configurations.implementation { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' } diff --git a/fast_barcode_scanner/android/gradle.properties b/fast_barcode_scanner/android/gradle.properties deleted file mode 100644 index 94adc3a3..00000000 --- a/fast_barcode_scanner/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/fast_barcode_scanner/android/gradle/wrapper/gradle-wrapper.properties b/fast_barcode_scanner/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..89dcc40c --- /dev/null +++ b/fast_barcode_scanner/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/Camera.kt b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/Camera.kt index 08f15049..69497693 100644 --- a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/Camera.kt +++ b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/Camera.kt @@ -7,6 +7,7 @@ import android.util.Log import android.view.Surface import androidx.camera.core.* import androidx.camera.core.Camera +import androidx.camera.core.resolutionselector.ResolutionSelector import androidx.camera.lifecycle.ProcessCameraProvider import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat @@ -14,7 +15,7 @@ import androidx.lifecycle.LifecycleOwner import com.google.android.gms.tasks.Task import com.google.android.gms.tasks.TaskCompletionSource import com.google.common.util.concurrent.ListenableFuture -import com.google.mlkit.vision.barcode.Barcode +import com.google.mlkit.vision.barcode.common.Barcode import com.google.mlkit.vision.barcode.BarcodeScannerOptions import com.jhoogstraat.fast_barcode_scanner.scanner.MLKitBarcodeScanner import com.jhoogstraat.fast_barcode_scanner.types.* @@ -199,7 +200,7 @@ class Camera( cameraSurfaceProvider = Preview.SurfaceProvider { val surfaceTexture = flutterTextureEntry.surfaceTexture() surfaceTexture.setDefaultBufferSize(it.resolution.width, it.resolution.height) - it.provideSurface(Surface(surfaceTexture), cameraExecutor, {}) + it.provideSurface(Surface(surfaceTexture), cameraExecutor) {} } // Attach the viewfinder's surface provider to preview use case diff --git a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPlugin.kt b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPlugin.kt index b5d1a0ec..f9c09044 100644 --- a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPlugin.kt +++ b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPlugin.kt @@ -1,5 +1,6 @@ package com.jhoogstraat.fast_barcode_scanner +import android.util.Log import android.annotation.SuppressLint import android.app.Activity import android.content.Intent @@ -12,7 +13,7 @@ import androidx.core.content.ContextCompat import com.google.android.gms.tasks.Task import com.google.android.gms.tasks.TaskCompletionSource import com.google.android.gms.tasks.Tasks -import com.google.mlkit.vision.barcode.Barcode +import com.google.mlkit.vision.barcode.common.Barcode import com.google.mlkit.vision.barcode.BarcodeScannerOptions import com.google.mlkit.vision.barcode.BarcodeScanning import com.google.mlkit.vision.common.InputImage @@ -42,7 +43,7 @@ class FastBarcodeScannerPlugin : FlutterPlugin, MethodCallHandler, StreamHandler private var pluginBinding: FlutterPlugin.FlutterPluginBinding? = null private var activityBinding: ActivityPluginBinding? = null private var camera: Camera? = null - + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { commandChannel = MethodChannel( flutterPluginBinding.binaryMessenger, @@ -89,8 +90,8 @@ class FastBarcodeScannerPlugin : FlutterPlugin, MethodCallHandler, StreamHandler } /* Detections EventChannel */ - override fun onListen(arguments: Any?, events: EventChannel.EventSink?) { - detectionEventSink = events + override fun onListen(arguments: Any?, sink: EventChannel.EventSink?) { + detectionEventSink = sink } override fun onCancel(arguments: Any?) { @@ -241,7 +242,7 @@ class FastBarcodeScannerPlugin : FlutterPlugin, MethodCallHandler, StreamHandler return pickImageCompleter!!.task.continueWithTask { if (it.result == null) Tasks.forResult(null) else - scanner.process(InputImage.fromFilePath(activityBinding.activity, it.result)) + scanner.process(InputImage.fromFilePath(activityBinding.activity, it.result as Uri)) } } } diff --git a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/scanner/MLKitBarcodeScanner.kt b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/scanner/MLKitBarcodeScanner.kt index 128ffbee..219d1b85 100644 --- a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/scanner/MLKitBarcodeScanner.kt +++ b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/scanner/MLKitBarcodeScanner.kt @@ -5,7 +5,7 @@ import androidx.camera.core.ImageAnalysis import androidx.camera.core.ImageProxy import com.google.android.gms.tasks.OnFailureListener import com.google.android.gms.tasks.OnSuccessListener -import com.google.mlkit.vision.barcode.Barcode +import com.google.mlkit.vision.barcode.common.Barcode import com.google.mlkit.vision.barcode.BarcodeScannerOptions import com.google.mlkit.vision.barcode.BarcodeScanning import com.google.mlkit.vision.common.InputImage diff --git a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/types/ScannerConfiguration.kt b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/types/ScannerConfiguration.kt index 5853240a..7339a0a7 100644 --- a/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/types/ScannerConfiguration.kt +++ b/fast_barcode_scanner/android/src/main/kotlin/com/jhoogstraat/fast_barcode_scanner/types/ScannerConfiguration.kt @@ -1,7 +1,7 @@ package com.jhoogstraat.fast_barcode_scanner.types import android.util.Size -import com.google.mlkit.vision.barcode.Barcode +import com.google.mlkit.vision.barcode.common.Barcode data class ScannerConfiguration(val formats: IntArray, val mode: DetectionMode, val resolution: Resolution, val framerate: Framerate, val position: CameraPosition) diff --git a/fast_barcode_scanner/android/src/test/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPluginTest.kt b/fast_barcode_scanner/android/src/test/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPluginTest.kt new file mode 100644 index 00000000..cc7a241d --- /dev/null +++ b/fast_barcode_scanner/android/src/test/kotlin/com/jhoogstraat/fast_barcode_scanner/FastBarcodeScannerPluginTest.kt @@ -0,0 +1,27 @@ +package com.jhoogstraat.fast_barcode_scanner + +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import kotlin.test.Test +import org.mockito.Mockito + +/* + * This demonstrates a simple unit test of the Kotlin portion of this plugin's implementation. + * + * Once you have built the plugin's example app, you can run these tests from the command + * line by running `./gradlew testDebugUnitTest` in the `example/android/` directory, or + * you can run them directly from IDEs that support JUnit such as Android Studio. + */ + +internal class FastBarcodeScannerPluginTest { + @Test + fun onMethodCall_getPlatformVersion_returnsExpectedValue() { + val plugin = FastBarcodeScannerPlugin() + + val call = MethodCall("getPlatformVersion", null) + val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java) + plugin.onMethodCall(call, mockResult) + + Mockito.verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE) + } +} diff --git a/fast_barcode_scanner/example/.metadata b/fast_barcode_scanner/example/.metadata index f941867c..44e9a3f5 100644 --- a/fast_barcode_scanner/example/.metadata +++ b/fast_barcode_scanner/example/.metadata @@ -1,10 +1,33 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: 4b330ddbedab445481cc73d50a4695b9154b4e4f - channel: dev + revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + channel: stable project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: android + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: ios + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/fast_barcode_scanner/example/android/app/build.gradle b/fast_barcode_scanner/example/android/app/build.gradle index c8e7bb57..208f6ceb 100644 --- a/fast_barcode_scanner/example/android/app/build.gradle +++ b/fast_barcode_scanner/example/android/app/build.gradle @@ -26,7 +26,9 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + namespace "com.jhoogstraat.fast_barcode_scanner_example" + compileSdk 34 + ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -43,8 +45,8 @@ android { defaultConfig { applicationId "com.jhoogstraat.fast_barcode_scanner_example" - minSdkVersion 21 - targetSdkVersion 31 + minSdk 21 + targetSdk 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -63,5 +65,10 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + } + +configurations.implementation { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' +} \ No newline at end of file diff --git a/fast_barcode_scanner/example/android/app/src/debug/AndroidManifest.xml b/fast_barcode_scanner/example/android/app/src/debug/AndroidManifest.xml index d40405e5..399f6981 100644 --- a/fast_barcode_scanner/example/android/app/src/debug/AndroidManifest.xml +++ b/fast_barcode_scanner/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/fast_barcode_scanner/example/android/app/src/main/AndroidManifest.xml b/fast_barcode_scanner/example/android/app/src/main/AndroidManifest.xml index 8d2640af..b9b683d8 100644 --- a/fast_barcode_scanner/example/android/app/src/main/AndroidManifest.xml +++ b/fast_barcode_scanner/example/android/app/src/main/AndroidManifest.xml @@ -1,17 +1,16 @@ - - + + android:windowSoftInputMode="adjustResize">