Various small improvements from inspection, dependency updates, preparing for 3.3.3

This commit is contained in:
Sean Owen 2018-05-29 08:26:06 -05:00
parent fa0e1d7556
commit 7a64f483fd
12 changed files with 79 additions and 83 deletions

View file

@ -378,3 +378,8 @@
- Minor DataMatrix bug fixes
- Improve WPA2 wi-fi configuration support in Barcode Scanner
- Various translation updates and minor improvements
3.3.3 (30 May 2018)
- Minor fixes and improvements
- Java 9+ support

View file

@ -88,7 +88,7 @@ public final class PreferencesFragment
}
}
private class CustomSearchURLValidator implements Preference.OnPreferenceChangeListener {
private final class CustomSearchURLValidator implements Preference.OnPreferenceChangeListener {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!isValid(newValue)) {

View file

@ -48,52 +48,38 @@ public final class OpenCameraInterface {
Log.w(TAG, "No cameras!");
return null;
}
if (cameraId >= numCameras) {
Log.w(TAG, "Requested camera does not exist: " + cameraId);
return null;
}
boolean explicitRequest = cameraId >= 0;
Camera.CameraInfo selectedCameraInfo = null;
int index;
if (explicitRequest) {
index = cameraId;
selectedCameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(index, selectedCameraInfo);
} else {
index = 0;
while (index < numCameras) {
if (cameraId <= NO_REQUESTED_CAMERA) {
cameraId = 0;
while (cameraId < numCameras) {
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(index, cameraInfo);
CameraFacing reportedFacing = CameraFacing.values()[cameraInfo.facing];
if (reportedFacing == CameraFacing.BACK) {
selectedCameraInfo = cameraInfo;
Camera.getCameraInfo(cameraId, cameraInfo);
if (CameraFacing.values()[cameraInfo.facing] == CameraFacing.BACK) {
break;
}
index++;
cameraId++;
}
}
Camera camera;
if (index < numCameras) {
Log.i(TAG, "Opening camera #" + index);
camera = Camera.open(index);
} else {
if (explicitRequest) {
Log.w(TAG, "Requested camera does not exist: " + cameraId);
camera = null;
} else {
if (cameraId == numCameras) {
Log.i(TAG, "No camera facing " + CameraFacing.BACK + "; returning camera #0");
camera = Camera.open(0);
selectedCameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(0, selectedCameraInfo);
cameraId = 0;
}
}
Log.i(TAG, "Opening camera #" + cameraId);
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, cameraInfo);
Camera camera = Camera.open(cameraId);
if (camera == null) {
return null;
}
return new OpenCamera(index,
return new OpenCamera(cameraId,
camera,
CameraFacing.values()[selectedCameraInfo.facing],
selectedCameraInfo.orientation);
CameraFacing.values()[cameraInfo.facing],
cameraInfo.orientation);
}
}

View file

@ -67,7 +67,7 @@ final class MECARDContactEncoder extends ContactEncoder {
return new String[] { newContents.toString(), newDisplayContents.toString() };
}
private static class MECARDFieldFormatter implements Formatter {
private static final class MECARDFieldFormatter implements Formatter {
private static final Pattern RESERVED_MECARD_CHARS = Pattern.compile("([\\\\:;])");
private static final Pattern NEWLINE = Pattern.compile("\\n");
@Override
@ -76,7 +76,7 @@ final class MECARDContactEncoder extends ContactEncoder {
}
}
private static class MECARDTelDisplayFormatter implements Formatter {
private static final class MECARDTelDisplayFormatter implements Formatter {
private static final Pattern NOT_DIGITS_OR_PLUS = Pattern.compile("[^0-9+]+");
@Override
public CharSequence format(CharSequence value, int index) {
@ -84,7 +84,7 @@ final class MECARDContactEncoder extends ContactEncoder {
}
}
private static class MECARDNameDisplayFormatter implements Formatter {
private static final class MECARDNameDisplayFormatter implements Formatter {
private static final Pattern COMMA = Pattern.compile(",");
@Override
public CharSequence format(CharSequence value, int index) {

View file

@ -205,7 +205,8 @@ public abstract class ResultHandler {
putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation);
int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0, Contents.PHONE_KEYS.length);
if (phoneNumbers != null) {
int phoneCount = Math.min(phoneNumbers.length, Contents.PHONE_KEYS.length);
for (int x = 0; x < phoneCount; x++) {
putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]);
if (phoneTypes != null && x < phoneTypes.length) {
@ -215,8 +216,10 @@ public abstract class ResultHandler {
}
}
}
}
int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length);
if (emails != null) {
int emailCount = Math.min(emails.length, Contents.EMAIL_KEYS.length);
for (int x = 0; x < emailCount; x++) {
putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
if (emailTypes != null && x < emailTypes.length) {
@ -226,6 +229,7 @@ public abstract class ResultHandler {
}
}
}
}
ArrayList<ContentValues> data = new ArrayList<>();
if (urls != null) {

View file

@ -60,12 +60,13 @@
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<executions>
<execution>
<goals>
@ -74,7 +75,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>

View file

@ -524,8 +524,8 @@ public final class Detector {
* @param newSide the new length of the size of the square in the target bit matrix
* @return the corners of the expanded square
*/
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, float oldSide, float newSide) {
float ratio = newSide / (2 * oldSide);
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide) {
float ratio = newSide / (2.0f * oldSide);
float dx = cornerPoints[0].getX() - cornerPoints[2].getX();
float dy = cornerPoints[0].getY() - cornerPoints[2].getY();
float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f;

View file

@ -108,7 +108,7 @@ public final class Encoder {
}
// [Re]stuff the bits if this is the first opportunity, or if the
// wordSize has changed
if (wordSize != WORD_SIZE[layers]) {
if (stuffedBits == null || wordSize != WORD_SIZE[layers]) {
wordSize = WORD_SIZE[layers];
stuffedBits = stuffBits(bits, wordSize);
}

View file

@ -40,16 +40,15 @@ final class BoundingBox {
ResultPoint bottomLeft,
ResultPoint topRight,
ResultPoint bottomRight) throws NotFoundException {
if ((topLeft == null && topRight == null) ||
(bottomLeft == null && bottomRight == null) ||
(topLeft != null && bottomLeft == null) ||
(topRight != null && bottomRight == null)) {
boolean leftUnspecified = topLeft == null || bottomLeft == null;
boolean rightUnspecified = topRight == null || bottomRight == null;
if (leftUnspecified && rightUnspecified) {
throw NotFoundException.getNotFoundInstance();
}
if (topLeft == null) {
if (leftUnspecified) {
topLeft = new ResultPoint(0, topRight.getY());
bottomLeft = new ResultPoint(0, bottomRight.getY());
} else if (topRight == null) {
} else if (rightUnspecified) {
topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());
bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());
}

18
pom.xml
View file

@ -205,7 +205,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
@ -231,12 +231,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -278,7 +278,7 @@
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.5</version>
<version>1.10.0</version>
</dependency>
</dependencies>
<configuration>
@ -291,7 +291,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.5</version>
<version>1.10.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -301,7 +301,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -339,7 +339,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
@ -430,7 +430,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7</version>
<version>3.7.1</version>
<inherited>false</inherited>
</plugin>
<plugin>
@ -466,7 +466,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.10</version>
<version>8.10.1</version>
</dependency>
</dependencies>
</plugin>

View file

@ -54,43 +54,45 @@
<script type="text/javascript">
$(function(){
var playLink = $(".playLink");
var man = $("#man");
// If device is Android, change URI to Android-friendly. Otherwise use HTTP URI.
if(navigator.userAgent.toLowerCase().indexOf("android") !== -1) {
$(".playLink").attr("src","market://details?id=com.google.zxing.client.android");
playLink.attr("src","market://details?id=com.google.zxing.client.android");
}
// Detect GET-parameters from URL
GET = {};
var GET = {};
$.each(location.search.substr(1).split("&"),function(k,v){
var prm = v.split("=");
GET[decodeURIComponent(prm[0])] = decodeURIComponent(prm[1]);
});
// Check is it possible to use manual mode
if(GET.ret == "" || GET.ret == void(0) || GET.ret.indexOf("http") == -1){
$("#man").hide();
if(GET["ret"] === "" || GET["ret"] === void(0) || GET["ret"].indexOf("http") === -1){
man.hide();
}
// When Google Play -badge is clicked ...
$(".playLink").click(function(){
playLink.click(function(){
$("#info").hide();
$("#error").hide();
$("#installed").show();
var url = location.href;
if(url.indexOf("?") == -1) url = url + "?";
if(url.indexOf("?") === -1) url = url + "?";
url = url + "&installed=1";
$("#installed a").attr("href",url);
});
// When manual-button is clicked ...
$("#man").click(function(e){
man.click(function(e){
e.preventDefault();
var man = prompt("Please type barcode below");
if(man){
var url = GET.ret;
if (url.indexOf("{CODE}") == -1) {
var url = GET["ret"];
if (url.indexOf("{CODE}") === -1) {
// Return URL has no {CODE} place holder, so add a query parameter
if (url.indexOf("?") == -1)
if (url.indexOf("?") === -1)
url = url + "?" + encodeURIComponent("{CODE}") + "=" + encodeURIComponent(man);
else
url = url + "&" + encodeURIComponent("{CODE}") + "=" + encodeURIComponent(man);
@ -103,7 +105,7 @@
});
// If app isn't installed after visiting on Google Play, show error
if(GET.installed !== void(0)){
if(GET["installed"] !== void(0)){
$("#info").hide();
$("#error").show();
}

View file

@ -39,7 +39,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.1-android</version>
<version>25.1-android</version>
</dependency>
<dependency>
<groupId>junit</groupId>