diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 921890ca7e..20d2bd371f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -123,6 +123,29 @@ + + + + + + + + + + + + + + + + + + + () { + @Override + protected String[] onExecute(Context context, Bundle args) throws Throwable { + Uri uri = args.getParcelable("uri"); + + InputStream is = null; + try { + ContentResolver resolver = context.getContentResolver(); + AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(uri, "*/*", null); + is = new BufferedInputStream(descriptor.createInputStream()); + + Properties props = MessageHelper.getSessionProperties(Helper.AUTH_TYPE_PASSWORD, null, false); + Session isession = Session.getInstance(props, null); + MimeMessage mmessage = new MimeMessage(isession, is); + + String body = null; + try { + MessageHelper helper = new MessageHelper(mmessage); + MessageHelper.MessageParts parts = helper.getMessageParts(); + body = parts.getHtml(context); + } catch (Throwable ex) { + body = ex.toString(); + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + mmessage.writeTo(bos); + String eml = new String(bos.toByteArray()); + + return new String[]{eml, body}; + } finally { + if (is != null) + is.close(); + } + } + + @Override + protected void onExecuted(Bundle args, String[] data) { + tvEml.setText(data[0]); + tvBody.setText(Html.fromHtml(data[1])); + grpEml.setVisibility(View.VISIBLE); + pbWait.setVisibility(View.GONE); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(ActivityEml.this, ActivityEml.this, ex); + } + }.execute(this, args, "eml"); + } +} diff --git a/app/src/main/res/layout/activity_eml.xml b/app/src/main/res/layout/activity_eml.xml new file mode 100644 index 0000000000..0cd1ed581a --- /dev/null +++ b/app/src/main/res/layout/activity_eml.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + \ No newline at end of file