Browse Source

Fixed send-to

Fixes #63
main
M66B 6 years ago
parent
commit
fe86f757f0
2 changed files with 36 additions and 21 deletions
  1. +11
    -1
      app/src/main/AndroidManifest.xml
  2. +25
    -20
      app/src/main/java/eu/faircode/email/ActivityCompose.java

+ 11
- 1
app/src/main/AndroidManifest.xml View File

@ -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>


+ 25
- 20
app/src/main/java/eu/faircode/email/ActivityCompose.java View File

@ -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.ACTION_SENDTO.equals(getIntent().getAction()) ||
Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) {
Intent intent = getIntent();
String action = intent.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))
args.putString("to", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL)));
Uri uri = intent.getData();
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))
args.putString("cc", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_CC)));
if (intent.hasExtra(Intent.EXTRA_CC))
args.putString("cc", TextUtils.join(", ", intent.getStringArrayExtra(Intent.EXTRA_CC)));
if (getIntent().hasExtra(Intent.EXTRA_BCC))
args.putString("bcc", TextUtils.join(", ", getIntent().getStringArrayExtra(Intent.EXTRA_BCC)));
if (intent.hasExtra(Intent.EXTRA_BCC))
args.putString("bcc", TextUtils.join(", ", intent.getStringArrayExtra(Intent.EXTRA_BCC)));
if (getIntent().hasExtra(Intent.EXTRA_SUBJECT))
args.putString("subject", getIntent().getStringExtra(Intent.EXTRA_SUBJECT));
if (intent.hasExtra(Intent.EXTRA_SUBJECT))
args.putString("subject", intent.getStringExtra(Intent.EXTRA_SUBJECT));
if (getIntent().hasExtra(Intent.EXTRA_TEXT))
args.putString("body", getIntent().getStringExtra(Intent.EXTRA_TEXT)); // Intent.EXTRA_HTML_TEXT
if (intent.hasExtra(Intent.EXTRA_TEXT))
args.putString("body", intent.getStringExtra(Intent.EXTRA_TEXT)); // Intent.EXTRA_HTML_TEXT
if (getIntent().hasExtra(Intent.EXTRA_STREAM))
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction()))
args.putParcelableArrayList("attachments", getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM));
if (intent.hasExtra(Intent.EXTRA_STREAM))
if (Intent.ACTION_SEND_MULTIPLE.equals(action))
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