-
Notifications
You must be signed in to change notification settings - Fork 14
chore: update Kscan to 0.6.0 #1164
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3cfcdb
chore: update Kscan to 0.6.0
wodoro 0ceaf82
fix: remove unused ios BarcodeFormats
wodoro 1035c2b
fix: address CRAI concerns
wodoro e6ec390
fix: update result calls to updatedResult
wodoro e2e1665
fix: address CRAI nitpick
wodoro 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
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
60 changes: 60 additions & 0 deletions
60
shared/kscan/src/androidMain/kotlin/org/ncgroup/kscan/BarcodeFormatMapper.kt
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,60 @@ | ||
| package org.ncgroup.kscan | ||
|
|
||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_ALL_FORMATS | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_AZTEC | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_CODABAR | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_CODE_128 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_CODE_39 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_CODE_93 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_DATA_MATRIX | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_EAN_13 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_EAN_8 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_ITF | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_PDF417 | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_QR_CODE | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_UNKNOWN | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_UPC_A | ||
| import com.google.mlkit.vision.barcode.common.Barcode.FORMAT_UPC_E | ||
|
|
||
| /** | ||
| * Maps between app [BarcodeFormat] and ML Kit barcode format integers. | ||
| */ | ||
| internal object BarcodeFormatMapper { | ||
| private val APP_TO_MLKIT_FORMAT_MAP: Map<BarcodeFormat, Int> = | ||
| mapOf( | ||
| BarcodeFormat.FORMAT_QR_CODE to FORMAT_QR_CODE, | ||
| BarcodeFormat.FORMAT_CODE_128 to FORMAT_CODE_128, | ||
| BarcodeFormat.FORMAT_CODE_39 to FORMAT_CODE_39, | ||
| BarcodeFormat.FORMAT_CODE_93 to FORMAT_CODE_93, | ||
| BarcodeFormat.FORMAT_CODABAR to FORMAT_CODABAR, | ||
| BarcodeFormat.FORMAT_DATA_MATRIX to FORMAT_DATA_MATRIX, | ||
| BarcodeFormat.FORMAT_EAN_13 to FORMAT_EAN_13, | ||
| BarcodeFormat.FORMAT_EAN_8 to FORMAT_EAN_8, | ||
| BarcodeFormat.FORMAT_ITF to FORMAT_ITF, | ||
| BarcodeFormat.FORMAT_UPC_A to FORMAT_UPC_A, | ||
| BarcodeFormat.FORMAT_UPC_E to FORMAT_UPC_E, | ||
| BarcodeFormat.FORMAT_PDF417 to FORMAT_PDF417, | ||
| BarcodeFormat.FORMAT_AZTEC to FORMAT_AZTEC, | ||
| ) | ||
|
|
||
| private val MLKIT_TO_APP_FORMAT_MAP: Map<Int, BarcodeFormat> = | ||
| APP_TO_MLKIT_FORMAT_MAP.entries | ||
| .associateBy({ it.value }) { it.key } | ||
| .plus(FORMAT_UNKNOWN to BarcodeFormat.TYPE_UNKNOWN) | ||
|
|
||
| fun toMlKitFormats(appFormats: List<BarcodeFormat>): Int { | ||
| if (appFormats.isEmpty() || appFormats.contains(BarcodeFormat.FORMAT_ALL_FORMATS)) { | ||
| return FORMAT_ALL_FORMATS | ||
| } | ||
|
|
||
| return appFormats | ||
| .mapNotNull { APP_TO_MLKIT_FORMAT_MAP[it] } | ||
| .distinct() | ||
| .fold(0) { acc, formatInt -> acc or formatInt } | ||
| .let { if (it == 0) FORMAT_ALL_FORMATS else it } | ||
| } | ||
|
|
||
| fun toAppFormat(mlKitFormat: Int): BarcodeFormat = MLKIT_TO_APP_FORMAT_MAP[mlKitFormat] ?: BarcodeFormat.TYPE_UNKNOWN | ||
|
|
||
| fun isKnownFormat(mlKitFormat: Int): Boolean = MLKIT_TO_APP_FORMAT_MAP.containsKey(mlKitFormat) | ||
| } |
68 changes: 0 additions & 68 deletions
68
shared/kscan/src/androidMain/kotlin/org/ncgroup/kscan/BarcodeFormats.android.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.