Skip to content
Browse files

Send through EAN extension with metadata

git-svn-id: http://zxing.googlecode.com/svn/trunk@2186 59b500cc-1b3d-0410-9834-0bbf25fbcc57
  • Loading branch information...
1 parent 815ed97 commit 03929b1d93e3ad3ae7cdf622c78fb2f750027ac3 srowen committed Feb 15, 2012
View
1 AUTHORS
@@ -23,6 +23,7 @@ David Albert (Bug Labs)
David Olivier
David Walker (Google)
Diego Pierotto
+Dion Hardy
drejc83
Eduardo Castillejo (University of Deusto)
Emanuele Aina
View
4 android/src/com/google/zxing/client/android/CaptureActivity.java
@@ -629,6 +629,10 @@ private void handleDecodeExternally(Result rawResult, ResultHandler resultHandle
}
Map<ResultMetadataType,?> metadata = rawResult.getResultMetadata();
if (metadata != null) {
+ if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
+ intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
+ metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
+ }
Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION);
if (orientation != null) {
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
View
5 android/src/com/google/zxing/client/android/Intents.java
@@ -117,6 +117,11 @@ private Intents() {
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
/**
+ * Call intent.getStringExtra(RESULT_UPC_EAN_EXTENSION) to return any scanned additional barcode
+ */
+ public static final String RESULT_UPC_EAN_EXTENSION = "SCAN_RESULT_UPC_EAN_EXTENSION";
+
+ /**
* Call intent.getByteArrayExtra(RESULT_BYTES) to get a {@code byte[]} of raw bytes in the
* barcode, if available.
*/
View
7 core/src/com/google/zxing/ResultMetadataType.java
@@ -70,6 +70,11 @@
* For some products, the possible country of manufacture as a {@link String} denoting the
* ISO country code. Some map to multiple possible countries, like "US/CA".
*/
- POSSIBLE_COUNTRY
+ POSSIBLE_COUNTRY,
+
+ /**
+ * For some products, the extension text
+ */
+ UPC_EAN_EXTENSION,
}
View
8 core/src/com/google/zxing/oned/MultiFormatUPCEANReader.java
@@ -98,7 +98,13 @@ public Result decodeRow(int rowNumber,
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
if (ean13MayBeUPCA && canReturnUPCA) {
- return new Result(result.getText().substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
+ // Transfer the metdata across
+ Result resultUPCA = new Result(result.getText().substring(1),
+ result.getRawBytes(),
+ result.getResultPoints(),
+ BarcodeFormat.UPC_A);
+ resultUPCA.putAllMetadata(result.getResultMetadata());
+ return resultUPCA;
}
return result;
}
View
1 core/src/com/google/zxing/oned/UPCEANReader.java
@@ -192,6 +192,7 @@ public Result decodeRow(int rowNumber,
try {
Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
+ decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.getText());
decodeResult.putAllMetadata(extensionResult.getResultMetadata());
decodeResult.addResultPoints(extensionResult.getResultPoints());
} catch (ReaderException re) {

0 comments on commit 03929b1

Please sign in to comment.
Something went wrong with that request. Please try again.