1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-26 16:03:18 +00:00

Allow opening EML in EML

This commit is contained in:
M66B 2020-01-24 11:13:56 +01:00
parent c31308f347
commit 0b08c39845

View file

@ -67,6 +67,19 @@ import javax.mail.Session;
import javax.mail.internet.MimeMessage;
public class ActivityEML extends ActivityBase {
private TextView tvFrom;
private TextView tvTo;
private TextView tvReplyTo;
private TextView tvCc;
private TextView tvSent;
private TextView tvReceived;
private TextView tvSubject;
private View vSeparatorAttachments;
private RecyclerView rvAttachment;
private TextView tvBody;
private ContentLoadingProgressBar pbWait;
private Group grpReady;
private Uri uri;
private MessageHelper.AttachmentPart apart;
private static final int REQUEST_ATTACHMENT = 1;
@ -78,18 +91,18 @@ public class ActivityEML extends ActivityBase {
getSupportActionBar().setSubtitle("EML");
setContentView(R.layout.activity_eml);
final TextView tvFrom = findViewById(R.id.tvFrom);
final TextView tvTo = findViewById(R.id.tvTo);
final TextView tvReplyTo = findViewById(R.id.tvReplyTo);
final TextView tvCc = findViewById(R.id.tvCc);
final TextView tvSent = findViewById(R.id.tvSent);
final TextView tvReceived = findViewById(R.id.tvReceived);
final TextView tvSubject = findViewById(R.id.tvSubject);
final View vSeparatorAttachments = findViewById(R.id.vSeparatorAttachments);
final RecyclerView rvAttachment = findViewById(R.id.rvAttachment);
final TextView tvBody = findViewById(R.id.tvBody);
final ContentLoadingProgressBar pbWait = findViewById(R.id.pbWait);
final Group grpReady = findViewById(R.id.grpReady);
tvFrom = findViewById(R.id.tvFrom);
tvTo = findViewById(R.id.tvTo);
tvReplyTo = findViewById(R.id.tvReplyTo);
tvCc = findViewById(R.id.tvCc);
tvSent = findViewById(R.id.tvSent);
tvReceived = findViewById(R.id.tvReceived);
tvSubject = findViewById(R.id.tvSubject);
vSeparatorAttachments = findViewById(R.id.vSeparatorAttachments);
rvAttachment = findViewById(R.id.rvAttachment);
tvBody = findViewById(R.id.tvBody);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);
rvAttachment.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(this);
@ -100,19 +113,29 @@ public class ActivityEML extends ActivityBase {
vSeparatorAttachments.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
uri = getIntent().getData();
if (uri == null) {
pbWait.setVisibility(View.GONE);
return;
} else
pbWait.setVisibility(View.VISIBLE);
load();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
load();
}
private void load() {
uri = getIntent().getData();
Log.i("EML uri=" + uri);
Bundle args = new Bundle();
args.putParcelable("uri", uri);
new SimpleTask<Result>() {
@Override
protected void onPreExecute(Bundle args) {
pbWait.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(Bundle args) {
pbWait.setVisibility(View.GONE);
@ -122,6 +145,9 @@ public class ActivityEML extends ActivityBase {
protected Result onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme()) &&
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.w("EML uri=" + uri);