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

Unverified Commit 58598c07 authored by williamvds's avatar williamvds
Browse files

Add unified inbox to drawer

parent e5a95805
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -619,10 +619,19 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
    }

    public void openFolder(String folderName) {
        search = new LocalSearch(folderName);
        LocalSearch search = new LocalSearch(folderName);
        search.addAccountUuid(account.getUuid());
        search.addAllowedFolder(folderName);

        performSearch(search);
    }

    public void openUnifiedInbox() {
        drawer.selectUnifiedInbox();
        performSearch(SearchAccount.createUnifiedInboxAccount().getRelatedSearch());
    }

    private void performSearch(LocalSearch search) {
        initializeFromLocalSearch(search);

        FragmentManager fragmentManager = getSupportFragmentManager();
+25 −4
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import android.util.TypedValue;
import android.view.View;

import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.ui.R;
import com.fsck.k9.mailstore.Folder;
import com.fsck.k9.ui.folders.FolderNameFormatter;
@@ -23,14 +24,16 @@ import com.mikepenz.materialdrawer.model.BaseDrawerItem;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import timber.log.Timber;

public class K9Drawer {
    // Bit shift for identifiers of user folders items, to leave space for other items
    private static final short DRAWER_FOLDER_SHIFT = 2;

    // Identifiers of static drawer items
    private static final long DRAWER_ID_PREFERENCES = 0;
    private static final long DRAWER_ID_UNIFIED_INBOX = 0;
    private static final long DRAWER_ID_PREFERENCES = 1;

    private int headerCount = 0;

    // Resources
    private int iconFolderInboxResId;
@@ -64,6 +67,17 @@ public class K9Drawer {
                .withSavedInstance(savedInstanceState)
                .build();

        // header
        if (!K9.isHideSpecialAccounts()) {
            drawer.addItems(new PrimaryDrawerItem()
                    .withName(R.string.integrated_inbox_title)
                    .withIcon(getResId(R.attr.iconUnifiedInbox))
                    .withIdentifier(DRAWER_ID_UNIFIED_INBOX),
                    new DividerDrawerItem());

            headerCount += 2;
        }

        // footer
        drawer.addItems(new DividerDrawerItem(),
                new PrimaryDrawerItem()
@@ -117,7 +131,10 @@ public class K9Drawer {
            @Override
            public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                long id = drawerItem.getIdentifier();
                if (id == DRAWER_ID_PREFERENCES) {
                if (id == DRAWER_ID_UNIFIED_INBOX) {
                    parent.openUnifiedInbox();
                    return false;
                } else if (id == DRAWER_ID_PREFERENCES) {
                    SettingsActivity.launch(parent);
                    return false;
                }
@@ -152,7 +169,7 @@ public class K9Drawer {
                    .withIdentifier(id)
                    .withTag(folder)
                    .withName(getFolderDisplayName(folder)),
                    0);
                    headerCount);

            userFolderIds.add(id);

@@ -184,6 +201,10 @@ public class K9Drawer {
        }
    }

    public void selectUnifiedInbox() {
        drawer.setSelection(DRAWER_ID_UNIFIED_INBOX, false);
    }

    public DrawerLayout getLayout() {
        return drawer.getDrawerLayout();
    }
+7 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:width="24dp"
    android:viewportWidth="24"
		android:viewportHeight="24">
    <path android:fillColor="#fff" android:pathData="M19 3H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 6h-4c0 1.62-1.38 3-3 3s-3-1.38-3-3H5V5h14v4zm-4 7h6v3c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-3h6c0 1.66 1.34 3 3 3s3-1.34 3-3z" />
</vector>
+8 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="24dp"
    android:width="24dp"
    android:alpha="0.54"
    android:viewportWidth="24"
		android:viewportHeight="24">
    <path android:fillColor="#000" android:pathData="M19 3H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 6h-4c0 1.62-1.38 3-3 3s-3-1.38-3-3H5V5h14v4zm-4 7h6v3c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-3h6c0 1.66 1.34 3 3 3s3-1.34 3-3z" />
</vector>
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
<resources>

    <declare-styleable name="K9Styles">
        <attr name="iconUnifiedInbox" format="reference" />
        <attr name="iconFolder" format="reference" />
        <attr name="iconFolderInbox" format="reference" />
        <attr name="iconFolderOutbox" format="reference" />
Loading