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

Unverified Commit 6de17040 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #3823 from ByteHamster/folder-list

Removed unneeded options from folder list
parents ea13abb0 f69a1850
Loading
Loading
Loading
Loading
+1 −116
Original line number Diff line number Diff line
@@ -190,39 +190,6 @@ public class FolderList extends K9ListActivity {
        }
    }

    /**
    * This class is responsible for reloading the list of local messages for a
    * given folder, notifying the adapter that the message have been loaded and
    * queueing up a remote update of the folder.
     */

    private void checkMail(FolderInfoHolder folder) {
        TracingPowerManager pm = TracingPowerManager.getPowerManager(this);
        final TracingWakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "FolderList checkMail");
        wakeLock.setReferenceCounted(false);
        wakeLock.acquire(K9.WAKE_LOCK_TIMEOUT);
        MessagingListener listener = new SimpleMessagingListener() {
            @Override
            public void synchronizeMailboxFinished(Account account, String folderServerId, int totalMessagesInMailbox, int numNewMessages) {
                if (!account.equals(FolderList.this.account)) {
                    return;
                }
                wakeLock.release();
            }

            @Override
            public void synchronizeMailboxFailed(Account account, String folderServerId,
            String message) {
                if (!account.equals(FolderList.this.account)) {
                    return;
                }
                wakeLock.release();
            }
        };
        MessagingController.getInstance(getApplication()).synchronizeMailbox(account, folder.serverId, listener, null);
        sendMail(account);
    }

    public static Intent actionHandleAccountIntent(Context context, Account account, boolean fromShortcut) {
        Intent intent = new Intent(context, FolderList.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -254,15 +221,13 @@ public class FolderList extends K9ListActivity {
        actionBarProgressView = getActionBarProgressView();
        listView = getListView();
        listView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        listView.setLongClickable(true);
        listView.setFastScrollEnabled(true);
        listView.setScrollingCacheEnabled(false);
        listView.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                onOpenFolder(((FolderInfoHolder) adapter.getItem(position)).serverId);
                FolderSettings.actionSettings(FolderList.this, account, ((FolderInfoHolder) adapter.getItem(position)).serverId);
            }
        });
        registerForContextMenu(listView);

        listView.setSaveEnabled(true);

@@ -279,11 +244,6 @@ public class FolderList extends K9ListActivity {
             */
            return;
        }

        ChangeLog cl = new ChangeLog(this);
        if (cl.isFirstRun()) {
            cl.getLogDialog().show();
        }
    }

    @SuppressLint("InflateParams")
@@ -387,18 +347,11 @@ public class FolderList extends K9ListActivity {
            onAccounts();
            return true;
        }

        case KeyEvent.KEYCODE_S: {
            onEditSettings();
            return true;
        }

        case KeyEvent.KEYCODE_H: {
            Toast toast = Toast.makeText(this, R.string.folder_list_help_key, Toast.LENGTH_LONG);
            toast.show();
            return true;
        }

        case KeyEvent.KEYCODE_1: {
            setDisplayMode(FolderMode.FIRST_CLASS);
            return true;
@@ -433,13 +386,7 @@ public class FolderList extends K9ListActivity {


    private void onRefresh(final boolean forceRemote) {

        MessagingController.getInstance(getApplication()).listFolders(account, forceRemote, adapter.mListener);

    }

    private void onEditSettings() {
        SettingsActivity.launch(this);
    }

    private void onAccounts() {
@@ -447,46 +394,18 @@ public class FolderList extends K9ListActivity {
        finish();
    }

    private void onEmptyTrash(final Account account) {
        handler.dataChanged();

        MessagingController.getInstance(getApplication()).emptyTrash(account, null);
    }

    private void onClearFolder(Account account, String folderServerId) {
        MessagingController.getInstance(getApplication()).clearFolder(account, folderServerId, adapter.mListener);
    }

    private void sendMail(Account account) {
        MessagingController.getInstance(getApplication()).sendPendingMessages(account, adapter.mListener);
    }

    @Override public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            onAccounts();
            return true;
        } else if (id == R.id.search) {
            onSearchRequested();
            return true;
        } else if (id == R.id.compose) {
            MessageActions.actionCompose(this, account);
            return true;
        } else if (id == R.id.check_mail) {
            MessagingController.getInstance(getApplication()).checkMail(this, account, true, true, adapter.mListener);
            return true;
        } else if (id == R.id.send_messages) {
            MessagingController.getInstance(getApplication()).sendPendingMessages(account, null);
            return true;
        } else if (id == R.id.list_folders) {
            onRefresh(REFRESH_REMOTE);
            return true;
        } else if (id == R.id.settings) {
            onEditSettings();
            return true;
        } else if (id == R.id.empty_trash) {
            onEmptyTrash(account);
            return true;
        } else if (id == R.id.compact) {
            onCompact(account);
            return true;
@@ -507,14 +426,6 @@ public class FolderList extends K9ListActivity {
        }
    }

    @Override
    public boolean onSearchRequested() {
         Bundle appData = new Bundle();
         appData.putString(MessageList.EXTRA_SEARCH_ACCOUNT, account.getUuid());
         startSearch(null, false, appData, false);
         return true;
     }

    private void onOpenFolder(String folder) {
        LocalSearch search = new LocalSearch(folder);
        search.addAccountUuid(account.getUuid());
@@ -565,32 +476,6 @@ public class FolderList extends K9ListActivity {
        });
    }

    @Override public boolean onContextItemSelected(android.view.MenuItem item) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo();
        FolderInfoHolder folder = (FolderInfoHolder) adapter.getItem(info.position);

        int id = item.getItemId();
        if (id == R.id.clear_local_folder) {
            onClearFolder(account, folder.serverId);
        } else if (id == R.id.refresh_folder) {
            checkMail(folder);
        } else if (id == R.id.folder_settings) {
            FolderSettings.actionSettings(this, account, folder.serverId);
        }

        return super.onContextItemSelected(item);
    }

    @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        getMenuInflater().inflate(R.menu.folder_context, menu);

        FolderInfoHolder folder = (FolderInfoHolder) adapter.getItem(info.position);

        menu.setHeaderTitle(folder.displayName);
    }

    class FolderListAdapter extends BaseAdapter implements Filterable {
        private List<FolderInfoHolder> mFolders = new ArrayList<>();
        private List<FolderInfoHolder> mFilteredFolders = Collections.unmodifiableList(mFolders);
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingRight="4dip"
        android:orientation="horizontal"
        android:gravity="center_vertical">
        android:gravity="center_vertical"
        android:descendantFocusability="blocksDescendants">

    <View
            android:id="@+id/chip"
+0 −15
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/refresh_folder"
        android:title="@string/check_mail_action"
    />
    <item
        android:id="@+id/clear_local_folder"
        android:title="@string/clear_local_folder_action"
    />
    <item
        android:id="@+id/folder_settings"
        android:title="@string/folders_action"
    />
</menu>
+0 −32
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/search"
        android:icon="?attr/iconActionSearch"
        app:showAsAction="ifRoom"
        android:title="@string/search_action"/>
    <item
        android:id="@+id/filter_folders"
        android:icon="?attr/iconActionSearchFolder"
        app:showAsAction="ifRoom|collapseActionView"
        android:title="@string/filter_folders_action"
        app:actionViewClass="android.widget.SearchView"/>
    <item
        android:id="@+id/check_mail"
        android:alphabeticShortcut="r"
        android:icon="?attr/iconActionRefresh"
        app:showAsAction="always"
        android:title="@string/check_mail_action"/>
    <item
        android:id="@+id/compose"
        android:alphabeticShortcut="c"
        android:icon="?attr/iconActionCompose"
        app:showAsAction="always"
        android:title="@string/compose_action"/>
    <item
        android:icon="?attr/iconFolder"
        android:title="@string/folder_list_display_mode_label">
@@ -42,15 +25,6 @@
                android:title="@string/folder_list_display_mode_not_second_class"/>
        </menu>
    </item>
    <item
        android:id="@+id/send_messages"
        android:icon="?attr/iconActionUpload"
        android:title="@string/send_messages_action"/>
    <item
        android:id="@+id/empty_trash"
        android:alphabeticShortcut="e"
        android:icon="?attr/iconActionDelete"
        android:title="@string/empty_trash_action"/>
    <item
        android:id="@+id/compact"
        app:showAsAction="never"
@@ -59,10 +33,4 @@
        android:id="@+id/list_folders"
        android:icon="?attr/iconActionRefresh"
        android:title="@string/refresh_folders_action"/>
    <item
        android:id="@+id/settings"
        android:icon="?attr/iconActionSettings"
        app:showAsAction="never"
        android:title="@string/preferences_action"/>

</menu>