setPackage on encode intent internally

This commit is contained in:
Sean Owen 2020-02-16 08:46:36 -06:00
parent c1fc401d9a
commit 24a5f9c654

View file

@ -104,11 +104,8 @@ public final class ShareActivity extends Activity {
};
private void launchSearch(String text) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
Intent intent = buildEncodeIntent(Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
@ -156,11 +153,8 @@ public final class ShareActivity extends Activity {
if (text == null) {
return; // Show error?
}
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
Intent intent = buildEncodeIntent(Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
@ -249,15 +243,20 @@ public final class ShareActivity extends Activity {
}
}
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.CONTACT);
Intent intent = buildEncodeIntent(Contents.Type.CONTACT);
intent.putExtra(Intents.Encode.DATA, bundle);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
private static Intent buildEncodeIntent(String type) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.setPackage("com.google.zxing.client.android");
intent.addFlags(Intents.FLAG_NEW_DOC);
intent.putExtra(Intents.Encode.TYPE, type);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
return intent;
}
private static String massageContactData(String data) {
// For now -- make sure we don't put newlines in shared contact data. It messes up
// any known encoding of contact data. Replace with space.