couple lines of comments on the case

This commit is contained in:
Stanislav Silnicki
2020-05-30 18:08:58 +03:00
parent a2a3f4d086
commit b1300a4416
@@ -203,12 +203,50 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity implement
int chatId = intent.getIntExtra(EXTRA_CHAT_ID, -1);
String[] extraEmail = getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL);
/*
usually, external app will try to start "e-mail sharing" intent, providing it:
1. address(s), packed in array, marked as Intent.EXTRA_EMAIL - mandatory
2. shared content (files, pics, video), packed in Intent.EXTRA_STREAM - optional
here is a sample code to trigger this routine from within external app:
try {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "someone@example.com", null));
File f = new File(getFilesDir() + "/somebinaryfile.bin");
f.createNewFile();
f.setReadable(true, false);
byte[] b = new byte[1024];
new Random().nextBytes(b);
FileOutputStream fOut = new FileOutputStream(f);
DataOutputStream dataStream = new DataOutputStream(fOut);
dataStream.write(b);
dataStream.close();
Uri sharedURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", f);
emailIntent.setAction(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"someone@example.com"});
emailIntent.setType("text/plain");
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.putExtra(Intent.EXTRA_STREAM, sharedURI);
// to EXPLICITLY fire DC's sharing activity:
// emailIntent.setComponent(new ComponentName("com.b44t.messenger.beta", "org.thoughtcrime.securesms.ShareActivity"));
startActivity(emailIntent);
} catch (IOException e) {
e.printStackTrace();
}catch (ActivityNotFoundException e) {
}
*/
if(chatId == -1 && extraEmail != null && extraEmail.length > 0) {
final String addr = extraEmail[0];
int contactId = dcContext.lookupContactIdByAddr(addr);
if(contactId == 0)
if(contactId == 0) {
contactId = dcContext.createContact(null, addr);
}
chatId = dcContext.createChatByContactId(contactId);
}