mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
A few more touch-ups from Codacy
This commit is contained in:
parent
11a88fe7aa
commit
ae6b9f4426
|
@ -637,60 +637,61 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
|
|
||||||
maybeSetClipboard(resultHandler);
|
maybeSetClipboard(resultHandler);
|
||||||
|
|
||||||
if (source == IntentSource.NATIVE_APP_INTENT) {
|
switch (source) {
|
||||||
|
case NATIVE_APP_INTENT:
|
||||||
// Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
|
// Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
|
||||||
// the deprecated intent is retired.
|
// the deprecated intent is retired.
|
||||||
Intent intent = new Intent(getIntent().getAction());
|
Intent intent = new Intent(getIntent().getAction());
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
|
intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
|
||||||
intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
|
intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
|
||||||
byte[] rawBytes = rawResult.getRawBytes();
|
byte[] rawBytes = rawResult.getRawBytes();
|
||||||
if (rawBytes != null && rawBytes.length > 0) {
|
if (rawBytes != null && rawBytes.length > 0) {
|
||||||
intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
|
intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
|
||||||
}
|
|
||||||
Map<ResultMetadataType,?> metadata = rawResult.getResultMetadata();
|
|
||||||
if (metadata != null) {
|
|
||||||
if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
|
|
||||||
intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
|
|
||||||
metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
|
|
||||||
}
|
}
|
||||||
Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
|
Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata();
|
||||||
if (orientation != null) {
|
if (metadata != null) {
|
||||||
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
|
if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
|
||||||
}
|
intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
|
||||||
String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
|
metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
|
||||||
if (ecLevel != null) {
|
}
|
||||||
intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
|
Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
|
||||||
}
|
if (orientation != null) {
|
||||||
@SuppressWarnings("unchecked")
|
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
|
||||||
Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
|
}
|
||||||
if (byteSegments != null) {
|
String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
|
||||||
int i = 0;
|
if (ecLevel != null) {
|
||||||
for (byte[] byteSegment : byteSegments) {
|
intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
|
||||||
intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
|
}
|
||||||
i++;
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
|
||||||
|
if (byteSegments != null) {
|
||||||
|
int i = 0;
|
||||||
|
for (byte[] byteSegment : byteSegments) {
|
||||||
|
intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);
|
||||||
sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);
|
break;
|
||||||
|
|
||||||
} else if (source == IntentSource.PRODUCT_SEARCH_LINK) {
|
|
||||||
|
|
||||||
// Reformulate the URL which triggered us into a query, so that the request goes to the same
|
|
||||||
// TLD as the scan URL.
|
|
||||||
int end = sourceUrl.lastIndexOf("/scan");
|
|
||||||
String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents() + "&source=zxing";
|
|
||||||
sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);
|
|
||||||
|
|
||||||
} else if (source == IntentSource.ZXING_LINK) {
|
|
||||||
|
|
||||||
if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
|
case PRODUCT_SEARCH_LINK:
|
||||||
String replyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
|
// Reformulate the URL which triggered us into a query, so that the request goes to the same
|
||||||
scanFromWebPageManager = null;
|
// TLD as the scan URL.
|
||||||
sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);
|
int end = sourceUrl.lastIndexOf("/scan");
|
||||||
}
|
String productReplyURL = sourceUrl.substring(0, end) + "?q=" +
|
||||||
|
resultHandler.getDisplayContents() + "&source=zxing";
|
||||||
|
sendReplyMessage(R.id.launch_product_query, productReplyURL, resultDurationMS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZXING_LINK:
|
||||||
|
if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
|
||||||
|
String linkReplyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
|
||||||
|
scanFromWebPageManager = null;
|
||||||
|
sendReplyMessage(R.id.launch_product_query, linkReplyURL, resultDurationMS);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,13 @@ import com.google.zxing.common.reedsolomon.ReedSolomonException;
|
||||||
*/
|
*/
|
||||||
public final class Detector {
|
public final class Detector {
|
||||||
|
|
||||||
|
private static final int[] EXPECTED_CORNER_BITS = {
|
||||||
|
0xee0, // 07340 XXX .XX X.. ...
|
||||||
|
0x1dc, // 00734 ... XXX .XX X..
|
||||||
|
0x83b, // 04073 X.. ... XXX .XX
|
||||||
|
0x707, // 03407 .XX X.. ... XXX
|
||||||
|
};
|
||||||
|
|
||||||
private final BitMatrix image;
|
private final BitMatrix image;
|
||||||
|
|
||||||
private boolean compact;
|
private boolean compact;
|
||||||
|
@ -146,13 +153,6 @@ public final class Detector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] EXPECTED_CORNER_BITS = {
|
|
||||||
0xee0, // 07340 XXX .XX X.. ...
|
|
||||||
0x1dc, // 00734 ... XXX .XX X..
|
|
||||||
0x83b, // 04073 X.. ... XXX .XX
|
|
||||||
0x707, // 03407 .XX X.. ... XXX
|
|
||||||
};
|
|
||||||
|
|
||||||
private static int getRotation(int[] sides, int length) throws NotFoundException {
|
private static int getRotation(int[] sides, int length) throws NotFoundException {
|
||||||
// In a normal pattern, we expect to See
|
// In a normal pattern, we expect to See
|
||||||
// ** .* D A
|
// ** .* D A
|
||||||
|
|
Loading…
Reference in a new issue