mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Issue 338
git-svn-id: https://zxing.googlecode.com/svn/trunk@1206 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
146c4e096f
commit
aa1a7cace4
|
@ -141,6 +141,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
private Source source;
|
private Source source;
|
||||||
private String sourceUrl;
|
private String sourceUrl;
|
||||||
private Vector<BarcodeFormat> decodeFormats;
|
private Vector<BarcodeFormat> decodeFormats;
|
||||||
|
private String characterSet;
|
||||||
private String versionName;
|
private String versionName;
|
||||||
private HistoryManager historyManager;
|
private HistoryManager historyManager;
|
||||||
|
|
||||||
|
@ -228,9 +229,11 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
decodeFormats = null;
|
decodeFormats = null;
|
||||||
resetStatusView();
|
resetStatusView();
|
||||||
}
|
}
|
||||||
|
characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);
|
||||||
} else {
|
} else {
|
||||||
source = Source.NONE;
|
source = Source.NONE;
|
||||||
decodeFormats = null;
|
decodeFormats = null;
|
||||||
|
characterSet = null;
|
||||||
if (lastResult == null) {
|
if (lastResult == null) {
|
||||||
resetStatusView();
|
resetStatusView();
|
||||||
}
|
}
|
||||||
|
@ -615,7 +618,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
}
|
}
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
boolean beginScanning = lastResult == null;
|
boolean beginScanning = lastResult == null;
|
||||||
handler = new CaptureActivityHandler(this, decodeFormats, beginScanning);
|
handler = new CaptureActivityHandler(this, decodeFormats, characterSet, beginScanning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,10 @@ public final class CaptureActivityHandler extends Handler {
|
||||||
|
|
||||||
CaptureActivityHandler(CaptureActivity activity,
|
CaptureActivityHandler(CaptureActivity activity,
|
||||||
Vector<BarcodeFormat> decodeFormats,
|
Vector<BarcodeFormat> decodeFormats,
|
||||||
|
String characterSet,
|
||||||
boolean beginScanning) {
|
boolean beginScanning) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
decodeThread = new DecodeThread(activity, decodeFormats,
|
decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
|
||||||
new ViewfinderResultPointCallback(activity.getViewfinderView()));
|
new ViewfinderResultPointCallback(activity.getViewfinderView()));
|
||||||
decodeThread.start();
|
decodeThread.start();
|
||||||
state = State.SUCCESS;
|
state = State.SUCCESS;
|
||||||
|
|
|
@ -49,14 +49,14 @@ final class DecodeThread extends Thread {
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private final CaptureActivity activity;
|
private final CaptureActivity activity;
|
||||||
private final MultiFormatReader multiFormatReader;
|
private final MultiFormatReader multiFormatReader;
|
||||||
private final ResultPointCallback resultPointCallback;
|
|
||||||
|
|
||||||
DecodeThread(CaptureActivity activity,
|
DecodeThread(CaptureActivity activity,
|
||||||
Vector<BarcodeFormat> decodeFormats,
|
Vector<BarcodeFormat> decodeFormats,
|
||||||
|
String characterSet,
|
||||||
ResultPointCallback resultPointCallback) {
|
ResultPointCallback resultPointCallback) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
multiFormatReader = new MultiFormatReader();
|
multiFormatReader = new MultiFormatReader();
|
||||||
this.resultPointCallback = resultPointCallback;
|
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
|
||||||
|
|
||||||
// The prefs can't change while the thread is running, so pick them up once here.
|
// The prefs can't change while the thread is running, so pick them up once here.
|
||||||
if (decodeFormats == null || decodeFormats.isEmpty()) {
|
if (decodeFormats == null || decodeFormats.isEmpty()) {
|
||||||
|
@ -64,15 +64,23 @@ final class DecodeThread extends Thread {
|
||||||
boolean decode1D = prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D, true);
|
boolean decode1D = prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D, true);
|
||||||
boolean decodeQR = prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR, true);
|
boolean decodeQR = prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR, true);
|
||||||
if (decode1D && decodeQR) {
|
if (decode1D && decodeQR) {
|
||||||
doSetDecodeMode(CaptureActivity.ALL_FORMATS);
|
hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.ALL_FORMATS);
|
||||||
} else if (decode1D) {
|
} else if (decode1D) {
|
||||||
doSetDecodeMode(CaptureActivity.ONE_D_FORMATS);
|
hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.ONE_D_FORMATS);
|
||||||
} else if (decodeQR) {
|
} else if (decodeQR) {
|
||||||
doSetDecodeMode(CaptureActivity.QR_CODE_FORMATS);
|
hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.QR_CODE_FORMATS);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doSetDecodeMode(decodeFormats);
|
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (characterSet != null) {
|
||||||
|
hints.put(DecodeHintType.CHARACTER_SET, characterSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
|
||||||
|
|
||||||
|
multiFormatReader.setHints(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler getHandler() {
|
Handler getHandler() {
|
||||||
|
@ -98,15 +106,6 @@ final class DecodeThread extends Thread {
|
||||||
Looper.loop();
|
Looper.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSetDecodeMode(Vector<BarcodeFormat> vector) {
|
|
||||||
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
|
|
||||||
if (vector != null) {
|
|
||||||
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
|
|
||||||
}
|
|
||||||
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
|
|
||||||
multiFormatReader.setHints(hints);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
|
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
|
||||||
* reuse the same reader objects from one decode to the next.
|
* reuse the same reader objects from one decode to the next.
|
||||||
|
|
|
@ -53,6 +53,11 @@ public final class Intents {
|
||||||
*/
|
*/
|
||||||
public static final String SCAN_FORMATS = "SCAN_FORMATS";
|
public static final String SCAN_FORMATS = "SCAN_FORMATS";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.google.zxing.DecodeHintType#CHARACTER_SET
|
||||||
|
*/
|
||||||
|
public static final String CHARACTER_SET = "CHARACTER_SET";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
|
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
|
||||||
* prices, reviews, etc. for products.
|
* prices, reviews, etc. for products.
|
||||||
|
|
Loading…
Reference in a new issue