mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Send through EAN extension with metadata
git-svn-id: https://zxing.googlecode.com/svn/trunk@2186 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
f1dc6c6dcd
commit
7eb6e8437a
1
AUTHORS
1
AUTHORS
|
@ -23,6 +23,7 @@ David Albert (Bug Labs)
|
||||||
David Olivier
|
David Olivier
|
||||||
David Walker (Google)
|
David Walker (Google)
|
||||||
Diego Pierotto
|
Diego Pierotto
|
||||||
|
Dion Hardy
|
||||||
drejc83
|
drejc83
|
||||||
Eduardo Castillejo (University of Deusto)
|
Eduardo Castillejo (University of Deusto)
|
||||||
Emanuele Aina
|
Emanuele Aina
|
||||||
|
|
|
@ -629,6 +629,10 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
}
|
}
|
||||||
Map<ResultMetadataType,?> metadata = rawResult.getResultMetadata();
|
Map<ResultMetadataType,?> metadata = rawResult.getResultMetadata();
|
||||||
if (metadata != null) {
|
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);
|
Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION);
|
||||||
if (orientation != null) {
|
if (orientation != null) {
|
||||||
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
|
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
|
||||||
|
|
|
@ -116,6 +116,11 @@ public final class Intents {
|
||||||
*/
|
*/
|
||||||
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
|
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
|
* Call intent.getByteArrayExtra(RESULT_BYTES) to get a {@code byte[]} of raw bytes in the
|
||||||
* barcode, if available.
|
* barcode, if available.
|
||||||
|
|
|
@ -70,6 +70,11 @@ public enum ResultMetadataType {
|
||||||
* For some products, the possible country of manufacture as a {@link String} denoting the
|
* 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".
|
* 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,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,13 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||||
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
|
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
|
||||||
|
|
||||||
if (ean13MayBeUPCA && canReturnUPCA) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
||||||
|
decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.getText());
|
||||||
decodeResult.putAllMetadata(extensionResult.getResultMetadata());
|
decodeResult.putAllMetadata(extensionResult.getResultMetadata());
|
||||||
decodeResult.addResultPoints(extensionResult.getResultPoints());
|
decodeResult.addResultPoints(extensionResult.getResultPoints());
|
||||||
} catch (ReaderException re) {
|
} catch (ReaderException re) {
|
||||||
|
|
Loading…
Reference in a new issue