Cleanup
This commit is contained in:
parent
f69ef280ba
commit
a50045844a
2 changed files with 86 additions and 98 deletions
|
@ -1,91 +1,84 @@
|
|||
package com.fsck.k9.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.controller.SimpleMessagingListener;
|
||||
|
||||
public class AttachmentDownloadDialogFragment extends DialogFragment {
|
||||
|
||||
ProgressDialog dialog;
|
||||
|
||||
int progress = 0;
|
||||
|
||||
MessagingListener messagingListener;
|
||||
|
||||
protected static final String ARG_SIZE = "size";
|
||||
protected static final String ARG_MESSAGE = "message";
|
||||
private MessagingController messagingController;
|
||||
|
||||
public static AttachmentDownloadDialogFragment newInstance(int size, String message) {
|
||||
AttachmentDownloadDialogFragment attachmentDownloadDialogFragment = new AttachmentDownloadDialogFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_SIZE, size);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
attachmentDownloadDialogFragment.setArguments(args);
|
||||
|
||||
return attachmentDownloadDialogFragment;
|
||||
}
|
||||
|
||||
public void updateDownloadProgress(int newProgress) {
|
||||
progress = newProgress;
|
||||
dialog.setProgress(newProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
int size = args.getInt(ARG_SIZE);
|
||||
String message = args.getString(ARG_MESSAGE);
|
||||
|
||||
progress = 0;
|
||||
|
||||
messagingListener = new SimpleMessagingListener() {
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
updateDownloadProgress(progress);
|
||||
}
|
||||
};
|
||||
|
||||
messagingController = MessagingController.getInstance(getActivity());
|
||||
messagingController.addListener(messagingListener);
|
||||
|
||||
dialog = new ProgressDialog(getActivity());
|
||||
dialog.setMessage(message);
|
||||
dialog.setMax(size);
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
dialog.setProgress(0);
|
||||
dialog.show();
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
messagingController.removeListener(messagingListener);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && activity instanceof AttachmentDownloadCancelListener) {
|
||||
AttachmentDownloadCancelListener listener = (AttachmentDownloadCancelListener) activity;
|
||||
listener.onProgressCancel(this);
|
||||
}
|
||||
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
public interface AttachmentDownloadCancelListener {
|
||||
void onProgressCancel(AttachmentDownloadDialogFragment fragment);
|
||||
}
|
||||
|
||||
}
|
||||
package com.fsck.k9.fragment;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.controller.SimpleMessagingListener;
|
||||
|
||||
|
||||
public class AttachmentDownloadDialogFragment extends DialogFragment {
|
||||
private static final String ARG_SIZE = "size";
|
||||
private static final String ARG_MESSAGE = "message";
|
||||
|
||||
|
||||
private ProgressDialog dialog;
|
||||
private MessagingListener messagingListener;
|
||||
private MessagingController messagingController;
|
||||
|
||||
|
||||
public static AttachmentDownloadDialogFragment newInstance(int size, String message) {
|
||||
AttachmentDownloadDialogFragment fragment = new AttachmentDownloadDialogFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_SIZE, size);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
fragment.setArguments(args);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
int size = args.getInt(ARG_SIZE);
|
||||
String message = args.getString(ARG_MESSAGE);
|
||||
|
||||
messagingListener = new SimpleMessagingListener() {
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
dialog.setProgress(progress);
|
||||
}
|
||||
};
|
||||
|
||||
messagingController = MessagingController.getInstance(getActivity());
|
||||
messagingController.addListener(messagingListener);
|
||||
|
||||
dialog = new ProgressDialog(getActivity());
|
||||
dialog.setMessage(message);
|
||||
dialog.setMax(size);
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
dialog.setProgress(0);
|
||||
dialog.show();
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
messagingController.removeListener(messagingListener);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && activity instanceof AttachmentDownloadCancelListener) {
|
||||
AttachmentDownloadCancelListener listener = (AttachmentDownloadCancelListener) activity;
|
||||
listener.onProgressCancel(this);
|
||||
}
|
||||
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
|
||||
public interface AttachmentDownloadCancelListener {
|
||||
void onProgressCancel(AttachmentDownloadDialogFragment fragment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import timber.log.Timber;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -36,22 +35,22 @@ import com.fsck.k9.activity.ChooseFolder;
|
|||
import com.fsck.k9.activity.MessageLoaderHelper;
|
||||
import com.fsck.k9.activity.MessageLoaderHelper.MessageLoaderCallbacks;
|
||||
import com.fsck.k9.activity.MessageReference;
|
||||
import com.fsck.k9.activity.setup.OpenPgpAppSelectDialog;
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.fragment.AttachmentDownloadDialogFragment;
|
||||
import com.fsck.k9.fragment.ConfirmationDialogFragment;
|
||||
import com.fsck.k9.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
|
||||
import com.fsck.k9.fragment.ProgressDialogFragment;
|
||||
import com.fsck.k9.helper.FileBrowserHelper;
|
||||
import com.fsck.k9.helper.FileBrowserHelper.FileBrowserFailOverCallback;
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
||||
import com.fsck.k9.mailstore.LocalMessage;
|
||||
import com.fsck.k9.mailstore.MessageViewInfo;
|
||||
import com.fsck.k9.activity.setup.OpenPgpAppSelectDialog;
|
||||
import com.fsck.k9.ui.messageview.CryptoInfoDialog.OnClickShowCryptoKeyListener;
|
||||
import com.fsck.k9.ui.messageview.MessageCryptoPresenter.MessageCryptoMvpView;
|
||||
import com.fsck.k9.view.MessageCryptoDisplayStatus;
|
||||
import com.fsck.k9.view.MessageHeader;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class MessageViewFragment extends Fragment implements ConfirmationDialogFragmentListener,
|
||||
|
@ -797,22 +796,18 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||
|
||||
@Override
|
||||
public void onViewAttachment(AttachmentViewInfo attachment) {
|
||||
//TODO: check if we have to download the attachment first
|
||||
currentAttachmentViewInfo = attachment;
|
||||
getAttachmentController(attachment).viewAttachment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveAttachment(AttachmentViewInfo attachment) {
|
||||
//TODO: check if we have to download the attachment first
|
||||
currentAttachmentViewInfo = attachment;
|
||||
getAttachmentController(attachment).saveAttachment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveAttachmentToUserProvidedDirectory(final AttachmentViewInfo attachment) {
|
||||
//TODO: check if we have to download the attachment first
|
||||
|
||||
currentAttachmentViewInfo = attachment;
|
||||
FileBrowserHelper.getInstance().showFileBrowserActivity(MessageViewFragment.this, null,
|
||||
ACTIVITY_CHOOSE_DIRECTORY, new FileBrowserFailOverCallback() {
|
||||
|
|
Loading…
Reference in a new issue