QRCodeEncoder.java (zxing-zxing-3.4.0) | : | QRCodeEncoder.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
import com.google.zxing.client.result.ParsedResult; | import com.google.zxing.client.result.ParsedResult; | |||
import com.google.zxing.client.result.ResultParser; | import com.google.zxing.client.result.ResultParser; | |||
import com.google.zxing.common.BitMatrix; | import com.google.zxing.common.BitMatrix; | |||
import android.content.Context; | import android.content.Context; | |||
import android.content.Intent; | import android.content.Intent; | |||
import android.graphics.Bitmap; | import android.graphics.Bitmap; | |||
import android.net.Uri; | import android.net.Uri; | |||
import android.os.Bundle; | import android.os.Bundle; | |||
import android.provider.ContactsContract; | import android.provider.ContactsContract; | |||
import android.util.Log; | ||||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | import java.io.IOException; | |||
import java.io.InputStream; | import java.io.InputStream; | |||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | |||
import java.util.ArrayList; | import java.util.ArrayList; | |||
import java.util.Arrays; | import java.util.Arrays; | |||
import java.util.Collections; | import java.util.Collections; | |||
import java.util.EnumMap; | import java.util.EnumMap; | |||
import java.util.List; | import java.util.List; | |||
import java.util.Map; | import java.util.Map; | |||
/** | /** | |||
* This class does the work of decoding the user's request and extracting all th e data | * This class does the work of decoding the user's request and extracting all th e data | |||
* to be encoded in a barcode. | * to be encoded in a barcode. | |||
* | * | |||
* @author dswitkin@google.com (Daniel Switkin) | * @author dswitkin@google.com (Daniel Switkin) | |||
*/ | */ | |||
final class QRCodeEncoder { | final class QRCodeEncoder { | |||
private static final String TAG = QRCodeEncoder.class.getSimpleName(); | ||||
private static final int WHITE = 0xFFFFFFFF; | private static final int WHITE = 0xFFFFFFFF; | |||
private static final int BLACK = 0xFF000000; | private static final int BLACK = 0xFF000000; | |||
private final Context activity; | private final Context activity; | |||
private String contents; | private String contents; | |||
private String displayContents; | private String displayContents; | |||
private String title; | private String title; | |||
private BarcodeFormat format; | private BarcodeFormat format; | |||
private final int dimension; | private final int dimension; | |||
private final boolean useVCard; | private final boolean useVCard; | |||
skipping to change at line 203 | skipping to change at line 200 | |||
byte[] buffer = new byte[2048]; | byte[] buffer = new byte[2048]; | |||
int bytesRead; | int bytesRead; | |||
while ((bytesRead = stream.read(buffer)) > 0) { | while ((bytesRead = stream.read(buffer)) > 0) { | |||
baos.write(buffer, 0, bytesRead); | baos.write(buffer, 0, bytesRead); | |||
} | } | |||
vcard = baos.toByteArray(); | vcard = baos.toByteArray(); | |||
vcardString = new String(vcard, 0, vcard.length, StandardCharsets.UTF_8); | vcardString = new String(vcard, 0, vcard.length, StandardCharsets.UTF_8); | |||
} catch (IOException ioe) { | } catch (IOException ioe) { | |||
throw new WriterException(ioe); | throw new WriterException(ioe); | |||
} | } | |||
Log.d(TAG, "Encoding share intent content:"); | ||||
Log.d(TAG, vcardString); | ||||
Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE); | Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE); | |||
ParsedResult parsedResult = ResultParser.parseResult(result); | ParsedResult parsedResult = ResultParser.parseResult(result); | |||
if (!(parsedResult instanceof AddressBookParsedResult)) { | if (!(parsedResult instanceof AddressBookParsedResult)) { | |||
throw new WriterException("Result was not an address"); | throw new WriterException("Result was not an address"); | |||
} | } | |||
encodeQRCodeContents((AddressBookParsedResult) parsedResult); | encodeQRCodeContents((AddressBookParsedResult) parsedResult); | |||
if (contents == null || contents.isEmpty()) { | if (contents == null || contents.isEmpty()) { | |||
throw new WriterException("No content to encode"); | throw new WriterException("No content to encode"); | |||
} | } | |||
} | } | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 0 lines changed or added |