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

Commit 029a8eb0 authored by cketti's avatar cketti
Browse files

Don't allow showing the password without authentication after an orientation change

parent a3be470b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ import com.google.android.material.textfield.TextInputLayout

/**
 * Configures a [TextInputLayout] so the password can only be revealed after authentication.
 *
 * **IMPORTANT**: Only call this after the instance state has been restored! Otherwise, restoring the previous state
 * after the initial state has been set will be detected as replacing the whole text. In that case showing the password
 * will be allowed without authentication.
 */
fun TextInputLayout.configureAuthenticatedPasswordToggle(
    activity: FragmentActivity,
+13 −10
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
    private CheckBox mSubscribedFoldersOnly;
    private AuthTypeAdapter mAuthTypeAdapter;
    private ConnectionSecurity[] mConnectionSecurityChoices = ConnectionSecurity.values();
    private boolean editSettings;

    public static void actionIncomingSettings(Activity context, Account account, boolean makeDefault) {
        Intent i = new Intent(context, AccountSetupIncoming.class);
@@ -174,16 +175,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
        mAuthTypeAdapter = AuthTypeAdapter.get(this, oAuthSupported);
        mAuthTypeView.setAdapter(mAuthTypeAdapter);

        boolean editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
        editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
        if (editSettings) {
            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)
            );

            if (getSupportActionBar() != null) {
                getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            }
@@ -386,6 +379,16 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
        mPasswordView.addTextChangedListener(validationTextWatcher);
        mServerView.addTextChangedListener(validationTextWatcher);
        mPortView.addTextChangedListener(validationTextWatcher);

        if (editSettings) {
            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
@@ -538,7 +541,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
        }

        if (resultCode == RESULT_OK) {
            if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
            if (editSettings) {
                Preferences.getPreferences().saveAccount(mAccount);
                finish();
            } else {
+13 −10
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
    private AuthTypeAdapter mAuthTypeAdapter;
    private Button mNextButton;
    private Account mAccount;
    private boolean editSettings;

    public static void actionOutgoingSettings(Context context, Account account) {
        Intent i = new Intent(context, AccountSetupOutgoing.class);
@@ -149,16 +150,8 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
            mAccount = Preferences.getPreferences().getAccount(accountUuid);
        }

        boolean editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
        editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());
        if (editSettings) {
            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)
            );

            if (getSupportActionBar() != null) {
                getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            }
@@ -321,6 +314,16 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
        mPasswordView.addTextChangedListener(validationTextWatcher);
        mServerView.addTextChangedListener(validationTextWatcher);
        mPortView.addTextChangedListener(validationTextWatcher);

        if (editSettings) {
            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
@@ -494,7 +497,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
        }

        if (resultCode == RESULT_OK) {
            if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
            if (editSettings) {
                Preferences.getPreferences().saveAccount(mAccount);
                finish();
            } else {