Skip to content

Commit

Permalink
support batch sending of event log with attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed May 22, 2017
1 parent a83c4e2 commit 6d98ef9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/info/guardianproject/phoneypot/ui/EventActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.widget.TextView;

import java.io.File;
import java.util.ArrayList;

import info.guardianproject.phoneypot.ListActivity;
import info.guardianproject.phoneypot.R;
Expand Down Expand Up @@ -131,10 +132,26 @@ public void onClick(View v) {

private void shareEvent ()
{
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plan");
intent.putExtra(Intent.EXTRA_TEXT,generateLog());
startActivity(intent);
String title = "Phoneypot: " + mEvent.getStartTime().toLocaleString();

//need to "send multiple" to get more than one attachment
final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");

emailIntent.putExtra(Intent.EXTRA_SUBJECT, title);
emailIntent.putExtra(Intent.EXTRA_TEXT, generateLog());
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (EventTrigger trigger : mEvent.getEventTriggers())
{
File fileIn = new File(trigger.getPath());
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}

emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(emailIntent, "Share event..."));
}

private String generateLog () {
Expand Down

0 comments on commit 6d98ef9

Please sign in to comment.