iOS & Android fix and upgrade
iOS: - x86_64 header fixing - sight adding Android: - Bug fix no params NullPointerException - sight adding
This commit is contained in:
parent
0f8fe5b1f7
commit
76246b80ed
@ -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" //default use true, create a red/green sight to center barcode
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -8,6 +8,10 @@ import org.json.JSONObject;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.hardware.Camera;
|
||||
import android.hardware.Camera.CameraInfo;
|
||||
import android.hardware.Camera.PreviewCallback;
|
||||
@ -18,8 +22,12 @@ 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.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.sourceforge.zbar.ImageScanner;
|
||||
@ -54,6 +62,16 @@ implements SurfaceHolder.Callback {
|
||||
String whichCamera;
|
||||
String flashMode;
|
||||
|
||||
|
||||
/* START - ALMAVIVA */
|
||||
RelativeLayout relativeLayout;
|
||||
RelativeLayout line;
|
||||
View parent;
|
||||
int width;
|
||||
int height;
|
||||
boolean drawSight = false;
|
||||
/* END - ALMAVIVA */
|
||||
|
||||
// For retrieving R.* resources, from the actual app package
|
||||
// (we can't use actual.application.package.R.* in our code as we
|
||||
// don't know the applciation package name when writing this plugin).
|
||||
@ -69,6 +87,9 @@ implements SurfaceHolder.Callback {
|
||||
|
||||
// Activity Lifecycle ----------------------------------------------
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
public void onCreate (Bundle savedInstanceState)
|
||||
{
|
||||
@ -84,6 +105,7 @@ implements SurfaceHolder.Callback {
|
||||
String textInstructions = params.optString("text_instructions");
|
||||
whichCamera = params.optString("camera");
|
||||
flashMode = params.optString("flash");
|
||||
drawSight = params.optString("drawSight") != null ? Boolean.valueOf(params.optString("drawSight").toLowerCase()) : false;
|
||||
|
||||
// Initiate instance variables
|
||||
autoFocusHandler = new Handler();
|
||||
@ -120,6 +142,65 @@ implements SurfaceHolder.Callback {
|
||||
((FrameLayout) findViewById(getResourceId("id/csZbarScannerView"))).addView(scannerSurface);
|
||||
findViewById(getResourceId("id/csZbarScannerTitle")).bringToFront();
|
||||
findViewById(getResourceId("id/csZbarScannerInstructions")).bringToFront();
|
||||
|
||||
/* START - ALMAVIVA */
|
||||
// Creating a new RelativeLayout
|
||||
if(drawSight){
|
||||
relativeLayout = new RelativeLayout(this);
|
||||
line = new RelativeLayout(this);
|
||||
|
||||
// Defining the RelativeLayout layout parameters.
|
||||
// In this case I want to fill its parent
|
||||
|
||||
parent = ((FrameLayout) findViewById(getResourceId("id/csZbarScannerView")));
|
||||
|
||||
|
||||
parent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
// Ensure you call it only once :
|
||||
parent.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
|
||||
width = parent.getWidth();
|
||||
height = parent.getHeight();
|
||||
double dim = width < height ? (width / 1.2) : (height / 1.2);
|
||||
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams((int)dim,(int)dim);
|
||||
rlp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
|
||||
rlp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
|
||||
rlp.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
|
||||
relativeLayout.setGravity(Gravity.CENTER);
|
||||
relativeLayout.setLayoutParams(rlp);
|
||||
relativeLayout.invalidate();
|
||||
relativeLayout.requestLayout();
|
||||
|
||||
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(((int)dim - 16),8);
|
||||
lp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
|
||||
lp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
|
||||
lp.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
|
||||
line.setGravity(Gravity.CENTER);
|
||||
line.setLayoutParams(lp);
|
||||
line.setBackgroundColor(Color.RED);
|
||||
line.invalidate();
|
||||
line.requestLayout();
|
||||
}
|
||||
});
|
||||
|
||||
ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class
|
||||
// get paint
|
||||
Paint paint = rectShapeDrawable.getPaint();
|
||||
|
||||
// set border color, stroke and stroke width
|
||||
paint.setColor(Color.GREEN);
|
||||
paint.setStyle(Style.STROKE);
|
||||
paint.setStrokeWidth(8); // you can change the value of 5
|
||||
relativeLayout.setBackgroundDrawable(rectShapeDrawable);
|
||||
|
||||
|
||||
relativeLayout.addView(line);
|
||||
((RelativeLayout) findViewById(getResourceId("id/csZbarScannerViewContainer"))).addView(relativeLayout);
|
||||
}
|
||||
/* END - ALMAVIVA */
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,38 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/csZbarScannerView"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/csZbarScannerViewContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/csZbarScannerBackground" >
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView android:id="@+id/csZbarScannerTitle"
|
||||
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:gravity="center"
|
||||
android:text="@string/csZbarScannerTitle"
|
||||
android:textColor="@color/csZbarScannerTextColor"
|
||||
android:background="@color/csZbarScannerTextBackground"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textSize="20pt" />
|
||||
<FrameLayout
|
||||
android:id="@+id/csZbarScannerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/csZbarScannerBackground" >
|
||||
|
||||
<TextView android:id="@+id/csZbarScannerInstructions"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:gravity="center"
|
||||
android:textSize="12pt"
|
||||
android:textColor="@color/csZbarScannerTextColor"
|
||||
android:background="@color/csZbarScannerTextBackground"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/csZbarScannerInstructions" />
|
||||
<TextView android:id="@+id/csZbarScannerTitle"
|
||||
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:gravity="center"
|
||||
android:text="@string/csZbarScannerTitle"
|
||||
android:textColor="@color/csZbarScannerTextColor"
|
||||
android:background="@color/csZbarScannerTextBackground"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:textSize="20pt" />
|
||||
|
||||
</FrameLayout>
|
||||
<TextView android:id="@+id/csZbarScannerInstructions"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:gravity="center"
|
||||
android:textSize="12pt"
|
||||
android:textColor="@color/csZbarScannerTextColor"
|
||||
android:background="@color/csZbarScannerTextBackground"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/csZbarScannerInstructions" />
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -61,8 +61,8 @@
|
||||
}
|
||||
|
||||
// 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];
|
||||
[infoButton setHidden:YES];
|
||||
//UIView *infoButton = [[[[[self.scanReader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:3];
|
||||
//[infoButton setHidden:YES];
|
||||
|
||||
[self.viewController presentModalViewController: self.scanReader animated: YES];
|
||||
}
|
||||
|
BIN
ios/libzbar.a
BIN
ios/libzbar.a
Binary file not shown.
Loading…
Reference in New Issue
Block a user