From d3073be89a794a6d6889c3d9e04d5086d2d019ce Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 20 Oct 2014 21:21:09 -0400 Subject: [PATCH] Rearrange fields/methods --- src/com/fsck/k9/view/AttachmentView.java | 42 +++++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/com/fsck/k9/view/AttachmentView.java b/src/com/fsck/k9/view/AttachmentView.java index 289ea4318..1fc9bec71 100644 --- a/src/com/fsck/k9/view/AttachmentView.java +++ b/src/com/fsck/k9/view/AttachmentView.java @@ -45,18 +45,20 @@ import org.apache.commons.io.IOUtils; public class AttachmentView extends FrameLayout implements OnClickListener, OnLongClickListener { private Context context; - private Button viewButton; - private Button downloadButton; - private LocalAttachmentBodyPart part; private Message message; + private LocalAttachmentBodyPart part; private Account account; private MessagingController controller; private MessagingListener listener; + private AttachmentFileDownloadCallback callback; + + private Button viewButton; + private Button downloadButton; + private String name; private String contentType; private long size; - private AttachmentFileDownloadCallback callback; public AttachmentView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); @@ -73,17 +75,6 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo this.context = context; } - - public interface AttachmentFileDownloadCallback { - /** - * This method is called to ask the user to pick a directory to save the attachment to. - *

- * After the user has selected a directory, the implementation of this interface has to call - * {@link #writeFile(File)} on the object supplied as argument in order for the attachment to be saved. - */ - public void pickDirectoryToSaveAttachmentTo(AttachmentView caller); - } - public void setButtonsEnabled(boolean enabled) { viewButton.setEnabled(enabled); downloadButton.setEnabled(enabled); @@ -214,7 +205,6 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo } } - private void onSaveButtonClicked() { boolean isExternalStorageMounted = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); if (!isExternalStorageMounted) { @@ -228,6 +218,10 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo } } + public void writeFile() { + writeFile(new File(K9.getAttachmentDefaultPath())); + } + /** * Saves the attachment as file in the given directory */ @@ -252,10 +246,6 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo } } - public void writeFile() { - writeFile(new File(K9.getAttachmentDefaultPath())); - } - public void showFile() { Uri uri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId()); Intent intent = new Intent(Intent.ACTION_VIEW); @@ -292,6 +282,18 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo this.callback = callback; } + + public interface AttachmentFileDownloadCallback { + /** + * This method is called to ask the user to pick a directory to save the attachment to. + *

+ * After the user has selected a directory, the implementation of this interface has to call + * {@link #writeFile(File)} on the object supplied as argument in order for the attachment to be saved. + */ + public void pickDirectoryToSaveAttachmentTo(AttachmentView caller); + } + + private class LoadAndDisplayThumbnailAsyncTask extends AsyncTask { private final ImageView thumbnail;