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

Use new workaround to hide Info button when building with iOS 11 SDK #122

Open
wants to merge 5 commits 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/res/drawable-hdpi/camera_flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-ldpi/camera_flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-mdpi/camera_flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xhdpi/camera_flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xxhdpi/camera_flash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/res/drawable/camera_flash.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 12 additions & 15 deletions android/res/layout/cszbarscanner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:paddingTop="15dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:gravity="center"
android:text="@string/csZbarScannerTitle"
android:textColor="@color/csZbarScannerTextColor"
android:background="@color/csZbarScannerTextBackground"
android:background="@color/csZbarScannerBackground"
android:fontFamily="sans-serif-light"
android:textSize="15pt" />
android:textSize="16sp" />

<TextView android:id="@+id/csZbarScannerInstructions"
android:layout_gravity="center|bottom"
android:layout_width="296dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="15dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:background="@color/csZbarScannerBackground"
android:gravity="center"
android:textSize="8pt"
android:textSize="14sp"
android:textColor="@color/csZbarScannerTextColor"
android:fontFamily="sans-serif-light"
android:text="@string/csZbarScannerInstructions" />
Expand All @@ -49,11 +46,11 @@
android:background="#ff0000" />

<ImageButton
android:layout_width="60dp"
android:layout_height="70dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/camera_flash"
android:background="@color/csZbarScannerTextBackground"
android:background="@color/csZbarScannerBackground"
android:onClick="toggleFlash"
android:longClickable="true"
android:visibility="visible"
Expand Down
21 changes: 21 additions & 0 deletions ios/AlmaZBarReaderViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,25 @@ - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfac
}
}

- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

UIToolbar* toolbar = [[controls subviews] firstObject];
if (![toolbar isKindOfClass:UIToolbar.class])
return;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
// HACK to hide the Info button
for (UIBarButtonItem* item in [toolbar items]) {
UIButton* button = [item customView];
if ([button isKindOfClass:UIButton.class]) {
UIButtonType buttonType = [button buttonType];
if (buttonType == UIButtonTypeInfoDark || buttonType == UIButtonTypeInfoLight) {
[button setHidden:YES];
}
}
}
#endif
}

@end
16 changes: 15 additions & 1 deletion ios/CsZBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
// 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) {
Expand All @@ -80,6 +81,7 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
}
UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:2] subviews] objectAtIndex:0] subviews] objectAtIndex:infoButtonIndex];
[infoButton setHidden:YES];
#endif

//UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setTitle:@"Press Me" forState:UIControlStateNormal]; [button sizeToFit]; [self.view addSubview:button];
CGRect screenRect = [[UIScreen mainScreen] bounds];
Expand All @@ -92,8 +94,20 @@ - (void)scan: (CDVInvokedUrlCommand*)command;
//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)];
// UIBarButtonItem *buttonFlash = [[UIBarButtonItem alloc] initWithTitle:@"Flash" style:UIBarButtonItemStyleDone target:self action:@selector(toggleflash)];


NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"ZBar" withExtension:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithURL:bundleURL];
NSString *imagePath = [bundle pathForResource:@"torch" ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];

UIBarButtonItem *buttonFlash = [[UIBarButtonItem alloc]
initWithImage:image
style:UIBarButtonItemStylePlain
target:(id)self
action:@selector(toggleflash)];

NSArray *buttons = [NSArray arrayWithObjects: buttonFlash, nil];
[toolbarViewFlash setItems:buttons animated:NO];
[self.scanReader.view addSubview:toolbarViewFlash];
Expand Down
Binary file added ios/ZBar.bundle/torch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/ZBar.bundle/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/ZBar.bundle/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
<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/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"/>
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable-mdpi"/>
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable-xhdpi"/>
<source-file src="android/res/drawable/camera_flash.png" target-dir="res/drawable-xxhdpi"/>
<source-file src="android/res/drawable-hdpi/camera_flash.png" target-dir="res/drawable-hdpi"/>
<source-file src="android/res/drawable-ldpi/camera_flash.png" target-dir="res/drawable-ldpi"/>
<source-file src="android/res/drawable-mdpi/camera_flash.png" target-dir="res/drawable-mdpi"/>
<source-file src="android/res/drawable-xhdpi/camera_flash.png" target-dir="res/drawable-xhdpi"/>
<source-file src="android/res/drawable-xxhdpi/camera_flash.png" target-dir="res/drawable-xxhdpi"/>
</platform>

<platform name="ios">
Expand Down Expand Up @@ -108,6 +108,7 @@
<header-file src="ios/ZBarSDK/zbar/Video.h" />
<header-file src="ios/ZBarSDK/zbar/Window.h" />
<resource-file src="ios/Resources/CsZBarScanView.xib" />
<resource-file src="ios/ZBar.bundle"/>
</platform>

</plugin>