mirror of https://github.com/moparisthebest/k-9
Reindent MessageView.java in advance of refactoring
This commit is contained in:
parent
04717b817a
commit
094215ebe0
|
@ -126,26 +126,20 @@ public class MessageView extends K9Activity
|
|||
|
||||
private Menu optionsMenu = null;
|
||||
|
||||
private DateFormat getDateFormat()
|
||||
{
|
||||
if (dateFormat == null)
|
||||
{
|
||||
private DateFormat getDateFormat() {
|
||||
if (dateFormat == null) {
|
||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.DATE_FORMAT);
|
||||
if (dateFormatS != null) {
|
||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
||||
}
|
||||
}
|
||||
return dateFormat;
|
||||
}
|
||||
private DateFormat getTimeFormat()
|
||||
{
|
||||
if (timeFormat == null)
|
||||
{
|
||||
private DateFormat getTimeFormat() {
|
||||
if (timeFormat == null) {
|
||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.TIME_12_24);
|
||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
||||
|
@ -153,8 +147,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
return timeFormat;
|
||||
}
|
||||
private void clearFormats()
|
||||
{
|
||||
private void clearFormats() {
|
||||
dateFormat = null;
|
||||
timeFormat = null;
|
||||
}
|
||||
|
@ -167,12 +160,10 @@ public class MessageView extends K9Activity
|
|||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
boolean ret = false;
|
||||
|
||||
if (KeyEvent.ACTION_DOWN == event.getAction())
|
||||
{
|
||||
if (KeyEvent.ACTION_DOWN == event.getAction()) {
|
||||
ret = onKeyDown(event.getKeyCode(), event);
|
||||
}
|
||||
if (ret == false)
|
||||
{
|
||||
if (ret == false) {
|
||||
ret = super.dispatchKeyEvent(event);
|
||||
}
|
||||
return ret;
|
||||
|
@ -180,20 +171,49 @@ public class MessageView extends K9Activity
|
|||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_DEL: { onDelete(); return true;}
|
||||
case KeyEvent.KEYCODE_D: { onDelete(); return true;}
|
||||
case KeyEvent.KEYCODE_F: { onForward(); return true;}
|
||||
case KeyEvent.KEYCODE_A: { onReplyAll(); return true; }
|
||||
case KeyEvent.KEYCODE_R: { onReply(); return true; }
|
||||
case KeyEvent.KEYCODE_G: { onFlag(); return true; }
|
||||
case KeyEvent.KEYCODE_DEL: {
|
||||
onDelete();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_D: {
|
||||
onDelete();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_F: {
|
||||
onForward();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_A: {
|
||||
onReplyAll();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_R: {
|
||||
onReply();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_G: {
|
||||
onFlag();
|
||||
return true;
|
||||
}
|
||||
|
||||
case KeyEvent.KEYCODE_M: { onMove(); return true; }
|
||||
case KeyEvent.KEYCODE_Y: { onCopy(); return true; }
|
||||
case KeyEvent.KEYCODE_M: {
|
||||
onMove();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_Y: {
|
||||
onCopy();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_J:
|
||||
case KeyEvent.KEYCODE_P:
|
||||
{ onPrevious(); return true; }
|
||||
case KeyEvent.KEYCODE_P: {
|
||||
onPrevious();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_N:
|
||||
case KeyEvent.KEYCODE_K: { onNext(); return true; }
|
||||
case KeyEvent.KEYCODE_K: {
|
||||
onNext();
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_Z: {
|
||||
if (event.isShiftPressed()) {
|
||||
mHandler.post(new Runnable() {
|
||||
|
@ -259,8 +279,7 @@ public class MessageView extends K9Activity
|
|||
if (values[2]!=null) {
|
||||
mDateView.setText(values[2]);
|
||||
mDateView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mDateView.setVisibility(View.GONE);
|
||||
}
|
||||
mTimeView.setText(values[3]);
|
||||
|
@ -283,8 +302,7 @@ public class MessageView extends K9Activity
|
|||
null, // top
|
||||
null, // right
|
||||
null); // bottom
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null, // left
|
||||
null, // top
|
||||
|
@ -452,7 +470,9 @@ public class MessageView extends K9Activity
|
|||
|
||||
mFlagged = (CheckBox)findViewById(R.id.flagged);
|
||||
mFlagged.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) { onFlag(); }
|
||||
public void onClick(View v) {
|
||||
onFlag();
|
||||
}
|
||||
});
|
||||
|
||||
mMessageContentView.setVerticalScrollBarEnabled(true);
|
||||
|
@ -496,8 +516,7 @@ public class MessageView extends K9Activity
|
|||
mFolder = icicle.getString(EXTRA_FOLDER);
|
||||
mMessageUid = icicle.getString(EXTRA_MESSAGE);
|
||||
mMessageUids = icicle.getStringArrayList(EXTRA_MESSAGE_UIDS);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (uri==null) {
|
||||
mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||
mFolder = intent.getStringExtra(EXTRA_FOLDER);
|
||||
|
@ -507,8 +526,7 @@ public class MessageView extends K9Activity
|
|||
Log.v(Email.LOG_TAG, "mAccount number: " + mAccount.getAccountNumber());
|
||||
Log.v(Email.LOG_TAG, "mFolder: " + mFolder);
|
||||
Log.v(Email.LOG_TAG, "mMessageUid: " + mMessageUid);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Log.v(Email.LOG_TAG, "uri: " + uri.toString());
|
||||
List<String> segmentList = uri.getPathSegments();
|
||||
Log.v(Email.LOG_TAG, "segmentList size: " + segmentList.size());
|
||||
|
@ -533,8 +551,7 @@ public class MessageView extends K9Activity
|
|||
mFolder = segmentList.get(1);
|
||||
mMessageUid = segmentList.get(2);
|
||||
mMessageUids = new ArrayList<String>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (String segment : segmentList) {
|
||||
Log.v(Email.LOG_TAG, "segment: " + segment);
|
||||
}
|
||||
|
@ -566,23 +583,15 @@ public class MessageView extends K9Activity
|
|||
Account.HideButtons hideButtons = mAccount.getHideMessageViewButtons();
|
||||
|
||||
//MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||
if (Account.HideButtons.ALWAYS == hideButtons)
|
||||
{
|
||||
if (Account.HideButtons.ALWAYS == hideButtons) {
|
||||
hideButtons();
|
||||
}
|
||||
else if (Account.HideButtons.NEVER == hideButtons)
|
||||
{
|
||||
} else if (Account.HideButtons.NEVER == hideButtons) {
|
||||
showButtons();
|
||||
}
|
||||
else // Account.HideButtons.KEYBOARD_AVAIL
|
||||
{
|
||||
} else { // Account.HideButtons.KEYBOARD_AVAIL
|
||||
final Configuration config = this.getResources().getConfiguration();
|
||||
if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO )
|
||||
{
|
||||
if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO ) {
|
||||
hideButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
showButtons();
|
||||
}
|
||||
}
|
||||
|
@ -590,16 +599,14 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState (Bundle outState)
|
||||
{
|
||||
protected void onSaveInstanceState (Bundle outState) {
|
||||
outState.putSerializable(EXTRA_ACCOUNT, mAccount);
|
||||
outState.putString(EXTRA_FOLDER, mFolder);
|
||||
outState.putString(EXTRA_MESSAGE, mMessageUid);
|
||||
outState.putStringArrayList(EXTRA_MESSAGE_UIDS, mMessageUids);
|
||||
}
|
||||
|
||||
private void displayMessage(String uid)
|
||||
{
|
||||
private void displayMessage(String uid) {
|
||||
mMessageUid = uid;
|
||||
mMessageContentView.getSettings().setBlockNetworkImage(true);
|
||||
mAttachments.removeAllViews();
|
||||
|
@ -619,27 +626,23 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
|
||||
private void showButtons()
|
||||
{
|
||||
private void showButtons() {
|
||||
View buttons = findViewById(R.id.scrolling_buttons);
|
||||
if (buttons != null) {
|
||||
buttons.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideButtons()
|
||||
{
|
||||
private void hideButtons() {
|
||||
View buttons = findViewById(R.id.bottom_buttons);
|
||||
if (buttons != null) {
|
||||
buttons.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setOnClickListener(int viewCode)
|
||||
{
|
||||
private void setOnClickListener(int viewCode) {
|
||||
View thisView = findViewById(viewCode);
|
||||
if (thisView != null)
|
||||
{
|
||||
if (thisView != null) {
|
||||
thisView.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
@ -678,8 +681,7 @@ public class MessageView extends K9Activity
|
|||
null);
|
||||
if (mNextMessageUid != null) {
|
||||
onNext();
|
||||
}
|
||||
else if (mPreviousMessageUid != null) {
|
||||
} else if (mPreviousMessageUid != null) {
|
||||
onPrevious();
|
||||
} else {
|
||||
finish();
|
||||
|
@ -740,27 +742,21 @@ public class MessageView extends K9Activity
|
|||
if (mMessage != null) {
|
||||
MessagingController.getInstance(getApplication()).setMessageFlag(mAccount,
|
||||
mMessage.getFolder().getName(), mMessage.getUid(), Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
||||
try
|
||||
{
|
||||
try {
|
||||
mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
||||
setHeaders(mAccount, mMessage.getFolder().getName(), mMessage.getUid(), mMessage);
|
||||
setMenuFlag();
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
} catch (MessagingException me) {
|
||||
Log.e(Email.LOG_TAG, "Could not set flag on local message", me);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onMove()
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mAccount) == false)
|
||||
{
|
||||
private void onMove() {
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mAccount) == false) {
|
||||
return;
|
||||
}
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mMessage) == false)
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mMessage) == false) {
|
||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
|
@ -772,14 +768,11 @@ public class MessageView extends K9Activity
|
|||
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_MOVE);
|
||||
}
|
||||
|
||||
private void onCopy()
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mAccount) == false)
|
||||
{
|
||||
private void onCopy() {
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mAccount) == false) {
|
||||
return;
|
||||
}
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mMessage) == false)
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mMessage) == false) {
|
||||
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
|
@ -806,8 +799,7 @@ public class MessageView extends K9Activity
|
|||
String srcFolderName = data.getStringExtra(ChooseFolder.EXTRA_CUR_FOLDER);
|
||||
String uid = data.getStringExtra(ChooseFolder.EXTRA_MESSAGE_UID);
|
||||
|
||||
if (uid.equals(mMessageUid) && srcFolderName.equals(mFolder))
|
||||
{
|
||||
if (uid.equals(mMessageUid) && srcFolderName.equals(mFolder)) {
|
||||
|
||||
switch (requestCode) {
|
||||
case ACTIVITY_CHOOSE_FOLDER_MOVE:
|
||||
|
@ -850,8 +842,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
private void onMarkAsUnread() {
|
||||
if (mMessage != null)
|
||||
{
|
||||
if (mMessage != null) {
|
||||
MessagingController.getInstance(getApplication()).markMessageRead(
|
||||
mAccount,
|
||||
mFolder,
|
||||
|
@ -879,8 +870,7 @@ public class MessageView extends K9Activity
|
|||
String name = filename.substring(0, index);
|
||||
String extension = filename.substring(index);
|
||||
format = name + "-%d" + extension;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
format = filename + "-%d";
|
||||
}
|
||||
for (int i = 2; i < Integer.MAX_VALUE; i++) {
|
||||
|
@ -903,8 +893,7 @@ public class MessageView extends K9Activity
|
|||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (mMessage != null)
|
||||
{
|
||||
if (mMessage != null) {
|
||||
MessagingController.getInstance(getApplication()).loadAttachment(
|
||||
mAccount,
|
||||
mMessage,
|
||||
|
@ -915,8 +904,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
private void onViewAttachment(Attachment attachment) {
|
||||
if (mMessage != null)
|
||||
{
|
||||
if (mMessage != null) {
|
||||
MessagingController.getInstance(getApplication()).loadAttachment(
|
||||
mAccount,
|
||||
mMessage,
|
||||
|
@ -1018,12 +1006,10 @@ public class MessageView extends K9Activity
|
|||
getMenuInflater().inflate(R.menu.message_view_option, menu);
|
||||
optionsMenu = menu;
|
||||
setMenuFlag();
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mAccount) == false)
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isCopyCapable(mAccount) == false) {
|
||||
menu.findItem(R.id.copy).setVisible(false);
|
||||
}
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mAccount) == false)
|
||||
{
|
||||
if (MessagingController.getInstance(getApplication()).isMoveCapable(mAccount) == false) {
|
||||
menu.findItem(R.id.move).setVisible(false);
|
||||
}
|
||||
return true;
|
||||
|
@ -1035,14 +1021,11 @@ public class MessageView extends K9Activity
|
|||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
private void setMenuFlag()
|
||||
{
|
||||
private void setMenuFlag() {
|
||||
Menu menu = optionsMenu;
|
||||
if (menu != null)
|
||||
{
|
||||
if (menu != null) {
|
||||
MenuItem flagItem = menu.findItem(R.id.flag);
|
||||
if (flagItem != null && mMessage != null)
|
||||
{
|
||||
if (flagItem != null && mMessage != null) {
|
||||
flagItem.setTitle((mMessage.isSet(Flag.FLAGGED) ? R.string.unflag_action : R.string.flag_action));
|
||||
}
|
||||
}
|
||||
|
@ -1059,8 +1042,7 @@ public class MessageView extends K9Activity
|
|||
// part.getBody().writeTo(cr.getStream());
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
@ -1089,8 +1071,7 @@ public class MessageView extends K9Activity
|
|||
splittedHeaders,
|
||||
HttpURLConnection.HTTP_OK);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
@ -1105,8 +1086,7 @@ public class MessageView extends K9Activity
|
|||
attachment.part.getAttachmentId(),
|
||||
62,
|
||||
62)));
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* We don't care what happened, we just return null for the preview icon.
|
||||
*/
|
||||
|
@ -1124,14 +1104,11 @@ public class MessageView extends K9Activity
|
|||
long gb = (mb * 1024);
|
||||
if (size < kb) {
|
||||
return String.format("%d bytes", (int) size);
|
||||
}
|
||||
else if (size < mb) {
|
||||
} else if (size < mb) {
|
||||
return String.format("%.1f kB", size / kb);
|
||||
}
|
||||
else if (size < gb) {
|
||||
} else if (size < gb) {
|
||||
return String.format("%.1f MB", size / mb);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return String.format("%.1f GB", size / gb);
|
||||
}
|
||||
}
|
||||
|
@ -1140,8 +1117,7 @@ public class MessageView extends K9Activity
|
|||
String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
|
||||
String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition());
|
||||
String name = MimeUtility.getHeaderParameter(contentType, "name");
|
||||
if (name == null)
|
||||
{
|
||||
if (name == null) {
|
||||
name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
|
||||
}
|
||||
if (name != null) {
|
||||
|
@ -1213,8 +1189,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
private void setHeaders(Account account, String folder, String uid,
|
||||
final Message message) throws MessagingException
|
||||
{
|
||||
final Message message) throws MessagingException {
|
||||
String subjectText = message.getSubject();
|
||||
String fromText = Address.toFriendly(message.getFrom());
|
||||
String dateText = Utility.isDateToday(message.getSentDate()) ?
|
||||
|
@ -1255,8 +1230,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
try {
|
||||
setHeaders(account, folder, uid, message);
|
||||
}
|
||||
catch (MessagingException me) {
|
||||
} catch (MessagingException me) {
|
||||
if (Config.LOGV) {
|
||||
Log.v(Email.LOG_TAG, "loadMessageForViewHeadersAvailable", me);
|
||||
}
|
||||
|
@ -1278,18 +1252,15 @@ public class MessageView extends K9Activity
|
|||
part = MimeUtility.findFirstPartByMimeType(mMessage, "text/plain");
|
||||
if (part == null) {
|
||||
text = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LocalTextBody body = (LocalTextBody)part.getBody();
|
||||
if (body == null) {
|
||||
text = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = body.getBodyForDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = MimeUtility.getTextFromPart(part);
|
||||
}
|
||||
|
||||
|
@ -1305,8 +1276,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
});
|
||||
mHandler.showShowPictures(text.contains("<img"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
mMessageContentView.loadUrl("file:///android_asset/empty.html");
|
||||
|
@ -1315,8 +1285,7 @@ public class MessageView extends K9Activity
|
|||
}
|
||||
|
||||
renderAttachments(mMessage, 0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
if (Config.LOGV) {
|
||||
Log.v(Email.LOG_TAG, "loadMessageForViewBodyAvailable", e);
|
||||
}
|
||||
|
@ -1336,8 +1305,7 @@ public class MessageView extends K9Activity
|
|||
setProgressBarIndeterminateVisibility(false);
|
||||
if (t instanceof IllegalArgumentException) {
|
||||
mHandler.invalidIdError();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mHandler.networkError();
|
||||
}
|
||||
mMessageContentView.loadUrl("file:///android_asset/empty.html");
|
||||
|
@ -1416,24 +1384,19 @@ public class MessageView extends K9Activity
|
|||
in.close();
|
||||
mHandler.attachmentSaved(file.getName());
|
||||
new MediaScannerNotifier(MessageView.this, file);
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
} catch (IOException ioe) {
|
||||
mHandler.attachmentNotSaved();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Uri uri = AttachmentProvider.getAttachmentUri(
|
||||
mAccount,
|
||||
attachment.part.getAttachmentId());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(uri);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
try
|
||||
{
|
||||
try {
|
||||
startActivity(intent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
Toast toast = Toast.makeText(MessageView.this, getString(R.string.message_view_no_viewer, attachment.contentType), Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue