Allow opening EML in EML

pull/172/head
M66B 6 years ago
parent c31308f347
commit 0b08c39845

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

Loading…
Cancel
Save