1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-12 14:18:02 -05:00

onRefile removes code duplication

This commit is contained in:
Jesse Vincent 2010-12-26 03:49:20 +00:00
parent db02383d4a
commit f2b2fddd5a

View File

@ -293,12 +293,12 @@ public class MessageView extends K9Activity implements OnClickListener
} }
case KeyEvent.KEYCODE_S: case KeyEvent.KEYCODE_S:
{ {
onSpam(); onRefile(mAccount.getSpamFolderName());
return true; return true;
} }
case KeyEvent.KEYCODE_V: case KeyEvent.KEYCODE_V:
{ {
onArchive(); onRefile(mAccount.getArchiveFolderName());
return true; return true;
} }
case KeyEvent.KEYCODE_Y: case KeyEvent.KEYCODE_Y:
@ -1265,16 +1265,14 @@ public class MessageView extends K9Activity implements OnClickListener
// accidental clicks) // accidental clicks)
disableButtons(); disableButtons();
Message messageToDelete = mMessage; Message messageToDelete = mMessage;
showNextMessageOrReturn(); showNextMessageOrReturn();
MessagingController.getInstance(getApplication()).deleteMessages( MessagingController.getInstance(getApplication()).deleteMessages(
new Message[]{messageToDelete}, new Message[]{messageToDelete},
null); null);
} }
} }
private void onArchive() private void onRefile(String dstFolder)
{ {
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount)) if (!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
{ {
@ -1286,9 +1284,7 @@ public class MessageView extends K9Activity implements OnClickListener
toast.show(); toast.show();
return; return;
} }
String srcFolder = mMessageReference.folderName; String srcFolder = mMessageReference.folderName;
String dstFolder = mAccount.getArchiveFolderName();
Message messageToMove = mMessage; Message messageToMove = mMessage;
if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder)) if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder))
{ {
@ -1299,30 +1295,7 @@ public class MessageView extends K9Activity implements OnClickListener
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null); .moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
} }
private void onSpam()
{
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mAccount))
{
return;
}
if (!MessagingController.getInstance(getApplication()).isMoveCapable(mMessage))
{
Toast toast = Toast.makeText(this, R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
toast.show();
return;
}
String srcFolder = mMessageReference.folderName;
String dstFolder = mAccount.getSpamFolderName();
Message messageToMove = mMessage;
if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder))
{
return;
}
showNextMessageOrReturn();
MessagingController.getInstance(getApplication())
.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
}
private void showNextMessageOrReturn() private void showNextMessageOrReturn()
{ {
@ -1748,11 +1721,11 @@ public class MessageView extends K9Activity implements OnClickListener
break; break;
case R.id.archive: case R.id.archive:
case R.id.archive_scrolling: case R.id.archive_scrolling:
onArchive(); onRefile(mAccount.getArchiveFolderName());
break; break;
case R.id.spam: case R.id.spam:
case R.id.spam_scrolling: case R.id.spam_scrolling:
onSpam(); onRefile(mAccount.getSpamFolderName());
break; break;
case R.id.move: case R.id.move:
case R.id.move_scrolling: case R.id.move_scrolling:
@ -1811,10 +1784,10 @@ public class MessageView extends K9Activity implements OnClickListener
onFlag(); onFlag();
break; break;
case R.id.archive: case R.id.archive:
onArchive(); onRefile(mAccount.getArchiveFolderName());
break; break;
case R.id.spam: case R.id.spam:
onSpam(); onRefile(mAccount.getSpamFolderName());
break; break;
case R.id.move: case R.id.move:
onMove(); onMove();