renamed BarcodeFormat to ZBarcodeFormat, fixed indentation and added sdk check for continuous focus
This commit is contained in:
parent
80a3632a15
commit
2b738063ef
@ -38,8 +38,8 @@ import net.sourceforge.zbar.Config;
|
||||
public class ZBarScannerActivity extends Activity
|
||||
implements SurfaceHolder.Callback {
|
||||
|
||||
//for barcode types
|
||||
private Collection<BarcodeFormat> mFormats = null;
|
||||
//for barcode types
|
||||
private Collection<ZBarcodeFormat> mFormats = null;
|
||||
|
||||
// Config ----------------------------------------------------------
|
||||
|
||||
@ -102,7 +102,8 @@ implements SurfaceHolder.Callback {
|
||||
scanner.setConfig(0, Config.X_DENSITY, 3);
|
||||
scanner.setConfig(0, Config.Y_DENSITY, 3);
|
||||
|
||||
for(BarcodeFormat format : getFormats()) {
|
||||
// Set the config for barcode formats
|
||||
for(ZBarcodeFormat format : getFormats()) {
|
||||
scanner.setConfig(format.getId(), Config.ENABLE, 1);
|
||||
}
|
||||
|
||||
@ -184,7 +185,9 @@ implements SurfaceHolder.Callback {
|
||||
} else {
|
||||
camParams.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
|
||||
}
|
||||
camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||
camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
}
|
||||
|
||||
try { camera.setParameters(camParams); }
|
||||
catch (RuntimeException e) {
|
||||
@ -363,9 +366,9 @@ implements SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<BarcodeFormat> getFormats() {
|
||||
public Collection<ZBarcodeFormat> getFormats() {
|
||||
if(mFormats == null) {
|
||||
return BarcodeFormat.ALL_FORMATS;
|
||||
return ZBarcodeFormat.ALL_FORMATS;
|
||||
}
|
||||
return mFormats;
|
||||
}
|
||||
|
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;
|
||||
}
|
||||
}
|
25
package.json
25
package.json
@ -1,25 +0,0 @@
|
||||
{
|
||||
"version": "1.3.0",
|
||||
"name": "org.cloudsky.cordovaplugins.zbar",
|
||||
"cordova_name": "ZBar barcode scanner",
|
||||
"description": "Plugin to integrate with the ZBar barcode scanning library.",
|
||||
"license": "Apache 2.0",
|
||||
"keywords": [
|
||||
"cszbar",
|
||||
"zbar",
|
||||
"barcode",
|
||||
"qr",
|
||||
"qr code",
|
||||
"scanner"
|
||||
],
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
],
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova",
|
||||
"version": ">=3.0.0"
|
||||
}
|
||||
]
|
||||
}
|
@ -44,7 +44,7 @@
|
||||
<color name="csZbarScannerBackground">#000000</color>
|
||||
</config-file>
|
||||
<resource-file src="android/res/layout/cszbarscanner.xml" target="res/layout/cszbarscanner.xml" />
|
||||
<source-file src="android/BarcodeFormat.java" target-dir="src/org/cloudsky/cordovaPlugins" />
|
||||
<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" />
|
||||
|
Loading…
Reference in New Issue
Block a user