mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Issue 1213 add 'raw' param to send back raw barcode text not processed form
git-svn-id: https://zxing.googlecode.com/svn/trunk@2229 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
9f45bab33c
commit
f74fc09d54
|
@ -100,6 +100,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
private static final String[] ZXING_URLS = { "http://zxing.appspot.com/scan", "zxing://scan/" };
|
private static final String[] ZXING_URLS = { "http://zxing.appspot.com/scan", "zxing://scan/" };
|
||||||
private static final String RETURN_CODE_PLACEHOLDER = "{CODE}";
|
private static final String RETURN_CODE_PLACEHOLDER = "{CODE}";
|
||||||
private static final String RETURN_URL_PARAM = "ret";
|
private static final String RETURN_URL_PARAM = "ret";
|
||||||
|
private static final String RAW_PARAM = "raw";
|
||||||
|
|
||||||
public static final int HISTORY_REQUEST_CODE = 0x0000bacc;
|
public static final int HISTORY_REQUEST_CODE = 0x0000bacc;
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
private IntentSource source;
|
private IntentSource source;
|
||||||
private String sourceUrl;
|
private String sourceUrl;
|
||||||
private String returnUrlTemplate;
|
private String returnUrlTemplate;
|
||||||
|
private boolean returnRaw;
|
||||||
private Collection<BarcodeFormat> decodeFormats;
|
private Collection<BarcodeFormat> decodeFormats;
|
||||||
private String characterSet;
|
private String characterSet;
|
||||||
private String versionName;
|
private String versionName;
|
||||||
|
@ -257,6 +259,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
sourceUrl = dataString;
|
sourceUrl = dataString;
|
||||||
Uri inputUri = Uri.parse(sourceUrl);
|
Uri inputUri = Uri.parse(sourceUrl);
|
||||||
returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM);
|
returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM);
|
||||||
|
returnRaw = inputUri.getQueryParameter(RAW_PARAM) != null;
|
||||||
decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri);
|
decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -663,9 +666,9 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
// Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
|
// Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
|
||||||
// with the scanned code. This allows both queries and REST-style URLs to work.
|
// with the scanned code. This allows both queries and REST-style URLs to work.
|
||||||
if (returnUrlTemplate != null) {
|
if (returnUrlTemplate != null) {
|
||||||
String codeReplacement = String.valueOf(resultHandler.getDisplayContents());
|
CharSequence codeReplacement = returnRaw ? rawResult.getText() : resultHandler.getDisplayContents();
|
||||||
try {
|
try {
|
||||||
codeReplacement = URLEncoder.encode(codeReplacement, "UTF-8");
|
codeReplacement = URLEncoder.encode(codeReplacement.toString(), "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
|
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue