mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Update plugins, dependencies, and clean up small code inspection issues
This commit is contained in:
parent
3912f3fd9f
commit
308d91de1c
|
@ -21,6 +21,7 @@ import com.google.zxing.client.result.AddressBookParsedResult;
|
|||
import com.google.zxing.client.result.ParsedResult;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Typeface;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
|
@ -205,7 +206,7 @@ public final class AddressBookResultHandler extends ResultHandler {
|
|||
if (namesLength > 0) {
|
||||
// Bold the full name to make it stand out a bit.
|
||||
Spannable styled = new SpannableString(contents.toString());
|
||||
styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
|
||||
styled.setSpan(new StyleSpan(Typeface.BOLD), 0, namesLength, 0);
|
||||
return styled;
|
||||
} else {
|
||||
return contents.toString();
|
||||
|
|
|
@ -53,7 +53,7 @@ final class BenchmarkItem {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder(30);
|
||||
result.append(decoded ? "DECODED " + format.toString() + ": " : "FAILED: ");
|
||||
result.append(decoded ? "DECODED " + format + ": " : "FAILED: ");
|
||||
result.append(path);
|
||||
result.append(" (");
|
||||
result.append(getAverageTime());
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
* decode a QR code. The decoder may optionally receive hints from the caller which may help
|
||||
* it decode more quickly or accurately.
|
||||
*
|
||||
* See {@link com.google.zxing.MultiFormatReader}, which attempts to determine what barcode
|
||||
* See {@link MultiFormatReader}, which attempts to determine what barcode
|
||||
* format is present within the image as well, and then decodes it accordingly.
|
||||
*
|
||||
* @author Sean Owen
|
||||
|
@ -48,7 +48,7 @@ public interface Reader {
|
|||
* hints, each possibly associated to some data, which may help the implementation decode.
|
||||
*
|
||||
* @param image image of barcode to decode
|
||||
* @param hints passed as a {@link java.util.Map} from {@link com.google.zxing.DecodeHintType}
|
||||
* @param hints passed as a {@link java.util.Map} from {@link DecodeHintType}
|
||||
* to arbitrary data. The
|
||||
* meaning of the data depends upon the hint type. The implementation may or may not do
|
||||
* anything with these hints.
|
||||
|
|
|
@ -271,7 +271,7 @@ public final class Decoder {
|
|||
boolean[] extractBits(BitMatrix matrix) {
|
||||
boolean compact = ddata.isCompact();
|
||||
int layers = ddata.getNbLayers();
|
||||
int baseMatrixSize = compact ? 11 + layers * 4 : 14 + layers * 4; // not including alignment lines
|
||||
int baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines
|
||||
int[] alignmentMap = new int[baseMatrixSize];
|
||||
boolean[] rawbits = new boolean[totalBitsInLayer(layers, compact)];
|
||||
|
||||
|
@ -290,7 +290,7 @@ public final class Decoder {
|
|||
}
|
||||
}
|
||||
for (int i = 0, rowOffset = 0; i < layers; i++) {
|
||||
int rowSize = compact ? (layers - i) * 4 + 9 : (layers - i) * 4 + 12;
|
||||
int rowSize = (layers - i) * 4 + (compact ? 9 : 12);
|
||||
// The top-left most point of this layer is <low, low> (not including alignment lines)
|
||||
int low = i * 2;
|
||||
// The bottom-right most point of this layer is <high, high> (not including alignment lines)
|
||||
|
|
|
@ -129,7 +129,7 @@ public final class Encoder {
|
|||
BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords);
|
||||
|
||||
// allocate symbol
|
||||
int baseMatrixSize = compact ? 11 + layers * 4 : 14 + layers * 4; // not including alignment lines
|
||||
int baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines
|
||||
int[] alignmentMap = new int[baseMatrixSize];
|
||||
int matrixSize;
|
||||
if (compact) {
|
||||
|
@ -152,7 +152,7 @@ public final class Encoder {
|
|||
|
||||
// draw data bits
|
||||
for (int i = 0, rowOffset = 0; i < layers; i++) {
|
||||
int rowSize = compact ? (layers - i) * 4 + 9 : (layers - i) * 4 + 12;
|
||||
int rowSize = (layers - i) * 4 + (compact ? 9 : 12);
|
||||
for (int j = 0; j < rowSize; j++) {
|
||||
int columnOffset = j * 2;
|
||||
for (int k = 0; k < 2; k++) {
|
||||
|
|
|
@ -307,7 +307,7 @@ public final class BitArray implements Cloneable {
|
|||
public void reverse() {
|
||||
int[] newBits = new int[bits.length];
|
||||
// reverse all int's first
|
||||
int len = ((size-1) / 32);
|
||||
int len = (size - 1) / 32;
|
||||
int oldBitsLen = len + 1;
|
||||
for (int i = 0; i < oldBitsLen; i++) {
|
||||
long x = (long) bits[i];
|
||||
|
|
|
@ -128,7 +128,7 @@ public final class MonochromeRectangleDetector {
|
|||
if (lastRange[0] < centerX) {
|
||||
if (lastRange[1] > centerX) {
|
||||
// straddle, choose one or the other based on direction
|
||||
return new ResultPoint(deltaY > 0 ? lastRange[0] : lastRange[1], lastY);
|
||||
return new ResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY);
|
||||
}
|
||||
return new ResultPoint(lastRange[0], lastY);
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ public final class MonochromeRectangleDetector {
|
|||
int lastX = x - deltaX;
|
||||
if (lastRange[0] < centerY) {
|
||||
if (lastRange[1] > centerY) {
|
||||
return new ResultPoint(lastX, deltaX < 0 ? lastRange[0] : lastRange[1]);
|
||||
return new ResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]);
|
||||
}
|
||||
return new ResultPoint(lastX, lastRange[0]);
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DefaultPlacement {
|
|||
}
|
||||
|
||||
final void setBit(int col, int row, boolean bit) {
|
||||
bits[row * numcols + col] = bit ? (byte) 1 : (byte) 0;
|
||||
bits[row * numcols + col] = (byte) (bit ? 1 : 0);
|
||||
}
|
||||
|
||||
final boolean hasBit(int col, int row) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public final class HighLevelEncoder {
|
|||
private static char randomize253State(char ch, int codewordPosition) {
|
||||
int pseudoRandom = ((149 * codewordPosition) % 253) + 1;
|
||||
int tempVariable = ch + pseudoRandom;
|
||||
return tempVariable <= 254 ? (char) tempVariable : (char) (tempVariable - 254);
|
||||
return (char) (tempVariable <= 254 ? tempVariable : tempVariable - 254);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,8 +45,6 @@ final class DecodedBitStreamParser {
|
|||
private static final char FS = '\u001C';
|
||||
private static final char GS = '\u001D';
|
||||
private static final char RS = '\u001E';
|
||||
private static final NumberFormat NINE_DIGITS = new DecimalFormat("000000000");
|
||||
private static final NumberFormat THREE_DIGITS = new DecimalFormat("000");
|
||||
|
||||
private static final String[] SETS = {
|
||||
"\nABCDEFGHIJKLMNOPQRSTUVWXYZ"+ECI+FS+GS+RS+NS+' '+PAD+"\"#$%&'()*+,-./0123456789:"+SHIFTB+SHIFTC+SHIFTD+SHIFTE+LATCHB,
|
||||
|
@ -73,8 +71,9 @@ final class DecodedBitStreamParser {
|
|||
} else {
|
||||
postcode = getPostCode3(bytes);
|
||||
}
|
||||
String country = THREE_DIGITS.format(getCountry(bytes));
|
||||
String service = THREE_DIGITS.format(getServiceClass(bytes));
|
||||
NumberFormat threeDigits = new DecimalFormat("000");
|
||||
String country = threeDigits.format(getCountry(bytes));
|
||||
String service = threeDigits.format(getServiceClass(bytes));
|
||||
result.append(getMessage(bytes, 10, 84));
|
||||
if (result.toString().startsWith("[)>"+RS+"01"+GS)) {
|
||||
result.insert(9, postcode + GS + country + GS + service + GS);
|
||||
|
@ -175,7 +174,7 @@ final class DecodedBitStreamParser {
|
|||
break;
|
||||
case NS:
|
||||
int nsval = (bytes[++i] << 24) + (bytes[++i] << 18) + (bytes[++i] << 12) + (bytes[++i] << 6) + bytes[++i];
|
||||
sb.append(NINE_DIGITS.format(nsval));
|
||||
sb.append(new DecimalFormat("000000000").format(nsval));
|
||||
break;
|
||||
case LOCK:
|
||||
shift = -1;
|
||||
|
|
|
@ -166,8 +166,8 @@ public final class QRCodeMultiReader extends QRCodeReader implements MultipleBar
|
|||
private static final class SAComparator implements Comparator<Result>, Serializable {
|
||||
@Override
|
||||
public int compare(Result a, Result b) {
|
||||
int aNumber = (int) (a.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE));
|
||||
int bNumber = (int) (b.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE));
|
||||
int aNumber = (int) a.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
int bNumber = (int) b.getResultMetadata().get(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE);
|
||||
if (aNumber < bNumber) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -468,8 +468,8 @@ public final class PDF417ScanningDecoder {
|
|||
int moduleNumber = 0;
|
||||
int increment = leftToRight ? 1 : -1;
|
||||
boolean previousPixelValue = leftToRight;
|
||||
while (((leftToRight && imageColumn < maxColumn) || (!leftToRight && imageColumn >= minColumn)) &&
|
||||
moduleNumber < moduleBitCount.length) {
|
||||
while ((leftToRight ? imageColumn < maxColumn : imageColumn >= minColumn) &&
|
||||
moduleNumber < moduleBitCount.length) {
|
||||
if (image.get(imageColumn, imageRow) == previousPixelValue) {
|
||||
moduleBitCount[moduleNumber]++;
|
||||
imageColumn += increment;
|
||||
|
@ -479,7 +479,8 @@ public final class PDF417ScanningDecoder {
|
|||
}
|
||||
}
|
||||
if (moduleNumber == moduleBitCount.length ||
|
||||
(((leftToRight && imageColumn == maxColumn) || (!leftToRight && imageColumn == minColumn)) && moduleNumber == moduleBitCount.length - 1)) {
|
||||
((imageColumn == (leftToRight ? maxColumn : minColumn)) &&
|
||||
moduleNumber == moduleBitCount.length - 1)) {
|
||||
return moduleBitCount;
|
||||
}
|
||||
return null;
|
||||
|
@ -499,8 +500,8 @@ public final class PDF417ScanningDecoder {
|
|||
int increment = leftToRight ? -1 : 1;
|
||||
// there should be no black pixels before the start column. If there are, then we need to start earlier.
|
||||
for (int i = 0; i < 2; i++) {
|
||||
while (((leftToRight && correctedStartColumn >= minColumn) || (!leftToRight && correctedStartColumn < maxColumn)) &&
|
||||
leftToRight == image.get(correctedStartColumn, imageRow)) {
|
||||
while ((leftToRight ? correctedStartColumn >= minColumn : correctedStartColumn < maxColumn) &&
|
||||
leftToRight == image.get(correctedStartColumn, imageRow)) {
|
||||
if (Math.abs(codewordStartColumn - correctedStartColumn) > CODEWORD_SKEW_SIZE) {
|
||||
return codewordStartColumn;
|
||||
}
|
||||
|
|
|
@ -379,11 +379,10 @@ final class PDF417HighLevelEncoder {
|
|||
if (count == 1 && startmode == TEXT_COMPACTION) {
|
||||
sb.append((char) SHIFT_TO_BYTE);
|
||||
} else {
|
||||
boolean sixpack = ((count % 6) == 0);
|
||||
if (sixpack) {
|
||||
sb.append((char)LATCH_TO_BYTE);
|
||||
if ((count % 6) == 0) {
|
||||
sb.append((char) LATCH_TO_BYTE);
|
||||
} else {
|
||||
sb.append((char)LATCH_TO_BYTE_PADDED);
|
||||
sb.append((char) LATCH_TO_BYTE_PADDED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,7 +533,7 @@ final class PDF417HighLevelEncoder {
|
|||
*/
|
||||
private static int determineConsecutiveBinaryCount(String msg, int startpos, Charset encoding)
|
||||
throws WriterException {
|
||||
final CharsetEncoder encoder = encoding.newEncoder();
|
||||
CharsetEncoder encoder = encoding.newEncoder();
|
||||
int len = msg.length();
|
||||
int idx = startpos;
|
||||
while (idx < len) {
|
||||
|
|
|
@ -85,14 +85,15 @@ final class FormatInformation {
|
|||
static int numBitsDiffering(int a, int b) {
|
||||
a ^= b; // a now has a 1 bit exactly where its bit differs with b's
|
||||
// Count bits set quickly with a series of lookups:
|
||||
return BITS_SET_IN_HALF_BYTE[a & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 4 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 8 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 12 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 16 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 20 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 24 & 0x0F)] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 28 & 0x0F)];
|
||||
return
|
||||
BITS_SET_IN_HALF_BYTE[a & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 4) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 8) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 12) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 16) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 20) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 24) & 0x0F] +
|
||||
BITS_SET_IN_HALF_BYTE[(a >>> 28) & 0x0F];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -110,7 +110,7 @@ final class AlignmentPatternFinder {
|
|||
if (image.get(j, i)) {
|
||||
// Black pixel
|
||||
if (currentState == 1) { // Counting black pixels
|
||||
stateCount[currentState]++;
|
||||
stateCount[1]++;
|
||||
} else { // Counting white pixels
|
||||
if (currentState == 2) { // A winner?
|
||||
if (foundPatternCross(stateCount)) { // Yes
|
||||
|
|
|
@ -103,8 +103,10 @@ final class MaskUtil {
|
|||
}
|
||||
|
||||
private static boolean isWhiteHorizontal(byte[] rowArray, int from, int to) {
|
||||
from = Math.max(from, 0);
|
||||
to = Math.min(to, rowArray.length);
|
||||
for (int i = from; i < to; i++) {
|
||||
if (i >= 0 && i < rowArray.length && rowArray[i] == 1) {
|
||||
if (rowArray[i] == 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +114,10 @@ final class MaskUtil {
|
|||
}
|
||||
|
||||
private static boolean isWhiteVertical(byte[][] array, int col, int from, int to) {
|
||||
from = Math.max(from, 0);
|
||||
to = Math.min(to, array.length);
|
||||
for (int i = from; i < to; i++) {
|
||||
if (i >= 0 && i < array.length && array[i][col] == 1) {
|
||||
if (array[i][col] == 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link com.google.zxing.client.result.GeoParsedResult}.
|
||||
* Tests {@link GeoParsedResult}.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link com.google.zxing.qrcode.decoder.DecodedBitStreamParser}.
|
||||
* Tests {@link DecodedBitStreamParser}.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.jai-imageio</groupId>
|
||||
<artifactId>jai-imageio-core</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.zxing.common.BitMatrix;
|
|||
import com.beust.jcommander.JCommander;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class CommandLineEncoder {
|
|||
if (EncoderConfig.DEFAULT_OUTPUT_FILE_BASE.equals(outFileString)) {
|
||||
outFileString += '.' + config.imageFormat.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
|
||||
if (config.errorCorrectionLevel != null) {
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, config.errorCorrectionLevel);
|
||||
}
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -44,7 +44,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>18.0</version>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
|
@ -168,7 +168,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<version>3.5</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
|
@ -333,7 +333,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19</version>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<forkCount>0.5C</forkCount>
|
||||
<systemPropertyVariables>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</parent>
|
||||
|
||||
<properties>
|
||||
<gwt.version>2.7.0</gwt.version>
|
||||
<gwt.version>2.8.0-beta1</gwt.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>9.3.6.v20151106</version>
|
||||
<version>9.3.7.v20160115</version>
|
||||
<configuration>
|
||||
<webAppSourceDirectory>src/web</webAppSourceDirectory>
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in a new issue