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

Unverified Commit 2673d64f authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #4233 from k9mail/remove_accounts_activity

Remove 'Accounts' activity
parents 2a96e5d3 2fcef664
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -80,23 +80,16 @@
            android:name="com.samsung.android.sdk.multiwindow.penwindow.enable"
            android:value="true"/>

        <activity
        <!-- activity-alias so old launcher shortcuts work -->
        <!-- TODO: Remove after 2020-12-31 -->
        <activity-alias
            android:name=".activity.Accounts"
            android:configChanges="locale"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:uiOptions="splitActionBarWhenNarrow">
            android:targetActivity=".activity.MessageList" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER" />

                <!-- TODO: Remove once minSdkVersion has been changed to 24+ -->
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
                <category android:name="android.intent.category.PENWINDOW_LAUNCHER"/>
            </intent-filter>
        </activity>
        </activity-alias>

        <activity
            android:name=".ui.onboarding.OnboardingActivity"
@@ -220,8 +213,14 @@
            android:launchMode="singleTop"
            android:uiOptions="splitActionBarWhenNarrow">
            <intent-filter>
                <!-- This action is only to allow an entry point for launcher shortcuts -->
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>

                <!-- TODO: Remove once minSdkVersion has been changed to 24+ -->
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
                <category android:name="android.intent.category.PENWINDOW_LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
+27 −70
Original line number Diff line number Diff line
@@ -6,16 +6,12 @@ import java.util.List;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import androidx.core.app.TaskStackBuilder;
import android.text.TextUtils;

import com.fsck.k9.Account;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.Accounts;
import com.fsck.k9.activity.FolderList;
import com.fsck.k9.activity.MessageList;
import com.fsck.k9.controller.MessageReference;
import com.fsck.k9.activity.NotificationDeleteConfirmation;
@@ -47,40 +43,40 @@ class K9NotificationActionCreator implements NotificationActionCreator {

    @Override
    public PendingIntent createViewMessagePendingIntent(MessageReference messageReference, int notificationId) {
        TaskStackBuilder stack = buildMessageViewBackStack(messageReference);
        return stack.getPendingIntent(notificationId, PendingIntent.FLAG_UPDATE_CURRENT);
        Intent intent = createMessageViewIntent(messageReference);
        return PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    @Override
    public PendingIntent createViewFolderPendingIntent(Account account, String folderServerId, int notificationId) {
        TaskStackBuilder stack = buildMessageListBackStack(account, folderServerId);
        return stack.getPendingIntent(notificationId, PendingIntent.FLAG_UPDATE_CURRENT);
        Intent intent = createMessageListIntent(account, folderServerId);
        return PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    @Override
    public PendingIntent createViewMessagesPendingIntent(Account account, List<MessageReference> messageReferences,
            int notificationId) {

        TaskStackBuilder stack;
        Intent intent;
        if (account.isGoToUnreadMessageSearch()) {
            stack = buildUnreadBackStack(account);
            intent = createUnreadIntent(account);
        } else {
            String folderServerId = getFolderServerIdOfAllMessages(messageReferences);

            if (folderServerId == null) {
                stack = buildFolderListBackStack(account);
                intent = createMessageListIntent(account);
            } else {
                stack = buildMessageListBackStack(account, folderServerId);
                intent = createMessageListIntent(account, folderServerId);
            }
        }

        return stack.getPendingIntent(notificationId, PendingIntent.FLAG_UPDATE_CURRENT);
        return PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    @Override
    public PendingIntent createViewFolderListPendingIntent(Account account, int notificationId) {
        TaskStackBuilder stack = buildFolderListBackStack(account);
        return stack.getPendingIntent(notificationId, PendingIntent.FLAG_UPDATE_CURRENT);
        Intent intent = createMessageListIntent(account);
        return PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    @Override
@@ -207,63 +203,32 @@ class K9NotificationActionCreator implements NotificationActionCreator {
        return PendingIntent.getService(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    private TaskStackBuilder buildAccountsBackStack() {
        TaskStackBuilder stack = TaskStackBuilder.create(context);
        if (!skipAccountsInBackStack()) {
            Intent intent = new Intent(context, Accounts.class);
            intent.putExtra(Accounts.EXTRA_STARTUP, false);

            stack.addNextIntent(intent);
        }
        return stack;
    }

    private TaskStackBuilder buildFolderListBackStack(Account account) {
        TaskStackBuilder stack = buildAccountsBackStack();

        Intent intent = FolderList.actionHandleAccountIntent(context, account, false);

        stack.addNextIntent(intent);

        return stack;
    }

    private TaskStackBuilder buildUnreadBackStack(final Account account) {
        TaskStackBuilder stack = buildAccountsBackStack();

    private Intent createUnreadIntent(final Account account) {
        String searchTitle = context.getString(R.string.search_title, account.getDescription(), context.getString(R.string.unread_modifier));
        LocalSearch search = accountSearchConditions.createUnreadSearch(account, searchTitle);
        Intent intent = MessageList.intentDisplaySearch(context, search, true, false, false);

        stack.addNextIntent(intent);

        return stack;
        return MessageList.intentDisplaySearch(context, search, true, false, false);
    }

    private TaskStackBuilder buildMessageListBackStack(Account account, String folderServerId) {
        TaskStackBuilder stack = skipFolderListInBackStack(account, folderServerId) ?
                buildAccountsBackStack() : buildFolderListBackStack(account);

    private Intent createMessageListIntent(Account account) {
        String folderServerId = account.getAutoExpandFolder();
        if (folderServerId == null) {
            folderServerId = account.getInboxFolder();
        }
        LocalSearch search = new LocalSearch(folderServerId);
        search.addAllowedFolder(folderServerId);
        search.addAccountUuid(account.getUuid());
        Intent intent = MessageList.intentDisplaySearch(context, search, false, true, true);

        stack.addNextIntent(intent);

        return stack;
        return MessageList.intentDisplaySearch(context, search, false, true, true);
    }

    private TaskStackBuilder buildMessageViewBackStack(MessageReference message) {
        Account account = Preferences.getPreferences(context).getAccount(message.getAccountUuid());
        String folderServerId = message.getFolderServerId();
        TaskStackBuilder stack = buildMessageListBackStack(account, folderServerId);

        Intent intent = MessageList.actionDisplayMessageIntent(context, message);

        stack.addNextIntent(intent);
    private Intent createMessageListIntent(Account account, String folderServerId) {
        LocalSearch search = new LocalSearch(folderServerId);
        search.addAllowedFolder(folderServerId);
        search.addAccountUuid(account.getUuid());
        return MessageList.intentDisplaySearch(context, search, false, true, true);
    }

        return stack;
    private Intent createMessageViewIntent(MessageReference message) {
        return MessageList.actionDisplayMessageIntent(context, message);
    }

    private String getFolderServerIdOfAllMessages(List<MessageReference> messageReferences) {
@@ -278,12 +243,4 @@ class K9NotificationActionCreator implements NotificationActionCreator {

        return folderServerId;
    }

    private boolean skipFolderListInBackStack(Account account, String folderServerId) {
        return folderServerId != null && folderServerId.equals(account.getAutoExpandFolder());
    }

    private boolean skipAccountsInBackStack() {
        return Preferences.getPreferences(context).getAccounts().size() == 1;
    }
}
+0 −1990

File deleted.

Preview size limit exceeded, changes collapsed.

+2 −12
Original line number Diff line number Diff line
@@ -287,8 +287,7 @@ public class FolderList extends K9ListActivity {
        super.onResume();

        if (!account.isAvailable(this)) {
            Timber.i("account unavaliabale, not showing folder-list but account-list");
            Accounts.listAccounts(this);
            Timber.i("Account is unavailable right now: " + account);
            finish();
            return;
        }
@@ -311,10 +310,6 @@ public class FolderList extends K9ListActivity {
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        //Shortcuts that work no matter what is selected
        switch (keyCode) {
        case KeyEvent.KEYCODE_Q: {
            onAccounts();
            return true;
        }
        case KeyEvent.KEYCODE_H: {
            Toast toast = Toast.makeText(this, R.string.folder_list_help_key, Toast.LENGTH_LONG);
            toast.show();
@@ -357,15 +352,10 @@ public class FolderList extends K9ListActivity {
        MessagingController.getInstance(getApplication()).listFolders(account, forceRemote, adapter.activityListener);
    }

    private void onAccounts() {
        Accounts.listAccounts(this);
        finish();
    }

    @Override public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            onAccounts();
            onBackPressed();
            return true;
        } else if (id == R.id.list_folders) {
            onRefresh(REFRESH_REMOTE);
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
             * There are no accounts set up. This should not have happened. Prompt the
             * user to set up an account as an acceptable bailout.
             */
            startActivity(new Intent(this, Accounts.class));
            MessageList.launch(this);
            changesMadeSinceLastSave = false;
            finish();
            return;
Loading