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

Commit 8fca99be authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Fixes to unbreak incoming account setup after CRAM_MD5 implementation

parent 361cc4cb
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -52,6 +52,12 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
        "webdav", "webdav+ssl", "webdav+ssl+", "webdav+tls", "webdav+tls+"
    };

    private static final String authTypes[] =
    {
        "PLAIN", "CRAM_MD5"
    };


    private int mAccountPorts[];
    private String mAccountSchemes[];
    private EditText mUsernameView;
@@ -128,7 +134,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
            new SpinnerOption(4, getString(R.string.account_setup_incoming_security_tls_label)),
        };

        SpinnerOption authTypes[] =
        // This needs to be kept in sync with the list at the top of the file.
        // that makes me somewhat unhappy
        SpinnerOption authTypeSpinnerOptions[] =
        {
            new SpinnerOption(0, "PLAIN"),
            new SpinnerOption(1, "CRAM_MD5")
@@ -140,7 +148,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
        mSecurityTypeView.setAdapter(securityTypesAdapter);

        ArrayAdapter<SpinnerOption> authTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
                android.R.layout.simple_spinner_item, authTypes);
                android.R.layout.simple_spinner_item, authTypeSpinnerOptions);
        authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mAuthTypeView.setAdapter(authTypesAdapter);

@@ -206,16 +214,30 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
            URI uri = new URI(mAccount.getStoreUri());
            String username = null;
            String password = null;
            String authType = null;

            if (uri.getUserInfo() != null)
            {
                String[] userInfoParts = uri.getUserInfo().split(":", 2);
                username = userInfoParts[0];
                if (userInfoParts.length > 1)
                String[] userInfoParts = uri.getUserInfo().split(":");
                if (userInfoParts.length == 3)
                {
                    authType = userInfoParts[0];
                    username = userInfoParts[1];
                    password = userInfoParts[2];
                }
                else if (userInfoParts.length == 2)
                {
                    username = userInfoParts[0];
                    password = userInfoParts[1];
                }
                else if (userInfoParts.length == 1)
                {
                    username = userInfoParts[0];
                }
            }



            if (username != null)
            {
                mUsernameView.setText(username);
@@ -226,6 +248,18 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
                mPasswordView.setText(password);
            }

            if (authType != null)
            {
                for (int i = 0; i < authTypes.length; i++)
                {
                    if (authTypes[i].equals(authType))
                    {
                        SpinnerOption.setSpinnerOptionValue(mAuthTypeView, i);
                    }
                }
            }


            mImapFolderDrafts.setText(mAccount.getDraftsFolderName());
            mImapFolderSent.setText(mAccount.getSentFolderName());
            mImapFolderTrash.setText(mAccount.getTrashFolderName());