diff --git a/README.md b/README.md index 4888add..c732141 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ Add a repository: Gradle dependency string: - com.hardbacknutter.tinyzxingwrapper:TinyZXingWrapper:1.0.1:release@aar + com.hardbacknutter.tinyzxingwrapper:TinyZXingWrapper:1.1.0:release@aar diff --git a/TinyZXingWrapper/build.gradle b/TinyZXingWrapper/build.gradle index cd774f3..a725dea 100644 --- a/TinyZXingWrapper/build.gradle +++ b/TinyZXingWrapper/build.gradle @@ -26,7 +26,7 @@ kotlin { ext { // build version for the library - tinyZXingWrapperVersion = "1.0.1" + tinyZXingWrapperVersion = "1.1.0" } android { diff --git a/TinyZXingWrapper/src/main/java/com/hardbacknutter/tinyzxingwrapper/ScanOptions.java b/TinyZXingWrapper/src/main/java/com/hardbacknutter/tinyzxingwrapper/ScanOptions.java index 49e5274..daa70b6 100644 --- a/TinyZXingWrapper/src/main/java/com/hardbacknutter/tinyzxingwrapper/ScanOptions.java +++ b/TinyZXingWrapper/src/main/java/com/hardbacknutter/tinyzxingwrapper/ScanOptions.java @@ -68,18 +68,25 @@ public ScanOptions setUseCameraWithLensFacing(final int lensFacing) { /** * Set the desired barcode formats to try and decode. + *
+ * IMPORTANT:
+ * The value is stored as an {@link ArrayList} with the {@code String} values
+ * of the {@link BarcodeFormat} enum names !
*
* @param list of {@link BarcodeFormat}s to try decoding
*
* @return this
*
* @see DecodeHintType#POSSIBLE_FORMATS
+ * @see BarcodeScanner.Builder#addHints(Bundle)
*/
@NonNull
public ScanOptions setBarcodeFormats(@NonNull final List
* Only used if {@link #setDecoderFactory(DecoderFactory)} is NOT called.
*
- * @param barcodeFormats names of {@link BarcodeFormat}s to scan for
+ * @param barcodeFormats the {@link BarcodeFormat}s to scan for
*
* @return this
*/
@NonNull
public Builder setBarcodeFormats(@NonNull final List
- * {@link DecodeHintType#NEED_RESULT_POINT_CALLBACK} is NOT supported
+ * IMPORTANT:
+ * {@link DecodeHintType#POSSIBLE_FORMATS} is expected to have as value
+ * an {@link ArrayList} with the {@code String} values of the {@link BarcodeFormat}
+ * enum names !
+ *
+ * Note that {@link DecodeHintType#NEED_RESULT_POINT_CALLBACK} is NOT supported
* as it's used internally.
*
* Only used if {@link #setDecoderFactory(DecoderFactory)} is NOT called.
@@ -457,6 +462,8 @@ public Builder addHint(@NonNull final DecodeHintType hintType,
* @param args a Bundle with hints; may contain other options which will be ignored.
*
* @return this
+ *
+ * @see ScanOptions#setBarcodeFormats(List)
*/
@NonNull
public Builder addHints(@Nullable final Bundle args) {
@@ -467,9 +474,34 @@ public Builder addHints(@Nullable final Bundle args) {
.forEach(hintType -> {
final String hintName = hintType.name();
if (args.containsKey(hintName)) {
+ // A switch 'hint': if present, store it with a boolean 'True'
+ // (this is faster than 6 string equality test)
+ // PURE_BARCODE
+ // TRY_HARDER
+ // ASSUME_CODE_39_CHECK_DIGIT
+ // ASSUME_GS1
+ // RETURN_CODABAR_START_END
+ // ALSO_INVERTED
if (hintType.getValueType().equals(Void.class)) {
this.hints.put(hintType, Boolean.TRUE);
+
+ } else if ("POSSIBLE_FORMATS".equals(hintName)) {
+ // the value is ArrayList of strings with the enum names.
+ // Convert them back to the actual enums.
+ final ArrayList