Permalink
Browse files

Migrate to Account.has(Special)Folder() methods.

  • Loading branch information...
1 parent c9a747f commit 32ae7bad9c3eb5df34f34480e6cd5223c82746a2 @andrewachen andrewachen committed Apr 11, 2012
@@ -959,6 +959,14 @@ public synchronized void setDraftsFolderName(String draftsFolderName) {
mDraftsFolderName = draftsFolderName;
}
+ /**
+ * Checks if this account has a drafts folder set.
+ * @return true if account has a drafts folder set.
+ */
+ public synchronized boolean hasDraftsFolder() {
+ return !K9.FOLDER_NONE.equalsIgnoreCase(mDraftsFolderName);
+ }
+
public synchronized String getSentFolderName() {
return mSentFolderName;
}
@@ -971,6 +979,15 @@ public synchronized void setSentFolderName(String sentFolderName) {
mSentFolderName = sentFolderName;
}
+ /**
+ * Checks if this account has a sent folder set.
+ * @return true if account has a sent folder set.
+ */
+ public synchronized boolean hasSentFolder() {
+ return !K9.FOLDER_NONE.equalsIgnoreCase(mSentFolderName);
+ }
+
+
public synchronized String getTrashFolderName() {
return mTrashFolderName;
}
@@ -979,6 +996,14 @@ public synchronized void setTrashFolderName(String trashFolderName) {
mTrashFolderName = trashFolderName;
}
+ /**
+ * Checks if this account has a trash folder set.
+ * @return true if account has a trash folder set.
+ */
+ public synchronized boolean hasTrashFolder() {
+ return !K9.FOLDER_NONE.equalsIgnoreCase(mTrashFolderName);
+ }
+
public synchronized String getArchiveFolderName() {
return mArchiveFolderName;
}
@@ -1003,6 +1028,14 @@ public synchronized void setSpamFolderName(String spamFolderName) {
mSpamFolderName = spamFolderName;
}
+ /**
+ * Checks if this account has a spam folder set.
+ * @return true if account has a spam folder set.
+ */
+ public synchronized boolean hasSpamFolder() {
+ return !K9.FOLDER_NONE.equalsIgnoreCase(mSpamFolderName);
+ }
+
public synchronized String getOutboxFolderName() {
return OUTBOX;
}
@@ -1550,7 +1550,7 @@ private void saveMessage() {
private void saveIfNeeded() {
if (!mDraftNeedsSaving || mPreventDraftSaving || mPgpData.hasEncryptionKeys() ||
- mEncryptCheckbox.isChecked() || isDraftsFolderDisabled()) {
+ mEncryptCheckbox.isChecked() || !mAccount.hasDraftsFolder()) {
return;
}
@@ -2033,7 +2033,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.message_compose_option, menu);
// Disable the 'Save' menu option if Drafts folder is set to -NONE-
- if (isDraftsFolderDisabled()) {
+ if (!mAccount.hasDraftsFolder()) {
menu.findItem(R.id.save).setEnabled(false);
}
@@ -2063,7 +2063,7 @@ public void onBackPressed() {
if (mDraftNeedsSaving) {
if (mEncryptCheckbox.isChecked()) {
showDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
- } else if (isDraftsFolderDisabled()) {
+ } else if (!mAccount.hasDraftsFolder()) {
showDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
} else {
showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
@@ -2078,10 +2078,6 @@ public void onBackPressed() {
}
}
- private boolean isDraftsFolderDisabled() {
- return mAccount.getDraftsFolderName().equals(K9.FOLDER_NONE);
- }
-
@Override
public Dialog onCreateDialog(int id) {
switch (id) {
@@ -1652,7 +1652,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
if (!mAccount.hasArchiveFolder()) {
menu.findItem(R.id.batch_archive_op).setVisible(false);
}
- if (K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName())) {
+ if (!mAccount.hasSpamFolder()) {
menu.findItem(R.id.batch_spam_op).setVisible(false);
}
@@ -1861,7 +1861,7 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuIn
menu.findItem(R.id.archive).setVisible(false);
}
- if (K9.FOLDER_NONE.equalsIgnoreCase(account.getSpamFolderName())) {
+ if (!mAccount.hasSpamFolder()) {
menu.findItem(R.id.spam).setVisible(false);
}
@@ -454,7 +454,7 @@ private void setupDisplayMessageButtons() {
mAccount.hasArchiveFolder());
// Only enable the button if the Spam folder is not the current folder and not NONE.
mSpam.setEnabled(!mMessageReference.folderName.equals(mAccount.getSpamFolderName()) &&
- !K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName()));
+ mAccount.hasSpamFolder());
mMove.setEnabled(true);
} else {
disableMoveButtons();
@@ -881,7 +881,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
if (!mAccount.hasArchiveFolder()) {
menu.findItem(R.id.archive).setVisible(false);
}
- if (K9.FOLDER_NONE.equalsIgnoreCase(mAccount.getSpamFolderName())) {
+ if (!mAccount.hasSpamFolder()) {
menu.findItem(R.id.spam).setVisible(false);
}
return true;
@@ -3181,9 +3181,9 @@ public void sendPendingMessagesSynchronous(final Account account) {
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxProgress(account, account.getSentFolderName(), progress, todo);
}
- if (K9.FOLDER_NONE.equals(account.getSentFolderName())) {
+ if (!account.hasSentFolder()) {
if (K9.DEBUG)
- Log.i(K9.LOG_TAG, "Sent folder set to " + K9.FOLDER_NONE + ", deleting sent message");
+ Log.i(K9.LOG_TAG, "Account does not have a sent mail folder; deleting sent message");
message.setFlag(Flag.DELETED, true);
} else {
LocalFolder localSentFolder = (LocalFolder) localStore.getFolder(account.getSentFolderName());
@@ -3516,7 +3516,7 @@ private void deleteMessagesSynchronous(final Account account, final String folde
Store localStore = account.getLocalStore();
localFolder = localStore.getFolder(folder);
Map<String, String> uidMap = null;
- if (folder.equals(account.getTrashFolderName()) || K9.FOLDER_NONE.equals(account.getTrashFolderName())) {
+ if (folder.equals(account.getTrashFolderName()) || !account.hasTrashFolder()) {
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "Deleting messages in trash folder or trash set to -None-, not copying");

0 comments on commit 32ae7ba

Please sign in to comment.