mirror of
https://github.com/thunderbird/thunderbird-android.git
synced 2024-09-20 12:12:15 +02:00
Remove AccountSetupOutgoing
activity
This commit is contained in:
parent
e366fb3dad
commit
c76e3a13e8
@ -72,11 +72,6 @@
|
||||
android:configChanges="locale"
|
||||
android:label="@string/account_settings_composition_title"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.setup.AccountSetupOutgoing"
|
||||
android:configChanges="locale"
|
||||
android:label="@string/account_setup_outgoing_title"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.ChooseAccount"
|
||||
android:configChanges="locale"
|
||||
|
@ -1,547 +0,0 @@
|
||||
package com.fsck.k9.activity.setup;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.LocalKeyStoreManager;
|
||||
import com.fsck.k9.Preferences;
|
||||
import app.k9mail.core.common.mail.Protocols;
|
||||
import com.fsck.k9.ui.R;
|
||||
import com.fsck.k9.account.AccountCreatorHelper;
|
||||
import com.fsck.k9.ui.base.K9Activity;
|
||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.MailServerDirection;
|
||||
import com.fsck.k9.mail.ServerSettings;
|
||||
import com.fsck.k9.ui.base.extensions.TextInputLayoutHelper;
|
||||
import com.fsck.k9.view.ClientCertificateSpinner;
|
||||
import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListener;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import timber.log.Timber;
|
||||
|
||||
@Deprecated(since = "Remove once the new account edit feature is the default")
|
||||
public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
||||
OnCheckedChangeListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
private static final String STATE_SECURITY_TYPE_POSITION = "stateSecurityTypePosition";
|
||||
private static final String STATE_AUTH_TYPE_POSITION = "authTypePosition";
|
||||
|
||||
|
||||
private final AccountCreatorHelper accountCreatorHelper = DI.get(AccountCreatorHelper.class);
|
||||
|
||||
private TextInputEditText mUsernameView;
|
||||
private TextInputEditText mPasswordView;
|
||||
private TextInputLayout mPasswordLayoutView;
|
||||
private ClientCertificateSpinner mClientCertificateSpinner;
|
||||
private TextInputEditText mServerView;
|
||||
private TextInputEditText mPortView;
|
||||
private String mCurrentPortViewSetting;
|
||||
private CheckBox mRequireLoginView;
|
||||
private ViewGroup mRequireLoginSettingsView;
|
||||
private ViewGroup mAllowClientCertificateView;
|
||||
|
||||
private Spinner mSecurityTypeView;
|
||||
private int mCurrentSecurityTypeViewPosition;
|
||||
private Spinner mAuthTypeView;
|
||||
private int mCurrentAuthTypeViewPosition;
|
||||
private AuthTypeAdapter mAuthTypeAdapter;
|
||||
private Button mNextButton;
|
||||
private Account mAccount;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setLayout(R.layout.account_setup_outgoing);
|
||||
setTitle(R.string.account_setup_outgoing_title);
|
||||
|
||||
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
mAccount = Preferences.getPreferences().getAccount(accountUuid);
|
||||
|
||||
ServerSettings incomingServerSettings = mAccount.getIncomingServerSettings();
|
||||
|
||||
mUsernameView = findViewById(R.id.account_username);
|
||||
mPasswordView = findViewById(R.id.account_password);
|
||||
mClientCertificateSpinner = findViewById(R.id.account_client_certificate_spinner);
|
||||
mPasswordLayoutView = findViewById(R.id.account_password_layout);
|
||||
mServerView = findViewById(R.id.account_server);
|
||||
mPortView = findViewById(R.id.account_port);
|
||||
mRequireLoginView = findViewById(R.id.account_require_login);
|
||||
mRequireLoginSettingsView = findViewById(R.id.account_require_login_settings);
|
||||
mAllowClientCertificateView = findViewById(R.id.account_allow_client_certificate);
|
||||
|
||||
mSecurityTypeView = findViewById(R.id.account_security_type);
|
||||
mAuthTypeView = findViewById(R.id.account_auth_type);
|
||||
mNextButton = findViewById(R.id.next);
|
||||
|
||||
mNextButton.setOnClickListener(this);
|
||||
|
||||
mSecurityTypeView.setAdapter(ConnectionSecurityAdapter.get(this));
|
||||
|
||||
mAuthTypeAdapter = AuthTypeAdapter.get(this, true);
|
||||
mAuthTypeView.setAdapter(mAuthTypeAdapter);
|
||||
|
||||
/*
|
||||
* Only allow digits in the port field.
|
||||
*/
|
||||
mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
|
||||
|
||||
//FIXME: get Account object again?
|
||||
accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
mAccount = Preferences.getPreferences().getAccount(accountUuid);
|
||||
|
||||
/*
|
||||
* If we're being reloaded we override the original account with the one
|
||||
* we saved
|
||||
*/
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_ACCOUNT)) {
|
||||
accountUuid = savedInstanceState.getString(EXTRA_ACCOUNT);
|
||||
mAccount = Preferences.getPreferences().getAccount(accountUuid);
|
||||
}
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
ServerSettings settings = mAccount.getOutgoingServerSettings();
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
// The first item is selected if settings.authenticationType is null or is not in mAuthTypeAdapter
|
||||
mCurrentAuthTypeViewPosition = mAuthTypeAdapter.getAuthPosition(settings.authenticationType);
|
||||
} else {
|
||||
mCurrentAuthTypeViewPosition = savedInstanceState.getInt(STATE_AUTH_TYPE_POSITION);
|
||||
}
|
||||
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
|
||||
updateViewFromAuthType();
|
||||
|
||||
// Select currently configured security type
|
||||
if (savedInstanceState == null) {
|
||||
mCurrentSecurityTypeViewPosition = settings.connectionSecurity.ordinal();
|
||||
} 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);
|
||||
}
|
||||
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
|
||||
|
||||
updateAuthPlainTextFromSecurityType(getSelectedSecurity());
|
||||
updateViewFromSecurity();
|
||||
|
||||
if (!settings.username.isEmpty()) {
|
||||
mUsernameView.setText(settings.username);
|
||||
mRequireLoginView.setChecked(true);
|
||||
mRequireLoginSettingsView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (settings.password != null) {
|
||||
mPasswordView.setText(settings.password);
|
||||
}
|
||||
|
||||
if (settings.clientCertificateAlias != null) {
|
||||
mClientCertificateSpinner.setAlias(settings.clientCertificateAlias);
|
||||
}
|
||||
|
||||
if (settings.host != null) {
|
||||
mServerView.setText(settings.host);
|
||||
}
|
||||
|
||||
if (settings.port != -1) {
|
||||
mPortView.setText(String.format(Locale.ROOT, "%d", settings.port));
|
||||
} else {
|
||||
updatePortFromSecurityType();
|
||||
}
|
||||
mCurrentPortViewSetting = mPortView.getText().toString();
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* We should always be able to parse our own settings.
|
||||
*/
|
||||
failure(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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) {
|
||||
|
||||
/*
|
||||
* 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();
|
||||
updateViewFromSecurity();
|
||||
boolean isInsecure = (ConnectionSecurity.NONE == getSelectedSecurity());
|
||||
boolean isAuthExternal = (AuthType.EXTERNAL == getSelectedAuthType());
|
||||
boolean loginNotRequired = !mRequireLoginView.isChecked();
|
||||
|
||||
/*
|
||||
* If the user selects ConnectionSecurity.NONE, a
|
||||
* warning would normally pop up if the authentication
|
||||
* is AuthType.EXTERNAL (i.e., using client
|
||||
* certificates). But such a warning is irrelevant if
|
||||
* login is not required. So to avoid such a warning
|
||||
* (generated in validateFields()) under those
|
||||
* conditions, we change the (irrelevant) authentication
|
||||
* method to PLAIN.
|
||||
*/
|
||||
if (isInsecure && isAuthExternal && loginNotRequired) {
|
||||
OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
|
||||
mAuthTypeView.setOnItemSelectedListener(null);
|
||||
mCurrentAuthTypeViewPosition = mAuthTypeAdapter.getAuthPosition(AuthType.PLAIN);
|
||||
mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
|
||||
mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
|
||||
updateViewFromAuthType();
|
||||
}
|
||||
|
||||
validateFields();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
|
||||
});
|
||||
|
||||
mAuthTypeView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
if (mCurrentAuthTypeViewPosition == position) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewFromAuthType();
|
||||
updateViewFromSecurity();
|
||||
validateFields();
|
||||
AuthType selection = getSelectedAuthType();
|
||||
|
||||
// Have the user select the client certificate if not already selected
|
||||
if ((AuthType.EXTERNAL == selection) && (mClientCertificateSpinner.getAlias() == null)) {
|
||||
// This may again invoke validateFields()
|
||||
mClientCertificateSpinner.chooseCertificate();
|
||||
} else {
|
||||
mPasswordView.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) { /* unused */ }
|
||||
});
|
||||
|
||||
mRequireLoginView.setOnCheckedChangeListener(this);
|
||||
mClientCertificateSpinner.setOnClientCertificateChangedListener(clientCertificateChangedListener);
|
||||
mUsernameView.addTextChangedListener(validationTextWatcher);
|
||||
mPasswordView.addTextChangedListener(validationTextWatcher);
|
||||
mServerView.addTextChangedListener(validationTextWatcher);
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
|
||||
TextInputLayoutHelper.configureAuthenticatedPasswordToggle(
|
||||
mPasswordLayoutView,
|
||||
this,
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_title),
|
||||
getString(R.string.account_setup_basics_show_password_biometrics_subtitle),
|
||||
getString(R.string.account_setup_basics_show_password_need_lock)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(EXTRA_ACCOUNT, mAccount.getUuid());
|
||||
outState.putInt(STATE_SECURITY_TYPE_POSITION, mCurrentSecurityTypeViewPosition);
|
||||
outState.putInt(STATE_AUTH_TYPE_POSITION, mCurrentAuthTypeViewPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
|
||||
if (mRequireLoginView.isChecked()) {
|
||||
mRequireLoginSettingsView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mRequireLoginSettingsView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows/hides password field
|
||||
*/
|
||||
private void updateViewFromAuthType() {
|
||||
switch (getSelectedAuthType()) {
|
||||
case EXTERNAL:
|
||||
case XOAUTH2:
|
||||
mPasswordLayoutView.setVisibility(View.GONE);
|
||||
break;
|
||||
default:
|
||||
mPasswordLayoutView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows/hides client certificate spinner
|
||||
*/
|
||||
private void updateViewFromSecurity() {
|
||||
ConnectionSecurity security = getSelectedSecurity();
|
||||
boolean isUsingTLS = ((ConnectionSecurity.SSL_TLS_REQUIRED == security) || (ConnectionSecurity.STARTTLS_REQUIRED == security));
|
||||
boolean isUsingOAuth = getSelectedAuthType() == AuthType.XOAUTH2;
|
||||
|
||||
if (isUsingTLS && !isUsingOAuth) {
|
||||
mAllowClientCertificateView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mAllowClientCertificateView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.)
|
||||
*/
|
||||
private void validateFields() {
|
||||
AuthType authType = getSelectedAuthType();
|
||||
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
|
||||
|
||||
ConnectionSecurity connectionSecurity = getSelectedSecurity();
|
||||
boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
|
||||
|
||||
if (isAuthTypeExternal && !hasConnectionSecurity) {
|
||||
|
||||
// Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
|
||||
String toastText = getString(R.string.account_setup_outgoing_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();
|
||||
updateViewFromSecurity();
|
||||
|
||||
onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
|
||||
mSecurityTypeView.setOnItemSelectedListener(null);
|
||||
mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
|
||||
mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
|
||||
updateAuthPlainTextFromSecurityType(getSelectedSecurity());
|
||||
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(mCurrentPortViewSetting);
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
|
||||
authType = getSelectedAuthType();
|
||||
isAuthTypeExternal = (AuthType.EXTERNAL == authType);
|
||||
|
||||
connectionSecurity = getSelectedSecurity();
|
||||
hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
|
||||
} else {
|
||||
mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
|
||||
mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
|
||||
mCurrentPortViewSetting = mPortView.getText().toString();
|
||||
}
|
||||
|
||||
boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
|
||||
boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);
|
||||
|
||||
boolean hasValidPasswordSettings = hasValidUserName
|
||||
&& !isAuthTypeExternal
|
||||
&& Utility.requiredFieldValid(mPasswordView);
|
||||
|
||||
boolean hasValidExternalAuthSettings = hasValidUserName
|
||||
&& isAuthTypeExternal
|
||||
&& hasConnectionSecurity
|
||||
&& hasValidCertificateAlias;
|
||||
|
||||
boolean hasValidOAuthSettings = hasValidUserName
|
||||
&& hasConnectionSecurity
|
||||
&& authType == AuthType.XOAUTH2;
|
||||
|
||||
mNextButton
|
||||
.setEnabled(Utility.domainFieldValid(mServerView)
|
||||
&& Utility.requiredFieldValid(mPortView)
|
||||
&& (!mRequireLoginView.isChecked()
|
||||
|| hasValidPasswordSettings || hasValidExternalAuthSettings || hasValidOAuthSettings));
|
||||
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
||||
}
|
||||
|
||||
private void updatePortFromSecurityType() {
|
||||
ConnectionSecurity securityType = getSelectedSecurity();
|
||||
updateAuthPlainTextFromSecurityType(securityType);
|
||||
|
||||
// Remove listener so as not to trigger validateFields() which is called
|
||||
// elsewhere as a result of user interaction.
|
||||
mPortView.removeTextChangedListener(validationTextWatcher);
|
||||
mPortView.setText(String.valueOf(accountCreatorHelper.getDefaultPort(securityType, Protocols.SMTP)));
|
||||
mPortView.addTextChangedListener(validationTextWatcher);
|
||||
}
|
||||
|
||||
private void updateAuthPlainTextFromSecurityType(ConnectionSecurity securityType) {
|
||||
mAuthTypeAdapter.useInsecureText(securityType == ConnectionSecurity.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode != AccountSetupCheckSettings.ACTIVITY_REQUEST_CODE) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resultCode == RESULT_OK) {
|
||||
Preferences.getPreferences().saveAccount(mAccount);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onNext() {
|
||||
ConnectionSecurity securityType = getSelectedSecurity();
|
||||
String username = "";
|
||||
String password = null;
|
||||
String clientCertificateAlias = null;
|
||||
AuthType authType = AuthType.AUTOMATIC;
|
||||
if ((ConnectionSecurity.STARTTLS_REQUIRED == securityType) ||
|
||||
(ConnectionSecurity.SSL_TLS_REQUIRED == securityType)) {
|
||||
clientCertificateAlias = mClientCertificateSpinner.getAlias();
|
||||
}
|
||||
if (mRequireLoginView.isChecked()) {
|
||||
username = mUsernameView.getText().toString().trim();
|
||||
authType = getSelectedAuthType();
|
||||
|
||||
if (AuthType.EXTERNAL != authType) {
|
||||
password = mPasswordView.getText().toString();
|
||||
}
|
||||
}
|
||||
|
||||
String newHost = mServerView.getText().toString();
|
||||
int newPort = Integer.parseInt(mPortView.getText().toString());
|
||||
ServerSettings server = new ServerSettings(Protocols.SMTP, newHost, newPort, securityType, authType, username,
|
||||
password, clientCertificateAlias);
|
||||
DI.get(LocalKeyStoreManager.class).deleteCertificate(mAccount, newHost, newPort, MailServerDirection.OUTGOING);
|
||||
mAccount.setOutgoingServerSettings(server);
|
||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.OUTGOING);
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.next) {
|
||||
onNext();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mRequireLoginSettingsView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
validateFields();
|
||||
}
|
||||
|
||||
private void failure(Exception use) {
|
||||
Timber.e(use, "Failure");
|
||||
String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());
|
||||
|
||||
Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
}
|
||||
};
|
||||
|
||||
OnClientCertificateChangedListener clientCertificateChangedListener = alias -> validateFields();
|
||||
|
||||
private AuthType getSelectedAuthType() {
|
||||
AuthTypeHolder holder = (AuthTypeHolder) mAuthTypeView.getSelectedItem();
|
||||
return holder.authType;
|
||||
}
|
||||
|
||||
private ConnectionSecurity getSelectedSecurity() {
|
||||
ConnectionSecurityHolder holder = (ConnectionSecurityHolder) mSecurityTypeView.getSelectedItem();
|
||||
return holder.connectionSecurity;
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
tools:context="com.fsck.k9.activity.setup.AccountSetupOutgoing">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:padding="6dip"
|
||||
android:fadingEdge="none"
|
||||
android:scrollbarStyle="outsideInset">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/account_server"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textUri"
|
||||
android:hint="@string/account_setup_outgoing_smtp_server_label"
|
||||
android:singleLine="true" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:text="@string/account_setup_outgoing_security_label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="6dp"
|
||||
style="@style/InputLabel" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/account_security_type"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:contentDescription="@string/account_setup_outgoing_security_label" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/account_port"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:hint="@string/account_setup_outgoing_port_label"
|
||||
android:singleLine="true" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/account_require_login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/account_setup_outgoing_require_login_label"
|
||||
tools:checked="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_require_login_settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/account_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textEmailAddress"
|
||||
android:hint="@string/account_setup_outgoing_username_label"
|
||||
android:singleLine="true" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:text="@string/account_setup_outgoing_authentication_label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_marginTop="6dp"
|
||||
style="@style/InputLabel" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/account_auth_type"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:contentDescription="@string/account_setup_outgoing_authentication_label" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/account_password_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing"
|
||||
app:endIconMode="password_toggle">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/account_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/account_setup_outgoing_password_label"
|
||||
android:singleLine="true"
|
||||
android:inputType="textPassword"
|
||||
android:nextFocusDown="@+id/next"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_allow_client_certificate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:text="@string/account_setup_incoming_client_certificate_label"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
style="@style/InputLabel"
|
||||
android:layout_marginTop="6dp"/>
|
||||
|
||||
<com.fsck.k9.view.ClientCertificateSpinner
|
||||
android:id="@+id/account_client_certificate_spinner"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<include layout="@layout/wizard_next" />
|
||||
|
||||
</LinearLayout>
|
@ -6,7 +6,6 @@
|
||||
|
||||
<dimen name="input_label_vertical_spacing">8dp</dimen>
|
||||
<dimen name="input_label_horizontal_spacing">4dp</dimen>
|
||||
<dimen name="account_setup_margin_between_items_incoming_and_outgoing">12dp</dimen>
|
||||
|
||||
<dimen name="message_view_pager_page_margin">16dp</dimen>
|
||||
<dimen name="messageListSwipeThreshold">72dp</dimen>
|
||||
|
@ -370,9 +370,6 @@
|
||||
<string name="account_setup_auth_type_tls_client_certificate">Client certificate</string>
|
||||
<string name="account_setup_auth_type_oauth2">OAuth 2.0</string>
|
||||
|
||||
<string name="account_setup_incoming_client_certificate_label">Client certificate</string>
|
||||
<string name="account_setup_incoming_security_label">Security</string>
|
||||
<string name="account_setup_incoming_auth_type_label">Authentication</string>
|
||||
<string name="account_setup_incoming_security_none_label">None</string>
|
||||
<string name="account_setup_incoming_security_ssl_label">SSL/TLS</string>
|
||||
<string name="account_setup_incoming_security_tls_label">STARTTLS</string>
|
||||
@ -396,19 +393,6 @@
|
||||
<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>
|
||||
|
||||
<string name="account_setup_outgoing_title">Outgoing server settings</string>
|
||||
<string name="account_setup_outgoing_smtp_server_label">SMTP server</string>
|
||||
<string name="account_setup_outgoing_port_label">Port</string>
|
||||
<string name="account_setup_outgoing_security_label">Security</string>
|
||||
<string name="account_setup_outgoing_require_login_label">Require sign-in.</string>
|
||||
<string name="account_setup_outgoing_username_label">Username</string>
|
||||
<string name="account_setup_outgoing_password_label">Password</string>
|
||||
<string name="account_setup_outgoing_authentication_label">Authentication</string>
|
||||
<string name="account_setup_outgoing_invalid_setting_combo_notice">\"<xliff:g id="setting_1_label">%1$s</xliff:g> = <xliff:g id="setting_1_value">%2$s</xliff:g>\" is not valid with \"<xliff:g id="setting_2_label">%3$s</xliff:g> = <xliff:g id="setting_2_value">%4$s</xliff:g>\"</string>
|
||||
|
||||
<string name="account_setup_bad_uri">Invalid setup: <xliff:g id="err_mess">%s</xliff:g></string>
|
||||
|
||||
|
||||
<string name="account_setup_options_mail_check_frequency_label">Folder poll frequency</string>
|
||||
<string name="account_setup_options_mail_check_frequency_never">Never</string>
|
||||
<string name="account_setup_options_mail_check_frequency_15min">Every 15 minutes</string>
|
||||
|
Loading…
Reference in New Issue
Block a user