Skip to content

Commit

Permalink
Adding Interleaved 2 of 5 (not ITF/ITF14) Barcode Type #191
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Mar 6, 2019
1 parent 47f6c5b commit 1816d26
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [3.1.0](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.1.0) (2019-03-06)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/36?closed=1)


## [3.0.3](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.0.3) (2019-02-21)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/35?closed=1)


## [3.0.2](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/3.0.2) (2019-02-05)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-barcodescanner/milestone/34?closed=1)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ npm run demo-ng.ios (or demo.ios.device)

### iOS only
* CODE_39_MOD_43
* INTERLEAVED_2_OF_5

### A note about `UPC_A` and `EAN_13`
When either (or both) of these are specified, both can be returned.
Expand Down
2 changes: 1 addition & 1 deletion demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<iOS>
<Label class="h3" text="Scanner declared in XML"/>
<Label class="body" text="Beeps and logs to console when a QR_CODE or EAN_13 is scanned. The image was added to show how to add an arbitrary overlay." textWrap="true"/>
<Label class="body" text="Beeps and logs to console when a QR_CODE, EAN_13, or CODE_128 is scanned. The image was added to show how to add an arbitrary overlay." textWrap="true"/>
<GridLayout>
<Barcode:BarcodeScannerView
class="scanner-round"
Expand Down
3 changes: 2 additions & 1 deletion src/barcodescanner-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export type BarcodeFormat =
"UPC_A" |
"CODABAR" |
"MAXICODE" |
"RSS_14";
"RSS_14" |
"INTERLEAVED_2_OF_5";

export interface ScanResult {
text: string;
Expand Down
9 changes: 6 additions & 3 deletions src/barcodescanner.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class BarcodeScannerView extends BarcodeScannerBaseView {
this._hasSupport = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) !== null;
if (this._hasSupport) {
// play nice with others
AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, AVAudioSessionCategoryOptions.MixWithOthers)
AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, AVAudioSessionCategoryOptions.MixWithOthers);
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ export class BarcodeScanner {

constructor() {
// play nice with others
AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, AVAudioSessionCategoryOptions.MixWithOthers)
AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, AVAudioSessionCategoryOptions.MixWithOthers);

this._device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
if (this._device && this._device.hasTorch && this._device.hasFlash) {
Expand Down Expand Up @@ -348,6 +348,7 @@ const getBarcodeFormat = (nativeFormat: string): BarcodeFormat => {
else if (nativeFormat === AVMetadataObjectTypeEAN8Code) return "EAN_8";
else if (nativeFormat === AVMetadataObjectTypeITF14Code) return "ITF";
else if (nativeFormat === AVMetadataObjectTypeEAN13Code) return "EAN_13";
else if (nativeFormat === AVMetadataObjectTypeInterleaved2of5Code) return "INTERLEAVED_2_OF_5";
else {
console.log("Unknown format scanned: " + nativeFormat + ", please report this at https://github.com/EddyVerbruggen/nativescript-barcodescanner/issues");
return <BarcodeFormat>nativeFormat;
Expand All @@ -371,14 +372,16 @@ const getBarcodeTypes = (formatsString: string): Array<string> => {
else if (format === "DATA_MATRIX") types.push(AVMetadataObjectTypeDataMatrixCode);
else if (format === "EAN_8") types.push(AVMetadataObjectTypeEAN8Code);
else if (format === "ITF") types.push(AVMetadataObjectTypeITF14Code);
else if (format === "INTERLEAVED_2_OF_5") types.push(AVMetadataObjectTypeInterleaved2of5Code);
// see https://github.com/EddyVerbruggen/nativescript-barcodescanner/issues/176
else if (format === "EAN_13" || format === "UPC_A") types.push(AVMetadataObjectTypeEAN13Code);
}
} else {
types.push(AVMetadataObjectTypeUPCECode, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode93Code,
AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeDataMatrixCode, AVMetadataObjectTypeITF14Code,
AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode);
AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode,
AVMetadataObjectTypeInterleaved2of5Code);
}
return types;
};
Expand Down
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-barcodescanner",
"version": "3.0.3",
"version": "3.1.0",
"description": "Scan QR/barcodes with your NativeScript app.",
"main": "barcodescanner",
"typings": "index.d.ts",
Expand Down Expand Up @@ -69,9 +69,9 @@
},
"homepage": "https://github.com/eddyverbruggen/nativescript-barcodescanner",
"devDependencies": {
"tns-core-modules": "~5.1.2",
"tns-platform-declarations": "~5.1.2",
"typescript": "~3.1.2",
"tns-core-modules": "~5.2.2",
"tns-platform-declarations": "~5.2.2",
"typescript": "~2.8.0",
"prompt": "^1.0.0",
"rimraf": "^2.6.2",
"tslint": "^5.11.0",
Expand Down

0 comments on commit 1816d26

Please sign in to comment.