Update proguard to 7. Remove unused slf4j. Minor code tweaks and dep updates. (#1307)

This commit is contained in:
Sean Owen 2020-08-26 13:09:20 -05:00 committed by GitHub
parent 85e37821a5
commit da049f21d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 68 deletions

View file

@ -55,8 +55,6 @@ import java.util.Map;
*/
final class QRCodeEncoder {
private static final String TAG = QRCodeEncoder.class.getSimpleName();
private static final int WHITE = 0xFFFFFFFF;
private static final int BLACK = 0xFF000000;

View file

@ -41,9 +41,6 @@
<profiles>
<profile>
<id>proguard-library</id>
<activation>
<jdk>[,9)</jdk> <!-- Proguard won't work with JDK 9 -->
</activation>
<build>
<plugins>
<plugin>
@ -66,7 +63,7 @@
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>5.0.1</version>
<version>5.1.2</version>
<executions>
<execution>
<goals>

View file

@ -117,11 +117,11 @@ public final class BitMatrix implements Cloneable {
nRows++;
}
pos++;
} else if (stringRepresentation.substring(pos, pos + setString.length()).equals(setString)) {
} else if (stringRepresentation.startsWith(setString, pos)) {
pos += setString.length();
bits[bitsPos] = true;
bitsPos++;
} else if (stringRepresentation.substring(pos, pos + unsetString.length()).equals(unsetString)) {
} else if (stringRepresentation.startsWith(unsetString, pos)) {
pos += unsetString.length();
bits[bitsPos] = false;
bitsPos++;

View file

@ -76,7 +76,7 @@ class C40Encoder implements Encoder {
}
static void writeNextTriplet(EncoderContext context, StringBuilder buffer) {
context.writeCodewords(encodeToCodewords(buffer, 0));
context.writeCodewords(encodeToCodewords(buffer));
buffer.delete(0, 3);
}
@ -168,11 +168,8 @@ class C40Encoder implements Encoder {
return len;
}
private static String encodeToCodewords(CharSequence sb, int startPos) {
char c1 = sb.charAt(startPos);
char c2 = sb.charAt(startPos + 1);
char c3 = sb.charAt(startPos + 2);
int v = (1600 * c1) + (40 * c2) + c3 + 1;
private static String encodeToCodewords(CharSequence sb) {
int v = (1600 * sb.charAt(0)) + (40 * sb.charAt(1)) + sb.charAt(2) + 1;
char cw1 = (char) (v / 256);
char cw2 = (char) (v % 256);
return new String(new char[] {cw1, cw2});

View file

@ -34,7 +34,7 @@ final class EdifactEncoder implements Encoder {
int count = buffer.length();
if (count >= 4) {
context.writeCodewords(encodeToCodewords(buffer, 0));
context.writeCodewords(encodeToCodewords(buffer));
buffer.delete(0, 4);
int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode());
@ -80,7 +80,7 @@ final class EdifactEncoder implements Encoder {
throw new IllegalStateException("Count must not exceed 4");
}
int restChars = count - 1;
String encoded = encodeToCodewords(buffer, 0);
String encoded = encodeToCodewords(buffer);
boolean endOfSymbolReached = !context.hasMoreCharacters();
boolean restInAscii = endOfSymbolReached && restChars <= 2;
@ -115,15 +115,15 @@ final class EdifactEncoder implements Encoder {
}
}
private static String encodeToCodewords(CharSequence sb, int startPos) {
int len = sb.length() - startPos;
private static String encodeToCodewords(CharSequence sb) {
int len = sb.length();
if (len == 0) {
throw new IllegalStateException("StringBuilder must not be empty");
}
char c1 = sb.charAt(startPos);
char c2 = len >= 2 ? sb.charAt(startPos + 1) : 0;
char c3 = len >= 3 ? sb.charAt(startPos + 2) : 0;
char c4 = len >= 4 ? sb.charAt(startPos + 3) : 0;
char c1 = sb.charAt(0);
char c2 = len >= 2 ? sb.charAt(1) : 0;
char c3 = len >= 3 ? sb.charAt(2) : 0;
char c4 = len >= 4 ? sb.charAt(3) : 0;
int v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
char cw1 = (char) ((v >> 16) & 255);

View file

@ -19,7 +19,6 @@ package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import java.util.Collection;
@ -35,8 +34,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
private static final Pattern NUMERIC = Pattern.compile("[0-9]+");
@Override
public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
throws WriterException {
public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height) {
return encode(contents, format, width, height, null);
}

View file

@ -72,7 +72,7 @@ public final class Detector {
*/
public static PDF417DetectorResult detect(BinaryBitmap image, Map<DecodeHintType,?> hints, boolean multiple)
throws NotFoundException {
// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even
// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even
// different binarizers
//boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
@ -188,10 +188,10 @@ public final class Detector {
boolean found = false;
int[] counters = new int[pattern.length];
for (; startRow < height; startRow += ROW_STEP) {
int[] loc = findGuardPattern(matrix, startColumn, startRow, width, false, pattern, counters);
int[] loc = findGuardPattern(matrix, startColumn, startRow, width, pattern, counters);
if (loc != null) {
while (startRow > 0) {
int[] previousRowLoc = findGuardPattern(matrix, startColumn, --startRow, width, false, pattern, counters);
int[] previousRowLoc = findGuardPattern(matrix, startColumn, --startRow, width, pattern, counters);
if (previousRowLoc != null) {
loc = previousRowLoc;
} else {
@ -211,7 +211,7 @@ public final class Detector {
int skippedRowCount = 0;
int[] previousRowLoc = {(int) result[0].getX(), (int) result[1].getX()};
for (; stopRow < height; stopRow++) {
int[] loc = findGuardPattern(matrix, previousRowLoc[0], stopRow, width, false, pattern, counters);
int[] loc = findGuardPattern(matrix, previousRowLoc[0], stopRow, width, pattern, counters);
// a found pattern is only considered to belong to the same barcode if the start and end positions
// don't differ too much. Pattern drift should be not bigger than two for consecutive rows. With
// a higher number of skipped rows drift could be larger. To keep it simple for now, we allow a slightly
@ -253,7 +253,6 @@ public final class Detector {
int column,
int row,
int width,
boolean whiteFirst,
int[] pattern,
int[] counters) {
Arrays.fill(counters, 0, counters.length, 0);
@ -267,13 +266,13 @@ public final class Detector {
int x = patternStart;
int counterPosition = 0;
int patternLength = pattern.length;
for (boolean isWhite = whiteFirst; x < width; x++) {
for (boolean isWhite = false; x < width; x++) {
boolean pixel = matrix.get(x, row);
if (pixel != isWhite) {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
if (patternMatchVariance(counters, pattern) < MAX_AVG_VARIANCE) {
return new int[] {patternStart, x};
}
patternStart += counters[0] + counters[1];
@ -289,7 +288,7 @@ public final class Detector {
}
}
if (counterPosition == patternLength - 1 &&
patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
patternMatchVariance(counters, pattern) < MAX_AVG_VARIANCE) {
return new int[] {patternStart, x - 1};
}
return null;
@ -303,10 +302,9 @@ public final class Detector {
*
* @param counters observed counters
* @param pattern expected pattern
* @param maxIndividualVariance The most any counter can differ before we give up
* @return ratio of total variance between counters and pattern compared to total pattern size
*/
private static float patternMatchVariance(int[] counters, int[] pattern, float maxIndividualVariance) {
private static float patternMatchVariance(int[] counters, int[] pattern) {
int numCounters = counters.length;
int total = 0;
int patternLength = 0;
@ -323,7 +321,7 @@ public final class Detector {
// Scale up patternLength so that intermediate values below like scaledCounter will have
// more "significant digits".
float unitBarWidth = (float) total / patternLength;
maxIndividualVariance *= unitBarWidth;
float maxIndividualVariance = MAX_INDIVIDUAL_VARIANCE * unitBarWidth;
float totalVariance = 0.0f;
for (int x = 0; x < numCounters; x++) {

62
pom.xml
View file

@ -24,23 +24,6 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
@ -83,9 +66,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<android.home>${env.ANDROID_HOME}</android.home>
<proguard.version>6.3.0beta1</proguard.version>
<proguard.plugin.version>2.2.0</proguard.plugin.version>
<slf4j.version>1.8.0-beta4</slf4j.version>
<proguard.version>7.0.0</proguard.version>
<proguard.plugin.version>2.3.0</proguard.plugin.version>
<!-- This can't reference project.version as some subprojects version differently -->
<zxing.version>3.4.1-SNAPSHOT</zxing.version>
<android.platform>22</android.platform>
@ -230,7 +212,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -305,7 +287,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -327,7 +309,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<version>3.0.0-M5</version>
<configuration>
<forkCount>0.5C</forkCount>
<systemPropertyVariables>
@ -338,7 +320,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
@ -384,10 +366,15 @@
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-base</artifactId>
<version>${proguard.version}</version>
</dependency>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-core</artifactId>
<version>${proguard.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
@ -419,23 +406,29 @@
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-base</artifactId>
<version>${proguard.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-core</artifactId>
<version>${proguard.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.0</version>
<version>3.9.1</version>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -460,7 +453,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.32</version>
<version>8.35</version>
</dependency>
</dependencies>
</plugin>
@ -689,6 +682,17 @@
<tag>HEAD</tag>
</scm>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-guardsquare-proguard</id>
<name>bintray</name>
<url>https://dl.bintray.com/guardsquare/proguard</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>

View file

@ -16,7 +16,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>zxing.appspot.com</artifactId>
<version>3.4.1-SNAPSHOT</version>
<packaging>war</packaging>
@ -37,7 +37,7 @@
</parent>
<properties>
<gwt.version>2.8.2</gwt.version>
<gwt.version>2.9.0</gwt.version>
</properties>
<build>

View file

@ -49,7 +49,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.6.RELEASE</version>
<version>5.2.8.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>