Use TextInputLayout on setup outgoing

Also adds password visibility toggle
This commit is contained in:
MonkeyMatt 2020-12-21 14:11:37 +13:00
parent c889259707
commit c0341851fc
2 changed files with 80 additions and 78 deletions

View file

@ -20,7 +20,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@ -42,6 +41,8 @@ import com.fsck.k9.mail.MailServerDirection;
import com.fsck.k9.mail.ServerSettings;
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;
public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
@ -56,13 +57,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
private final BackendManager backendManager = DI.get(BackendManager.class);
private final AccountCreator accountCreator = DI.get(AccountCreator.class);
private EditText mUsernameView;
private EditText mPasswordView;
private TextInputEditText mUsernameView;
private TextInputEditText mPasswordView;
private TextInputLayout mPasswordLayoutView;
private ClientCertificateSpinner mClientCertificateSpinner;
private TextView mClientCertificateLabelView;
private TextView mPasswordLabelView;
private EditText mServerView;
private EditText mPortView;
private TextInputEditText mServerView;
private TextInputEditText mPortView;
private String mCurrentPortViewSetting;
private CheckBox mRequireLoginView;
private ViewGroup mRequireLoginSettingsView;
@ -119,7 +120,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
mPasswordView = findViewById(R.id.account_password);
mClientCertificateSpinner = findViewById(R.id.account_client_certificate_spinner);
mClientCertificateLabelView = findViewById(R.id.account_client_certificate_label);
mPasswordLabelView = findViewById(R.id.account_password_label);
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);
@ -354,15 +355,13 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
if (isAuthTypeExternal) {
// hide password fields, show client certificate fields
mPasswordView.setVisibility(View.GONE);
mPasswordLabelView.setVisibility(View.GONE);
mPasswordLayoutView.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);
mPasswordLayoutView.setVisibility(View.VISIBLE);
mClientCertificateLabelView.setVisibility(View.GONE);
mClientCertificateSpinner.setVisibility(View.GONE);
}

View file

@ -1,14 +1,16 @@
<?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="fill_parent"
android:layout_width="fill_parent">
android:layout_height="match_parent"
android:layout_width="match_parent">
<include layout="@layout/toolbar"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="6dip"
@ -16,87 +18,87 @@
android:scrollbarStyle="outsideInset">
<LinearLayout
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="@string/account_setup_outgoing_smtp_server_label"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
<EditText
android:id="@+id/account_server"
android:singleLine="true"
android:inputType="textUri"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_outgoing_smtp_server_label" />
<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="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
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="fill_parent"
android:layout_width="match_parent"
android:contentDescription="@string/account_setup_outgoing_security_label" />
<TextView
android:text="@string/account_setup_outgoing_port_label"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
<EditText
android:id="@+id/account_port"
android:singleLine="true"
android:inputType="number"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_outgoing_port_label" />
<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_incoming_port_label"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/account_require_login"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/account_setup_outgoing_require_login_label" />
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="fill_parent"
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
android:visibility="gone"
tools:visibility="visible">
<TextView
android:text="@string/account_setup_outgoing_username_label"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing">
<EditText
android:id="@+id/account_username"
android:singleLine="true"
android:inputType="textEmailAddress"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_outgoing_username_label" />
<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:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
android:layout_marginTop="6dp"
style="@style/InputLabel" />
<Spinner
android:id="@+id/account_auth_type"
@ -104,27 +106,28 @@
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_outgoing_authentication_label" />
<TextView
android:id="@+id/account_password_label"
android:text="@string/account_setup_outgoing_password_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_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
android:layout_marginTop="@dimen/account_setup_margin_between_items_incoming_and_outgoing"
app:passwordToggleEnabled="true">
<EditText
android:id="@+id/account_password"
android:singleLine="true"
android:inputType="textPassword"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:contentDescription="@string/account_setup_outgoing_password_label" />
<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>
<TextView
android:id="@+id/account_client_certificate_label"
android:text="@string/account_setup_incoming_client_certificate_label"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:visibility="gone" />
@ -132,12 +135,12 @@
<com.fsck.k9.view.ClientCertificateSpinner
android:id="@+id/account_client_certificate_spinner"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:visibility="gone" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
</LinearLayout>