whitespace

This commit is contained in:
Jesse Vincent 2010-12-26 03:49:23 +00:00
parent f2b2fddd5a
commit d352b8a4a5
1 changed files with 25 additions and 76 deletions

View File

@ -379,7 +379,7 @@ public class MessageView extends K9Activity implements OnClickListener
return true; return true;
} }
} }
return super.onKeyUp(keyCode,event); return super.onKeyUp(keyCode, event);
} }
class MessageViewHandler extends Handler class MessageViewHandler extends Handler
@ -438,7 +438,7 @@ public class MessageView extends K9Activity implements OnClickListener
} }
public void setHeaders( public void setHeaders(
final Message message) throws MessagingException final Message message) throws MessagingException
{ {
final Contacts contacts = K9.showContactName() ? mContacts : null; final Contacts contacts = K9.showContactName() ? mContacts : null;
final CharSequence from = Address.toFriendly(message.getFrom(), contacts); final CharSequence from = Address.toFriendly(message.getFrom(), contacts);
@ -509,7 +509,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
Toast.makeText(MessageView.this, Toast.makeText(MessageView.this,
R.string.status_network_error, Toast.LENGTH_LONG).show(); R.string.status_network_error, Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -522,7 +521,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
Toast.makeText(MessageView.this, Toast.makeText(MessageView.this,
R.string.status_invalid_id_error, Toast.LENGTH_LONG).show(); R.string.status_invalid_id_error, Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -536,8 +534,6 @@ public class MessageView extends K9Activity implements OnClickListener
Toast.makeText(MessageView.this, String.format( Toast.makeText(MessageView.this, String.format(
getString(R.string.message_view_status_attachment_saved), filename), getString(R.string.message_view_status_attachment_saved), filename),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -548,11 +544,9 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
public void run() public void run()
{ {
Toast.makeText(MessageView.this, Toast.makeText(MessageView.this,
getString(R.string.message_view_status_attachment_not_saved), getString(R.string.message_view_status_attachment_not_saved),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -1053,22 +1047,18 @@ public class MessageView extends K9Activity implements OnClickListener
mMessageReference = ref; mMessageReference = ref;
if (K9.DEBUG) if (K9.DEBUG)
Log.d(K9.LOG_TAG, "MessageView displaying message " + mMessageReference); Log.d(K9.LOG_TAG, "MessageView displaying message " + mMessageReference);
mAccount = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid); mAccount = Preferences.getPreferences(this).getAccount(mMessageReference.accountUuid);
mTopView.setVisibility(View.GONE); mTopView.setVisibility(View.GONE);
mTopView.scrollTo(0, 0); mTopView.scrollTo(0, 0);
mMessageContentView.scrollTo(0, 0); mMessageContentView.scrollTo(0, 0);
mHandler.hideHeaderContainer(); mHandler.hideHeaderContainer();
mMessageContentView.clearView(); mMessageContentView.clearView();
setLoadPictures(false); setLoadPictures(false);
mAttachments.removeAllViews(); mAttachments.removeAllViews();
findSurroundingMessagesUid(); findSurroundingMessagesUid();
// start with fresh, empty PGP data // start with fresh, empty PGP data
mPgpData = null; mPgpData = null;
initializeCrypto(); initializeCrypto();
mTopView.setVisibility(View.VISIBLE); mTopView.setVisibility(View.VISIBLE);
MessagingController.getInstance(getApplication()).loadMessageForView( MessagingController.getInstance(getApplication()).loadMessageForView(
mAccount, mAccount,
@ -1088,11 +1078,11 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
// Only enable the button if the Archive folder is not the current folder and not NONE. // Only enable the button if the Archive folder is not the current folder and not NONE.
mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) && mArchive.setEnabled(!mMessageReference.folderName.equals(mAccount.getArchiveFolderName()) &&
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName())); !K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getArchiveFolderName()));
// Only enable the button if the Spam folder is not the current folder and not NONE. // Only enable the button if the Spam folder is not the current folder and not NONE.
mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) && mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) &&
!K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName())); !K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()));
mMove.setEnabled(true); mMove.setEnabled(true);
} }
else else
{ {
@ -1254,7 +1244,7 @@ public class MessageView extends K9Activity implements OnClickListener
dismissDialog(id); dismissDialog(id);
} }
}); });
return builder.create(); return builder.create();
} }
private void delete() private void delete()
@ -1267,8 +1257,8 @@ public class MessageView extends K9Activity implements OnClickListener
Message messageToDelete = mMessage; Message messageToDelete = mMessage;
showNextMessageOrReturn(); showNextMessageOrReturn();
MessagingController.getInstance(getApplication()).deleteMessages( MessagingController.getInstance(getApplication()).deleteMessages(
new Message[]{messageToDelete}, new Message[] {messageToDelete},
null); null);
} }
} }
@ -1292,7 +1282,7 @@ public class MessageView extends K9Activity implements OnClickListener
} }
showNextMessageOrReturn(); showNextMessageOrReturn();
MessagingController.getInstance(getApplication()) MessagingController.getInstance(getApplication())
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null); .moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
} }
@ -1383,7 +1373,7 @@ public class MessageView extends K9Activity implements OnClickListener
if (mMessage != null) if (mMessage != null)
{ {
MessagingController.getInstance(getApplication()).setFlag(mAccount, MessagingController.getInstance(getApplication()).setFlag(mAccount,
mMessage.getFolder().getName(), new String[]{mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED)); mMessage.getFolder().getName(), new String[] {mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
try try
{ {
mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED)); mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
@ -1628,16 +1618,12 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
mDownloadRemainder.setEnabled(false); mDownloadRemainder.setEnabled(false);
MessagingController.getInstance(getApplication()).loadMessageForViewRemote( MessagingController.getInstance(getApplication()).loadMessageForViewRemote(
mAccount, mAccount,
mMessageReference.folderName, mMessageReference.folderName,
mMessageReference.uid, mMessageReference.uid,
mListener); mListener);
} }
private void onDownloadAttachment(Attachment attachment) private void onDownloadAttachment(Attachment attachment)
@ -1659,7 +1645,7 @@ public class MessageView extends K9Activity implements OnClickListener
mAccount, mAccount,
mMessage, mMessage,
attachment.part, attachment.part,
new Object[] { true, attachment }, new Object[] {true, attachment},
mListener); mListener);
} }
} }
@ -1842,11 +1828,10 @@ public class MessageView extends K9Activity implements OnClickListener
prepareMenuItems(); prepareMenuItems();
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);
} }
// TODO: when switching to API version 8, override onCreateDialog(int, Bundle) // TODO: when switching to API version 8, override onCreateDialog(int, Bundle)
/** /**
* @param id * @param id The id of the dialog.
* The id of the dialog.
* @return The dialog. If you return null, the dialog will not be created. * @return The dialog. If you return null, the dialog will not be created.
* @see android.app.Activity#onCreateDialog(int) * @see android.app.Activity#onCreateDialog(int)
*/ */
@ -1873,7 +1858,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
flagItem.setTitle((mMessage.isSet(Flag.FLAGGED) ? R.string.unflag_action : R.string.flag_action)); flagItem.setTitle((mMessage.isSet(Flag.FLAGGED) ? R.string.unflag_action : R.string.flag_action));
} }
MenuItem additionalHeadersItem = menu.findItem(R.id.show_full_header); MenuItem additionalHeadersItem = menu.findItem(R.id.show_full_header);
if (additionalHeadersItem != null) if (additionalHeadersItem != null)
{ {
@ -1908,18 +1892,14 @@ public class MessageView extends K9Activity implements OnClickListener
String contentType = MimeUtility.unfoldAndDecode(part.getContentType()); String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition()); String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition());
String name = MimeUtility.getHeaderParameter(contentType, "name"); String name = MimeUtility.getHeaderParameter(contentType, "name");
// Inline parts with a content-id are almost certainly components of an HTML message // Inline parts with a content-id are almost certainly components of an HTML message
// not attachments. Don't show attachment download buttons for them. // not attachments. Don't show attachment download buttons for them.
if (contentDisposition != null && if (contentDisposition != null &&
MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)") MimeUtility.getHeaderParameter(contentDisposition, null).matches("^(?i:inline)")
&& part.getHeader("Content-ID") != null) && part.getHeader("Content-ID") != null)
{ {
return; return;
} }
if (name == null) if (name == null)
{ {
name = MimeUtility.getHeaderParameter(contentDisposition, "filename"); name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
@ -1940,16 +1920,13 @@ public class MessageView extends K9Activity implements OnClickListener
attachment.contentType = mimeType; attachment.contentType = mimeType;
attachment.name = name; attachment.name = name;
attachment.part = (LocalAttachmentBodyPart) part; attachment.part = (LocalAttachmentBodyPart) part;
LayoutInflater inflater = getLayoutInflater(); LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.message_view_attachment, null); View view = inflater.inflate(R.layout.message_view_attachment, null);
TextView attachmentName = (TextView) view.findViewById(R.id.attachment_name);
TextView attachmentName = (TextView)view.findViewById(R.id.attachment_name); TextView attachmentInfo = (TextView) view.findViewById(R.id.attachment_info);
TextView attachmentInfo = (TextView)view.findViewById(R.id.attachment_info); ImageView attachmentIcon = (ImageView) view.findViewById(R.id.attachment_icon);
ImageView attachmentIcon = (ImageView)view.findViewById(R.id.attachment_icon); Button attachmentView = (Button) view.findViewById(R.id.view);
Button attachmentView = (Button)view.findViewById(R.id.view); Button attachmentDownload = (Button) view.findViewById(R.id.download);
Button attachmentDownload = (Button)view.findViewById(R.id.download);
if ((!MimeUtility.mimeTypeMatches(attachment.contentType, if ((!MimeUtility.mimeTypeMatches(attachment.contentType,
K9.ACCEPTABLE_ATTACHMENT_VIEW_TYPES)) K9.ACCEPTABLE_ATTACHMENT_VIEW_TYPES))
|| (MimeUtility.mimeTypeMatches(attachment.contentType, || (MimeUtility.mimeTypeMatches(attachment.contentType,
@ -1964,26 +1941,21 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
attachmentDownload.setVisibility(View.GONE); attachmentDownload.setVisibility(View.GONE);
} }
if (attachment.size > K9.MAX_ATTACHMENT_DOWNLOAD_SIZE) if (attachment.size > K9.MAX_ATTACHMENT_DOWNLOAD_SIZE)
{ {
attachmentView.setVisibility(View.GONE); attachmentView.setVisibility(View.GONE);
attachmentDownload.setVisibility(View.GONE); attachmentDownload.setVisibility(View.GONE);
} }
attachment.viewButton = attachmentView; attachment.viewButton = attachmentView;
attachment.downloadButton = attachmentDownload; attachment.downloadButton = attachmentDownload;
attachment.iconView = attachmentIcon; attachment.iconView = attachmentIcon;
view.setTag(attachment); view.setTag(attachment);
attachmentView.setOnClickListener(this); attachmentView.setOnClickListener(this);
attachmentView.setTag(attachment); attachmentView.setTag(attachment);
attachmentDownload.setOnClickListener(this); attachmentDownload.setOnClickListener(this);
attachmentDownload.setTag(attachment); attachmentDownload.setTag(attachment);
attachmentName.setText(name); attachmentName.setText(name);
attachmentInfo.setText(SizeFormatter.formatSize(getApplication(),size)); attachmentInfo.setText(SizeFormatter.formatSize(getApplication(), size));
Bitmap previewIcon = getPreviewIcon(attachment); Bitmap previewIcon = getPreviewIcon(attachment);
if (previewIcon != null) if (previewIcon != null)
{ {
@ -2018,7 +1990,6 @@ public class MessageView extends K9Activity implements OnClickListener
class Listener extends MessagingListener class Listener extends MessagingListener
{ {
@Override @Override
public void loadMessageForViewHeadersAvailable(Account account, String folder, String uid, public void loadMessageForViewHeadersAvailable(Account account, String folder, String uid,
final Message message) final Message message)
@ -2028,10 +1999,7 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
MessageView.this.mMessage = message; MessageView.this.mMessage = message;
if (!message.isSet(Flag.X_DOWNLOADED_FULL) if (!message.isSet(Flag.X_DOWNLOADED_FULL)
&& !message.isSet(Flag.X_DOWNLOADED_PARTIAL)) && !message.isSet(Flag.X_DOWNLOADED_PARTIAL))
{ {
@ -2064,23 +2032,17 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
try try
{ {
if (MessageView.this.mMessage!=null if (MessageView.this.mMessage != null
&& MessageView.this.mMessage.isSet(Flag.X_DOWNLOADED_PARTIAL) && MessageView.this.mMessage.isSet(Flag.X_DOWNLOADED_PARTIAL)
&& message.isSet(Flag.X_DOWNLOADED_FULL)) && message.isSet(Flag.X_DOWNLOADED_FULL))
{ {
setHeaders(folder, uid, message); setHeaders(folder, uid, message);
mHandler.showHeaderContainer(); mHandler.showHeaderContainer();
} }
MessageView.this.mMessage = message; MessageView.this.mMessage = message;
mHandler.removeAllAttachments(); mHandler.removeAllAttachments();
String text; String text;
String type = "text/html"; String type = "text/html";
if (mPgpData.getDecryptedData() != null) if (mPgpData.getDecryptedData() != null)
@ -2102,7 +2064,7 @@ public class MessageView extends K9Activity implements OnClickListener
} }
else else
{ {
LocalTextBody body = (LocalTextBody)part.getBody(); LocalTextBody body = (LocalTextBody) part.getBody();
if (body == null) if (body == null)
{ {
text = null; text = null;
@ -2119,7 +2081,6 @@ public class MessageView extends K9Activity implements OnClickListener
text = MimeUtility.getTextFromPart(part); text = MimeUtility.getTextFromPart(part);
} }
} }
if (text != null) if (text != null)
{ {
final String emailText = text; final String emailText = text;
@ -2142,7 +2103,6 @@ public class MessageView extends K9Activity implements OnClickListener
updateDecryptLayout(); updateDecryptLayout();
} }
}); });
// If the message contains external pictures and the "Show pictures" // If the message contains external pictures and the "Show pictures"
// button wasn't already pressed, see if the user's preferences has us // button wasn't already pressed, see if the user's preferences has us
// showing them anyway. // showing them anyway.
@ -2171,7 +2131,6 @@ public class MessageView extends K9Activity implements OnClickListener
} }
}); });
} }
renderAttachments(mMessage, 0); renderAttachments(mMessage, 0);
} }
catch (Exception e) catch (Exception e)
@ -2215,7 +2174,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
mHandler.post(new Runnable() mHandler.post(new Runnable()
{ {
public void run() public void run()
@ -2248,7 +2206,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
mHandler.post(new Runnable() mHandler.post(new Runnable()
{ {
public void run() public void run()
@ -2266,7 +2223,6 @@ public class MessageView extends K9Activity implements OnClickListener
{ {
return; return;
} }
mHandler.post(new Runnable() mHandler.post(new Runnable()
{ {
public void run() public void run()
@ -2281,11 +2237,10 @@ public class MessageView extends K9Activity implements OnClickListener
public void loadAttachmentStarted(Account account, Message message, public void loadAttachmentStarted(Account account, Message message,
Part part, Object tag, boolean requiresDownload) Part part, Object tag, boolean requiresDownload)
{ {
if (mMessage!=message) if (mMessage != message)
{ {
return; return;
} }
mHandler.setAttachmentsEnabled(false); mHandler.setAttachmentsEnabled(false);
mHandler.progress(true); mHandler.progress(true);
if (requiresDownload) if (requiresDownload)
@ -2298,18 +2253,15 @@ public class MessageView extends K9Activity implements OnClickListener
public void loadAttachmentFinished(Account account, Message message, public void loadAttachmentFinished(Account account, Message message,
Part part, Object tag) Part part, Object tag)
{ {
if (mMessage!=message) if (mMessage != message)
{ {
return; return;
} }
mHandler.setAttachmentsEnabled(true); mHandler.setAttachmentsEnabled(true);
mHandler.progress(false); mHandler.progress(false);
Object[] params = (Object[]) tag; Object[] params = (Object[]) tag;
boolean download = (Boolean) params[0]; boolean download = (Boolean) params[0];
Attachment attachment = (Attachment) params[1]; Attachment attachment = (Attachment) params[1];
if (download) if (download)
{ {
try try
@ -2358,11 +2310,10 @@ public class MessageView extends K9Activity implements OnClickListener
public void loadAttachmentFailed(Account account, Message message, Part part, public void loadAttachmentFailed(Account account, Message message, Part part,
Object tag, String reason) Object tag, String reason)
{ {
if (mMessage!=message) if (mMessage != message)
{ {
return; return;
} }
mHandler.setAttachmentsEnabled(true); mHandler.setAttachmentsEnabled(true);
mHandler.progress(false); mHandler.progress(false);
mHandler.networkError(); mHandler.networkError();
@ -2402,11 +2353,9 @@ public class MessageView extends K9Activity implements OnClickListener
mConnection.disconnect(); mConnection.disconnect();
} }
} }
} }
private void initializeCrypto() private void initializeCrypto()
{ {
if (mPgpData != null) if (mPgpData != null)