Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit d07cd850 authored by toppk's avatar toppk
Browse files

Allow setting password and client certificates from first step of account setup.

parent 05e5c802
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
@@ -60,6 +61,7 @@ public class AccountSetupBasics extends K9Activity
    private Button mNextButton;
    private Button mManualSetupButton;
    private Account mAccount;
    private ViewGroup mAllowClientCertificateView;

    private EmailAddressValidator mEmailValidator = new EmailAddressValidator();
    private boolean mCheckedIncoming = false;
@@ -77,6 +79,8 @@ public class AccountSetupBasics extends K9Activity
        mPasswordView = findViewById(R.id.account_password);
        mClientCertificateCheckBox = findViewById(R.id.account_client_certificate);
        mClientCertificateSpinner = findViewById(R.id.account_client_certificate_spinner);
        mAllowClientCertificateView = findViewById(R.id.account_allow_client_certificate);

        mNextButton = findViewById(R.id.next);
        mManualSetupButton = findViewById(R.id.manual_setup);
        mNextButton.setOnClickListener(this);
@@ -151,21 +155,19 @@ public class AccountSetupBasics extends K9Activity
        updateViewVisibility(isChecked);
        validateFields();

        // Have the user select (or confirm) the client certificate
        if (isChecked) {
        // Have the user select the client certificate if not already selected
        if ((isChecked) && (mClientCertificateSpinner.getAlias() == null)) {
            mClientCertificateSpinner.chooseCertificate();
        }
    }

    private void updateViewVisibility(boolean usingCertificates) {
        if (usingCertificates) {
            // hide password fields, show client certificate spinner
            mPasswordView.setVisibility(View.GONE);
            mClientCertificateSpinner.setVisibility(View.VISIBLE);
            // show client certificate spinner
            mAllowClientCertificateView.setVisibility(View.VISIBLE);
        } else {
            // show password fields, hide client certificate spinner
            mPasswordView.setVisibility(View.VISIBLE);
            mClientCertificateSpinner.setVisibility(View.GONE);
            // hide client certificate spinner
            mAllowClientCertificateView.setVisibility(View.GONE);
        }
    }

@@ -314,12 +316,15 @@ public class AccountSetupBasics extends K9Activity
        String password = null;
        String clientCertificateAlias = null;
        AuthType authenticationType;
        if (mClientCertificateCheckBox.isChecked()) {
            authenticationType = AuthType.EXTERNAL;
            clientCertificateAlias = mClientCertificateSpinner.getAlias();
        } else {

        authenticationType = AuthType.PLAIN;
        password = mPasswordView.getText().toString();
        if (mClientCertificateCheckBox.isChecked()) {
            clientCertificateAlias = mClientCertificateSpinner.getAlias();
            if (mPasswordView.getText().toString().equals("")) {
                authenticationType = AuthType.EXTERNAL;
                password = null;
            }
        }

        if (mAccount == null) {
+17 −2
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
@@ -48,12 +49,26 @@
                    android:inputType="textPassword"
                    android:nextFocusDown="@+id/next"/>
            </com.google.android.material.textfield.TextInputLayout>
        <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:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />
                android:layout_height="wrap_content" />
        </LinearLayout>

            <com.fsck.k9.view.FoldableLinearLayout
                android:id="@+id/foldable_advanced_options"