Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
add ITF (less than 14 digit) support (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdesimone authored and jcesarmobile committed Mar 30, 2018
1 parent bc42890 commit a78262b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/ios/CDVBarcodeScanner.mm
Expand Up @@ -510,7 +510,7 @@ - (NSString*)setUpCaptureSession {
else {
return @"unable to add video capture output to session";
}

[output setMetadataObjectTypes:[self formatObjectTypes]];

// setup capture preview layer
Expand Down Expand Up @@ -585,7 +585,9 @@ - (NSString*)formatStringFromMetadata:(AVMetadataMachineReadableCodeObject*)form
if (format.type == AVMetadataObjectTypeCode128Code) return @"CODE_128";
if (format.type == AVMetadataObjectTypeCode93Code) return @"CODE_93";
if (format.type == AVMetadataObjectTypeCode39Code) return @"CODE_39";
if (format.type == AVMetadataObjectTypeITF14Code) return @"ITF";
if (format.type == AVMetadataObjectTypeInterleaved2of5Code) return @"ITF";
if (format.type == AVMetadataObjectTypeITF14Code) return @"ITF_14";

if (format.type == AVMetadataObjectTypePDF417Code) return @"PDF_417";
return @"???";
}
Expand All @@ -598,9 +600,9 @@ - (NSArray*) formatObjectTypes {
if (self.formats != nil) {
supportedFormats = [self.formats componentsSeparatedByString:@","];
}

NSMutableArray * formatObjectTypes = [NSMutableArray array];

if (self.formats == nil || [supportedFormats containsObject:@"QR_CODE"]) [formatObjectTypes addObject:AVMetadataObjectTypeQRCode];
if (self.formats == nil || [supportedFormats containsObject:@"AZTEC"]) [formatObjectTypes addObject:AVMetadataObjectTypeAztecCode];
if (self.formats == nil || [supportedFormats containsObject:@"DATA_MATRIX"]) [formatObjectTypes addObject:AVMetadataObjectTypeDataMatrixCode];
Expand All @@ -610,9 +612,10 @@ - (NSArray*) formatObjectTypes {
if (self.formats == nil || [supportedFormats containsObject:@"CODE_128"]) [formatObjectTypes addObject:AVMetadataObjectTypeCode128Code];
if (self.formats == nil || [supportedFormats containsObject:@"CODE_93"]) [formatObjectTypes addObject:AVMetadataObjectTypeCode93Code];
if (self.formats == nil || [supportedFormats containsObject:@"CODE_39"]) [formatObjectTypes addObject:AVMetadataObjectTypeCode39Code];
if (self.formats == nil || [supportedFormats containsObject:@"ITF"]) [formatObjectTypes addObject:AVMetadataObjectTypeITF14Code];
if (self.formats == nil || [supportedFormats containsObject:@"ITF"]) [formatObjectTypes addObject:AVMetadataObjectTypeInterleaved2of5Code];
if (self.formats == nil || [supportedFormats containsObject:@"ITF_14"]) [formatObjectTypes addObject:AVMetadataObjectTypeITF14Code];
if (self.formats == nil || [supportedFormats containsObject:@"PDF_417"]) [formatObjectTypes addObject:AVMetadataObjectTypePDF417Code];

return formatObjectTypes;
}

Expand Down Expand Up @@ -795,16 +798,16 @@ - (UIView *)buildOverlayViewFromXib
NSLog(@"%@", @"An error occurred loading the overlay xib. It appears that the overlayView outlet is not set.");
return nil;
}

self.overlayView.autoresizesSubviews = YES;
self.overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.overlayView.opaque = NO;

CGRect bounds = self.view.bounds;
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);

[self.overlayView setFrame:bounds];

return self.overlayView;
}

Expand Down

0 comments on commit a78262b

Please sign in to comment.