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 - Minor DataMatrix bug fixes
- Improve WPA2 wi-fi configuration support in Barcode Scanner - Improve WPA2 wi-fi configuration support in Barcode Scanner
- Various translation updates and minor improvements - 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 @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!isValid(newValue)) { if (!isValid(newValue)) {

View file

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

View file

@ -67,7 +67,7 @@ final class MECARDContactEncoder extends ContactEncoder {
return new String[] { newContents.toString(), newDisplayContents.toString() }; 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 RESERVED_MECARD_CHARS = Pattern.compile("([\\\\:;])");
private static final Pattern NEWLINE = Pattern.compile("\\n"); private static final Pattern NEWLINE = Pattern.compile("\\n");
@Override @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+]+"); private static final Pattern NOT_DIGITS_OR_PLUS = Pattern.compile("[^0-9+]+");
@Override @Override
public CharSequence format(CharSequence value, int index) { 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(","); private static final Pattern COMMA = Pattern.compile(",");
@Override @Override
public CharSequence format(CharSequence value, int index) { public CharSequence format(CharSequence value, int index) {

View file

@ -205,24 +205,28 @@ public abstract class ResultHandler {
putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation); putExtra(intent, ContactsContract.Intents.Insert.PHONETIC_NAME, pronunciation);
int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0, Contents.PHONE_KEYS.length); if (phoneNumbers != null) {
for (int x = 0; x < phoneCount; x++) { int phoneCount = Math.min(phoneNumbers.length, Contents.PHONE_KEYS.length);
putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]); for (int x = 0; x < phoneCount; x++) {
if (phoneTypes != null && x < phoneTypes.length) { putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]);
int type = toPhoneContractType(phoneTypes[x]); if (phoneTypes != null && x < phoneTypes.length) {
if (type >= 0) { int type = toPhoneContractType(phoneTypes[x]);
intent.putExtra(Contents.PHONE_TYPE_KEYS[x], type); if (type >= 0) {
intent.putExtra(Contents.PHONE_TYPE_KEYS[x], type);
}
} }
} }
} }
int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length); if (emails != null) {
for (int x = 0; x < emailCount; x++) { int emailCount = Math.min(emails.length, Contents.EMAIL_KEYS.length);
putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]); for (int x = 0; x < emailCount; x++) {
if (emailTypes != null && x < emailTypes.length) { putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
int type = toEmailContractType(emailTypes[x]); if (emailTypes != null && x < emailTypes.length) {
if (type >= 0) { int type = toEmailContractType(emailTypes[x]);
intent.putExtra(Contents.EMAIL_TYPE_KEYS[x], type); if (type >= 0) {
intent.putExtra(Contents.EMAIL_TYPE_KEYS[x], type);
}
} }
} }
} }

View file

@ -60,12 +60,13 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>biz.aQute.bnd</groupId> <groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId> <artifactId>bnd-maven-plugin</artifactId>
<version>3.5.0</version> <version>4.0.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@ -74,7 +75,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <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 * @param newSide the new length of the size of the square in the target bit matrix
* @return the corners of the expanded square * @return the corners of the expanded square
*/ */
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, float oldSide, float newSide) { private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide) {
float ratio = newSide / (2 * oldSide); float ratio = newSide / (2.0f * oldSide);
float dx = cornerPoints[0].getX() - cornerPoints[2].getX(); float dx = cornerPoints[0].getX() - cornerPoints[2].getX();
float dy = cornerPoints[0].getY() - cornerPoints[2].getY(); float dy = cornerPoints[0].getY() - cornerPoints[2].getY();
float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f; 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 // [Re]stuff the bits if this is the first opportunity, or if the
// wordSize has changed // wordSize has changed
if (wordSize != WORD_SIZE[layers]) { if (stuffedBits == null || wordSize != WORD_SIZE[layers]) {
wordSize = WORD_SIZE[layers]; wordSize = WORD_SIZE[layers];
stuffedBits = stuffBits(bits, wordSize); stuffedBits = stuffBits(bits, wordSize);
} }

View file

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

18
pom.xml
View file

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

View file

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

View file

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