Skip to content

Commit

Permalink
Update plugins, dependencies, and clean up small code inspection issues
Browse files Browse the repository at this point in the history
  • Loading branch information
srowen committed Jan 21, 2016
1 parent 3912f3f commit 308d91d
Show file tree
Hide file tree
Showing 23 changed files with 56 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -205,7 +206,7 @@ public CharSequence getDisplayContents() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void setFormat(BarcodeFormat format) {
@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());
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/com/google/zxing/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* 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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private boolean[] correctBits(boolean[] rawbits) throws FormatException {
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)];

Expand All @@ -290,7 +290,7 @@ boolean[] extractBits(BitMatrix matrix) {
}
}
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static AztecCode encode(byte[] data, int minECCPercent, int userSpecified
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) {
Expand All @@ -152,7 +152,7 @@ public static AztecCode encode(byte[] data, int minECCPercent, int userSpecified

// 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++) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/google/zxing/common/BitArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public int[] getBitArray() {
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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private ResultPoint findCornerFromCenter(int centerX,
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 {
Expand All @@ -138,7 +138,7 @@ private ResultPoint findCornerFromCenter(int centerX,
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final boolean getBit(int col, int row) {
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static byte[] getBytesForMessage(String msg) {
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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -73,8 +71,9 @@ static DecoderResult decode(byte[] bytes, int mode) {
} 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);
Expand Down Expand Up @@ -175,7 +174,7 @@ private static String getMessage(byte[] bytes, int start, int len) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ private static List<Result> processStructuredAppend(List<Result> results) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ private static int[] getModuleBitCount(BitMatrix image,
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;
Expand All @@ -479,7 +479,8 @@ private static int[] getModuleBitCount(BitMatrix image,
}
}
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;
Expand All @@ -499,8 +500,8 @@ private static int adjustCodewordStartColumn(BitMatrix image,
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,10 @@ private static void encodeBinary(byte[] bytes,
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);
}
}

Expand Down Expand Up @@ -534,7 +533,7 @@ private static int determineConsecutiveTextCount(CharSequence msg, int startpos)
*/
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ private FormatInformation(int formatInfo) {
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];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ AlignmentPattern find() throws NotFoundException {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,21 @@ static int applyMaskPenaltyRule3(ByteMatrix matrix) {
}

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;
}
}
return true;
}

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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.junit.Test;

/**
* Tests {@link com.google.zxing.client.result.GeoParsedResult}.
* Tests {@link GeoParsedResult}.
*
* @author Sean Owen
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.junit.Test;

/**
* Tests {@link com.google.zxing.qrcode.decoder.DecodedBitStreamParser}.
* Tests {@link DecodedBitStreamParser}.
*
* @author Sean Owen
*/
Expand Down
2 changes: 1 addition & 1 deletion javase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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;

Expand All @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception {
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);
}
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion zxing.appspot.com/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</parent>

<properties>
<gwt.version>2.7.0</gwt.version>
<gwt.version>2.8.0-beta1</gwt.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion zxingorg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 308d91d

Please sign in to comment.