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

Move our "pick a folder" preferences out of the account setup wizard,

where you're unlikely to even have access to them the first time you
walk through into the "Folders" preferences.

At the same time, move toward using a list preference widget, rather
than a custom activity.
This commit is contained in:
Jesse Vincent 2010-11-17 03:43:02 +00:00
parent b6ccba9c7d
commit 46300ac421
5 changed files with 121 additions and 170 deletions

View File

@ -116,43 +116,6 @@
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/imap_folder_setup_section"
android:orientation="vertical">
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_archive"
android:layout_width="fill_parent"></TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/account_imap_folder_archive" android:layout_width="fill_parent"></Button>
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_drafts"
android:layout_width="fill_parent"></TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/account_imap_folder_drafts" android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_incoming_imap_folder_drafts"></Button>
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_sent"
android:layout_width="fill_parent"></TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/account_imap_folder_sent" android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_incoming_imap_folder_sent"></Button>
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_spam"
android:layout_width="fill_parent"></TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/account_imap_folder_spam" android:layout_width="fill_parent"></Button>
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_trash"
android:layout_width="fill_parent"></TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/account_imap_folder_trash" android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_incoming_imap_folder_trash"></Button>
<TextView android:layout_height="wrap_content"
android:text="@string/account_setup_incoming_imap_folder_outbox"
android:layout_width="fill_parent"></TextView>
<EditText
android:id="@+id/account_imap_folder_outbox"
android:singleLine="true"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_incoming_imap_folder_outbox" />
<CheckBox
android:id="@+id/subscribed_folders_only"
android:layout_height="wrap_content"

View File

@ -412,12 +412,12 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_setup_incoming_imap_path_prefix_label">IMAP path prefix</string>
<string name="account_setup_incoming_imap_path_prefix_hint">(Automatic using NAMESPACE if available)</string>
<string name="account_setup_incoming_imap_folder_drafts">Drafts folder name</string>
<string name="account_setup_incoming_imap_folder_sent">Sent folder name</string>
<string name="account_setup_incoming_imap_folder_trash">Trash folder name</string>
<string name="account_setup_incoming_imap_folder_archive">Archive folder name</string>
<string name="account_setup_incoming_imap_folder_spam">Spam folder name</string>
<string name="account_setup_incoming_imap_folder_outbox">Outbox folder name</string>
<string name="drafts_folder_label">Drafts folder</string>
<string name="sent_folder_label">Sent folder</string>
<string name="trash_folder_label">Trash folder</string>
<string name="archive_folder_label">Archive folder</string>
<string name="spam_folder_label">Spam folder</string>
<string name="outbox_folder_label">Outbox folder</string>
<string name="account_setup_incoming_subscribed_folders_only_label">Show only subscribed folders</string>
<string name="account_setup_auto_expand_folder">Auto-expand folder</string>

View File

@ -251,10 +251,9 @@
android:title="@string/account_settings_folders"
android:key="folders">
<Preference
<ListPreference
android:persistent="false"
android:key="account_setup_auto_expand_folder"
android:singleLine="true"
android:title="@string/account_setup_auto_expand_folder"
android:summary="" />
@ -282,6 +281,40 @@
android:entryValues="@array/account_settings_searchable_values"
android:dialogTitle="@string/account_settings_searchable_label" />
<ListPreference
android:persistent="false"
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"
android:key="sent_folder"
android:title="@string/sent_folder_label"
android:dialogTitle="@string/sent_folder_label" />
<ListPreference
android:persistent="false"
android:key="spam_folder"
android:title="@string/spam_folder_label"
android:dialogTitle="@string/spam_folder_label" />
<ListPreference
android:persistent="false"
android:key="trash_folder"
android:title="@string/trash_folder_label"
android:dialogTitle="@string/trash_folder_label" />
</PreferenceScreen>
<PreferenceScreen
android:title="@string/account_settings_storage_title"

View File

@ -15,12 +15,15 @@ import android.util.Log;
import android.view.KeyEvent;
import java.util.Map;
import java.util.LinkedList;
import java.util.List;
import com.fsck.k9.Account;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.activity.ChooseFolder;
import com.fsck.k9.activity.ChooseIdentity;
import com.fsck.k9.activity.ColorPickerDialog;
@ -91,6 +94,15 @@ public class AccountSettings extends K9PreferenceActivity
private static final String PREFERENCE_LOCAL_STORAGE_PROVIDER = "local_storage_provider";
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";
private Account mAccount;
private boolean mIsPushCapable = false;
private boolean mIsExpungeCapable = false;
@ -120,7 +132,7 @@ public class AccountSettings extends K9PreferenceActivity
private ListPreference mDeletePolicy;
private ListPreference mExpungePolicy;
private ListPreference mSearchableFolders;
private Preference mAutoExpandFolder;
private ListPreference mAutoExpandFolder;
private Preference mChipColor;
private Preference mLedColor;
private boolean mIncomingChanged = false;
@ -137,6 +149,15 @@ public class AccountSettings extends K9PreferenceActivity
private ListPreference mLocalStorageProvider;
private ListPreference mArchiveFolder;
private ListPreference mDraftsFolder;
private ListPreference mOutboxFolder;
private ListPreference mSentFolder;
private ListPreference mSpamFolder;
private ListPreference mTrashFolder;
public static void actionSettings(Context context, Account account)
{
Intent i = new Intent(context, AccountSettings.class);
@ -552,16 +573,57 @@ public class AccountSettings extends K9PreferenceActivity
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
mAutoExpandFolder = (Preference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName()));
mAutoExpandFolder.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
List<? extends Folder> folders = new LinkedList<LocalFolder>();;
try
{
public boolean onPreferenceClick(Preference preference)
{
onChooseAutoExpandFolder();
return false;
}
});
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] = "";
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 = (Preference)findPreference(PREFERENCE_CHIP_COLOR);
mChipColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
@ -709,6 +771,14 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked());
mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue());
mAccount.setAutoExpandFolderName(reverseTranslateFolder(mAutoExpandFolder.getValue().toString()));
mAccount.setArchiveFolderName(mArchiveFolder.getValue().toString());
mAccount.setDraftsFolderName(mDraftsFolder.getValue().toString());
mAccount.setOutboxFolderName(mOutboxFolder.getValue().toString());
mAccount.setSentFolderName(mSentFolder.getValue().toString());
mAccount.setSpamFolderName(mSpamFolder.getValue().toString());
mAccount.setTrashFolderName(mTrashFolder.getValue().toString());
if (mIsPushCapable)
{
@ -748,7 +818,6 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setHideMessageViewMoveButtons(Account.HideButtons.valueOf(mAccountHideMoveButtons.getValue()));
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
mAccount.setEnableMoveButtons(mAccountEnableMoveButtons.isChecked());
mAccount.setAutoExpandFolderName(reverseTranslateFolder(mAutoExpandFolder.getSummary().toString()));
mAccount.save(Preferences.getPreferences(this));
if (needsRefresh && needsPushRestart)

View File

@ -30,12 +30,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
private static final String EXTRA_ACCOUNT = "account";
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
private static final int SELECT_DRAFT_FOLDER = 100;
private static final int SELECT_SENT_FOLDER = 101;
private static final int SELECT_TRASH_FOLDER = 102;
private static final int SELECT_ARCHIVE_FOLDER = 103;
private static final int SELECT_SPAM_FOLDER = 104;
private static final int popPorts[] =
{
110, 995, 995, 110, 110
@ -76,12 +70,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
private Spinner mSecurityTypeView;
private Spinner mAuthTypeView;
private EditText mImapPathPrefixView;
private Button mImapFolderDrafts;
private Button mImapFolderSent;
private Button mImapFolderTrash;
private Button mImapFolderArchive;
private Button mImapFolderSpam;
private EditText mImapFolderOutbox;
private EditText mWebdavPathPrefixView;
private EditText mWebdavAuthPathView;
private EditText mWebdavMailboxPathView;
@ -123,12 +111,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
mSecurityTypeView = (Spinner)findViewById(R.id.account_security_type);
mAuthTypeView = (Spinner)findViewById(R.id.account_auth_type);
mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix);
mImapFolderDrafts = (Button)findViewById(R.id.account_imap_folder_drafts);
mImapFolderSent = (Button)findViewById(R.id.account_imap_folder_sent);
mImapFolderTrash = (Button)findViewById(R.id.account_imap_folder_trash);
mImapFolderArchive = (Button)findViewById(R.id.account_imap_folder_archive);
mImapFolderSpam = (Button)findViewById(R.id.account_imap_folder_spam);
mImapFolderOutbox = (EditText)findViewById(R.id.account_imap_folder_outbox);
mWebdavPathPrefixView = (EditText)findViewById(R.id.webdav_path_prefix);
mWebdavAuthPathView = (EditText)findViewById(R.id.webdav_auth_path);
mWebdavMailboxPathView = (EditText)findViewById(R.id.webdav_mailbox_path);
@ -138,11 +120,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
compressionOther = (CheckBox)findViewById(R.id.compression_other);
subscribedFoldersOnly = (CheckBox)findViewById(R.id.subscribed_folders_only);
mImapFolderDrafts.setOnClickListener(this);
mImapFolderSent.setOnClickListener(this);
mImapFolderTrash.setOnClickListener(this);
mImapFolderArchive.setOnClickListener(this);
mImapFolderSpam.setOnClickListener(this);
mNextButton.setOnClickListener(this);
SpinnerOption securityTypes[] =
@ -284,21 +261,11 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
}
mImapFolderDrafts.setText(mAccount.getDraftsFolderName());
mImapFolderSent.setText(mAccount.getSentFolderName());
mImapFolderTrash.setText(mAccount.getTrashFolderName());
mImapFolderArchive.setText(mAccount.getArchiveFolderName());
mImapFolderSpam.setText(mAccount.getSpamFolderName());
mImapFolderOutbox.setText(mAccount.getOutboxFolderName());
if (uri.getScheme().startsWith("pop3"))
{
serverLabelView.setText(R.string.account_setup_incoming_pop_server_label);
mAccountPorts = popPorts;
mAccountSchemes = popSchemes;
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
findViewById(R.id.webdav_path_debug_section).setVisibility(View.GONE);
findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
@ -449,24 +416,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
{
if (resultCode == RESULT_OK)
{
switch (requestCode)
{
case SELECT_DRAFT_FOLDER:
mImapFolderDrafts.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
return;
case SELECT_SENT_FOLDER:
mImapFolderSent.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
return;
case SELECT_TRASH_FOLDER:
mImapFolderTrash.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
return;
case SELECT_ARCHIVE_FOLDER:
mImapFolderArchive.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
return;
case SELECT_SPAM_FOLDER:
mImapFolderSpam.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
return;
}
if (Intent.ACTION_EDIT.equals(getIntent().getAction()))
{
mAccount.save(Preferences.getPreferences(this));
@ -556,12 +505,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
mAccount.setStoreUri(uri.toString());
mAccount.setDraftsFolderName(mImapFolderDrafts.getText().toString());
mAccount.setSentFolderName(mImapFolderSent.getText().toString());
mAccount.setTrashFolderName(mImapFolderTrash.getText().toString());
mAccount.setArchiveFolderName(mImapFolderArchive.getText().toString());
mAccount.setSpamFolderName(mImapFolderSpam.getText().toString());
mAccount.setOutboxFolderName(mImapFolderOutbox.getText().toString());
mAccount.setCompression(Account.TYPE_MOBILE, compressionMobile.isChecked());
mAccount.setCompression(Account.TYPE_WIFI, compressionWifi.isChecked());
mAccount.setCompression(Account.TYPE_OTHER, compressionOther.isChecked());
@ -585,21 +528,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
case R.id.next:
onNext();
break;
case R.id.account_imap_folder_drafts:
selectImapFolder(SELECT_DRAFT_FOLDER);
break;
case R.id.account_imap_folder_sent:
selectImapFolder(SELECT_SENT_FOLDER);
break;
case R.id.account_imap_folder_trash:
selectImapFolder(SELECT_TRASH_FOLDER);
break;
case R.id.account_imap_folder_archive:
selectImapFolder(SELECT_ARCHIVE_FOLDER);
break;
case R.id.account_imap_folder_spam:
selectImapFolder(SELECT_SPAM_FOLDER);
break;
}
}
catch (Exception e)
@ -608,48 +536,6 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
}
}
private void selectImapFolder(int activityCode)
{
String curFolder = null;
boolean showFolderNone = false;
switch (activityCode)
{
case SELECT_DRAFT_FOLDER:
curFolder = mImapFolderDrafts.getText().toString();
break;
case SELECT_SENT_FOLDER:
curFolder = mImapFolderSent.getText().toString();
showFolderNone = true;
break;
case SELECT_TRASH_FOLDER:
curFolder = mImapFolderTrash.getText().toString();
showFolderNone = true;
break;
case SELECT_ARCHIVE_FOLDER:
curFolder = mImapFolderArchive.getText().toString();
showFolderNone = true;
break;
case SELECT_SPAM_FOLDER:
curFolder = mImapFolderSpam.getText().toString();
showFolderNone = true;
break;
default:
throw new IllegalArgumentException(
"Cannot select folder for: " + activityCode);
}
Intent selectIntent = new Intent(this, ChooseFolder.class);
String uri = mAccount.getStoreUri();
if (showFolderNone && uri.startsWith("imap"))
{
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_FOLDER_NONE, "yes");
}
selectIntent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
selectIntent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, curFolder);
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
startActivityForResult(selectIntent, activityCode);
}
private void failure(Exception use)
{
Log.e(K9.LOG_TAG, "Failure", use);