diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index d4c85eb48a..c9665121cf 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -204,6 +204,20 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB drawerLayout.closeDrawer(drawerList); } }); + drawerList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + @Override + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + DrawerItem item = (DrawerItem) parent.getAdapter().getItem(position); + switch (item.getId()) { + case -1: + drawerLayout.closeDrawer(drawerList); + onMenuInbox((long) item.getData()); + return true; + default: + return false; + } + } + }); getSupportFragmentManager().addOnBackStackChangedListener(this); @@ -707,6 +721,32 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB fragmentTransaction.commit(); } + private void onMenuInbox(long account) { + Bundle args = new Bundle(); + args.putLong("account", account); + + new SimpleTask() { + @Override + protected Long onLoad(Context context, Bundle args) throws Throwable { + long account = args.getLong("account"); + return DB.getInstance(context).folder().getFolderByType(account, EntityFolder.INBOX).id; + } + + @Override + protected void onLoaded(Bundle args, Long folder) { + long account = args.getLong("account"); + + getSupportFragmentManager().popBackStack("unified", 0); + + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(ActivityView.this); + lbm.sendBroadcast( + new Intent(ActivityView.ACTION_VIEW_MESSAGES) + .putExtra("account", account) + .putExtra("folder", folder)); + } + }.load(this, args); + } + private void onMenuSetup() { startActivity(new Intent(ActivityView.this, ActivitySetup.class)); }