2008-11-01 17:32:06 -04:00
|
|
|
|
2008-12-16 18:34:01 -05:00
|
|
|
package com.android.email.activity.setup;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2008-12-18 19:20:56 -05:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.DialogInterface;
|
2008-11-01 17:32:06 -04:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.method.DigitsKeyListener;
|
Complete merge of DAmail functionality into K9mail. Following
features are added to K9mail:
1) Show unread message count on each folder
2) Sum unread count of all shown folders in an account to the account display
3) Periodically check selected folders for new mail, not just Inbox
4) Don't refresh folder when opened (unless folder is empty)
5) Show date and time of last sync for each folder
6) Fix timer for automatic periodic sync (use wakelock to assure completion)
7) Optimize local folder queries (speeds up account and folder lists)
8) Show Loading... message in status bar indicating which folder is being synced
9) Eliminate redundant sync of new messages (performance enhancement)
10) Improve notification text for multiple accounts
11) Do not automatically sync folders more often than the account-specific period
12) Use user-configured date and time formats
13) Select which folders are shown, using configurable Classes
14) Select which folders are synced, using configurable Classes
15) Added context (long press) menu to folders, to provide for Refresh
and Folder Settings
16) Status light flashes purple when there are unread messages
17) Folder list more quickly eliminates display of deleted and out-of-Class folders.
18) Delete works
19) Mark all messages as read (in the folder context menu)
20) Notifications only for new unread messages
21) One minute synchronization frequency
22) Deleting an unread message decrements unread counter
23) Notifications work for POP3 accounts
24) Message deletes work for POP3 accounts
25) Explicit errors show in folder list
26) Stack traces saved to folder K9mail-errors
27) Clear pending actions (danger, for emergencies only!)
28) Delete policy in Account settings
29) DNS cache in InetAddress disabled
30) Trapped some crash-causing error conditions
31) Eliminate duplicate copies to Sent folder
32) Prevent crashes due to message listener concurrency
33) Empty Trash
34) Nuclear "Mark all messages as read" (marks all messages as read in
server-side folder, irrespective of which messages have been downloaded)
35) Forward (alternate) to allow forwarding email through other programs
36) Accept text/plain Intents to allow other programs to send email through K9mail
37) Displays Outbox sending status
38) Manual retry of outbox sending when "Refresh"ing Outbox
39) Folder error status is persisted
40) Ability to log to arbitrary file
Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104,
107, 120, 148, 154
2008-12-30 22:49:09 -05:00
|
|
|
import android.util.Log;
|
2008-11-01 17:32:06 -04:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.Spinner;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2008-12-16 18:34:01 -05:00
|
|
|
import com.android.email.Account;
|
Complete merge of DAmail functionality into K9mail. Following
features are added to K9mail:
1) Show unread message count on each folder
2) Sum unread count of all shown folders in an account to the account display
3) Periodically check selected folders for new mail, not just Inbox
4) Don't refresh folder when opened (unless folder is empty)
5) Show date and time of last sync for each folder
6) Fix timer for automatic periodic sync (use wakelock to assure completion)
7) Optimize local folder queries (speeds up account and folder lists)
8) Show Loading... message in status bar indicating which folder is being synced
9) Eliminate redundant sync of new messages (performance enhancement)
10) Improve notification text for multiple accounts
11) Do not automatically sync folders more often than the account-specific period
12) Use user-configured date and time formats
13) Select which folders are shown, using configurable Classes
14) Select which folders are synced, using configurable Classes
15) Added context (long press) menu to folders, to provide for Refresh
and Folder Settings
16) Status light flashes purple when there are unread messages
17) Folder list more quickly eliminates display of deleted and out-of-Class folders.
18) Delete works
19) Mark all messages as read (in the folder context menu)
20) Notifications only for new unread messages
21) One minute synchronization frequency
22) Deleting an unread message decrements unread counter
23) Notifications work for POP3 accounts
24) Message deletes work for POP3 accounts
25) Explicit errors show in folder list
26) Stack traces saved to folder K9mail-errors
27) Clear pending actions (danger, for emergencies only!)
28) Delete policy in Account settings
29) DNS cache in InetAddress disabled
30) Trapped some crash-causing error conditions
31) Eliminate duplicate copies to Sent folder
32) Prevent crashes due to message listener concurrency
33) Empty Trash
34) Nuclear "Mark all messages as read" (marks all messages as read in
server-side folder, irrespective of which messages have been downloaded)
35) Forward (alternate) to allow forwarding email through other programs
36) Accept text/plain Intents to allow other programs to send email through K9mail
37) Displays Outbox sending status
38) Manual retry of outbox sending when "Refresh"ing Outbox
39) Folder error status is persisted
40) Ability to log to arbitrary file
Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104,
107, 120, 148, 154
2008-12-30 22:49:09 -05:00
|
|
|
import com.android.email.Email;
|
2008-12-16 18:34:01 -05:00
|
|
|
import com.android.email.Preferences;
|
|
|
|
import com.android.email.R;
|
|
|
|
import com.android.email.Utility;
|
2009-03-24 14:20:16 -04:00
|
|
|
import com.android.email.activity.ChooseFolder;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
public class AccountSetupIncoming extends Activity implements OnClickListener {
|
|
|
|
private static final String EXTRA_ACCOUNT = "account";
|
|
|
|
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
2009-03-24 14:20:16 -04:00
|
|
|
|
|
|
|
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_OUTBOX_FOLDER = 103;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
private static final int popPorts[] = {
|
|
|
|
110, 995, 995, 110, 110
|
|
|
|
};
|
|
|
|
private static final String popSchemes[] = {
|
|
|
|
"pop3", "pop3+ssl", "pop3+ssl+", "pop3+tls", "pop3+tls+"
|
|
|
|
};
|
|
|
|
private static final int imapPorts[] = {
|
|
|
|
143, 993, 993, 143, 143
|
|
|
|
};
|
|
|
|
private static final String imapSchemes[] = {
|
|
|
|
"imap", "imap+ssl", "imap+ssl+", "imap+tls", "imap+tls+"
|
|
|
|
};
|
2008-12-06 19:29:11 -05:00
|
|
|
private static final int webdavPorts[] = {
|
|
|
|
80, 443, 443, 443, 443
|
|
|
|
};
|
|
|
|
private static final String webdavSchemes[] = {
|
|
|
|
"webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
|
|
|
|
};
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
private int mAccountPorts[];
|
|
|
|
private String mAccountSchemes[];
|
|
|
|
private EditText mUsernameView;
|
|
|
|
private EditText mPasswordView;
|
|
|
|
private EditText mServerView;
|
|
|
|
private EditText mPortView;
|
|
|
|
private Spinner mSecurityTypeView;
|
|
|
|
private EditText mImapPathPrefixView;
|
2009-03-24 14:20:16 -04:00
|
|
|
private Button mImapFolderDrafts;
|
|
|
|
private Button mImapFolderSent;
|
|
|
|
private Button mImapFolderTrash;
|
|
|
|
private Button mImapFolderOutbox;
|
2009-01-21 00:27:22 -05:00
|
|
|
private EditText mWebdavPathPrefixView;
|
2009-01-25 02:37:10 -05:00
|
|
|
private EditText mWebdavAuthPathView;
|
|
|
|
private EditText mWebdavMailboxPathView;
|
2008-11-01 17:32:06 -04:00
|
|
|
private Button mNextButton;
|
|
|
|
private Account mAccount;
|
|
|
|
private boolean mMakeDefault;
|
|
|
|
|
|
|
|
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
|
|
|
|
Intent i = new Intent(context, AccountSetupIncoming.class);
|
|
|
|
i.putExtra(EXTRA_ACCOUNT, account);
|
|
|
|
i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
|
|
|
|
context.startActivity(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void actionEditIncomingSettings(Activity context, Account account) {
|
|
|
|
Intent i = new Intent(context, AccountSetupIncoming.class);
|
|
|
|
i.setAction(Intent.ACTION_EDIT);
|
|
|
|
i.putExtra(EXTRA_ACCOUNT, account);
|
|
|
|
context.startActivity(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.account_setup_incoming);
|
|
|
|
|
|
|
|
mUsernameView = (EditText)findViewById(R.id.account_username);
|
|
|
|
mPasswordView = (EditText)findViewById(R.id.account_password);
|
|
|
|
TextView serverLabelView = (TextView) findViewById(R.id.account_server_label);
|
|
|
|
mServerView = (EditText)findViewById(R.id.account_server);
|
|
|
|
mPortView = (EditText)findViewById(R.id.account_port);
|
|
|
|
mSecurityTypeView = (Spinner)findViewById(R.id.account_security_type);
|
|
|
|
mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix);
|
2009-03-24 14:20:16 -04:00
|
|
|
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);
|
|
|
|
mImapFolderOutbox = (Button)findViewById(R.id.account_imap_folder_outbox);
|
2009-01-21 00:27:22 -05:00
|
|
|
mWebdavPathPrefixView = (EditText)findViewById(R.id.webdav_path_prefix);
|
2009-01-25 02:37:10 -05:00
|
|
|
mWebdavAuthPathView = (EditText)findViewById(R.id.webdav_auth_path);
|
|
|
|
mWebdavMailboxPathView = (EditText)findViewById(R.id.webdav_mailbox_path);
|
2008-11-01 17:32:06 -04:00
|
|
|
mNextButton = (Button)findViewById(R.id.next);
|
|
|
|
|
2009-03-24 14:20:16 -04:00
|
|
|
mImapFolderDrafts.setOnClickListener(this);
|
|
|
|
mImapFolderSent.setOnClickListener(this);
|
|
|
|
mImapFolderTrash.setOnClickListener(this);
|
|
|
|
mImapFolderOutbox.setOnClickListener(this);
|
2008-11-01 17:32:06 -04:00
|
|
|
mNextButton.setOnClickListener(this);
|
|
|
|
|
|
|
|
SpinnerOption securityTypes[] = {
|
|
|
|
new SpinnerOption(0, getString(R.string.account_setup_incoming_security_none_label)),
|
|
|
|
new SpinnerOption(1,
|
|
|
|
getString(R.string.account_setup_incoming_security_ssl_optional_label)),
|
|
|
|
new SpinnerOption(2, getString(R.string.account_setup_incoming_security_ssl_label)),
|
|
|
|
new SpinnerOption(3,
|
|
|
|
getString(R.string.account_setup_incoming_security_tls_optional_label)),
|
|
|
|
new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
|
|
|
|
};
|
|
|
|
|
|
|
|
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
|
|
|
android.R.layout.simple_spinner_item, securityTypes);
|
|
|
|
securityTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
mSecurityTypeView.setAdapter(securityTypesAdapter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates the port when the user changes the security type. This allows
|
|
|
|
* us to show a reasonable default which the user can change.
|
|
|
|
*/
|
|
|
|
mSecurityTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) {
|
|
|
|
updatePortFromSecurityType();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onNothingSelected(AdapterView<?> arg0) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calls validateFields() which enables or disables the Next button
|
|
|
|
* based on the fields' validity.
|
|
|
|
*/
|
|
|
|
TextWatcher validationTextWatcher = new TextWatcher() {
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
validateFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
mUsernameView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mPasswordView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mServerView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mPortView.addTextChangedListener(validationTextWatcher);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only allow digits in the port field.
|
|
|
|
*/
|
|
|
|
mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
|
|
|
|
|
|
|
|
mAccount = (Account)getIntent().getSerializableExtra(EXTRA_ACCOUNT);
|
|
|
|
mMakeDefault = (boolean)getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're being reloaded we override the original account with the one
|
|
|
|
* we saved
|
|
|
|
*/
|
|
|
|
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_ACCOUNT)) {
|
|
|
|
mAccount = (Account)savedInstanceState.getSerializable(EXTRA_ACCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
URI uri = new URI(mAccount.getStoreUri());
|
|
|
|
String username = null;
|
|
|
|
String password = null;
|
|
|
|
if (uri.getUserInfo() != null) {
|
|
|
|
String[] userInfoParts = uri.getUserInfo().split(":", 2);
|
|
|
|
username = userInfoParts[0];
|
|
|
|
if (userInfoParts.length > 1) {
|
|
|
|
password = userInfoParts[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (username != null) {
|
|
|
|
mUsernameView.setText(username);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (password != null) {
|
|
|
|
mPasswordView.setText(password);
|
|
|
|
}
|
2009-04-09 11:05:24 -04:00
|
|
|
|
|
|
|
mImapFolderDrafts.setText(mAccount.getDraftsFolderName());
|
|
|
|
mImapFolderSent.setText(mAccount.getSentFolderName());
|
|
|
|
mImapFolderTrash.setText(mAccount.getTrashFolderName());
|
|
|
|
mImapFolderOutbox.setText(mAccount.getOutboxFolderName());
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
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);
|
2009-03-11 21:13:26 -04:00
|
|
|
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
2009-01-21 00:27:22 -05:00
|
|
|
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
|
2009-01-25 02:37:10 -05:00
|
|
|
findViewById(R.id.webdav_path_debug_section).setVisibility(View.GONE);
|
2008-11-01 17:32:06 -04:00
|
|
|
} else if (uri.getScheme().startsWith("imap")) {
|
|
|
|
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
|
|
|
|
mAccountPorts = imapPorts;
|
|
|
|
mAccountSchemes = imapSchemes;
|
|
|
|
|
|
|
|
if (uri.getPath() != null && uri.getPath().length() > 0) {
|
|
|
|
mImapPathPrefixView.setText(uri.getPath().substring(1));
|
|
|
|
}
|
2009-01-21 00:27:22 -05:00
|
|
|
findViewById(R.id.webdav_path_prefix_section).setVisibility(View.GONE);
|
2009-01-25 02:37:10 -05:00
|
|
|
findViewById(R.id.webdav_path_debug_section).setVisibility(View.GONE);
|
2009-03-11 21:13:26 -04:00
|
|
|
|
2008-12-06 19:29:11 -05:00
|
|
|
} else if (uri.getScheme().startsWith("webdav")) {
|
|
|
|
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
|
|
|
|
mAccountPorts = webdavPorts;
|
|
|
|
mAccountSchemes = webdavSchemes;
|
2008-12-14 21:18:02 -05:00
|
|
|
|
|
|
|
/** Hide the unnecessary fields */
|
|
|
|
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
|
2009-03-11 21:13:26 -04:00
|
|
|
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
2009-01-21 00:27:22 -05:00
|
|
|
if (uri.getPath() != null && uri.getPath().length() > 0) {
|
2009-01-25 02:37:10 -05:00
|
|
|
String[] pathParts = uri.getPath().split("\\|");
|
|
|
|
|
|
|
|
for (int i = 0, count = pathParts.length; i < count; i++) {
|
|
|
|
if (i == 0) {
|
2009-01-31 17:09:16 -05:00
|
|
|
if (pathParts[0] != null &&
|
|
|
|
pathParts[0].length() > 1) {
|
2009-01-25 02:37:10 -05:00
|
|
|
mWebdavPathPrefixView.setText(pathParts[0].substring(1));
|
|
|
|
}
|
|
|
|
} else if (i == 1) {
|
2009-01-31 17:09:16 -05:00
|
|
|
if (pathParts[1] != null &&
|
|
|
|
pathParts[1].length() > 1) {
|
2009-01-25 02:37:10 -05:00
|
|
|
mWebdavAuthPathView.setText(pathParts[1]);
|
|
|
|
}
|
|
|
|
} else if (i == 2) {
|
2009-01-31 17:09:16 -05:00
|
|
|
if (pathParts[2] != null &&
|
|
|
|
pathParts[2].length() > 1) {
|
2009-01-25 02:37:10 -05:00
|
|
|
mWebdavMailboxPathView.setText(pathParts[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-21 00:27:22 -05:00
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
} else {
|
|
|
|
throw new Error("Unknown account type: " + mAccount.getStoreUri());
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < mAccountSchemes.length; i++) {
|
|
|
|
if (mAccountSchemes[i].equals(uri.getScheme())) {
|
|
|
|
SpinnerOption.setSpinnerOptionValue(mSecurityTypeView, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uri.getHost() != null) {
|
|
|
|
mServerView.setText(uri.getHost());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uri.getPort() != -1) {
|
|
|
|
mPortView.setText(Integer.toString(uri.getPort()));
|
|
|
|
} else {
|
|
|
|
updatePortFromSecurityType();
|
|
|
|
}
|
|
|
|
} catch (URISyntaxException use) {
|
|
|
|
/*
|
|
|
|
* We should always be able to parse our own settings.
|
|
|
|
*/
|
|
|
|
throw new Error(use);
|
|
|
|
}
|
|
|
|
|
|
|
|
validateFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
outState.putSerializable(EXTRA_ACCOUNT, mAccount);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void validateFields() {
|
|
|
|
mNextButton
|
|
|
|
.setEnabled(Utility.requiredFieldValid(mUsernameView)
|
|
|
|
&& Utility.requiredFieldValid(mPasswordView)
|
2008-12-18 19:20:56 -05:00
|
|
|
&& Utility.domainFieldValid(mServerView)
|
2008-11-01 17:32:06 -04:00
|
|
|
&& Utility.requiredFieldValid(mPortView));
|
|
|
|
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePortFromSecurityType() {
|
|
|
|
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
|
|
|
|
mPortView.setText(Integer.toString(mAccountPorts[securityType]));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
2009-03-24 14:20:16 -04:00
|
|
|
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_OUTBOX_FOLDER:
|
|
|
|
mImapFolderOutbox.setText(data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER));
|
|
|
|
return;
|
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
|
|
|
mAccount.save(Preferences.getPreferences(this));
|
|
|
|
finish();
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Set the username and password for the outgoing settings to the username and
|
|
|
|
* password the user just set for incoming.
|
|
|
|
*/
|
|
|
|
try {
|
|
|
|
URI oldUri = new URI(mAccount.getTransportUri());
|
|
|
|
URI uri = new URI(
|
|
|
|
oldUri.getScheme(),
|
|
|
|
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
|
|
|
oldUri.getHost(),
|
|
|
|
oldUri.getPort(),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null);
|
|
|
|
mAccount.setTransportUri(uri.toString());
|
|
|
|
} catch (URISyntaxException use) {
|
|
|
|
/*
|
|
|
|
* If we can't set up the URL we just continue. It's only for
|
|
|
|
* convenience.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount, mMakeDefault);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onNext() {
|
2009-01-25 02:37:10 -05:00
|
|
|
int securityType = (Integer)((SpinnerOption)mSecurityTypeView.getSelectedItem()).value;
|
|
|
|
try {
|
|
|
|
String path = null;
|
|
|
|
if (mAccountSchemes[securityType].startsWith("imap")) {
|
|
|
|
path = "/" + mImapPathPrefixView.getText();
|
|
|
|
} else if (mAccountSchemes[securityType].startsWith("webdav")) {
|
|
|
|
path = "/" + mWebdavPathPrefixView.getText();
|
|
|
|
path = path + "|" + mWebdavAuthPathView.getText();
|
|
|
|
path = path + "|" + mWebdavMailboxPathView.getText();
|
|
|
|
}
|
|
|
|
|
|
|
|
URI uri = new URI(
|
|
|
|
mAccountSchemes[securityType],
|
|
|
|
mUsernameView.getText() + ":" + mPasswordView.getText(),
|
|
|
|
mServerView.getText().toString(),
|
|
|
|
Integer.parseInt(mPortView.getText().toString()),
|
|
|
|
path, // path
|
|
|
|
null, // query
|
|
|
|
null);
|
|
|
|
mAccount.setStoreUri(uri.toString());
|
|
|
|
} catch (URISyntaxException use) {
|
|
|
|
/*
|
|
|
|
* It's unrecoverable if we cannot create a URI from components that
|
|
|
|
* we validated to be safe.
|
|
|
|
*/
|
|
|
|
throw new Error(use);
|
|
|
|
}
|
2008-12-18 19:20:56 -05:00
|
|
|
|
2009-03-11 21:13:26 -04:00
|
|
|
mAccount.setDraftsFolderName(mImapFolderDrafts.getText().toString());
|
|
|
|
mAccount.setSentFolderName(mImapFolderSent.getText().toString());
|
|
|
|
mAccount.setTrashFolderName(mImapFolderTrash.getText().toString());
|
|
|
|
mAccount.setOutboxFolderName(mImapFolderOutbox.getText().toString());
|
Complete merge of DAmail functionality into K9mail. Following
features are added to K9mail:
1) Show unread message count on each folder
2) Sum unread count of all shown folders in an account to the account display
3) Periodically check selected folders for new mail, not just Inbox
4) Don't refresh folder when opened (unless folder is empty)
5) Show date and time of last sync for each folder
6) Fix timer for automatic periodic sync (use wakelock to assure completion)
7) Optimize local folder queries (speeds up account and folder lists)
8) Show Loading... message in status bar indicating which folder is being synced
9) Eliminate redundant sync of new messages (performance enhancement)
10) Improve notification text for multiple accounts
11) Do not automatically sync folders more often than the account-specific period
12) Use user-configured date and time formats
13) Select which folders are shown, using configurable Classes
14) Select which folders are synced, using configurable Classes
15) Added context (long press) menu to folders, to provide for Refresh
and Folder Settings
16) Status light flashes purple when there are unread messages
17) Folder list more quickly eliminates display of deleted and out-of-Class folders.
18) Delete works
19) Mark all messages as read (in the folder context menu)
20) Notifications only for new unread messages
21) One minute synchronization frequency
22) Deleting an unread message decrements unread counter
23) Notifications work for POP3 accounts
24) Message deletes work for POP3 accounts
25) Explicit errors show in folder list
26) Stack traces saved to folder K9mail-errors
27) Clear pending actions (danger, for emergencies only!)
28) Delete policy in Account settings
29) DNS cache in InetAddress disabled
30) Trapped some crash-causing error conditions
31) Eliminate duplicate copies to Sent folder
32) Prevent crashes due to message listener concurrency
33) Empty Trash
34) Nuclear "Mark all messages as read" (marks all messages as read in
server-side folder, irrespective of which messages have been downloaded)
35) Forward (alternate) to allow forwarding email through other programs
36) Accept text/plain Intents to allow other programs to send email through K9mail
37) Displays Outbox sending status
38) Manual retry of outbox sending when "Refresh"ing Outbox
39) Folder error status is persisted
40) Ability to log to arbitrary file
Fixes K9 issues 11, 23, 24, 65, 69, 71, 79, 81, 82, 83, 87, 101, 104,
107, 120, 148, 154
2008-12-30 22:49:09 -05:00
|
|
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
switch (v.getId()) {
|
|
|
|
case R.id.next:
|
|
|
|
onNext();
|
|
|
|
break;
|
2009-03-24 14:20:16 -04:00
|
|
|
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_outbox:
|
|
|
|
selectImapFolder(SELECT_OUTBOX_FOLDER);
|
|
|
|
break;
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
}
|
2009-03-24 14:20:16 -04:00
|
|
|
|
|
|
|
private void selectImapFolder(int activityCode) {
|
|
|
|
String curFolder = null;
|
|
|
|
switch (activityCode) {
|
|
|
|
case SELECT_DRAFT_FOLDER:
|
|
|
|
curFolder = mImapFolderDrafts.getText().toString();
|
|
|
|
break;
|
|
|
|
case SELECT_SENT_FOLDER:
|
|
|
|
curFolder = mImapFolderSent.getText().toString();
|
|
|
|
break;
|
|
|
|
case SELECT_TRASH_FOLDER:
|
|
|
|
curFolder = mImapFolderTrash.getText().toString();
|
|
|
|
break;
|
|
|
|
case SELECT_OUTBOX_FOLDER:
|
|
|
|
curFolder = mImapFolderOutbox.getText().toString();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"Cannot select folder for: " + activityCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent selectIntent = new Intent(this, ChooseFolder.class);
|
|
|
|
selectIntent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount);
|
|
|
|
selectIntent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, curFolder);
|
|
|
|
selectIntent.putExtra(ChooseFolder.EXTRA_SHOW_CURRENT, "yes");
|
|
|
|
startActivityForResult(selectIntent, activityCode);
|
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|