[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
srowen
srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:31:45 UTC 2010
The following commit has been merged in the upstream branch:
commit 955cd3fba67623ca5b629f53aecb3f3cd1d7bbb8
Author: srowen <srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Thu May 27 11:52:49 2010 +0000
More logging, care with parsing vCard?
git-svn-id: http://zxing.googlecode.com/svn/trunk@1393 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
index 2a13011..5d1bbf8 100755
--- a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
+++ b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
@@ -39,7 +39,6 @@ import android.provider.Contacts;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
@@ -141,22 +140,25 @@ final class QRCodeEncoder {
InputStream stream = activity.getContentResolver().openInputStream(uri);
int length = stream.available();
byte[] vcard = new byte[length];
- stream.read(vcard, 0, length);
- String vcardString = new String(vcard, "UTF-8");
- Log.d(TAG, "Encoding share intent content: " + vcardString);
+ int bytesRead = stream.read(vcard, 0, length);
+ String vcardString = new String(vcard, 0, bytesRead, "UTF-8");
+ Log.d(TAG, "Encoding share intent content:");
+ Log.d(TAG, vcardString);
Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
ParsedResult parsedResult = ResultParser.parseResult(result);
if (!(parsedResult instanceof AddressBookParsedResult)) {
+ Log.d(TAG, "Result was not an address");
return false;
}
if (!encodeQRCodeContents((AddressBookParsedResult) parsedResult)) {
+ Log.d(TAG, "Unable to encode contents");
return false;
}
- } catch (FileNotFoundException e) {
- return false;
} catch (IOException e) {
+ Log.w(TAG, e);
return false;
} catch (NullPointerException e) {
+ Log.w(TAG, e);
// In case the uri was not found in the Intent.
return false;
}
@@ -259,17 +261,16 @@ final class QRCodeEncoder {
}
String[] addresses = contact.getAddresses();
if (addresses != null) {
- for (int x = 0; x < addresses.length; x++) {
- if (addresses[x] != null && addresses[x].length() > 0) {
- newContents.append("ADR:").append(addresses[x]).append(';');
- newDisplayContents.append('\n').append(addresses[x]);
+ for (String address : addresses) {
+ if (address != null && address.length() > 0) {
+ newContents.append("ADR:").append(address).append(';');
+ newDisplayContents.append('\n').append(address);
}
}
}
String[] phoneNumbers = contact.getPhoneNumbers();
if (phoneNumbers != null) {
- for (int x = 0; x < phoneNumbers.length; x++) {
- String phone = phoneNumbers[x];
+ for (String phone : phoneNumbers) {
if (phone != null && phone.length() > 0) {
newContents.append("TEL:").append(phone).append(';');
newDisplayContents.append('\n').append(PhoneNumberUtils.formatNumber(phone));
@@ -278,8 +279,7 @@ final class QRCodeEncoder {
}
String[] emails = contact.getEmails();
if (emails != null) {
- for (int x = 0; x < emails.length; x++) {
- String email = emails[x];
+ for (String email : emails) {
if (email != null && email.length() > 0) {
newContents.append("EMAIL:").append(email).append(';');
newDisplayContents.append('\n').append(email);
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list