Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions fast_barcode_scanner/.fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.24.3"
}
3 changes: 3 additions & 0 deletions fast_barcode_scanner/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
.pub/

build/

# FVM Version Cache
.fvm/
27 changes: 25 additions & 2 deletions fast_barcode_scanner/.metadata
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 3 additions & 0 deletions fast_barcode_scanner/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.24.3"
}
9 changes: 9 additions & 0 deletions fast_barcode_scanner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion fast_barcode_scanner/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
include: package:flutter_lints/flutter.yaml
1 change: 1 addition & 0 deletions fast_barcode_scanner/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.DS_Store
/build
/captures
.cxx
58 changes: 45 additions & 13 deletions fast_barcode_scanner/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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'
}
3 changes: 0 additions & 3 deletions fast_barcode_scanner/android/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ 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
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.*
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?) {
Expand Down Expand Up @@ -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))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
29 changes: 26 additions & 3 deletions fast_barcode_scanner/example/.metadata
Original file line number Diff line number Diff line change
@@ -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'
15 changes: 11 additions & 4 deletions fast_barcode_scanner/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jhoogstraat.fast_barcode_scanner_example">
<!-- Flutter needs it to communicate with the running application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jhoogstraat.fast_barcode_scanner_example">
<application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="fast_barcode_scanner_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
Loading