Fixed send-to

Fixes #63
pull/91/head
M66B 7 years ago
parent 694db33bb0
commit fe86f757f0

@ -62,12 +62,22 @@
android:parentActivityName=".ActivityView"> android:parentActivityName=".ActivityView">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<action android:name="android.intent.action.SEND_MULTIPLE" /> <action android:name="android.intent.action.SEND_MULTIPLE" />
<data android:mimeType="*/*" /> <data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter> </intent-filter>
</activity> </activity>

@ -49,40 +49,45 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
if (getSupportFragmentManager().getFragments().size() == 0) { if (getSupportFragmentManager().getFragments().size() == 0) {
Bundle args; Bundle args;
if (Intent.ACTION_SEND.equals(getIntent().getAction()) || Intent intent = getIntent();
Intent.ACTION_SENDTO.equals(getIntent().getAction()) || String action = intent.getAction();
Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) { if (Intent.ACTION_VIEW.equals(action) ||
Intent.ACTION_SENDTO.equals(action) ||
Intent.ACTION_SEND.equals(action) ||
Intent.ACTION_SEND_MULTIPLE.equals(action)) {
args = new Bundle(); args = new Bundle();
args.putString("action", "new"); args.putString("action", "new");
args.putLong("account", -1); args.putLong("account", -1);
if (getIntent().hasExtra(Intent.EXTRA_EMAIL)) Uri uri = intent.getData();
args.putString("to", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL))); if (uri != null && "mailto".equals(uri.getScheme()))
args.putString("to", uri.getSchemeSpecificPart());
if (intent.hasExtra(Intent.EXTRA_EMAIL))
args.putString("to", TextUtils.join(", ", intent.getStringArrayExtra(Intent.EXTRA_EMAIL)));
if (getIntent().hasExtra(Intent.EXTRA_CC)) if (intent.hasExtra(Intent.EXTRA_CC))
args.putString("cc", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_CC))); args.putString("cc", TextUtils.join(", ", intent.getStringArrayExtra(Intent.EXTRA_CC)));
if (getIntent().hasExtra(Intent.EXTRA_BCC)) if (intent.hasExtra(Intent.EXTRA_BCC))
args.putString("bcc", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_BCC))); args.putString("bcc", TextUtils.join(", ", intent.getStringArrayExtra(Intent.EXTRA_BCC)));
if (getIntent().hasExtra(Intent.EXTRA_SUBJECT)) if (intent.hasExtra(Intent.EXTRA_SUBJECT))
args.putString("subject", getIntent().getStringExtra(Intent.EXTRA_SUBJECT)); args.putString("subject", intent.getStringExtra(Intent.EXTRA_SUBJECT));
if (getIntent().hasExtra(Intent.EXTRA_TEXT)) if (intent.hasExtra(Intent.EXTRA_TEXT))
args.putString("body", getIntent().getStringExtra(Intent.EXTRA_TEXT)); // Intent.EXTRA_HTML_TEXT args.putString("body", intent.getStringExtra(Intent.EXTRA_TEXT)); // Intent.EXTRA_HTML_TEXT
if (getIntent().hasExtra(Intent.EXTRA_STREAM)) if (intent.hasExtra(Intent.EXTRA_STREAM))
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) if (Intent.ACTION_SEND_MULTIPLE.equals(action))
args.putParcelableArrayList("attachments", getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM)); args.putParcelableArrayList("attachments", intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM));
else { else {
ArrayList<Uri> uris = new ArrayList<>(); ArrayList<Uri> uris = new ArrayList<>();
uris.add((Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM)); uris.add((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM));
args.putParcelableArrayList("attachments", uris); args.putParcelableArrayList("attachments", uris);
} }
} else } else
args = getIntent().getExtras(); args = intent.getExtras();
FragmentCompose fragment = new FragmentCompose(); FragmentCompose fragment = new FragmentCompose();
fragment.setArguments(args); fragment.setArguments(args);

Loading…
Cancel
Save