EncodeActivity.java (zxing-zxing-3.4.0) | : | EncodeActivity.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 148 | skipping to change at line 148 | |||
} | } | |||
File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeSc anner"); | File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeSc anner"); | |||
File barcodesRoot = new File(bsRoot, "Barcodes"); | File barcodesRoot = new File(bsRoot, "Barcodes"); | |||
if (!barcodesRoot.exists() && !barcodesRoot.mkdirs()) { | if (!barcodesRoot.exists() && !barcodesRoot.mkdirs()) { | |||
Log.w(TAG, "Couldn't make dir " + barcodesRoot); | Log.w(TAG, "Couldn't make dir " + barcodesRoot); | |||
showErrorMessage(R.string.msg_unmount_usb); | showErrorMessage(R.string.msg_unmount_usb); | |||
return; | return; | |||
} | } | |||
File barcodeFile = new File(barcodesRoot, makeBarcodeFileName(contents) + ". png"); | File barcodeFile = new File(barcodesRoot, makeBarcodeFileName(contents) + ". png"); | |||
if (!barcodeFile.delete()) { | ||||
Log.w(TAG, "Could not delete " + barcodeFile); | ||||
// continue anyway | ||||
} | ||||
try (FileOutputStream fos = new FileOutputStream(barcodeFile)) { | try (FileOutputStream fos = new FileOutputStream(barcodeFile)) { | |||
bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos); | bitmap.compress(Bitmap.CompressFormat.PNG, 0, fos); | |||
} catch (IOException ioe) { | } catch (IOException ioe) { | |||
Log.w(TAG, "Couldn't access file " + barcodeFile + " due to " + ioe); | Log.w(TAG, "Couldn't access barcode file", ioe); | |||
showErrorMessage(R.string.msg_unmount_usb); | showErrorMessage(R.string.msg_unmount_usb); | |||
return; | return; | |||
} | } | |||
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); | Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); | |||
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " - " + encoder.getTitle()); | intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " - " + encoder.getTitle()); | |||
intent.putExtra(Intent.EXTRA_TEXT, contents); | intent.putExtra(Intent.EXTRA_TEXT, contents); | |||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + barcodeFile.getAb solutePath())); | intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + barcodeFile.getAb solutePath())); | |||
intent.setType("image/png"); | intent.setType("image/png"); | |||
intent.addFlags(Intents.FLAG_NEW_DOC); | intent.addFlags(Intents.FLAG_NEW_DOC); | |||
skipping to change at line 187 | skipping to change at line 183 | |||
@Override | @Override | |||
protected void onResume() { | protected void onResume() { | |||
super.onResume(); | super.onResume(); | |||
// This assumes the view is full screen, which is a good assumption | // This assumes the view is full screen, which is a good assumption | |||
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); | WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); | |||
Display display = manager.getDefaultDisplay(); | Display display = manager.getDefaultDisplay(); | |||
Point displaySize = new Point(); | Point displaySize = new Point(); | |||
display.getSize(displaySize); | display.getSize(displaySize); | |||
int width = displaySize.x; | int width = displaySize.x; | |||
int height = displaySize.y; | int height = displaySize.y; | |||
int smallerDimension = width < height ? width : height; | int smallerDimension = Math.min(width, height); | |||
smallerDimension = smallerDimension * 7 / 8; | smallerDimension = smallerDimension * 7 / 8; | |||
Intent intent = getIntent(); | Intent intent = getIntent(); | |||
if (intent == null) { | if (intent == null) { | |||
return; | return; | |||
} | } | |||
try { | try { | |||
boolean useVCard = intent.getBooleanExtra(USE_VCARD_KEY, false); | boolean useVCard = intent.getBooleanExtra(USE_VCARD_KEY, false); | |||
qrCodeEncoder = new QRCodeEncoder(this, intent, smallerDimension, useVCard ); | qrCodeEncoder = new QRCodeEncoder(this, intent, smallerDimension, useVCard ); | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 2 lines changed or added |