Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes iOS 12.+ crashes, Android libs for x86_64 #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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.
42 changes: 33 additions & 9 deletions ios/CsZBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

#pragma mark - Plugin API

+ (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) {
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 @@ -72,16 +90,22 @@ - (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;
Expand Down
2 changes: 2 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
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