"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "android/src/com/google/zxing/client/android/share/ShareActivity.java" between
zxing-zxing-3.4.0.tar.gz and zxing-zxing-3.4.1.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.

ShareActivity.java  (zxing-zxing-3.4.0):ShareActivity.java  (zxing-zxing-3.4.1)
skipping to change at line 107 skipping to change at line 107
if (!text.isEmpty()) { if (!text.isEmpty()) {
launchSearch(text); launchSearch(text);
} }
return true; return true;
} }
return false; return false;
} }
}; };
private void launchSearch(String text) { private void launchSearch(String text) {
Intent intent = new Intent(Intents.Encode.ACTION); Intent intent = buildEncodeIntent(Contents.Type.TEXT);
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent); startActivity(intent);
} }
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setContentView(R.layout.share); setContentView(R.layout.share);
findViewById(R.id.share_contact_button).setOnClickListener(contactListener); findViewById(R.id.share_contact_button).setOnClickListener(contactListener);
if (Build.VERSION.SDK_INT >= 23) { // Marshmallow / 6.0 if (Build.VERSION.SDK_INT >= 23) { // Marshmallow / 6.0
skipping to change at line 159 skipping to change at line 156
showContactAsBarcode(intent.getData()); showContactAsBarcode(intent.getData());
break; break;
} }
} }
} }
private void showTextAsBarcode(String text) { private void showTextAsBarcode(String text) {
if (text == null) { if (text == null) {
return; // Show error? return; // Show error?
} }
Intent intent = new Intent(Intents.Encode.ACTION); Intent intent = buildEncodeIntent(Contents.Type.TEXT);
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent); startActivity(intent);
} }
/** /**
* Takes a contact Uri and does the necessary database lookups to retrieve tha t person's info, * Takes a contact Uri and does the necessary database lookups to retrieve tha t person's info,
* then sends an Encode intent to render it as a QR Code. * then sends an Encode intent to render it as a QR Code.
* *
* @param contactUri A Uri of the form content://contacts/people/17 * @param contactUri A Uri of the form content://contacts/people/17
*/ */
private void showContactAsBarcode(Uri contactUri) { private void showContactAsBarcode(Uri contactUri) {
skipping to change at line 252 skipping to change at line 246
while (emailCursor.moveToNext() && foundEmail < Contents.EMAIL_KEYS.leng th) { while (emailCursor.moveToNext() && foundEmail < Contents.EMAIL_KEYS.leng th) {
String email = emailCursor.getString(emailColumn); String email = emailCursor.getString(emailColumn);
if (email != null && !email.isEmpty()) { if (email != null && !email.isEmpty()) {
bundle.putString(Contents.EMAIL_KEYS[foundEmail], massageContactData (email)); bundle.putString(Contents.EMAIL_KEYS[foundEmail], massageContactData (email));
} }
foundEmail++; foundEmail++;
} }
} }
} }
Intent intent = buildEncodeIntent(Contents.Type.CONTACT);
intent.putExtra(Intents.Encode.DATA, bundle);
startActivity(intent);
}
private static Intent buildEncodeIntent(String type) {
Intent intent = new Intent(Intents.Encode.ACTION); Intent intent = new Intent(Intents.Encode.ACTION);
intent.setPackage("com.google.zxing.client.android");
intent.addFlags(Intents.FLAG_NEW_DOC); intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.CONTACT); intent.putExtra(Intents.Encode.TYPE, type);
intent.putExtra(Intents.Encode.DATA, bundle);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
return intent;
startActivity(intent);
} }
private static String massageContactData(String data) { private static String massageContactData(String data) {
// For now -- make sure we don't put newlines in shared contact data. It mes ses up // For now -- make sure we don't put newlines in shared contact data. It mes ses up
// any known encoding of contact data. Replace with space. // any known encoding of contact data. Replace with space.
if (data.indexOf('\n') >= 0) { if (data.indexOf('\n') >= 0) {
data = data.replace("\n", " "); data = data.replace("\n", " ");
} }
if (data.indexOf('\r') >= 0) { if (data.indexOf('\r') >= 0) {
data = data.replace("\r", " "); data = data.replace("\r", " ");
 End of changes. 8 change blocks. 
12 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)