Merge remote-tracking branch 'base/master'
This commit is contained in:
commit
240b00769b
13
LICENSE.md
Normal file
13
LICENSE.md
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright 2016 Woon Tien Jing
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
24
README.md
24
README.md
@ -1,15 +1,16 @@
|
||||
**This repository is looking for a maintainer! If you believe you are the right person, please [leave a comment](https://github.com/tjwoon/csZBar/issues/60)!**
|
||||
|
||||
|
||||
|
||||
# ZBar Barcode Scanner Plugin
|
||||
|
||||
This plugin integrates with the [ZBar](http://zbar.sourceforge.net/) library,
|
||||
exposing a JavaScript interface for scanning barcodes (QR, 2D, etc).
|
||||
In this fork a button has been added to turn off and on device flash. In addition the plugin can now handle the device orientation change.
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugins install org.cloudsky.cordovaplugins.zbar
|
||||
|
||||
## License
|
||||
|
||||
This plugin is released under the Apache 2.0 license, but the ZBar library on which it depends (and which is distribute with this plugin) is under the LGPL license (2.1).
|
||||
cordova plugin add cordova-plugin-cszbar
|
||||
|
||||
## API
|
||||
|
||||
@ -27,7 +28,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
|
||||
drawSight: true || false //defaults to true, create a red sight/line in the center of the scanner view.
|
||||
}
|
||||
```
|
||||
|
||||
@ -45,7 +46,12 @@ Status:
|
||||
- Android: DONE
|
||||
- iOS: DONE
|
||||
|
||||
Quirks:
|
||||
|
||||
- __Android__: Flash "on" may cause the flash to alternate between on and off
|
||||
at about a half second/one second interval, instead of making it stay on...
|
||||
## LICENSE [Apache 2.0](LICENSE.md)
|
||||
|
||||
This plugin is released under the Apache 2.0 license, but the ZBar library on which it depends (and which is distribute with this plugin) is under the LGPL license (2.1).
|
||||
|
||||
|
||||
## Thanks
|
||||
|
||||
Thank you to @PaoloMessina and @nickgerman for code contributions.
|
||||
|
@ -5,29 +5,37 @@ import java.lang.RuntimeException;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
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.Parameters;
|
||||
import android.hardware.Camera.PreviewCallback;
|
||||
import android.hardware.Camera.AutoFocusCallback;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
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.ViewTreeObserver;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.view.Surface;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.zbar.ImageScanner;
|
||||
import net.sourceforge.zbar.Image;
|
||||
@ -38,16 +46,19 @@ import net.sourceforge.zbar.Config;
|
||||
public class ZBarScannerActivity extends Activity
|
||||
implements SurfaceHolder.Callback {
|
||||
|
||||
//for barcode types
|
||||
private Collection<ZBarcodeFormat> mFormats = null;
|
||||
|
||||
// Config ----------------------------------------------------------
|
||||
|
||||
private static int autoFocusInterval = 500; // Interval between AFcallback and next AF attempt.
|
||||
private static int autoFocusInterval = 2000; // Interval between AFcallback and next AF attempt.
|
||||
|
||||
// Public Constants ------------------------------------------------
|
||||
|
||||
public static final String EXTRA_QRVALUE = "qrValue";
|
||||
public static final String EXTRA_PARAMS = "params";
|
||||
public static final int RESULT_ERROR = RESULT_FIRST_USER + 1;
|
||||
|
||||
private static final int CAMERA_PERMISSION_REQUEST = 1;
|
||||
// State -----------------------------------------------------------
|
||||
|
||||
private Camera camera;
|
||||
@ -61,15 +72,6 @@ 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).
|
||||
@ -86,10 +88,47 @@ implements SurfaceHolder.Callback {
|
||||
// Activity Lifecycle ----------------------------------------------
|
||||
|
||||
@Override
|
||||
public void onCreate (Bundle savedInstanceState)
|
||||
{
|
||||
public void onCreate (Bundle savedInstanceState) {
|
||||
|
||||
|
||||
int permissionCheck = ContextCompat.checkSelfPermission(this.getBaseContext(), Manifest.permission.CAMERA);
|
||||
|
||||
if(permissionCheck == PackageManager.PERMISSION_GRANTED){
|
||||
|
||||
setUpCamera();
|
||||
|
||||
} else {
|
||||
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{Manifest.permission.CAMERA},
|
||||
CAMERA_PERMISSION_REQUEST);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
}
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case CAMERA_PERMISSION_REQUEST: {
|
||||
if (grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
setUpCamera();
|
||||
} else {
|
||||
|
||||
onBackPressed();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// other 'case' lines to check for other
|
||||
// permissions this app might request
|
||||
}
|
||||
}
|
||||
private void setUpCamera() {
|
||||
// If request is cancelled, the result arrays are empty.
|
||||
|
||||
|
||||
// Get parameters from JS
|
||||
Intent startIntent = getIntent();
|
||||
String paramStr = startIntent.getStringExtra(EXTRA_PARAMS);
|
||||
@ -98,6 +137,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");
|
||||
|
||||
@ -107,11 +147,24 @@ implements SurfaceHolder.Callback {
|
||||
scanner.setConfig(0, Config.X_DENSITY, 3);
|
||||
scanner.setConfig(0, Config.Y_DENSITY, 3);
|
||||
|
||||
drawSight = params.optString("drawSight") != null ? Boolean.valueOf(params.optString("drawSight").toLowerCase()) : true;
|
||||
// Set the config for barcode formats
|
||||
for(ZBarcodeFormat format : getFormats()) {
|
||||
scanner.setConfig(format.getId(), Config.ENABLE, 1);
|
||||
}
|
||||
|
||||
// Set content view
|
||||
setContentView(getResourceId("layout/cszbarscanner"));
|
||||
|
||||
// Update view with customisable strings
|
||||
TextView view_textTitle = (TextView) findViewById(getResourceId("id/csZbarScannerTitle"));
|
||||
TextView view_textInstructions = (TextView) findViewById(getResourceId("id/csZbarScannerInstructions"));
|
||||
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) {
|
||||
@ -130,64 +183,16 @@ 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);
|
||||
|
||||
/* START - ALMAVIVA */
|
||||
// Creating a new RelativeLayout
|
||||
if(drawSight){
|
||||
relativeLayout = new RelativeLayout(this);
|
||||
line = new RelativeLayout(this);
|
||||
findViewById(getResourceId("id/csZbarScannerTitle")).bringToFront();
|
||||
findViewById(getResourceId("id/csZbarScannerInstructions")).bringToFront();
|
||||
findViewById(getResourceId("id/csZbarScannerSightContainer")).bringToFront();
|
||||
findViewById(getResourceId("id/csZbarScannerSight")).bringToFront();
|
||||
scannerView.requestLayout();
|
||||
scannerView.invalidate();
|
||||
|
||||
// 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(8,((int)dim - 16));
|
||||
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
|
||||
@ -211,29 +216,36 @@ implements SurfaceHolder.Callback {
|
||||
|
||||
if(camera == null) throw new Exception ("Error: No suitable camera found.");
|
||||
} catch (RuntimeException e) {
|
||||
die("Error: Could not open the camera.");
|
||||
//die("Error: Could not open the camera.");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
die(e.getMessage());
|
||||
// die(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Camera.Parameters camParams = camera.getParameters();
|
||||
if(flashMode.equals("on")) {
|
||||
camParams.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
|
||||
} else if(flashMode.equals("off")) {
|
||||
camParams.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
|
||||
} else {
|
||||
camParams.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
|
||||
}
|
||||
try { camera.setParameters(camParams); }
|
||||
catch (RuntimeException e) {
|
||||
Log.d("csZBar", "Unsupported camera parameter reported for flash mode: "+flashMode);
|
||||
private void setCameraDisplayOrientation(Activity activity ,int cameraId) {
|
||||
android.hardware.Camera.CameraInfo info =
|
||||
new android.hardware.Camera.CameraInfo();
|
||||
android.hardware.Camera.getCameraInfo(cameraId, info);
|
||||
int rotation = activity.getWindowManager().getDefaultDisplay()
|
||||
.getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_0: degrees = 0; break;
|
||||
case Surface.ROTATION_90: degrees = 90; break;
|
||||
case Surface.ROTATION_180: degrees = 180; break;
|
||||
case Surface.ROTATION_270: degrees = 270; break;
|
||||
}
|
||||
|
||||
tryStartPreview();
|
||||
int result;
|
||||
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||
result = (info.orientation + degrees) % 360;
|
||||
result = (360 - result) % 360; // compensate the mirror
|
||||
} else { // back-facing
|
||||
result = (info.orientation - degrees + 360) % 360;
|
||||
}
|
||||
camera.setDisplayOrientation(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause ()
|
||||
{
|
||||
@ -244,7 +256,7 @@ implements SurfaceHolder.Callback {
|
||||
@Override
|
||||
public void onDestroy ()
|
||||
{
|
||||
scanner.destroy();
|
||||
if(scanner != null) scanner.destroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@ -288,18 +300,86 @@ implements SurfaceHolder.Callback {
|
||||
holder = hld;
|
||||
tryStartPreview();
|
||||
}
|
||||
public void onConfigurationChanged(Configuration newConfig)
|
||||
{
|
||||
super.onConfigurationChanged(newConfig);
|
||||
int rotation = getWindowManager().getDefaultDisplay().getRotation();
|
||||
switch(rotation)
|
||||
{
|
||||
case 0: // '\0'
|
||||
rotation = 90;
|
||||
break;
|
||||
|
||||
case 1: // '\001'
|
||||
rotation = 0;
|
||||
break;
|
||||
|
||||
case 2: // '\002'
|
||||
rotation = 270;
|
||||
break;
|
||||
|
||||
case 3: // '\003'
|
||||
rotation = 180;
|
||||
break;
|
||||
|
||||
default:
|
||||
rotation = 90;
|
||||
break;
|
||||
}
|
||||
camera.setDisplayOrientation(rotation);
|
||||
android.hardware.Camera.Parameters params = camera.getParameters();
|
||||
tryStopPreview();
|
||||
tryStartPreview();
|
||||
|
||||
}
|
||||
|
||||
public void toggleFlash(View view) {
|
||||
camera.startPreview();
|
||||
android.hardware.Camera.Parameters camParams = camera.getParameters();
|
||||
//If the flash is set to off
|
||||
try {
|
||||
if (camParams.getFlashMode().equals(Parameters.FLASH_MODE_OFF) && !(camParams.getFlashMode().equals(Parameters.FLASH_MODE_TORCH)) && !(camParams.getFlashMode().equals(Parameters.FLASH_MODE_ON)))
|
||||
camParams.setFlashMode(Parameters.FLASH_MODE_TORCH);
|
||||
else //if(camParams.getFlashMode() == Parameters.FLASH_MODE_ON || camParams.getFlashMode()== Parameters.FLASH_MODE_TORCH)
|
||||
camParams.setFlashMode(Parameters.FLASH_MODE_OFF);
|
||||
} catch(RuntimeException e) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
// camera.setParameters(camParams);
|
||||
camera.setPreviewDisplay(holder);
|
||||
camera.setPreviewCallback(previewCb);
|
||||
camera.startPreview();
|
||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||
camera.autoFocus(autoFocusCb); // We are not using any of the
|
||||
// continuous autofocus modes as that does not seem to work
|
||||
// well with flash setting of "on"... At least with this
|
||||
// simple and stupid focus method, we get to turn the flash
|
||||
// on during autofocus.
|
||||
camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
}
|
||||
//tryStopPreview();
|
||||
//tryStartPreview();
|
||||
//camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
camera.setParameters(camParams);
|
||||
} catch(RuntimeException e) {
|
||||
Log.d("csZBar", (new StringBuilder("Unsupported camera parameter reported for flash mode: ")).append(flashMode).toString());
|
||||
} catch (IOException e) {
|
||||
Log.d("csZBar", (new StringBuilder("Wrong holder data")).append(flashMode).toString());
|
||||
}
|
||||
}
|
||||
// Continuously auto-focus -----------------------------------------
|
||||
// For API Level < 14
|
||||
|
||||
private AutoFocusCallback autoFocusCb = new AutoFocusCallback()
|
||||
{
|
||||
public void onAutoFocus(boolean success, Camera camera) {
|
||||
try{
|
||||
// some devices crash without this try/catch and cancelAutoFocus()... (#9)
|
||||
try {
|
||||
camera.cancelAutoFocus();
|
||||
autoFocusHandler.postDelayed(doAutoFocus, autoFocusInterval);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
};
|
||||
|
||||
@ -404,22 +484,68 @@ implements SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<ZBarcodeFormat> getFormats() {
|
||||
if(mFormats == null) {
|
||||
return ZBarcodeFormat.ALL_FORMATS;
|
||||
}
|
||||
return mFormats;
|
||||
}
|
||||
|
||||
|
||||
// Start the camera preview if possible.
|
||||
// If start is attempted but fails, exit with error message.
|
||||
private void tryStartPreview () {
|
||||
if(holder != null) {
|
||||
try {
|
||||
int rotation = getWindowManager().getDefaultDisplay().getRotation();
|
||||
switch(rotation)
|
||||
{
|
||||
case 0: // '\0'
|
||||
rotation = 90;
|
||||
break;
|
||||
|
||||
case 1: // '\001'
|
||||
rotation = 0;
|
||||
break;
|
||||
|
||||
case 2: // '\002'
|
||||
rotation = 270;
|
||||
break;
|
||||
|
||||
case 3: // '\003'
|
||||
rotation = 180;
|
||||
break;
|
||||
|
||||
default:
|
||||
rotation = 90;
|
||||
break;
|
||||
}
|
||||
// 90 degrees rotation for Portrait orientation Activity.
|
||||
camera.setDisplayOrientation(90);
|
||||
// camera.setDisplayOrientation(rotation);
|
||||
setCameraDisplayOrientation(this, 0);
|
||||
|
||||
android.hardware.Camera.Parameters camParams = camera.getParameters();
|
||||
|
||||
//camParams.setFlashMode(Parameters.FLASH_MODE_TORCH);
|
||||
|
||||
try {
|
||||
camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
camera.setParameters(camParams);
|
||||
} catch (Exception e) {
|
||||
// TODO: don't swallow
|
||||
}
|
||||
|
||||
camera.setPreviewDisplay(holder);
|
||||
camera.setPreviewCallback(previewCb);
|
||||
camera.startPreview();
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||
camera.autoFocus(autoFocusCb); // We are not using any of the
|
||||
// continuous autofocus modes as that does not seem to work
|
||||
// well with flash setting of "on"... At least with this
|
||||
// simple and stupid focus method, we get to turn the flash
|
||||
// on during autofocus.
|
||||
}
|
||||
} catch (IOException e) {
|
||||
die("Could not start camera preview: " + e.getMessage());
|
||||
}
|
||||
|
72
android/ZBarcodeFormat.java
Normal file
72
android/ZBarcodeFormat.java
Normal file
@ -0,0 +1,72 @@
|
||||
package org.cloudsky.cordovaPlugins;
|
||||
|
||||
import net.sourceforge.zbar.Symbol;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ZBarcodeFormat {
|
||||
private int mId;
|
||||
private String mName;
|
||||
|
||||
public static final ZBarcodeFormat NONE = new ZBarcodeFormat(Symbol.NONE, "NONE");
|
||||
public static final ZBarcodeFormat PARTIAL = new ZBarcodeFormat(Symbol.PARTIAL, "PARTIAL");
|
||||
public static final ZBarcodeFormat EAN8 = new ZBarcodeFormat(Symbol.EAN8, "EAN8");
|
||||
public static final ZBarcodeFormat UPCE = new ZBarcodeFormat(Symbol.UPCE, "UPCE");
|
||||
public static final ZBarcodeFormat ISBN10 = new ZBarcodeFormat(Symbol.ISBN10, "ISBN10");
|
||||
public static final ZBarcodeFormat UPCA = new ZBarcodeFormat(Symbol.UPCA, "UPCA");
|
||||
public static final ZBarcodeFormat EAN13 = new ZBarcodeFormat(Symbol.EAN13, "EAN13");
|
||||
public static final ZBarcodeFormat ISBN13 = new ZBarcodeFormat(Symbol.ISBN13, "ISBN13");
|
||||
public static final ZBarcodeFormat I25 = new ZBarcodeFormat(Symbol.I25, "I25");
|
||||
public static final ZBarcodeFormat DATABAR = new ZBarcodeFormat(Symbol.DATABAR, "DATABAR");
|
||||
public static final ZBarcodeFormat DATABAR_EXP = new ZBarcodeFormat(Symbol.DATABAR_EXP, "DATABAR_EXP");
|
||||
public static final ZBarcodeFormat CODABAR = new ZBarcodeFormat(Symbol.CODABAR, "CODABAR");
|
||||
public static final ZBarcodeFormat CODE39 = new ZBarcodeFormat(Symbol.CODE39, "CODE39");
|
||||
public static final ZBarcodeFormat PDF417 = new ZBarcodeFormat(Symbol.PDF417, "PDF417");
|
||||
public static final ZBarcodeFormat QRCODE = new ZBarcodeFormat(Symbol.QRCODE, "QRCODE");
|
||||
public static final ZBarcodeFormat CODE93 = new ZBarcodeFormat(Symbol.CODE93, "CODE93");
|
||||
public static final ZBarcodeFormat CODE128 = new ZBarcodeFormat(Symbol.CODE128, "CODE128");
|
||||
|
||||
public static final List<ZBarcodeFormat> ALL_FORMATS = new ArrayList<ZBarcodeFormat>();
|
||||
|
||||
static {
|
||||
ALL_FORMATS.add(ZBarcodeFormat.PARTIAL);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.EAN8);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.UPCE);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.ISBN10);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.UPCA);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.EAN13);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.ISBN13);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.I25);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.DATABAR);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.DATABAR_EXP);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.CODABAR);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.CODE39);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.PDF417);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.QRCODE);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.CODE93);
|
||||
ALL_FORMATS.add(ZBarcodeFormat.CODE128);
|
||||
}
|
||||
|
||||
public ZBarcodeFormat(int id, String name) {
|
||||
mId = id;
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public static ZBarcodeFormat getFormatById(int id) {
|
||||
for(ZBarcodeFormat format : ALL_FORMATS) {
|
||||
if(format.getId() == id) {
|
||||
return format;
|
||||
}
|
||||
}
|
||||
return ZBarcodeFormat.NONE;
|
||||
}
|
||||
}
|
BIN
android/libs/arm64-v8a/libiconv.so
Executable file
BIN
android/libs/arm64-v8a/libiconv.so
Executable file
Binary file not shown.
BIN
android/libs/arm64-v8a/libzbarjni.so
Executable file
BIN
android/libs/arm64-v8a/libzbarjni.so
Executable file
Binary file not shown.
BIN
android/libs/armeabi-v7a/libiconv.so
Normal file → Executable file
BIN
android/libs/armeabi-v7a/libiconv.so
Normal file → Executable file
Binary file not shown.
BIN
android/libs/armeabi-v7a/libzbarjni.so
Normal file → Executable file
BIN
android/libs/armeabi-v7a/libzbarjni.so
Normal file → Executable file
Binary file not shown.
BIN
android/libs/armeabi/libiconv.so
Normal file → Executable file
BIN
android/libs/armeabi/libiconv.so
Normal file → Executable file
Binary file not shown.
BIN
android/libs/armeabi/libzbarjni.so
Normal file → Executable file
BIN
android/libs/armeabi/libzbarjni.so
Normal file → Executable file
Binary file not shown.
BIN
android/libs/x86/libiconv.so
Normal file → Executable file
BIN
android/libs/x86/libiconv.so
Normal file → Executable file
Binary file not shown.
BIN
android/libs/x86/libzbarjni.so
Normal file → Executable file
BIN
android/libs/x86/libzbarjni.so
Normal file → Executable file
Binary file not shown.
BIN
android/res/drawable/camera_flash.png
Normal file
BIN
android/res/drawable/camera_flash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -1,15 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/csZbarScannerViewContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<FrameLayout
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/csZbarScannerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/csZbarScannerBackground" >
|
||||
|
||||
</FrameLayout>
|
||||
<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="15pt" />
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView android:id="@+id/csZbarScannerInstructions"
|
||||
android:layout_gravity="center|bottom"
|
||||
android:layout_width="296dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:gravity="center"
|
||||
android:textSize="8pt"
|
||||
android:textColor="@color/csZbarScannerTextColor"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/csZbarScannerInstructions" />
|
||||
|
||||
<RelativeLayout android:id="@+id/csZbarScannerSightContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_horizontal|bottom">
|
||||
|
||||
<View android:id="@+id/csZbarScannerSight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center_vertical"
|
||||
android:background="#ff0000" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="70dp"
|
||||
android:id="@+id/imageButton"
|
||||
android:src="@drawable/camera_flash"
|
||||
android:background="@color/csZbarScannerTextBackground"
|
||||
android:onClick="toggleFlash"
|
||||
android:longClickable="true"
|
||||
android:visibility="visible"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "AlmaZBarReaderViewController.h"
|
||||
#import "CsZbar.h"
|
||||
|
||||
@interface AlmaZBarReaderViewController ()
|
||||
|
||||
@ -14,28 +15,92 @@
|
||||
|
||||
@implementation AlmaZBarReaderViewController
|
||||
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
||||
//[button setTitle:@"Flash" forState:UIControlStateNormal];
|
||||
[button sizeToFit];
|
||||
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
||||
//[button setContentEdgeInsets:UIEdgeInsetsMake(20, 30, 20, 30)];
|
||||
CGRect frame;
|
||||
if(screenRect.size.height>(screenRect.size.width)){
|
||||
frame = CGRectMake(0,0, screenRect.size.width*(0.15), screenRect.size.height*0.15);
|
||||
|
||||
//button.center = CGPointMake( 0,0);
|
||||
}else{
|
||||
frame = CGRectMake(0,0, screenRect.size.width*(0.10), screenRect.size.height*0.20);
|
||||
|
||||
//button.center = CGPointMake(0,0);
|
||||
}
|
||||
|
||||
button.frame =frame;
|
||||
button.layer.cornerRadius = 10;
|
||||
button.clipsToBounds = YES;
|
||||
// Set a new (x,y) point for the button's center
|
||||
|
||||
|
||||
|
||||
//[button setBackgroundColor:[UIColor colorWithRed:.859 green:.765 blue:.616 alpha:1.0] forState:UIControlStateHighlighted];
|
||||
|
||||
//button.center = CGPointMake( 0,0);
|
||||
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self.view addSubview:button];
|
||||
|
||||
}
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
//Techedge Changes NSS fase 2
|
||||
- (void)buttonPressed: (UIButton *) button {
|
||||
|
||||
CsZBar *obj = [[CsZBar alloc] init];
|
||||
|
||||
[obj toggleflash];
|
||||
|
||||
-(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 {
|
||||
- (BOOL)shouldAutorotate{
|
||||
return YES;
|
||||
}
|
||||
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
|
||||
//AlmaZBarReaderViewController.scanner.scanner.cameraOverlayView = poli
|
||||
//NSDictionary *params = (NSDictionary*) [command argumentAtIndex:0];
|
||||
BOOL drawSight = true;//[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(0,dim / 2, dim, 1)];
|
||||
lineView.backgroundColor = [UIColor redColor];
|
||||
[polygonView addSubview:lineView];
|
||||
self.cameraOverlayView = polygonView;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
#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
|
||||
|
@ -1,9 +1,14 @@
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
#import "ZBarSDK.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CsZBar : CDVPlugin <ZBarReaderDelegate>
|
||||
|
||||
- (void)scan: (CDVInvokedUrlCommand*)command;
|
||||
- (void)toggleflash;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
85
ios/CsZBar.m
85
ios/CsZBar.m
@ -1,4 +1,5 @@
|
||||
#import "CsZBar.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import "AlmaZBarReaderViewController.h"
|
||||
|
||||
#pragma mark - State
|
||||
@ -7,6 +8,7 @@
|
||||
@property bool scanInProgress;
|
||||
@property NSString *scanCallbackId;
|
||||
@property AlmaZBarReaderViewController *scanReader;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -25,12 +27,31 @@
|
||||
{
|
||||
self.scanInProgress = NO;
|
||||
}
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
return;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
return YES; //(interfaceOrientation == UIInterfaceOrientationPortrait);
|
||||
}
|
||||
/*
|
||||
- (void)viewDidLoad {
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[button setTitle:@"Turn on Flash" forState:UIControlStateNormal];
|
||||
[button sizeToFit];
|
||||
// Set a new (x,y) point for the button's center
|
||||
button.center = CGPointMake(320/2, 60);
|
||||
[button addTarget:self action:@selector(flashOn) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.viewController parentViewController:button];
|
||||
}*/
|
||||
|
||||
#pragma mark - Plugin API
|
||||
|
||||
- (void)scan: (CDVInvokedUrlCommand*)command;
|
||||
{
|
||||
|
||||
|
||||
if(self.scanInProgress) {
|
||||
[self.commandDelegate
|
||||
sendPluginResult: [CDVPluginResult
|
||||
@ -53,29 +74,48 @@
|
||||
// as not all devices will have a rear-facing camera.
|
||||
self.scanReader.cameraDevice = UIImagePickerControllerCameraDeviceFront;
|
||||
}
|
||||
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
|
||||
|
||||
NSString *flash = [params objectForKey:@"flash"];
|
||||
if([flash isEqualToString:@"on"]) {
|
||||
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
|
||||
} else if([flash isEqualToString:@"off"]) {
|
||||
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
|
||||
}else if([flash isEqualToString:@"auto"]) {
|
||||
self.scanReader.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
|
||||
}
|
||||
|
||||
// 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];
|
||||
// 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];
|
||||
// Add an action in current code file (i.e. target)
|
||||
// [infoButton addTarget: action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
BOOL drawSight = [params objectForKey:@"drawSight"] ? [[params objectForKey:@"drawSight"] boolValue] : true;
|
||||
if(drawSight){
|
||||
//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;
|
||||
|
||||
|
||||
BOOL drawSight = [params objectForKey:@"drawSight"] ? [[params objectForKey:@"drawSight"] boolValue] : true;
|
||||
UIToolbar *toolbarViewFlash = [[UIToolbar alloc] init];
|
||||
//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)];
|
||||
NSArray *buttons = [NSArray arrayWithObjects: buttonFlash, nil];
|
||||
[toolbarViewFlash setItems:buttons animated:NO];
|
||||
[self.scanReader.view addSubview:toolbarViewFlash];
|
||||
|
||||
if(drawSight){
|
||||
|
||||
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)];
|
||||
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,dim / 2, dim, 1)];
|
||||
lineView.backgroundColor = [UIColor redColor];
|
||||
[polygonView addSubview:lineView];
|
||||
|
||||
@ -83,10 +123,27 @@
|
||||
//[self.scanReader.view addSubview:polygonView];
|
||||
}
|
||||
|
||||
[self.viewController presentModalViewController: self.scanReader animated: YES];
|
||||
[self.viewController presentViewController:self.scanReader animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleflash{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
[device lockForConfiguration:nil];
|
||||
if (device.torchAvailable == 1) {
|
||||
if (device.torchMode == 0) {
|
||||
[device setTorchMode:AVCaptureTorchModeOn];
|
||||
[device setFlashMode:AVCaptureFlashModeOn];
|
||||
|
||||
}else{
|
||||
[device setTorchMode:AVCaptureTorchModeOff];
|
||||
[device setFlashMode:AVCaptureFlashModeOff];
|
||||
}
|
||||
|
||||
}
|
||||
[device unlockForConfiguration];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
@ -98,35 +155,43 @@
|
||||
|
||||
#pragma mark - ZBarReaderDelegate
|
||||
|
||||
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
|
||||
{
|
||||
if ([self.scanReader isBeingDismissed]) { return; }
|
||||
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
|
||||
ZBarSymbol *symbol = nil;
|
||||
for(symbol in results) break; // get the first result
|
||||
|
||||
[self.scanReader dismissModalViewControllerAnimated: YES];
|
||||
[self.scanReader dismissViewControllerAnimated: YES completion: ^(void) {
|
||||
self.scanInProgress = NO;
|
||||
[self sendScanResult: [CDVPluginResult
|
||||
resultWithStatus: CDVCommandStatus_OK
|
||||
messageAsString: symbol.data]];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void) imagePickerControllerDidCancel:(UIImagePickerController*)picker
|
||||
{
|
||||
[self.scanReader dismissModalViewControllerAnimated: YES];
|
||||
[self.scanReader dismissViewControllerAnimated: YES completion: ^(void) {
|
||||
self.scanInProgress = NO;
|
||||
[self sendScanResult: [CDVPluginResult
|
||||
resultWithStatus: CDVCommandStatus_ERROR
|
||||
messageAsString: @"cancelled"]];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void) readerControllerDidFailToRead:(ZBarReaderController*)reader withRetry:(BOOL)retry
|
||||
{
|
||||
[self.scanReader dismissModalViewControllerAnimated: YES];
|
||||
[self.scanReader dismissViewControllerAnimated: YES completion: ^(void) {
|
||||
self.scanInProgress = NO;
|
||||
[self sendScanResult: [CDVPluginResult
|
||||
resultWithStatus: CDVCommandStatus_ERROR
|
||||
messageAsString: @"Failed"]];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
43
package.json
Normal file
43
package.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "cordova-plugin-cszbar",
|
||||
"version": "1.3.3",
|
||||
"description": "Plugin to integrate with the ZBar barcode scanning library.",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-cszbar",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tjwoon/csZBar.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cszbar",
|
||||
"zbar",
|
||||
"barcode",
|
||||
"qr",
|
||||
"qr code",
|
||||
"scanner",
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-ios"
|
||||
],
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova-android",
|
||||
"version": ">=3.0.0"
|
||||
},
|
||||
{
|
||||
"name": "cordova-ios",
|
||||
"version": ">=3.0.0"
|
||||
}
|
||||
],
|
||||
"author": "TJ Woon <tj@cloudsky.org>",
|
||||
"license": "Apache 2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tjwoon/csZBar/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tjwoon/csZBar#readme"
|
||||
}
|
27
plugin.xml
27
plugin.xml
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="org.cloudsky.cordovaplugins.zbar" version="1.2.0">
|
||||
|
||||
id="cordova-plugin-cszbar" version="1.3.2">
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0" />
|
||||
@ -24,15 +24,14 @@
|
||||
</feature>
|
||||
</config-file>
|
||||
<config-file target="AndroidManifest.xml" parent="application">
|
||||
<activity
|
||||
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
|
||||
android:name="org.cloudsky.cordovaPlugins.ZBarScannerActivity"
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
||||
android:screenOrientation="portrait" >
|
||||
</activity>
|
||||
android:screenOrientation="fullUser"
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
|
||||
</config-file>
|
||||
<config-file target="AndroidManifest.xml" parent="/*">
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
@ -44,16 +43,26 @@
|
||||
<color name="csZbarScannerTextBackground">#88000000</color>
|
||||
<color name="csZbarScannerBackground">#000000</color>
|
||||
</config-file>
|
||||
<framework src="com.android.support:support-v4:23.1.0" />
|
||||
<resource-file src="android/res/layout/cszbarscanner.xml" target="res/layout/cszbarscanner.xml" />
|
||||
<source-file src="android/ZBarcodeFormat.java" target-dir="src/org/cloudsky/cordovaPlugins" />
|
||||
<source-file src="android/ZBar.java" target-dir="src/org/cloudsky/cordovaPlugins" />
|
||||
<source-file src="android/ZBarScannerActivity.java" target-dir="src/org/cloudsky/cordovaPlugins" />
|
||||
<source-file src="android/libs/ZBar.jar" target-dir="libs" />
|
||||
<source-file src="android/libs/zbar.jar" target-dir="libs" />
|
||||
<source-file src="android/libs/armeabi/libiconv.so" target-dir="libs/armeabi" />
|
||||
<source-file src="android/libs/armeabi/libzbarjni.so" target-dir="libs/armeabi" />
|
||||
<source-file src="android/libs/armeabi-v7a/libiconv.so" target-dir="libs/armeabi-v7a" />
|
||||
<source-file src="android/libs/armeabi-v7a/libzbarjni.so" target-dir="libs/armeabi-v7a" />
|
||||
<source-file src="android/libs/arm64-v8a/libiconv.so" target-dir="libs/arm64-v8a" />
|
||||
<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/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"/>
|
||||
</platform>
|
||||
|
||||
<platform name="ios">
|
||||
@ -67,7 +76,7 @@
|
||||
<framework src="CoreVideo.framework" />
|
||||
<framework src="QuartzCore.framework" />
|
||||
<framework src="libiconv.dylib" />
|
||||
<source-file src="ios/libzbar.a" framework="true" />
|
||||
<source-file src="ios/libzbar.a" framework="true" custom="true"/>
|
||||
<source-file src="ios/CsZBar.m" />
|
||||
<header-file src="ios/CsZBar.h" />
|
||||
<source-file src="ios/AlmaZBarReaderViewController.m" />
|
||||
|
Loading…
Reference in New Issue
Block a user