diff --git a/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java b/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java index 9b17eccf9..3a444df58 100755 --- a/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java +++ b/F-Droid/src/com/google/zxing/encode/QRCodeEncoder.java @@ -82,34 +82,39 @@ public final class QRCodeEncoder { } private void encodeQRCodeContents(String data, Bundle bundle, String type) { - if (type.equals(Contents.Type.TEXT)) { + switch (type) { + case Contents.Type.TEXT: if (data != null && data.length() > 0) { contents = data; displayContents = data; title = "Text"; } - } else if (type.equals(Contents.Type.EMAIL)) { + break; + case Contents.Type.EMAIL: data = trim(data); if (data != null) { contents = "mailto:" + data; displayContents = data; title = "E-Mail"; } - } else if (type.equals(Contents.Type.PHONE)) { + break; + case Contents.Type.PHONE: data = trim(data); if (data != null) { contents = "tel:" + data; displayContents = PhoneNumberUtils.formatNumber(data); title = "Phone"; } - } else if (type.equals(Contents.Type.SMS)) { + break; + case Contents.Type.SMS: data = trim(data); if (data != null) { contents = "sms:" + data; displayContents = PhoneNumberUtils.formatNumber(data); title = "SMS"; } - } else if (type.equals(Contents.Type.CONTACT)) { + break; + case Contents.Type.CONTACT: if (bundle != null) { StringBuilder newContents = new StringBuilder(100); StringBuilder newDisplayContents = new StringBuilder(100); @@ -128,7 +133,7 @@ public final class QRCodeEncoder { newDisplayContents.append('\n').append(address); } - Collection uniquePhones = new HashSet(Contents.PHONE_KEYS.length); + Collection uniquePhones = new HashSet<>(Contents.PHONE_KEYS.length); for (int x = 0; x < Contents.PHONE_KEYS.length; x++) { String phone = trim(bundle.getString(Contents.PHONE_KEYS[x])); if (phone != null) { @@ -140,7 +145,7 @@ public final class QRCodeEncoder { newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone)); } - Collection uniqueEmails = new HashSet(Contents.EMAIL_KEYS.length); + Collection uniqueEmails = new HashSet<>(Contents.EMAIL_KEYS.length); for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) { String email = trim(bundle.getString(Contents.EMAIL_KEYS[x])); if (email != null) { @@ -177,7 +182,8 @@ public final class QRCodeEncoder { } } - } else if (type.equals(Contents.Type.LOCATION)) { + break; + case Contents.Type.LOCATION: if (bundle != null) { // These must use Bundle.getFloat(), not getDouble(), it's part of the API. float latitude = bundle.getFloat("LAT", Float.MAX_VALUE); @@ -188,6 +194,7 @@ public final class QRCodeEncoder { title = "Location"; } } + break; } } @@ -197,7 +204,7 @@ public final class QRCodeEncoder { Map hints = null; String encoding = guessAppropriateEncoding(contents); if (encoding != null) { - hints = new EnumMap(EncodeHintType.class); + hints = new EnumMap<>(EncodeHintType.class); hints.put(EncodeHintType.CHARACTER_SET, encoding); } MultiFormatWriter writer = new MultiFormatWriter(); diff --git a/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java b/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java index 52ba797c8..1aa0c6a38 100644 --- a/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java +++ b/F-Droid/src/com/google/zxing/integration/android/IntentIntegrator.java @@ -147,7 +147,7 @@ public class IntentIntegrator { private String buttonYes; private String buttonNo; private List targetApplications; - private final Map moreExtras = new HashMap(3); + private final Map moreExtras = new HashMap<>(3); /** * @param activity {@link Activity} invoking the integration diff --git a/F-Droid/src/com/google/zxing/integration/android/IntentResult.java b/F-Droid/src/com/google/zxing/integration/android/IntentResult.java index 2469af92c..0ff095cb2 100644 --- a/F-Droid/src/com/google/zxing/integration/android/IntentResult.java +++ b/F-Droid/src/com/google/zxing/integration/android/IntentResult.java @@ -82,14 +82,8 @@ public final class IntentResult { @Override public String toString() { - StringBuilder dialogText = new StringBuilder(100); - dialogText.append("Format: ").append(formatName).append('\n'); - dialogText.append("Contents: ").append(contents).append('\n'); - int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; - dialogText.append("Raw bytes: (").append(rawBytesLength).append(" bytes)\n"); - dialogText.append("Orientation: ").append(orientation).append('\n'); - dialogText.append("EC level: ").append(errorCorrectionLevel).append('\n'); - return dialogText.toString(); + int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; + return "Format: " + formatName + '\n' + "Contents: " + contents + '\n' + "Raw bytes: (" + rawBytesLength + " bytes)\n" + "Orientation: " + orientation + '\n' + "EC level: " + errorCorrectionLevel + '\n'; } }