Also apply fixes to custom zxing code
This commit is contained in:
parent
e314c401e7
commit
45137f2f8e
@ -82,34 +82,39 @@ public final class QRCodeEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void encodeQRCodeContents(String data, Bundle bundle, String type) {
|
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) {
|
if (data != null && data.length() > 0) {
|
||||||
contents = data;
|
contents = data;
|
||||||
displayContents = data;
|
displayContents = data;
|
||||||
title = "Text";
|
title = "Text";
|
||||||
}
|
}
|
||||||
} else if (type.equals(Contents.Type.EMAIL)) {
|
break;
|
||||||
|
case Contents.Type.EMAIL:
|
||||||
data = trim(data);
|
data = trim(data);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
contents = "mailto:" + data;
|
contents = "mailto:" + data;
|
||||||
displayContents = data;
|
displayContents = data;
|
||||||
title = "E-Mail";
|
title = "E-Mail";
|
||||||
}
|
}
|
||||||
} else if (type.equals(Contents.Type.PHONE)) {
|
break;
|
||||||
|
case Contents.Type.PHONE:
|
||||||
data = trim(data);
|
data = trim(data);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
contents = "tel:" + data;
|
contents = "tel:" + data;
|
||||||
displayContents = PhoneNumberUtils.formatNumber(data);
|
displayContents = PhoneNumberUtils.formatNumber(data);
|
||||||
title = "Phone";
|
title = "Phone";
|
||||||
}
|
}
|
||||||
} else if (type.equals(Contents.Type.SMS)) {
|
break;
|
||||||
|
case Contents.Type.SMS:
|
||||||
data = trim(data);
|
data = trim(data);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
contents = "sms:" + data;
|
contents = "sms:" + data;
|
||||||
displayContents = PhoneNumberUtils.formatNumber(data);
|
displayContents = PhoneNumberUtils.formatNumber(data);
|
||||||
title = "SMS";
|
title = "SMS";
|
||||||
}
|
}
|
||||||
} else if (type.equals(Contents.Type.CONTACT)) {
|
break;
|
||||||
|
case Contents.Type.CONTACT:
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
StringBuilder newContents = new StringBuilder(100);
|
StringBuilder newContents = new StringBuilder(100);
|
||||||
StringBuilder newDisplayContents = new StringBuilder(100);
|
StringBuilder newDisplayContents = new StringBuilder(100);
|
||||||
@ -128,7 +133,7 @@ public final class QRCodeEncoder {
|
|||||||
newDisplayContents.append('\n').append(address);
|
newDisplayContents.append('\n').append(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> uniquePhones = new HashSet<String>(Contents.PHONE_KEYS.length);
|
Collection<String> uniquePhones = new HashSet<>(Contents.PHONE_KEYS.length);
|
||||||
for (int x = 0; x < Contents.PHONE_KEYS.length; x++) {
|
for (int x = 0; x < Contents.PHONE_KEYS.length; x++) {
|
||||||
String phone = trim(bundle.getString(Contents.PHONE_KEYS[x]));
|
String phone = trim(bundle.getString(Contents.PHONE_KEYS[x]));
|
||||||
if (phone != null) {
|
if (phone != null) {
|
||||||
@ -140,7 +145,7 @@ public final class QRCodeEncoder {
|
|||||||
newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone));
|
newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> uniqueEmails = new HashSet<String>(Contents.EMAIL_KEYS.length);
|
Collection<String> uniqueEmails = new HashSet<>(Contents.EMAIL_KEYS.length);
|
||||||
for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) {
|
for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) {
|
||||||
String email = trim(bundle.getString(Contents.EMAIL_KEYS[x]));
|
String email = trim(bundle.getString(Contents.EMAIL_KEYS[x]));
|
||||||
if (email != null) {
|
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) {
|
if (bundle != null) {
|
||||||
// These must use Bundle.getFloat(), not getDouble(), it's part of the API.
|
// These must use Bundle.getFloat(), not getDouble(), it's part of the API.
|
||||||
float latitude = bundle.getFloat("LAT", Float.MAX_VALUE);
|
float latitude = bundle.getFloat("LAT", Float.MAX_VALUE);
|
||||||
@ -188,6 +194,7 @@ public final class QRCodeEncoder {
|
|||||||
title = "Location";
|
title = "Location";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +204,7 @@ public final class QRCodeEncoder {
|
|||||||
Map<EncodeHintType, Object> hints = null;
|
Map<EncodeHintType, Object> hints = null;
|
||||||
String encoding = guessAppropriateEncoding(contents);
|
String encoding = guessAppropriateEncoding(contents);
|
||||||
if (encoding != null) {
|
if (encoding != null) {
|
||||||
hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
|
hints = new EnumMap<>(EncodeHintType.class);
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, encoding);
|
hints.put(EncodeHintType.CHARACTER_SET, encoding);
|
||||||
}
|
}
|
||||||
MultiFormatWriter writer = new MultiFormatWriter();
|
MultiFormatWriter writer = new MultiFormatWriter();
|
||||||
|
@ -147,7 +147,7 @@ public class IntentIntegrator {
|
|||||||
private String buttonYes;
|
private String buttonYes;
|
||||||
private String buttonNo;
|
private String buttonNo;
|
||||||
private List<String> targetApplications;
|
private List<String> targetApplications;
|
||||||
private final Map<String,Object> moreExtras = new HashMap<String,Object>(3);
|
private final Map<String,Object> moreExtras = new HashMap<>(3);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param activity {@link Activity} invoking the integration
|
* @param activity {@link Activity} invoking the integration
|
||||||
|
@ -82,14 +82,8 @@ public final class IntentResult {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder dialogText = new StringBuilder(100);
|
int rawBytesLength = rawBytes == null ? 0 : rawBytes.length;
|
||||||
dialogText.append("Format: ").append(formatName).append('\n');
|
return "Format: " + formatName + '\n' + "Contents: " + contents + '\n' + "Raw bytes: (" + rawBytesLength + " bytes)\n" + "Orientation: " + orientation + '\n' + "EC level: " + errorCorrectionLevel + '\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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user