mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
extract folder preference setup to a method, so we can push it onto a thread
This commit is contained in:
parent
4a97f4a1a0
commit
b99eb47d15
@ -573,56 +573,7 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
|
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
|
||||||
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
|
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
|
||||||
|
|
||||||
|
populateFolderPreferences();
|
||||||
|
|
||||||
List<? extends Folder> folders = new LinkedList<LocalFolder>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
folders = mAccount.getLocalStore().getPersonalNamespaces(false);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
/// this can't be checked in
|
|
||||||
}
|
|
||||||
final String[] allFolderValues = new String[folders.size()+2];
|
|
||||||
final String[] allFolderLabels = new String[folders.size()+2];
|
|
||||||
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;
|
|
||||||
for (Folder folder : folders)
|
|
||||||
{
|
|
||||||
allFolderLabels[i] = folder.getName();
|
|
||||||
allFolderValues[i] = folder.getName();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mAutoExpandFolder = (ListPreference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
|
|
||||||
initListPreference(mAutoExpandFolder, mAccount.getAutoExpandFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mArchiveFolder = (ListPreference)findPreference(PREFERENCE_ARCHIVE_FOLDER);
|
|
||||||
initListPreference(mArchiveFolder, mAccount.getArchiveFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mDraftsFolder = (ListPreference)findPreference(PREFERENCE_DRAFTS_FOLDER);
|
|
||||||
initListPreference(mDraftsFolder, mAccount.getDraftsFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mOutboxFolder = (ListPreference)findPreference(PREFERENCE_OUTBOX_FOLDER);
|
|
||||||
initListPreference(mOutboxFolder, mAccount.getOutboxFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mSentFolder = (ListPreference)findPreference(PREFERENCE_SENT_FOLDER);
|
|
||||||
initListPreference(mSentFolder, mAccount.getSentFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mSpamFolder = (ListPreference)findPreference(PREFERENCE_SPAM_FOLDER);
|
|
||||||
initListPreference(mSpamFolder, mAccount.getSpamFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
mTrashFolder = (ListPreference)findPreference(PREFERENCE_TRASH_FOLDER);
|
|
||||||
initListPreference(mTrashFolder, mAccount.getTrashFolderName(), allFolderLabels,allFolderValues);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mChipColor = findPreference(PREFERENCE_CHIP_COLOR);
|
mChipColor = findPreference(PREFERENCE_CHIP_COLOR);
|
||||||
@ -950,4 +901,54 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
Integer.parseInt(mAccountVibratePattern.getValue()),
|
Integer.parseInt(mAccountVibratePattern.getValue()),
|
||||||
Integer.parseInt(mAccountVibrateTimes.getValue())), -1);
|
Integer.parseInt(mAccountVibrateTimes.getValue())), -1);
|
||||||
}
|
}
|
||||||
|
private void populateFolderPreferences() {
|
||||||
|
|
||||||
|
List<? extends Folder> folders = new LinkedList<LocalFolder>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
folders = mAccount.getLocalStore().getPersonalNamespaces(false);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
/// this can't be checked in
|
||||||
|
}
|
||||||
|
final String[] allFolderValues = new String[folders.size()+2];
|
||||||
|
final String[] allFolderLabels = new String[folders.size()+2];
|
||||||
|
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;
|
||||||
|
for (Folder folder : folders)
|
||||||
|
{
|
||||||
|
allFolderLabels[i] = folder.getName();
|
||||||
|
allFolderValues[i] = folder.getName();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAutoExpandFolder = (ListPreference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
|
||||||
|
initListPreference(mAutoExpandFolder, mAccount.getAutoExpandFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mArchiveFolder = (ListPreference)findPreference(PREFERENCE_ARCHIVE_FOLDER);
|
||||||
|
initListPreference(mArchiveFolder, mAccount.getArchiveFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mDraftsFolder = (ListPreference)findPreference(PREFERENCE_DRAFTS_FOLDER);
|
||||||
|
initListPreference(mDraftsFolder, mAccount.getDraftsFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mOutboxFolder = (ListPreference)findPreference(PREFERENCE_OUTBOX_FOLDER);
|
||||||
|
initListPreference(mOutboxFolder, mAccount.getOutboxFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mSentFolder = (ListPreference)findPreference(PREFERENCE_SENT_FOLDER);
|
||||||
|
initListPreference(mSentFolder, mAccount.getSentFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mSpamFolder = (ListPreference)findPreference(PREFERENCE_SPAM_FOLDER);
|
||||||
|
initListPreference(mSpamFolder, mAccount.getSpamFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
|
||||||
|
mTrashFolder = (ListPreference)findPreference(PREFERENCE_TRASH_FOLDER);
|
||||||
|
initListPreference(mTrashFolder, mAccount.getTrashFolderName(), allFolderLabels,allFolderValues);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user