mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-28 04:02:19 -05:00
move folderlist initialization into an asynctask, so it's not so slow to populate
This commit is contained in:
parent
b99eb47d15
commit
db7649c9af
@ -4,6 +4,7 @@ package com.fsck.k9.activity.setup;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
@ -573,8 +574,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();
|
new PopulateFolderPrefsTask().execute();
|
||||||
|
|
||||||
|
|
||||||
mChipColor = findPreference(PREFERENCE_CHIP_COLOR);
|
mChipColor = findPreference(PREFERENCE_CHIP_COLOR);
|
||||||
mChipColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
|
mChipColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
|
||||||
@ -901,9 +901,14 @@ 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() {
|
|
||||||
|
|
||||||
|
private class PopulateFolderPrefsTask extends AsyncTask<Void, Void, Void>
|
||||||
|
{
|
||||||
List<? extends Folder> folders = new LinkedList<LocalFolder>();
|
List<? extends Folder> folders = new LinkedList<LocalFolder>();
|
||||||
|
String[] allFolderValues;
|
||||||
|
String[] allFolderLabels;
|
||||||
|
protected Void doInBackground(Void... params)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
folders = mAccount.getLocalStore().getPersonalNamespaces(false);
|
folders = mAccount.getLocalStore().getPersonalNamespaces(false);
|
||||||
@ -912,8 +917,9 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
{
|
{
|
||||||
/// this can't be checked in
|
/// this can't be checked in
|
||||||
}
|
}
|
||||||
final String[] allFolderValues = new String[folders.size()+2];
|
allFolderValues = new String[folders.size()+2];
|
||||||
final String[] allFolderLabels = new String[folders.size()+2];
|
allFolderLabels = new String[folders.size()+2];
|
||||||
|
|
||||||
allFolderValues[0] = K9.FOLDER_NONE;
|
allFolderValues[0] = K9.FOLDER_NONE;
|
||||||
allFolderLabels[0] = K9.FOLDER_NONE;
|
allFolderLabels[0] = K9.FOLDER_NONE;
|
||||||
|
|
||||||
@ -929,26 +935,48 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
allFolderValues[i] = folder.getName();
|
allFolderValues[i] = folder.getName();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void onPreExecute()
|
||||||
|
{
|
||||||
mAutoExpandFolder = (ListPreference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
|
mAutoExpandFolder = (ListPreference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
|
||||||
initListPreference(mAutoExpandFolder, mAccount.getAutoExpandFolderName(), allFolderLabels,allFolderValues);
|
mAutoExpandFolder.setEnabled(false);
|
||||||
|
|
||||||
mArchiveFolder = (ListPreference)findPreference(PREFERENCE_ARCHIVE_FOLDER);
|
mArchiveFolder = (ListPreference)findPreference(PREFERENCE_ARCHIVE_FOLDER);
|
||||||
initListPreference(mArchiveFolder, mAccount.getArchiveFolderName(), allFolderLabels,allFolderValues);
|
mArchiveFolder.setEnabled(false);
|
||||||
|
|
||||||
mDraftsFolder = (ListPreference)findPreference(PREFERENCE_DRAFTS_FOLDER);
|
mDraftsFolder = (ListPreference)findPreference(PREFERENCE_DRAFTS_FOLDER);
|
||||||
initListPreference(mDraftsFolder, mAccount.getDraftsFolderName(), allFolderLabels,allFolderValues);
|
mDraftsFolder.setEnabled(false);
|
||||||
|
|
||||||
mOutboxFolder = (ListPreference)findPreference(PREFERENCE_OUTBOX_FOLDER);
|
mOutboxFolder = (ListPreference)findPreference(PREFERENCE_OUTBOX_FOLDER);
|
||||||
initListPreference(mOutboxFolder, mAccount.getOutboxFolderName(), allFolderLabels,allFolderValues);
|
mOutboxFolder.setEnabled(false);
|
||||||
|
|
||||||
mSentFolder = (ListPreference)findPreference(PREFERENCE_SENT_FOLDER);
|
mSentFolder = (ListPreference)findPreference(PREFERENCE_SENT_FOLDER);
|
||||||
initListPreference(mSentFolder, mAccount.getSentFolderName(), allFolderLabels,allFolderValues);
|
mSentFolder.setEnabled(false);
|
||||||
|
|
||||||
mSpamFolder = (ListPreference)findPreference(PREFERENCE_SPAM_FOLDER);
|
mSpamFolder = (ListPreference)findPreference(PREFERENCE_SPAM_FOLDER);
|
||||||
initListPreference(mSpamFolder, mAccount.getSpamFolderName(), allFolderLabels,allFolderValues);
|
mSpamFolder.setEnabled(false);
|
||||||
|
|
||||||
mTrashFolder = (ListPreference)findPreference(PREFERENCE_TRASH_FOLDER);
|
mTrashFolder = (ListPreference)findPreference(PREFERENCE_TRASH_FOLDER);
|
||||||
|
mTrashFolder.setEnabled(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
protected void onPostExecute(Void res)
|
||||||
|
{
|
||||||
|
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);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user