Merge branch 'pr/11'
This commit is contained in:
commit
3c5e5b5eb4
@ -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.
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -35,4 +35,19 @@
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/csZbarScannerInstructions" />
|
||||
|
||||
<RelativeLayout android:id="@+id/csZbarScannerSightContainer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<View android:id="@+id/csZbarScannerSight"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center_vertical"
|
||||
android:background="#ff0000" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
13
ios/AlmaZBarReaderViewController.h
Normal file
13
ios/AlmaZBarReaderViewController.h
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// AlmaZBarReaderViewController.h
|
||||
// BarCodeMix
|
||||
//
|
||||
// Created by eCompliance on 23/01/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import "ZBarReaderViewController.h"
|
||||
|
||||
@interface AlmaZBarReaderViewController : ZBarReaderViewController
|
||||
|
||||
@end
|
41
ios/AlmaZBarReaderViewController.m
Normal file
41
ios/AlmaZBarReaderViewController.m
Normal file
@ -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
|
31
ios/CsZBar.m
31
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];
|
||||
}
|
||||
}
|
||||
|
BIN
ios/libzbar.a
BIN
ios/libzbar.a
Binary file not shown.
@ -69,6 +69,8 @@
|
||||
<source-file src="ios/libzbar.a" framework="true" />
|
||||
<source-file src="ios/CsZBar.m" />
|
||||
<header-file src="ios/CsZBar.h" />
|
||||
<source-file src="ios/AlmaZBarReaderViewController.m" />
|
||||
<header-file src="ios/AlmaZBarReaderViewController.h" />
|
||||
<header-file src="ios/ZBarSDK/ZBarCameraSimulator.h" />
|
||||
<header-file src="ios/ZBarSDK/ZBarCaptureReader.h" />
|
||||
<header-file src="ios/ZBarSDK/ZBarHelpController.h" />
|
||||
|
Loading…
Reference in New Issue
Block a user