diff --git a/README.md b/README.md
index 75a07c2..7b66c80 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ Arguments:
text_instructions: "OPTIONAL Instruction Text - default = 'Please point your camera at the QR code.'", // Android only
camera: "front" || "back" // defaults to "back"
flash: "on" || "off" || "auto" // defaults to "auto". See Quirks
+ drawSight: true || false //defaults to true, create a red sight/line in the center of the scanner view.
}
```
diff --git a/android/ZBarScannerActivity.java b/android/ZBarScannerActivity.java
index b04fa97..d76c90d 100644
--- a/android/ZBarScannerActivity.java
+++ b/android/ZBarScannerActivity.java
@@ -18,6 +18,7 @@ import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -82,6 +83,7 @@ implements SurfaceHolder.Callback {
catch (JSONException e) { params = new JSONObject(); }
String textTitle = params.optString("text_title");
String textInstructions = params.optString("text_instructions");
+ Boolean drawSight = params.optBoolean("drawSight", true);
whichCamera = params.optString("camera");
flashMode = params.optString("flash");
@@ -100,6 +102,11 @@ implements SurfaceHolder.Callback {
view_textTitle.setText(textTitle);
view_textInstructions.setText(textInstructions);
+ // Draw/hide the sight
+ if(!drawSight) {
+ findViewById(getResourceId("id/csZbarScannerSight")).setVisibility(View.INVISIBLE);
+ }
+
// Create preview SurfaceView
scannerSurface = new SurfaceView (this) {
@Override
@@ -117,9 +124,14 @@ implements SurfaceHolder.Callback {
scannerSurface.getHolder().addCallback(this);
// Add preview SurfaceView to the screen
- ((FrameLayout) findViewById(getResourceId("id/csZbarScannerView"))).addView(scannerSurface);
+ FrameLayout scannerView = (FrameLayout) findViewById(getResourceId("id/csZbarScannerView"));
+ scannerView.addView(scannerSurface);
findViewById(getResourceId("id/csZbarScannerTitle")).bringToFront();
findViewById(getResourceId("id/csZbarScannerInstructions")).bringToFront();
+ findViewById(getResourceId("id/csZbarScannerSightContainer")).bringToFront();
+ findViewById(getResourceId("id/csZbarScannerSight")).bringToFront();
+ scannerView.requestLayout();
+ scannerView.invalidate();
}
@Override
@@ -226,7 +238,11 @@ implements SurfaceHolder.Callback {
private AutoFocusCallback autoFocusCb = new AutoFocusCallback()
{
public void onAutoFocus(boolean success, Camera camera) {
- autoFocusHandler.postDelayed(doAutoFocus, autoFocusInterval);
+ // some devices crash without this try/catch and cancelAutoFocus()... (#9)
+ try {
+ camera.cancelAutoFocus();
+ autoFocusHandler.postDelayed(doAutoFocus, autoFocusInterval);
+ } catch (Exception e) {}
}
};
diff --git a/android/res/layout/cszbarscanner.xml b/android/res/layout/cszbarscanner.xml
index 5e26bca..4566d31 100644
--- a/android/res/layout/cszbarscanner.xml
+++ b/android/res/layout/cszbarscanner.xml
@@ -35,4 +35,19 @@
android:fontFamily="sans-serif-light"
android:text="@string/csZbarScannerInstructions" />
+
+
+
+
+
+
diff --git a/ios/AlmaZBarReaderViewController.h b/ios/AlmaZBarReaderViewController.h
new file mode 100644
index 0000000..4eb14a6
--- /dev/null
+++ b/ios/AlmaZBarReaderViewController.h
@@ -0,0 +1,13 @@
+//
+// AlmaZBarReaderViewController.h
+// BarCodeMix
+//
+// Created by eCompliance on 23/01/15.
+//
+//
+
+#import "ZBarReaderViewController.h"
+
+@interface AlmaZBarReaderViewController : ZBarReaderViewController
+
+@end
diff --git a/ios/AlmaZBarReaderViewController.m b/ios/AlmaZBarReaderViewController.m
new file mode 100644
index 0000000..9144939
--- /dev/null
+++ b/ios/AlmaZBarReaderViewController.m
@@ -0,0 +1,41 @@
+//
+// AlmaZBarReaderViewController.m
+// BarCodeMix
+//
+// Created by eCompliance on 23/01/15.
+//
+//
+
+#import "AlmaZBarReaderViewController.h"
+
+@interface AlmaZBarReaderViewController ()
+
+@end
+
+@implementation AlmaZBarReaderViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view.
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+-(BOOL)shouldAutorotate{
+ return NO;
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ // Get the new view controller using [segue destinationViewController].
+ // Pass the selected object to the new view controller.
+}
+*/
+
+@end
diff --git a/ios/CsZBar.m b/ios/CsZBar.m
index 0af3803..6df2520 100644
--- a/ios/CsZBar.m
+++ b/ios/CsZBar.m
@@ -1,12 +1,12 @@
#import "CsZBar.h"
-
+#import "AlmaZBarReaderViewController.h"
#pragma mark - State
@interface CsZBar ()
@property bool scanInProgress;
@property NSString *scanCallbackId;
-@property ZBarReaderViewController *scanReader;
+@property AlmaZBarReaderViewController *scanReader;
@end
@@ -40,10 +40,10 @@
} else {
self.scanInProgress = YES;
self.scanCallbackId = [command callbackId];
- self.scanReader = [ZBarReaderViewController new];
+ self.scanReader = [AlmaZBarReaderViewController new];
self.scanReader.readerDelegate = self;
- self.scanReader.supportedOrientationsMask = ZBarOrientationMaskAll;
+ self.scanReader.supportedOrientationsMask = ZBarOrientationMask(UIInterfaceOrientationPortrait);
// Get user parameters
NSDictionary *params = (NSDictionary*) [command argumentAtIndex:0];
@@ -60,10 +60,29 @@
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
}
- // Hack to hide the bottom bar's Info button... http://stackoverflow.com/a/16353530
- UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:3];
+ // Hack to hide the bottom bar's Info button... originally based on http://stackoverflow.com/a/16353530
+ UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:2] subviews] objectAtIndex:0] subviews] objectAtIndex:3];
[infoButton setHidden:YES];
+ BOOL drawSight = [params objectForKey:@"drawSight"] ? [[params objectForKey:@"drawSight"] boolValue] : true;
+ if(drawSight){
+ CGRect screenRect = [[UIScreen mainScreen] bounds];
+ CGFloat screenWidth = screenRect.size.width;
+ CGFloat screenHeight = screenRect.size.height;
+ 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)];
+ //polygonView.center = self.scanReader.view.center;
+ //polygonView.layer.borderColor = [UIColor greenColor].CGColor;
+ //polygonView.layer.borderWidth = 3.0f;
+
+ UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(dim / 2, 0, 1, dim)];
+ lineView.backgroundColor = [UIColor redColor];
+ [polygonView addSubview:lineView];
+
+ self.scanReader.cameraOverlayView = polygonView;
+ //[self.scanReader.view addSubview:polygonView];
+ }
+
[self.viewController presentModalViewController: self.scanReader animated: YES];
}
}
diff --git a/ios/libzbar.a b/ios/libzbar.a
index defbed4..7533efb 100644
Binary files a/ios/libzbar.a and b/ios/libzbar.a differ
diff --git a/plugin.xml b/plugin.xml
index 5261fbe..bf1a411 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -69,6 +69,8 @@
+
+