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

Commit 33e74567 authored by M Madison Phillips's avatar M Madison Phillips Committed by cketti
Browse files

Don't crash when MessageCompose is started with no account configured

parent 262e0840
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -7,16 +7,22 @@ import android.os.Parcelable;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.activity.MessageCompose;
import com.fsck.k9.activity.setup.AccountSetupBasics;
import com.fsck.k9.controller.MessageReference;

public class MessageActions {
    /**
     * Compose a new message using the given account. If account is null the default account
     * will be used.
     * will be used. If there is no default account set, user will be sent to AccountSetupBasics
     * activity.
     */
    public static void actionCompose(Context context, Account account) {
        Account defaultAccount = Preferences.getPreferences(context).getDefaultAccount();
        if (account == null && defaultAccount == null) {
            AccountSetupBasics.actionNewAccount(context);
        } else {
            String accountUuid = (account == null) ?
                Preferences.getPreferences(context).getDefaultAccount().getUuid() :
                    defaultAccount.getUuid() :
                    account.getUuid();

            Intent i = new Intent(context, MessageCompose.class);
@@ -24,6 +30,7 @@ public class MessageActions {
            i.setAction(MessageCompose.ACTION_COMPOSE);
            context.startActivity(i);
        }
    }

    /**
     * Get intent for composing a new message as a reply to the given message. If replyAll is true