From 39ef6584a877d8b7ef7645b446e7fb1509849293 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 6 Jan 2011 16:56:37 +0000 Subject: [PATCH] continue to extract attachment code out to AttachmentView --- src/com/fsck/k9/activity/MessageView.java | 28 ++--------------------- src/com/fsck/k9/view/AttachmentView.java | 27 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 03955e244..3ec34e9c9 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -1484,30 +1484,6 @@ public class MessageView extends K9Activity implements OnClickListener mListener); } - private void onDownloadAttachment(AttachmentView attachment) - { - if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) - { - /* - * Abort early if there's no place to save the attachment. We don't want to spend - * the time downloading it and then abort. - */ - Toast.makeText(this, - getString(R.string.message_view_status_attachment_not_saved), - Toast.LENGTH_SHORT).show(); - return; - } - if (mMessage != null) - { - mController.loadAttachment( - mAccount, - mMessage, - attachment.part, - new Object[] {true, attachment}, - mListener); - } - } - private void onShowPictures() { // TODO: Download attachments that are used as inline image @@ -1571,7 +1547,7 @@ public class MessageView extends K9Activity implements OnClickListener onPrevious(); break; case R.id.download: - onDownloadAttachment((AttachmentView) view); + ((AttachmentView)view).saveFile(); break; case R.id.show_pictures: onShowPictures(); @@ -1974,7 +1950,7 @@ public class MessageView extends K9Activity implements OnClickListener AttachmentView attachment = (AttachmentView) params[1]; if (download) { - attachment.saveFile(); + attachment.writeFile(); } else diff --git a/src/com/fsck/k9/view/AttachmentView.java b/src/com/fsck/k9/view/AttachmentView.java index d8cffed97..bce21a9da 100644 --- a/src/com/fsck/k9/view/AttachmentView.java +++ b/src/com/fsck/k9/view/AttachmentView.java @@ -185,13 +185,10 @@ public class AttachmentView extends FrameLayout private void onSaveButtonClicked() { - if (mMessage != null) - { - mController.loadAttachment( mAccount, mMessage, part, new Object[] { true, this }, mListener); - } + saveFile(); } - public void saveFile () + public void writeFile () { try { @@ -212,6 +209,26 @@ public class AttachmentView extends FrameLayout } } + public void saveFile() + { + if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) + { + /* + * Abort early if there's no place to save the attachment. We don't want to spend + * the time downloading it and then abort. + */ + Toast.makeText(mContext, + mContext.getString(R.string.message_view_status_attachment_not_saved), + Toast.LENGTH_SHORT).show(); + return; + } + if (mMessage != null) + { + mController.loadAttachment( mAccount, mMessage, part, new Object[] {true, this}, mListener); + } + } + + public void showFile() { Uri uri = AttachmentProvider.getAttachmentUri( mAccount, part.getAttachmentId());