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

Commit c3c75934 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

add "Manage folders" item to drawer footer

part of #3750
parent 8b3d5168
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -617,6 +617,15 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
        actionDisplaySearch(this, SearchAccount.createUnifiedInboxAccount().getRelatedSearch(), false, false);
    }

    public void openFolderSettings() {
        if (account == null) {
            Timber.e("Tried to open account settings, but no account selected!");
            return;
        }

        FolderList.actionHandleAccount(this, account);
    }

    public void openRealAccount(Account realAccount) {
        if (realAccount.getAutoExpandFolder() == null) {
            FolderList.actionHandleAccount(this, realAccount);
+25 −6
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class K9Drawer {

    private static final long DRAWER_ID_UNIFIED_INBOX = 0;
    private static final long DRAWER_ID_PREFERENCES = 1;
    private static final long DRAWER_ID_FOLDERS = 2;


    private final FolderNameFormatter folderNameFormatter = DI.get(FolderNameFormatter.class);
@@ -75,6 +76,8 @@ public class K9Drawer {
    public K9Drawer(MessageList parent, Bundle savedInstanceState) {
        this.parent = parent;

        initializeFolderIcons();

        drawer = new DrawerBuilder()
                .withActivity(parent)
                .withDisplayBelowStatusBar(false)
@@ -88,8 +91,6 @@ public class K9Drawer {
                .build();

        addFooterItems();

        initializeFolderIcons();
    }

    private AccountHeader buildAccountHeader() {
@@ -159,11 +160,17 @@ public class K9Drawer {

    private void addFooterItems() {
        drawer.addItems(new DividerDrawerItem(),
                new PrimaryDrawerItem()
                        .withName(R.string.folders_action)
                        .withIcon(iconFolderResId)
                        .withIdentifier(DRAWER_ID_FOLDERS)
                        .withSelectable(false),
                new PrimaryDrawerItem()
                        .withName(R.string.preferences_action)
                        .withIcon(getResId(R.attr.iconActionSettings))
                        .withIdentifier(DRAWER_ID_PREFERENCES)
                .withSelectable(false));
                        .withSelectable(false)
        );
    }

    private void initializeFolderIcons() {
@@ -218,7 +225,14 @@ public class K9Drawer {
                    setUserFolders(folders);
                }
            });
            updateFolderSettingsItem();
        }
    }

    private void updateFolderSettingsItem() {
        IDrawerItem drawerItem = drawer.getDrawerItem(DRAWER_ID_FOLDERS);
        drawerItem.withEnabled(!unifiedInboxSelected);
        drawer.updateItem(drawerItem);
    }

    private OnDrawerItemClickListener createItemClickListener() {
@@ -229,6 +243,9 @@ public class K9Drawer {
                if (id == DRAWER_ID_PREFERENCES) {
                    SettingsActivity.launch(parent);
                    return false;
                } else if (id == DRAWER_ID_FOLDERS) {
                    parent.openFolderSettings();
                    return false;
                } else {
                    Folder folder = (Folder) drawerItem.getTag();
                    parent.openFolder(folder.getServerId());
@@ -285,6 +302,7 @@ public class K9Drawer {
                return;
            }
        }
        updateFolderSettingsItem();
    }

    public void selectUnifiedInbox() {
@@ -293,6 +311,7 @@ public class K9Drawer {
        accountHeader.setActiveProfile(DRAWER_ID_UNIFIED_INBOX);
        accountHeader.getHeaderBackgroundView().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY);
        clearUserFolders();
        updateFolderSettingsItem();
    }

    public DrawerLayout getLayout() {
+1 −1
Original line number Diff line number Diff line
@@ -10,6 +10,6 @@
    />
    <item
        android:id="@+id/folder_settings"
        android:title="@string/folder_settings_action"
        android:title="@string/folders_action"
    />
</menu>
+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ Please submit bug reports, contribute new features and ask questions at
    <string name="search_action">Search</string>
    <string name="search_results">Search results</string>
    <string name="preferences_action">Settings</string>
    <string name="folders_action">Manage folders</string>
    <string name="account_settings_action">Account settings</string>
    <string name="folder_settings_action">Folder settings</string>
    <string name="global_settings_action">Global settings</string>