1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Hardcode folder name for (local) outbox and don't show outbox when

only being allowed to select remote folders.
This commit is contained in:
cketti 2011-02-20 04:47:28 +01:00
parent 2ec5a712a2
commit 737cff0612
10 changed files with 42 additions and 34 deletions

View File

@ -300,17 +300,12 @@
android:key="archive_folder"
android:title="@string/archive_folder_label"
android:dialogTitle="@string/archive_folder_label" />
<ListPreference
android:persistent="false"
android:key="drafts_folder"
android:title="@string/drafts_folder_label"
android:dialogTitle="@string/drafts_folder_label" />
<ListPreference
android:persistent="false"
android:key="outbox_folder"
android:title="@string/outbox_folder_label"
android:dialogTitle="@string/outbox_folder_label" />
<ListPreference
android:persistent="false"

View File

@ -85,7 +85,6 @@ public class Account implements BaseAccount {
private String mTrashFolderName;
private String mArchiveFolderName;
private String mSpamFolderName;
private String mOutboxFolderName;
private String mAutoExpandFolderName;
private FolderMode mFolderDisplayMode;
private FolderMode mFolderSyncMode;
@ -252,7 +251,6 @@ public class Account implements BaseAccount {
mTrashFolderName = prefs.getString(mUuid + ".trashFolderName", "Trash");
mArchiveFolderName = prefs.getString(mUuid + ".archiveFolderName", "Archive");
mSpamFolderName = prefs.getString(mUuid + ".spamFolderName", "Spam");
mOutboxFolderName = prefs.getString(mUuid + ".outboxFolderName", "Outbox");
mExpungePolicy = prefs.getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY);
mSyncRemoteDeletions = prefs.getBoolean(mUuid + ".syncRemoteDeletions", true);
@ -396,7 +394,6 @@ public class Account implements BaseAccount {
editor.remove(mUuid + ".trashFolderName");
editor.remove(mUuid + ".archiveFolderName");
editor.remove(mUuid + ".spamFolderName");
editor.remove(mUuid + ".outboxFolderName");
editor.remove(mUuid + ".autoExpandFolderName");
editor.remove(mUuid + ".accountNumber");
editor.remove(mUuid + ".vibrate");
@ -493,7 +490,6 @@ public class Account implements BaseAccount {
editor.putString(mUuid + ".trashFolderName", mTrashFolderName);
editor.putString(mUuid + ".archiveFolderName", mArchiveFolderName);
editor.putString(mUuid + ".spamFolderName", mSpamFolderName);
editor.putString(mUuid + ".outboxFolderName", mOutboxFolderName);
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
editor.putString(mUuid + ".hideButtonsEnum", mScrollMessageViewButtons.name());
@ -828,11 +824,7 @@ public class Account implements BaseAccount {
}
public synchronized String getOutboxFolderName() {
return mOutboxFolderName;
}
public synchronized void setOutboxFolderName(String outboxFolderName) {
mOutboxFolderName = outboxFolderName;
return K9.OUTBOX;
}
public synchronized String getAutoExpandFolderName() {

View File

@ -213,6 +213,11 @@ public class K9 extends Application {
*/
public static final String INBOX = "INBOX";
/**
* This local folder is used to store messages to be sent.
*/
public static final String OUTBOX = "OUTBOX";
/**
* For use when displaying that no folder is selected
*/

View File

@ -12,6 +12,7 @@ import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.service.MailService;
public class ActivityListener extends MessagingListener {
private Account mAccount = null;
private String mLoadingFolderName = null;
private String mLoadingHeaderFolderName = null;
private String mLoadingAccountDescription = null;
@ -37,6 +38,9 @@ public class ActivityListener extends MessagingListener {
if (K9.INBOX.equalsIgnoreCase(displayName)) {
displayName = context.getString(R.string.special_mailbox_name_inbox);
}
else if ((mAccount != null) && mAccount.getOutboxFolderName().equals(displayName)) {
displayName = context.getString(R.string.special_mailbox_name_outbox);
}
if (mLoadingHeaderFolderName != null) {
@ -82,6 +86,7 @@ public class ActivityListener extends MessagingListener {
int numNewMessages) {
mLoadingAccountDescription = null;
mLoadingFolderName = null;
mAccount = null;
informUserOfStatus();
}
@ -89,6 +94,7 @@ public class ActivityListener extends MessagingListener {
public void synchronizeMailboxStarted(Account account, String folder) {
mLoadingAccountDescription = account.getDescription();
mLoadingFolderName = folder;
mAccount = account;
mFolderCompleted = 0;
mFolderTotal = 0;
informUserOfStatus();
@ -131,6 +137,7 @@ public class ActivityListener extends MessagingListener {
String message) {
mLoadingAccountDescription = null;
mLoadingFolderName = null;
mAccount = null;
informUserOfStatus();
}

View File

@ -301,7 +301,7 @@ public class ChooseFolder extends K9ListActivity {
if (K9.INBOX.equalsIgnoreCase(name)) {
mAdapter.add(getString(R.string.special_mailbox_name_inbox));
heldInbox = name;
} else if (!K9.ERROR_FOLDER_NAME.equals(name)) {
} else if (!K9.ERROR_FOLDER_NAME.equals(name) && !account.getOutboxFolderName().equals(name)) {
mAdapter.add(name);
}

View File

@ -104,7 +104,7 @@ public class FolderInfoHolder implements Comparable<FolderInfoHolder> {
}
if (this.name.equals(account.getOutboxFolderName())) {
this.displayName = String.format(context.getString(R.string.special_mailbox_name_outbox_fmt), this.name);
this.displayName = context.getString(R.string.special_mailbox_name_outbox);
}
if (this.name.equals(account.getDraftsFolderName())) {

View File

@ -488,6 +488,8 @@ public class MessageList
if (K9.INBOX.equalsIgnoreCase(displayName)) {
displayName = getString(R.string.special_mailbox_name_inbox);
} else if (mAccount.getOutboxFolderName().equals(displayName)) {
displayName = getString(R.string.special_mailbox_name_outbox);
}
String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount, getTimeFormat());

View File

@ -11,6 +11,7 @@ import android.preference.*;
import android.util.Log;
import android.view.KeyEvent;
import java.util.Iterator;
import java.util.Map;
import java.util.LinkedList;
import java.util.List;
@ -96,7 +97,6 @@ public class AccountSettings extends K9PreferenceActivity {
private static final String PREFERENCE_ARCHIVE_FOLDER = "archive_folder";
private static final String PREFERENCE_DRAFTS_FOLDER = "drafts_folder";
private static final String PREFERENCE_OUTBOX_FOLDER = "outbox_folder";
private static final String PREFERENCE_SENT_FOLDER = "sent_folder";
private static final String PREFERENCE_SPAM_FOLDER = "spam_folder";
private static final String PREFERENCE_TRASH_FOLDER = "trash_folder";
@ -157,7 +157,6 @@ public class AccountSettings extends K9PreferenceActivity {
private ListPreference mArchiveFolder;
private ListPreference mDraftsFolder;
private ListPreference mOutboxFolder;
private ListPreference mSentFolder;
private ListPreference mSpamFolder;
private ListPreference mTrashFolder;
@ -699,7 +698,6 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setAutoExpandFolderName(reverseTranslateFolder(mAutoExpandFolder.getValue()));
mAccount.setArchiveFolderName(mArchiveFolder.getValue());
mAccount.setDraftsFolderName(mDraftsFolder.getValue());
mAccount.setOutboxFolderName(mOutboxFolder.getValue());
mAccount.setSentFolderName(mSentFolder.getValue());
mAccount.setSpamFolderName(mSpamFolder.getValue());
mAccount.setTrashFolderName(mTrashFolder.getValue());
@ -852,18 +850,26 @@ public class AccountSettings extends K9PreferenceActivity {
} catch (Exception e) {
/// this can't be checked in
}
allFolderValues = new String[folders.size()+2];
allFolderLabels = new String[folders.size()+2];
// TODO: In the future the call above should be changed to only return remote folders.
// For now we just remove the Outbox folder if present.
Iterator<? extends Folder> iter = folders.iterator();
while (iter.hasNext())
{
Folder folder = iter.next();
if (mAccount.getOutboxFolderName().equals(folder.getName()))
{
iter.remove();
}
}
allFolderValues = new String[folders.size()+1];
allFolderLabels = new String[folders.size()+1];
allFolderValues[0] = K9.FOLDER_NONE;
allFolderLabels[0] = K9.FOLDER_NONE;
// There's a non-zero chance that "outbox" won't actually exist, so we force it into the list
allFolderValues[1] = mAccount.getOutboxFolderName();
allFolderLabels[1] = mAccount.getOutboxFolderName();
int i = 2;
int i = 1;
for (Folder folder : folders) {
allFolderLabels[i] = folder.getName();
allFolderValues[i] = folder.getName();
@ -880,8 +886,6 @@ public class AccountSettings extends K9PreferenceActivity {
mArchiveFolder.setEnabled(false);
mDraftsFolder = (ListPreference)findPreference(PREFERENCE_DRAFTS_FOLDER);
mDraftsFolder.setEnabled(false);
mOutboxFolder = (ListPreference)findPreference(PREFERENCE_OUTBOX_FOLDER);
mOutboxFolder.setEnabled(false);
mSentFolder = (ListPreference)findPreference(PREFERENCE_SENT_FOLDER);
mSentFolder.setEnabled(false);
mSpamFolder = (ListPreference)findPreference(PREFERENCE_SPAM_FOLDER);
@ -896,14 +900,12 @@ public class AccountSettings extends K9PreferenceActivity {
initListPreference(mAutoExpandFolder, mAccount.getAutoExpandFolderName(), allFolderLabels, allFolderValues);
initListPreference(mArchiveFolder, mAccount.getArchiveFolderName(), allFolderLabels, allFolderValues);
initListPreference(mDraftsFolder, mAccount.getDraftsFolderName(), allFolderLabels, allFolderValues);
initListPreference(mOutboxFolder, mAccount.getOutboxFolderName(), allFolderLabels, allFolderValues);
initListPreference(mSentFolder, mAccount.getSentFolderName(), allFolderLabels, allFolderValues);
initListPreference(mSpamFolder, mAccount.getSpamFolderName(), allFolderLabels, allFolderValues);
initListPreference(mTrashFolder, mAccount.getTrashFolderName(), allFolderLabels, allFolderValues);
mAutoExpandFolder.setEnabled(true);
mArchiveFolder.setEnabled(true);
mDraftsFolder.setEnabled(true);
mOutboxFolder.setEnabled(true);
mSentFolder.setEnabled(true);
mSpamFolder.setEnabled(true);
mTrashFolder.setEnabled(true);

View File

@ -233,7 +233,6 @@ public class AccountSetupBasics extends K9Activity
mAccount.setTrashFolderName(getString(R.string.special_mailbox_name_trash));
mAccount.setArchiveFolderName(getString(R.string.special_mailbox_name_archive));
mAccount.setSpamFolderName(getString(R.string.special_mailbox_name_spam));
mAccount.setOutboxFolderName(getString(R.string.special_mailbox_name_outbox));
mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent));
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, true);
} catch (UnsupportedEncodingException enc) {
@ -313,7 +312,6 @@ public class AccountSetupBasics extends K9Activity
}
mAccount.setDraftsFolderName(getString(R.string.special_mailbox_name_drafts));
mAccount.setTrashFolderName(getString(R.string.special_mailbox_name_trash));
mAccount.setOutboxFolderName(getString(R.string.special_mailbox_name_outbox));
mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent));
AccountSetupAccountType.actionSelectAccountType(this, mAccount, mDefaultView.isChecked());

View File

@ -386,6 +386,13 @@ public class ImapStore extends Store {
if (folder.equalsIgnoreCase(K9.INBOX)) {
continue;
} else if (folder.equalsIgnoreCase(K9.OUTBOX)) {
/*
* There is a folder on the server with the same name as our local
* outbox. Until we have a good plan to deal with this situation
* we simply ignore the folder on the server.
*/
continue;
} else {
if (getCombinedPrefix().length() > 0) {