2008-11-01 17:32:06 -04:00
|
|
|
|
2009-12-14 21:50:53 -05:00
|
|
|
package com.fsck.k9.activity.setup;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import android.app.Activity;
|
2013-01-17 09:24:22 -05:00
|
|
|
import android.content.Context;
|
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;
|
2009-12-09 22:16:42 -05:00
|
|
|
import android.widget.*;
|
2014-07-13 14:08:24 -04:00
|
|
|
import android.widget.AdapterView.OnItemSelectedListener;
|
2011-12-01 00:05:05 -05:00
|
|
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
2010-03-06 19:30:40 -05:00
|
|
|
|
2009-12-14 21:50:53 -05:00
|
|
|
import com.fsck.k9.*;
|
2015-02-15 02:37:52 -05:00
|
|
|
import com.fsck.k9.Account.DeletePolicy;
|
2014-02-28 19:33:25 -05:00
|
|
|
import com.fsck.k9.Account.FolderMode;
|
2015-02-15 02:37:52 -05:00
|
|
|
import com.fsck.k9.Account.NetworkType;
|
2010-05-19 14:17:06 -04:00
|
|
|
import com.fsck.k9.activity.K9Activity;
|
2013-11-23 13:26:57 -05:00
|
|
|
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
2010-05-19 14:17:06 -04:00
|
|
|
import com.fsck.k9.helper.Utility;
|
2014-02-13 17:18:16 -05:00
|
|
|
import com.fsck.k9.mail.AuthType;
|
2011-11-30 20:28:57 -05:00
|
|
|
import com.fsck.k9.mail.ConnectionSecurity;
|
|
|
|
import com.fsck.k9.mail.ServerSettings;
|
|
|
|
import com.fsck.k9.mail.Store;
|
2014-05-25 16:45:14 -04:00
|
|
|
import com.fsck.k9.mail.Transport;
|
2014-12-18 03:33:09 -05:00
|
|
|
import com.fsck.k9.mail.store.imap.ImapStore;
|
|
|
|
import com.fsck.k9.mail.store.pop3.Pop3Store;
|
2014-12-11 22:23:32 -05:00
|
|
|
import com.fsck.k9.mail.store.RemoteStore;
|
2014-12-18 03:33:09 -05:00
|
|
|
import com.fsck.k9.mail.store.webdav.WebDavStore;
|
|
|
|
import com.fsck.k9.mail.store.imap.ImapStore.ImapStoreSettings;
|
|
|
|
import com.fsck.k9.mail.store.webdav.WebDavStore.WebDavStoreSettings;
|
2014-05-25 16:45:14 -04:00
|
|
|
import com.fsck.k9.mail.transport.SmtpTransport;
|
2014-02-28 19:33:25 -05:00
|
|
|
import com.fsck.k9.service.MailService;
|
2014-05-25 16:45:14 -04:00
|
|
|
import com.fsck.k9.view.ClientCertificateSpinner;
|
|
|
|
import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListener;
|
2010-11-13 16:40:56 -05:00
|
|
|
|
2009-12-09 22:16:42 -05:00
|
|
|
import java.net.URI;
|
|
|
|
import java.net.URISyntaxException;
|
2011-11-30 23:10:13 -05:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
2009-12-09 22:16:42 -05:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public class AccountSetupIncoming extends K9Activity implements OnClickListener {
|
2013-01-17 09:24:22 -05:00
|
|
|
private static final String EXTRA_ACCOUNT = "account";
|
2008-11-01 17:32:06 -04:00
|
|
|
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
2014-07-28 12:56:01 -04:00
|
|
|
private static final String STATE_SECURITY_TYPE_POSITION = "stateSecurityTypePosition";
|
2014-07-28 15:29:44 -04:00
|
|
|
private static final String STATE_AUTH_TYPE_POSITION = "authTypePosition";
|
2009-11-21 17:45:39 -05:00
|
|
|
|
2014-02-13 19:43:24 -05:00
|
|
|
private static final String POP3_PORT = "110";
|
|
|
|
private static final String POP3_SSL_PORT = "995";
|
|
|
|
private static final String IMAP_PORT = "143";
|
|
|
|
private static final String IMAP_SSL_PORT = "993";
|
|
|
|
private static final String WEBDAV_PORT = "80";
|
|
|
|
private static final String WEBDAV_SSL_PORT = "443";
|
|
|
|
|
2011-11-30 23:10:13 -05:00
|
|
|
private String mStoreType;
|
2008-11-01 17:32:06 -04:00
|
|
|
private EditText mUsernameView;
|
|
|
|
private EditText mPasswordView;
|
2014-05-25 16:45:14 -04:00
|
|
|
private ClientCertificateSpinner mClientCertificateSpinner;
|
|
|
|
private TextView mClientCertificateLabelView;
|
|
|
|
private TextView mPasswordLabelView;
|
2008-11-01 17:32:06 -04:00
|
|
|
private EditText mServerView;
|
|
|
|
private EditText mPortView;
|
2014-07-13 14:08:24 -04:00
|
|
|
private String mCurrentPortViewSetting;
|
2008-11-01 17:32:06 -04:00
|
|
|
private Spinner mSecurityTypeView;
|
2014-07-13 14:08:24 -04:00
|
|
|
private int mCurrentSecurityTypeViewPosition;
|
2009-12-20 00:15:20 -05:00
|
|
|
private Spinner mAuthTypeView;
|
2014-07-13 14:08:24 -04:00
|
|
|
private int mCurrentAuthTypeViewPosition;
|
2011-12-01 00:05:05 -05:00
|
|
|
private CheckBox mImapAutoDetectNamespaceView;
|
2008-11-01 17:32:06 -04:00
|
|
|
private EditText mImapPathPrefixView;
|
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;
|
2011-05-14 16:17:15 -04:00
|
|
|
private CheckBox mCompressionMobile;
|
|
|
|
private CheckBox mCompressionWifi;
|
|
|
|
private CheckBox mCompressionOther;
|
|
|
|
private CheckBox mSubscribedFoldersOnly;
|
2014-12-17 13:37:18 -05:00
|
|
|
private AuthTypeAdapter mAuthTypeAdapter;
|
2014-02-13 19:43:24 -05:00
|
|
|
private String mDefaultPort = "";
|
|
|
|
private String mDefaultSslPort = "";
|
2014-02-26 17:59:29 -05:00
|
|
|
private ConnectionSecurity[] mConnectionSecurityChoices = ConnectionSecurity.values();
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
|
2008-11-01 17:32:06 -04:00
|
|
|
Intent i = new Intent(context, AccountSetupIncoming.class);
|
2010-03-03 23:00:30 -05:00
|
|
|
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
2008-11-01 17:32:06 -04:00
|
|
|
i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
|
|
|
|
context.startActivity(i);
|
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public static void actionEditIncomingSettings(Activity context, Account account) {
|
2013-01-17 09:24:22 -05:00
|
|
|
context.startActivity(intentActionEditIncomingSettings(context, account));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Intent intentActionEditIncomingSettings(Context context, Account account) {
|
2008-11-01 17:32:06 -04:00
|
|
|
Intent i = new Intent(context, AccountSetupIncoming.class);
|
|
|
|
i.setAction(Intent.ACTION_EDIT);
|
2010-03-03 23:00:30 -05:00
|
|
|
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
2013-01-17 09:24:22 -05:00
|
|
|
return i;
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-02-06 17:09:48 -05:00
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
2008-11-01 17:32:06 -04:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.account_setup_incoming);
|
|
|
|
|
|
|
|
mUsernameView = (EditText)findViewById(R.id.account_username);
|
|
|
|
mPasswordView = (EditText)findViewById(R.id.account_password);
|
2014-05-25 16:45:14 -04:00
|
|
|
mClientCertificateSpinner = (ClientCertificateSpinner)findViewById(R.id.account_client_certificate_spinner);
|
|
|
|
mClientCertificateLabelView = (TextView)findViewById(R.id.account_client_certificate_label);
|
|
|
|
mPasswordLabelView = (TextView)findViewById(R.id.account_password_label);
|
2008-11-01 17:32:06 -04:00
|
|
|
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);
|
2009-12-20 00:15:20 -05:00
|
|
|
mAuthTypeView = (Spinner)findViewById(R.id.account_auth_type);
|
2011-12-01 00:05:05 -05:00
|
|
|
mImapAutoDetectNamespaceView = (CheckBox)findViewById(R.id.imap_autodetect_namespace);
|
2008-11-01 17:32:06 -04:00
|
|
|
mImapPathPrefixView = (EditText)findViewById(R.id.imap_path_prefix);
|
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);
|
2011-05-14 16:17:15 -04:00
|
|
|
mCompressionMobile = (CheckBox)findViewById(R.id.compression_mobile);
|
|
|
|
mCompressionWifi = (CheckBox)findViewById(R.id.compression_wifi);
|
|
|
|
mCompressionOther = (CheckBox)findViewById(R.id.compression_other);
|
|
|
|
mSubscribedFoldersOnly = (CheckBox)findViewById(R.id.subscribed_folders_only);
|
2010-05-11 22:51:59 -04:00
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
mNextButton.setOnClickListener(this);
|
|
|
|
|
2011-12-01 00:05:05 -05:00
|
|
|
mImapAutoDetectNamespaceView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
mImapPathPrefixView.setEnabled(!isChecked);
|
|
|
|
if (isChecked && mImapPathPrefixView.hasFocus()) {
|
|
|
|
mImapPathPrefixView.focusSearch(View.FOCUS_UP).requestFocus();
|
|
|
|
} else if (!isChecked) {
|
|
|
|
mImapPathPrefixView.requestFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
mAuthTypeAdapter = AuthTypeAdapter.get(this);
|
2014-05-25 16:45:14 -04:00
|
|
|
mAuthTypeView.setAdapter(mAuthTypeAdapter);
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only allow digits in the port field.
|
|
|
|
*/
|
|
|
|
mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
|
|
|
|
|
2010-03-03 23:00:30 -05:00
|
|
|
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
|
|
|
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
2010-11-30 22:06:12 -05:00
|
|
|
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're being reloaded we override the original account with the one
|
|
|
|
* we saved
|
|
|
|
*/
|
2011-02-06 17:09:48 -05:00
|
|
|
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_ACCOUNT)) {
|
2010-03-03 23:00:30 -05:00
|
|
|
accountUuid = savedInstanceState.getString(EXTRA_ACCOUNT);
|
|
|
|
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
try {
|
2014-12-11 22:23:32 -05:00
|
|
|
ServerSettings settings = RemoteStore.decodeStoreUri(mAccount.getStoreUri());
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2014-07-28 15:29:44 -04:00
|
|
|
if (savedInstanceState == null) {
|
|
|
|
// The first item is selected if settings.authenticationType is null or is not in mAuthTypeAdapter
|
2014-12-17 13:37:18 -05:00
|
|
|
mCurrentAuthTypeViewPosition = mAuthTypeAdapter.getAuthPosition(settings.authenticationType);
|
2014-07-28 15:29:44 -04:00
|
|
|
} else {
|
|
|
|
mCurrentAuthTypeViewPosition = savedInstanceState.getInt(STATE_AUTH_TYPE_POSITION);
|
|
|
|
}
|
2014-07-13 14:08:24 -04:00
|
|
|
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
|
|
|
|
updateViewFromAuthType();
|
2014-05-25 16:45:14 -04:00
|
|
|
|
2011-11-30 20:28:57 -05:00
|
|
|
if (settings.username != null) {
|
|
|
|
mUsernameView.setText(settings.username);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2011-11-30 20:28:57 -05:00
|
|
|
if (settings.password != null) {
|
|
|
|
mPasswordView.setText(settings.password);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
2009-11-21 17:45:39 -05:00
|
|
|
|
2014-05-25 16:45:14 -04:00
|
|
|
if (settings.clientCertificateAlias != null) {
|
|
|
|
mClientCertificateSpinner.setAlias(settings.clientCertificateAlias);
|
|
|
|
}
|
2009-12-21 12:49:16 -05:00
|
|
|
|
2011-11-30 23:10:13 -05:00
|
|
|
mStoreType = settings.type;
|
2011-11-30 20:28:57 -05:00
|
|
|
if (Pop3Store.STORE_TYPE.equals(settings.type)) {
|
2008-11-01 17:32:06 -04:00
|
|
|
serverLabelView.setText(R.string.account_setup_incoming_pop_server_label);
|
2014-02-13 19:43:24 -05:00
|
|
|
mDefaultPort = POP3_PORT;
|
|
|
|
mDefaultSslPort = POP3_SSL_PORT;
|
2011-01-28 17:45:10 -05:00
|
|
|
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
|
2010-03-06 19:30:40 -05:00
|
|
|
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
2010-05-30 12:56:50 -04:00
|
|
|
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
2011-05-14 16:17:15 -04:00
|
|
|
mSubscribedFoldersOnly.setVisibility(View.GONE);
|
2015-02-15 02:37:52 -05:00
|
|
|
mAccount.setDeletePolicy(DeletePolicy.NEVER);
|
2011-11-30 20:28:57 -05:00
|
|
|
} else if (ImapStore.STORE_TYPE.equals(settings.type)) {
|
2008-11-01 17:32:06 -04:00
|
|
|
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
|
2014-02-13 19:43:24 -05:00
|
|
|
mDefaultPort = IMAP_PORT;
|
|
|
|
mDefaultSslPort = IMAP_SSL_PORT;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
2011-11-30 20:28:57 -05:00
|
|
|
ImapStoreSettings imapSettings = (ImapStoreSettings) settings;
|
2011-12-01 00:05:05 -05:00
|
|
|
|
|
|
|
mImapAutoDetectNamespaceView.setChecked(imapSettings.autoDetectNamespace);
|
2011-11-30 20:28:57 -05:00
|
|
|
if (imapSettings.pathPrefix != null) {
|
|
|
|
mImapPathPrefixView.setText(imapSettings.pathPrefix);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
2011-01-28 17:45:10 -05:00
|
|
|
|
|
|
|
findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
|
|
|
|
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
|
2015-02-15 02:37:52 -05:00
|
|
|
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
|
2009-11-16 13:23:56 -05:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
2009-11-16 13:23:56 -05:00
|
|
|
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
|
|
|
}
|
2011-11-30 20:28:57 -05:00
|
|
|
} else if (WebDavStore.STORE_TYPE.equals(settings.type)) {
|
2008-12-06 19:29:11 -05:00
|
|
|
serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
|
2014-02-13 19:43:24 -05:00
|
|
|
mDefaultPort = WEBDAV_PORT;
|
|
|
|
mDefaultSslPort = WEBDAV_SSL_PORT;
|
2014-02-26 17:59:29 -05:00
|
|
|
mConnectionSecurityChoices = new ConnectionSecurity[] {
|
|
|
|
ConnectionSecurity.NONE,
|
|
|
|
ConnectionSecurity.SSL_TLS_REQUIRED };
|
2008-12-14 21:18:02 -05:00
|
|
|
|
2011-11-30 23:17:32 -05:00
|
|
|
// Hide the unnecessary fields
|
2008-12-14 21:18:02 -05:00
|
|
|
findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
|
2010-05-30 12:56:50 -04:00
|
|
|
findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
|
2009-12-20 00:15:20 -05:00
|
|
|
findViewById(R.id.account_auth_type).setVisibility(View.GONE);
|
2010-03-06 19:30:40 -05:00
|
|
|
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
2010-05-30 12:56:50 -04:00
|
|
|
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
2011-05-14 16:17:15 -04:00
|
|
|
mSubscribedFoldersOnly.setVisibility(View.GONE);
|
2011-11-30 20:28:57 -05:00
|
|
|
|
|
|
|
WebDavStoreSettings webDavSettings = (WebDavStoreSettings) settings;
|
|
|
|
|
|
|
|
if (webDavSettings.path != null) {
|
|
|
|
mWebdavPathPrefixView.setText(webDavSettings.path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (webDavSettings.authPath != null) {
|
|
|
|
mWebdavAuthPathView.setText(webDavSettings.authPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (webDavSettings.mailboxPath != null) {
|
|
|
|
mWebdavMailboxPathView.setText(webDavSettings.mailboxPath);
|
2009-01-21 00:27:22 -05:00
|
|
|
}
|
2015-02-15 02:37:52 -05:00
|
|
|
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
|
2011-02-06 17:09:48 -05:00
|
|
|
} else {
|
2009-11-07 11:21:47 -05:00
|
|
|
throw new Exception("Unknown account type: " + mAccount.getStoreUri());
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2014-07-14 13:54:13 -04:00
|
|
|
// Note that mConnectionSecurityChoices is configured above based on server type
|
2014-12-17 13:37:18 -05:00
|
|
|
ConnectionSecurityAdapter securityTypesAdapter =
|
|
|
|
ConnectionSecurityAdapter.get(this, mConnectionSecurityChoices);
|
2014-07-14 13:54:13 -04:00
|
|
|
mSecurityTypeView.setAdapter(securityTypesAdapter);
|
|
|
|
|
|
|
|
// Select currently configured security type
|
2014-07-28 12:56:01 -04:00
|
|
|
if (savedInstanceState == null) {
|
2014-12-17 13:37:18 -05:00
|
|
|
mCurrentSecurityTypeViewPosition = securityTypesAdapter.getConnectionSecurityPosition(settings.connectionSecurity);
|
2014-07-28 12:56:01 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the spinner state now, before calling
|
|
|
|
* setOnItemSelectedListener(), thus avoiding a call to
|
|
|
|
* onItemSelected(). Then, when the system restores the state
|
|
|
|
* (again) in onRestoreInstanceState(), The system will see that
|
|
|
|
* the new state is the same as the current state (set here), so
|
|
|
|
* once again onItemSelected() will not be called.
|
|
|
|
*/
|
|
|
|
mCurrentSecurityTypeViewPosition = savedInstanceState.getInt(STATE_SECURITY_TYPE_POSITION);
|
|
|
|
}
|
2014-07-14 13:54:13 -04:00
|
|
|
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
|
|
|
|
|
|
|
|
updateAuthPlainTextFromSecurityType(settings.connectionSecurity);
|
|
|
|
|
2015-02-15 02:37:52 -05:00
|
|
|
mCompressionMobile.setChecked(mAccount.useCompression(NetworkType.MOBILE));
|
|
|
|
mCompressionWifi.setChecked(mAccount.useCompression(NetworkType.WIFI));
|
|
|
|
mCompressionOther.setChecked(mAccount.useCompression(NetworkType.OTHER));
|
2010-05-21 11:34:29 -04:00
|
|
|
|
2011-11-30 20:28:57 -05:00
|
|
|
if (settings.host != null) {
|
|
|
|
mServerView.setText(settings.host);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2011-11-30 20:28:57 -05:00
|
|
|
if (settings.port != -1) {
|
|
|
|
mPortView.setText(Integer.toString(settings.port));
|
2011-02-06 17:09:48 -05:00
|
|
|
} else {
|
2008-11-01 17:32:06 -04:00
|
|
|
updatePortFromSecurityType();
|
|
|
|
}
|
2014-07-13 14:08:24 -04:00
|
|
|
mCurrentPortViewSetting = mPortView.getText().toString();
|
2010-05-21 11:34:29 -04:00
|
|
|
|
2011-05-14 16:17:15 -04:00
|
|
|
mSubscribedFoldersOnly.setChecked(mAccount.subscribedFoldersOnly());
|
2011-02-06 17:09:48 -05:00
|
|
|
} catch (Exception e) {
|
2009-11-07 11:21:47 -05:00
|
|
|
failure(e);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-13 14:08:24 -04:00
|
|
|
/**
|
2014-07-17 11:36:54 -04:00
|
|
|
* Called at the end of either {@code onCreate()} or
|
|
|
|
* {@code onRestoreInstanceState()}, after the views have been initialized,
|
|
|
|
* so that the listeners are not triggered during the view initialization.
|
|
|
|
* This avoids needless calls to {@code validateFields()} which is called
|
|
|
|
* immediately after this is called.
|
2014-07-13 14:08:24 -04:00
|
|
|
*/
|
|
|
|
private void initializeViewListeners() {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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() {
|
|
|
|
@Override
|
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
|
|
|
long id) {
|
2014-07-28 12:56:01 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We keep our own record of the spinner state so we
|
|
|
|
* know for sure that onItemSelected() was called
|
|
|
|
* because of user input, not because of spinner
|
|
|
|
* state initialization. This assures that the port
|
|
|
|
* will not be replaced with a default value except
|
|
|
|
* on user input.
|
|
|
|
*/
|
|
|
|
if (mCurrentSecurityTypeViewPosition != position) {
|
|
|
|
updatePortFromSecurityType();
|
|
|
|
validateFields();
|
|
|
|
}
|
2014-07-13 14:08:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
|
|
|
|
});
|
|
|
|
|
|
|
|
mAuthTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
@Override
|
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
|
|
|
long id) {
|
2014-07-28 15:29:44 -04:00
|
|
|
if (mCurrentAuthTypeViewPosition == position) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-13 14:08:24 -04:00
|
|
|
updateViewFromAuthType();
|
|
|
|
validateFields();
|
2014-12-17 13:37:18 -05:00
|
|
|
AuthType selection = getSelectedAuthType();
|
2014-07-23 15:25:50 -04:00
|
|
|
|
|
|
|
// Have the user select (or confirm) the client certificate
|
2014-08-18 18:12:39 -04:00
|
|
|
if (AuthType.EXTERNAL == selection) {
|
2014-07-23 15:25:50 -04:00
|
|
|
|
|
|
|
// This may again invoke validateFields()
|
|
|
|
mClientCertificateSpinner.chooseCertificate();
|
|
|
|
} else {
|
|
|
|
mPasswordView.requestFocus();
|
|
|
|
}
|
2014-07-13 14:08:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
|
|
|
|
});
|
|
|
|
|
|
|
|
mClientCertificateSpinner.setOnClientCertificateChangedListener(clientCertificateChangedListener);
|
|
|
|
mUsernameView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mPasswordView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mServerView.addTextChangedListener(validationTextWatcher);
|
|
|
|
mPortView.addTextChangedListener(validationTextWatcher);
|
|
|
|
}
|
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
@Override
|
2011-02-06 17:09:48 -05:00
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
2008-11-01 17:32:06 -04:00
|
|
|
super.onSaveInstanceState(outState);
|
2010-03-03 23:00:30 -05:00
|
|
|
outState.putString(EXTRA_ACCOUNT, mAccount.getUuid());
|
2014-07-28 12:56:01 -04:00
|
|
|
outState.putInt(STATE_SECURITY_TYPE_POSITION, mCurrentSecurityTypeViewPosition);
|
2014-07-28 15:29:44 -04:00
|
|
|
outState.putInt(STATE_AUTH_TYPE_POSITION, mCurrentAuthTypeViewPosition);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2014-07-17 11:36:54 -04:00
|
|
|
@Override
|
2014-08-18 18:15:17 -04:00
|
|
|
protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
|
super.onPostCreate(savedInstanceState);
|
2014-07-17 11:36:54 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We didn't want the listeners active while the state was being restored
|
|
|
|
* because they could overwrite the restored port with a default port when
|
|
|
|
* the security type was restored.
|
|
|
|
*/
|
|
|
|
initializeViewListeners();
|
|
|
|
validateFields();
|
|
|
|
}
|
|
|
|
|
2014-05-25 16:45:14 -04:00
|
|
|
/**
|
|
|
|
* Shows/hides password field and client certificate spinner
|
|
|
|
*/
|
|
|
|
private void updateViewFromAuthType() {
|
2014-12-17 13:37:18 -05:00
|
|
|
AuthType authType = getSelectedAuthType();
|
2014-08-18 18:12:39 -04:00
|
|
|
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
|
2014-05-25 16:45:14 -04:00
|
|
|
|
|
|
|
if (isAuthTypeExternal) {
|
|
|
|
|
|
|
|
// hide password fields, show client certificate fields
|
|
|
|
mPasswordView.setVisibility(View.GONE);
|
|
|
|
mPasswordLabelView.setVisibility(View.GONE);
|
|
|
|
mClientCertificateLabelView.setVisibility(View.VISIBLE);
|
|
|
|
mClientCertificateSpinner.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// show password fields, hide client certificate fields
|
|
|
|
mPasswordView.setVisibility(View.VISIBLE);
|
|
|
|
mPasswordLabelView.setVisibility(View.VISIBLE);
|
|
|
|
mClientCertificateLabelView.setVisibility(View.GONE);
|
|
|
|
mClientCertificateSpinner.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 19:45:48 -04:00
|
|
|
/**
|
|
|
|
* This is invoked only when the user makes changes to a widget, not when
|
|
|
|
* widgets are changed programmatically. (The logic is simpler when you know
|
|
|
|
* that this is the last thing called after an input change.)
|
|
|
|
*/
|
2011-02-06 17:09:48 -05:00
|
|
|
private void validateFields() {
|
2014-12-17 13:37:18 -05:00
|
|
|
AuthType authType = getSelectedAuthType();
|
2014-08-18 18:12:39 -04:00
|
|
|
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
|
2014-05-25 16:45:14 -04:00
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
ConnectionSecurity connectionSecurity = getSelectedSecurity();
|
2014-08-18 18:12:39 -04:00
|
|
|
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
|
2014-07-13 14:08:24 -04:00
|
|
|
|
|
|
|
if (isAuthTypeExternal && !hasConnectionSecurity) {
|
|
|
|
|
|
|
|
// Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
|
|
|
|
String toastText = getString(R.string.account_setup_incoming_invalid_setting_combo_notice,
|
|
|
|
getString(R.string.account_setup_incoming_auth_type_label),
|
|
|
|
AuthType.EXTERNAL.toString(),
|
|
|
|
getString(R.string.account_setup_incoming_security_label),
|
|
|
|
ConnectionSecurity.NONE.toString());
|
|
|
|
Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();
|
|
|
|
|
|
|
|
// Reset the views back to their previous settings without recursing through here again
|
|
|
|
OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
|
|
|
|
mAuthTypeView.setOnItemSelectedListener(null);
|
|
|
|
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
|
|
|
|
mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
|
|
|
|
updateViewFromAuthType();
|
|
|
|
|
|
|
|
onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
|
|
|
|
mSecurityTypeView.setOnItemSelectedListener(null);
|
|
|
|
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
|
|
|
|
mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
|
2014-12-17 13:37:18 -05:00
|
|
|
updateAuthPlainTextFromSecurityType(getSelectedSecurity());
|
2014-07-13 14:08:24 -04:00
|
|
|
|
|
|
|
mPortView.removeTextChangedListener(validationTextWatcher);
|
|
|
|
mPortView.setText(mCurrentPortViewSetting);
|
|
|
|
mPortView.addTextChangedListener(validationTextWatcher);
|
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
authType = getSelectedAuthType();
|
2014-08-18 18:12:39 -04:00
|
|
|
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
|
2014-07-13 14:08:24 -04:00
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
connectionSecurity = getSelectedSecurity();
|
2014-08-18 18:12:39 -04:00
|
|
|
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
|
2014-07-13 14:08:24 -04:00
|
|
|
} else {
|
|
|
|
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
|
|
|
|
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
|
|
|
|
mCurrentPortViewSetting = mPortView.getText().toString();
|
|
|
|
}
|
|
|
|
|
2014-07-13 02:41:58 -04:00
|
|
|
boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
|
|
|
|
boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);
|
2014-05-25 16:45:14 -04:00
|
|
|
|
2014-07-13 02:41:58 -04:00
|
|
|
boolean hasValidPasswordSettings = hasValidUserName
|
|
|
|
&& !isAuthTypeExternal
|
|
|
|
&& Utility.requiredFieldValid(mPasswordView);
|
|
|
|
|
|
|
|
boolean hasValidExternalAuthSettings = hasValidUserName
|
|
|
|
&& isAuthTypeExternal
|
|
|
|
&& hasConnectionSecurity
|
|
|
|
&& hasValidCertificateAlias;
|
|
|
|
|
|
|
|
mNextButton.setEnabled(Utility.domainFieldValid(mServerView)
|
|
|
|
&& Utility.requiredFieldValid(mPortView)
|
|
|
|
&& (hasValidPasswordSettings || hasValidExternalAuthSettings));
|
2008-11-01 17:32:06 -04:00
|
|
|
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
private void updatePortFromSecurityType() {
|
2014-12-17 13:37:18 -05:00
|
|
|
ConnectionSecurity securityType = getSelectedSecurity();
|
2014-02-14 10:37:44 -05:00
|
|
|
updateAuthPlainTextFromSecurityType(securityType);
|
2014-07-16 19:45:48 -04:00
|
|
|
|
|
|
|
// Remove listener so as not to trigger validateFields() which is called
|
|
|
|
// elsewhere as a result of user interaction.
|
|
|
|
mPortView.removeTextChangedListener(validationTextWatcher);
|
|
|
|
mPortView.setText(getDefaultPort(securityType));
|
|
|
|
mPortView.addTextChangedListener(validationTextWatcher);
|
2014-02-13 19:43:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private String getDefaultPort(ConnectionSecurity securityType) {
|
|
|
|
String port;
|
|
|
|
switch (securityType) {
|
|
|
|
case NONE:
|
|
|
|
case STARTTLS_REQUIRED:
|
2014-02-26 17:59:29 -05:00
|
|
|
port = mDefaultPort;
|
2014-02-13 19:43:24 -05:00
|
|
|
break;
|
|
|
|
case SSL_TLS_REQUIRED:
|
|
|
|
port = mDefaultSslPort;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Log.e(K9.LOG_TAG, "Unhandled ConnectionSecurity type encountered");
|
|
|
|
port = "";
|
2009-11-07 11:21:47 -05:00
|
|
|
}
|
2014-02-13 19:43:24 -05:00
|
|
|
return port;
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2014-02-14 10:37:44 -05:00
|
|
|
private void updateAuthPlainTextFromSecurityType(ConnectionSecurity securityType) {
|
2014-12-17 13:37:18 -05:00
|
|
|
mAuthTypeAdapter.useInsecureText(securityType == ConnectionSecurity.NONE);
|
2014-02-14 10:37:44 -05:00
|
|
|
}
|
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
@Override
|
2011-02-06 17:09:48 -05:00
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
2014-02-28 19:33:25 -05:00
|
|
|
boolean isPushCapable = false;
|
|
|
|
try {
|
|
|
|
Store store = mAccount.getRemoteStore();
|
|
|
|
isPushCapable = store.isPushCapable();
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.e(K9.LOG_TAG, "Could not get remote store", e);
|
|
|
|
}
|
|
|
|
if (isPushCapable && mAccount.getFolderPushMode() != FolderMode.NONE) {
|
|
|
|
MailService.actionRestartPushers(this, null);
|
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
mAccount.save(Preferences.getPreferences(this));
|
|
|
|
finish();
|
2011-02-06 17:09:48 -05:00
|
|
|
} else {
|
2008-11-01 17:32:06 -04:00
|
|
|
/*
|
|
|
|
* Set the username and password for the outgoing settings to the username and
|
|
|
|
* password the user just set for incoming.
|
|
|
|
*/
|
2011-02-06 17:09:48 -05:00
|
|
|
try {
|
2014-05-25 16:45:14 -04:00
|
|
|
String username = mUsernameView.getText().toString();
|
|
|
|
|
|
|
|
String password = null;
|
|
|
|
String clientCertificateAlias = null;
|
2014-12-17 13:37:18 -05:00
|
|
|
AuthType authType = getSelectedAuthType();
|
2014-08-18 18:12:39 -04:00
|
|
|
if (AuthType.EXTERNAL == authType) {
|
2014-05-25 16:45:14 -04:00
|
|
|
clientCertificateAlias = mClientCertificateSpinner.getAlias();
|
|
|
|
} else {
|
|
|
|
password = mPasswordView.getText().toString();
|
|
|
|
}
|
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
URI oldUri = new URI(mAccount.getTransportUri());
|
2014-05-25 16:45:14 -04:00
|
|
|
ServerSettings transportServer = new ServerSettings(SmtpTransport.TRANSPORT_TYPE, oldUri.getHost(), oldUri.getPort(),
|
|
|
|
ConnectionSecurity.SSL_TLS_REQUIRED, authType, username, password, clientCertificateAlias);
|
|
|
|
String transportUri = Transport.createTransportUri(transportServer);
|
|
|
|
mAccount.setTransportUri(transportUri);
|
2011-02-06 17:09:48 -05:00
|
|
|
} catch (URISyntaxException use) {
|
2008-11-01 17:32:06 -04:00
|
|
|
/*
|
|
|
|
* If we can't set up the URL we just continue. It's only for
|
|
|
|
* convenience.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount, mMakeDefault);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
protected void onNext() {
|
|
|
|
try {
|
2014-12-17 13:37:18 -05:00
|
|
|
ConnectionSecurity connectionSecurity = getSelectedSecurity();
|
2009-01-25 02:37:10 -05:00
|
|
|
|
2011-11-30 23:10:13 -05:00
|
|
|
String username = mUsernameView.getText().toString();
|
2014-05-25 16:45:14 -04:00
|
|
|
String password = null;
|
|
|
|
String clientCertificateAlias = null;
|
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
AuthType authType = getSelectedAuthType();
|
2014-08-18 18:12:39 -04:00
|
|
|
if (authType == AuthType.EXTERNAL) {
|
2014-05-25 16:45:14 -04:00
|
|
|
clientCertificateAlias = mClientCertificateSpinner.getAlias();
|
|
|
|
} else {
|
|
|
|
password = mPasswordView.getText().toString();
|
|
|
|
}
|
2011-11-30 23:10:13 -05:00
|
|
|
String host = mServerView.getText().toString();
|
|
|
|
int port = Integer.parseInt(mPortView.getText().toString());
|
|
|
|
|
|
|
|
Map<String, String> extra = null;
|
|
|
|
if (ImapStore.STORE_TYPE.equals(mStoreType)) {
|
|
|
|
extra = new HashMap<String, String>();
|
2011-12-01 00:05:05 -05:00
|
|
|
extra.put(ImapStoreSettings.AUTODETECT_NAMESPACE_KEY,
|
|
|
|
Boolean.toString(mImapAutoDetectNamespaceView.isChecked()));
|
|
|
|
extra.put(ImapStoreSettings.PATH_PREFIX_KEY,
|
|
|
|
mImapPathPrefixView.getText().toString());
|
2011-11-30 23:10:13 -05:00
|
|
|
} else if (WebDavStore.STORE_TYPE.equals(mStoreType)) {
|
|
|
|
extra = new HashMap<String, String>();
|
2011-12-01 00:05:05 -05:00
|
|
|
extra.put(WebDavStoreSettings.PATH_KEY,
|
|
|
|
mWebdavPathPrefixView.getText().toString());
|
|
|
|
extra.put(WebDavStoreSettings.AUTH_PATH_KEY,
|
|
|
|
mWebdavAuthPathView.getText().toString());
|
|
|
|
extra.put(WebDavStoreSettings.MAILBOX_PATH_KEY,
|
|
|
|
mWebdavMailboxPathView.getText().toString());
|
2009-12-20 00:15:20 -05:00
|
|
|
}
|
2009-11-21 17:45:39 -05:00
|
|
|
|
2013-12-03 19:20:20 -05:00
|
|
|
mAccount.deleteCertificate(host, port, CheckDirection.INCOMING);
|
2011-11-30 23:10:13 -05:00
|
|
|
ServerSettings settings = new ServerSettings(mStoreType, host, port,
|
2014-05-25 16:45:14 -04:00
|
|
|
connectionSecurity, authType, username, password, clientCertificateAlias, extra);
|
2011-11-30 23:10:13 -05:00
|
|
|
|
2014-12-11 22:23:32 -05:00
|
|
|
mAccount.setStoreUri(RemoteStore.createStoreUri(settings));
|
2009-11-07 11:21:47 -05:00
|
|
|
|
2015-02-15 02:37:52 -05:00
|
|
|
mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
|
|
|
|
mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
|
|
|
|
mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
|
2011-05-14 16:17:15 -04:00
|
|
|
mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());
|
2010-05-11 22:51:59 -04:00
|
|
|
|
2013-11-23 13:26:57 -05:00
|
|
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
|
2011-02-06 17:09:48 -05:00
|
|
|
} catch (Exception e) {
|
2009-11-07 11:21:47 -05:00
|
|
|
failure(e);
|
2009-01-25 02:37:10 -05:00
|
|
|
}
|
2008-12-18 19:20:56 -05:00
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public void onClick(View v) {
|
|
|
|
try {
|
|
|
|
switch (v.getId()) {
|
|
|
|
case R.id.next:
|
|
|
|
onNext();
|
|
|
|
break;
|
2009-11-07 11:21:47 -05:00
|
|
|
}
|
2011-02-06 17:09:48 -05:00
|
|
|
} catch (Exception e) {
|
2009-11-07 11:21:47 -05:00
|
|
|
failure(e);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
}
|
2009-03-24 14:20:16 -04:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
private void failure(Exception use) {
|
2009-12-14 21:50:53 -05:00
|
|
|
Log.e(K9.LOG_TAG, "Failure", use);
|
2009-11-07 11:21:47 -05:00
|
|
|
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
|
2009-11-21 17:45:39 -05:00
|
|
|
|
2009-11-07 11:21:47 -05:00
|
|
|
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
|
|
|
toast.show();
|
|
|
|
}
|
2014-05-25 16:45:14 -04:00
|
|
|
|
2014-12-17 13:37:18 -05:00
|
|
|
|
2014-05-25 16:45:14 -04:00
|
|
|
/*
|
|
|
|
* 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) {
|
|
|
|
/* unused */
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
/* unused */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
OnClientCertificateChangedListener clientCertificateChangedListener = new OnClientCertificateChangedListener() {
|
|
|
|
@Override
|
|
|
|
public void onClientCertificateChanged(String alias) {
|
|
|
|
validateFields();
|
|
|
|
}
|
|
|
|
};
|
2014-12-17 13:37:18 -05:00
|
|
|
|
|
|
|
private AuthType getSelectedAuthType() {
|
|
|
|
AuthTypeHolder holder = (AuthTypeHolder) mAuthTypeView.getSelectedItem();
|
|
|
|
return holder.authType;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ConnectionSecurity getSelectedSecurity() {
|
|
|
|
ConnectionSecurityHolder holder = (ConnectionSecurityHolder) mSecurityTypeView.getSelectedItem();
|
|
|
|
return holder.connectionSecurity;
|
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|