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

Commit 8e245c1b authored by daquexian's avatar daquexian Committed by Vincent Breitmoser
Browse files

fix bug that go back to outgoing settings from account names when...

fix bug that go back to outgoing settings from account names when autoconfiguration and back button pressed
parent c4e60704
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1042,7 +1042,7 @@ public class ImapConnectionTest {
            }

            @Override
            public void authorizeApi(String username, Activity activity, OAuth2TokenProviderAuthCallback callback) {
            public void authorizeAPI(String username, Activity activity, OAuth2TokenProviderAuthCallback callback) {
                throw new UnsupportedOperationException();
            }
        };
+2 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.K9LibRobolectricTestRunner;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.OAuth2NeedUserPromptException;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.ServerSettings.Type;
import com.fsck.k9.mail.TransportUris;
@@ -52,7 +53,7 @@ public class SmtpTransportTest {

    
    @Before
    public void before() throws AuthenticationFailedException {
    public void before() throws AuthenticationFailedException, OAuth2NeedUserPromptException {
        socketFactory = TestTrustedSocketFactory.newInstance();
        oAuth2TokenProvider = mock(OAuth2TokenProvider.class);
        when(oAuth2TokenProvider.getToken(eq(USERNAME), anyInt()))
+14 −2
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
    private boolean makeDefault;
    private Provider provider;

    private boolean autoconfiguration;

    private static final int REQUEST_CODE_GMAIL = 1;

    enum Stage {
@@ -254,6 +256,8 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                    }

                    if (provider != null) {
                        autoconfiguration = true;

                        boolean usingOAuth2 = false;
                        if (onlyXOAuth2(email)) {
                            usingOAuth2 = true;
@@ -268,6 +272,7 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                }

                if (provider == null) {
                    autoconfiguration = false;
                    manualSetup(accountConfig.getEmail(), password);
                }
            }
@@ -1548,8 +1553,13 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
                break;
            case OUTGOING_CHECKING:
            case ACCOUNT_NAMES:
                if (autoconfiguration) {
                    stage = Stage.BASICS;
                    view.goToBasics();
                } else {
                    stage = Stage.OUTGOING;
                    view.goToOutgoing();
                }
                break;
            default:
                view.end();
@@ -1611,6 +1621,8 @@ public class AccountSetupPresenter implements AccountSetupContract.Presenter,
    }

    private void manualSetup(String email, String password) {
        autoconfiguration = false;

        if (accountConfig == null) {
            accountConfig = new AccountConfigImpl(preferences);
        }
+6 −0
Original line number Diff line number Diff line
@@ -3,9 +3,15 @@ package com.fsck.k9;

import android.content.Context;

import com.fsck.k9.mail.oauth.OAuth2TokenProvider;


public class GlobalsHelper {
    public static void setContext(Context context) {
        Globals.setContext(context);
    }

    public static void setOAuth2TokenProvider(OAuth2TokenProvider provider) {
        Globals.setOAuth2TokenProvider(provider);
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -13,9 +13,12 @@ import android.content.Context;

import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.Globals;
import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.account.AndroidAccountOAuth2TokenStore;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.CertificateValidationException;
@@ -28,6 +31,7 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.TransportProvider;
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.mailstore.LocalMessage;
import com.fsck.k9.mailstore.LocalStore;
@@ -139,6 +143,8 @@ public class MessagingControllerTest {
        ShadowLog.stream = System.out;
        MockitoAnnotations.initMocks(this);
        appContext = ShadowApplication.getInstance().getApplicationContext();
        GlobalsHelper.setContext(appContext);
        GlobalsHelper.setOAuth2TokenProvider(new AndroidAccountOAuth2TokenStore(appContext));

        controller = new MessagingController(appContext, notificationController, contacts, transportProvider);

@@ -832,7 +838,7 @@ public class MessagingControllerTest {
        when(localStore.getFolder(SENT_FOLDER_NAME)).thenReturn(sentFolder);
        when(sentFolder.getDatabaseId()).thenReturn(1L);
        when(localFolder.exists()).thenReturn(true);
        when(transportProvider.getTransport(appContext, account)).thenReturn(transport);
        when(transportProvider.getTransport(any(Context.class), any(Account.class), any(OAuth2TokenProvider.class))).thenReturn(transport);
        when(localFolder.getMessages(null)).thenReturn(Collections.singletonList(localMessageToSend1));
        when(localMessageToSend1.getUid()).thenReturn("localMessageToSend1");
        when(localMessageToSend1.getHeader(K9.IDENTITY_HEADER)).thenReturn(new String[]{});