-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
feat: Zxing implementation #3252
Conversation
Weirdly I can't link this PR to : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot say that I've understood everything but that looks correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments. Thank you for your work!
if (image is CameraImage) { | ||
if (image is CameraImage && supportCameraImage) { | ||
return onNewCameraImage(image); | ||
} else if (image is String) { | ||
} else if (image is String && supportCameraFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A plugin may support file and/or byte stream.
We ensure this here
@@ -0,0 +1,50 @@ | |||
group 'com.example.scanner_zxing' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is relevant, as this dependency will always be independant.
.../scanner/zxing/android/src/main/kotlin/org/openfoodfacts/scanner_zxing/ScannerZxingPlugin.kt
Outdated
Show resolved
Hide resolved
call.argument("path") as String?, | ||
call.argument("orientation") as Int?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any of these two are mandatory, I would remove the nullable and make it crash if we pass something wrong. It could be subdle to find issues related to the scanner not working just to find out we're passing null somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the check is done in the calling method, hence the nullable accepted here
|
||
object ZXingUtils { | ||
|
||
fun extractBarcodeFromImage(path: String?, orientation: Int?): String? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a look at the content of this method, I return a null string in the case of null args
packages/scanner/zxing/android/src/main/kotlin/org/openfoodfacts/scanner_zxing/ZXingUtils.kt
Outdated
Show resolved
Hide resolved
Future<List<String?>?> onNewCameraFile(String path) async { | ||
assert(path.isNotEmpty); | ||
|
||
return methodChannel.invokeMethod<String>('scanFile', <String, dynamic>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put an await here and then return the ternary operator below
|
||
@override | ||
Future<List<String?>?> onNewCameraImage(CameraImage image) async { | ||
throw UnimplementedError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only files are supported by Zxing -> so, yes
…ts/scanner_zxing/ZXingUtils.kt Co-authored-by: VaiTon <eyadlorenzo@gmail.com>
Co-authored-by: VaiTon <eyadlorenzo@gmail.com>
…ts/scanner_zxing/ScannerZxingPlugin.kt Co-authored-by: VaiTon <eyadlorenzo@gmail.com>
Codecov Report
@@ Coverage Diff @@
## develop #3252 +/- ##
=======================================
Coverage 7.86% 7.86%
=======================================
Files 250 250
Lines 12315 12315
=======================================
Hits 968 968
Misses 11347 11347 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I have no expierence in Kotlin so I can't add any value here, but I'm sure it will work |
Zxing is used with:
Other variants (iOS / Google Play / Samsung Gallery) still relies on MLKit