Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified android/libs/x86/libiconv.so
100755 → 100644
Empty file.
Empty file modified android/libs/x86/libzbarjni.so
100755 → 100644
Empty file.
Binary file added android/libs/x86_64/libiconv.so
Binary file not shown.
Binary file added android/libs/x86_64/libzbarjni.so
Binary file not shown.
62 changes: 43 additions & 19 deletions ios/CsZBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,25 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

#pragma mark - Plugin API

- (void)scan: (CDVInvokedUrlCommand*)command;
+ (UIView*) searchToolbarFrom:(UIView*) topView {
UIView* result = nil;
for (UIView* testView in topView.subviews) {
if([testView isKindOfClass:[UIToolbar class]]){
result = testView;
break;
} else {
if ([testView.subviews count] > 0){
result = [self searchToolbarFrom:testView];
if (result != nil){
break;
}
}
}
}
return result;
};

- (void)scan: (CDVInvokedUrlCommand*)command;
{
if (self.scanInProgress) {
[self.commandDelegate
Expand All @@ -49,7 +67,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
self.scanReader = [AlmaZBarReaderViewController new];

self.scanReader.readerDelegate = self;
self.scanReader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationPortrait);
self.scanReader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationPortrait || UIDeviceOrientationLandscapeRight || UIDeviceOrientationLandscapeLeft);

// Get user parameters
NSDictionary *params = (NSDictionary*) [command argumentAtIndex:0];
Expand All @@ -62,7 +80,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;

NSString *flash = [params objectForKey:@"flash"];

if ([flash isEqualToString:@"on"]) {
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
} else if ([flash isEqualToString:@"off"]) {
Expand All @@ -72,36 +90,42 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
}

// Hack to hide the bottom bar's Info button... originally based on http://stackoverflow.com/a/16353530
NSInteger infoButtonIndex;
if ([[[UIDevice currentDevice] systemVersion] compare:@"10.0" options:NSNumericSearch] != NSOrderedAscending) {
infoButtonIndex = 1;
} else {
infoButtonIndex = 3;

UIView* testView = self.scanReader.view;
UIView* toolBar = [[self class] searchToolbarFrom:testView];

for (UIBarButtonItem* item in ((UIToolbar*)toolBar).items) {
if (item.customView != nil){
if([item.customView isKindOfClass:[UIButton class]]){
UIButton* but = (UIButton*)item.customView;
if (but.buttonType == UIButtonTypeInfoLight
|| but.buttonType == UIButtonTypeInfoDark){
but.hidden = YES;
}
}
}
}
UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:2] subviews] objectAtIndex:0] subviews] objectAtIndex:infoButtonIndex];
[infoButton setHidden:YES];

//UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setTitle:@"Press Me" forState:UIControlStateNormal]; [button sizeToFit]; [self.view addSubview:button];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;

BOOL drawSight = [params objectForKey:@"drawSight"] ? [[params objectForKey:@"drawSight"] boolValue] : true;
UIToolbar *toolbarViewFlash = [[UIToolbar alloc] init];

//The bar length it depends on the orientation
toolbarViewFlash.frame = CGRectMake(0.0, 0, (screenWidth > screenHeight ?screenWidth:screenHeight), 44.0);
toolbarViewFlash.barStyle = UIBarStyleBlackOpaque;
UIBarButtonItem *buttonFlash = [[UIBarButtonItem alloc] initWithTitle:@"Flash" style:UIBarButtonItemStyleDone target:self action:@selector(toggleflash)];

NSArray *buttons = [NSArray arrayWithObjects: buttonFlash, nil];
[toolbarViewFlash setItems:buttons animated:NO];
[self.scanReader.view addSubview:toolbarViewFlash];

if (drawSight) {
CGFloat dim = screenWidth < screenHeight ? screenWidth / 1.1 : screenHeight / 1.1;
UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( (screenWidth/2) - (dim/2), (screenHeight/2) - (dim/2), dim, dim)];

UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,dim / 2, dim, 1)];
lineView.backgroundColor = [UIColor redColor];
[polygonView addSubview:lineView];
Expand All @@ -115,7 +139,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;

- (void)toggleflash {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

[device lockForConfiguration:nil];
if (device.torchAvailable == 1) {
if (device.torchMode == 0) {
Expand All @@ -126,7 +150,7 @@ - (void)toggleflash {
[device setFlashMode:AVCaptureFlashModeOff];
}
}

[device unlockForConfiguration];
}

Expand All @@ -146,9 +170,9 @@ - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingM
if ([self.scanReader isBeingDismissed]) {
return;
}

id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];

ZBarSymbol *symbol = nil;
for (symbol in results) break; // get the first result

Expand Down
5 changes: 3 additions & 2 deletions ios/ZBarSDK/ZBarHelpController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//------------------------------------------------------------------------

#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>

@class ZBarHelpController;

Expand All @@ -36,12 +37,12 @@
// failure dialog w/a few useful tips

@interface ZBarHelpController : UIViewController
< UIWebViewDelegate,
< WKNavigationDelegate,
UIAlertViewDelegate >
{
NSString *reason;
id delegate;
UIWebView *webView;
WKWebView *webView;
UIToolbar *toolbar;
UIBarButtonItem *doneBtn, *backBtn, *space;
NSURL *linkURL;
Expand Down
12 changes: 7 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="application">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name="org.cloudsky.cordovaPlugins.ZBarScannerActivity"
android:screenOrientation="fullUser"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name="org.cloudsky.cordovaPlugins.ZBarScannerActivity"
android:screenOrientation="fullUser"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-feature android:name="android.hardware.camera" />
Expand Down Expand Up @@ -57,6 +57,8 @@
<source-file src="android/libs/arm64-v8a/libzbarjni.so" target-dir="libs/arm64-v8a" />s
<source-file src="android/libs/x86/libiconv.so" target-dir="libs/x86" />
<source-file src="android/libs/x86/libzbarjni.so" target-dir="libs/x86" />
<source-file src="android/libs/x86_64/libiconv.so" target-dir="libs/x86_64" />
<source-file src="android/libs/x86_64/libzbarjni.so" target-dir="libs/x86_64" />
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable"/>
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable-hdpi"/>
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable-ldpi"/>
Expand Down Expand Up @@ -110,4 +112,4 @@
<resource-file src="ios/Resources/CsZBarScanView.xib" />
</platform>

</plugin>
</plugin>