From 705ba76509427de8a51b02b6edad65d1abf49727 Mon Sep 17 00:00:00 2001 From: cketti Date: Sat, 12 Jan 2013 22:52:09 +0100 Subject: [PATCH] Close thread view when last message has been moved/deleted --- src/com/fsck/k9/activity/MessageList.java | 25 +++++++++++-------- .../fsck/k9/fragment/MessageListFragment.java | 16 ++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 66202ed12..00e009c79 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -364,16 +364,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: { - FragmentManager fragmentManager = getSupportFragmentManager(); - if (fragmentManager.getBackStackEntryCount() > 0) { - fragmentManager.popBackStack(); - } else if (mMessageListFragment.isManualSearch()) { - onBackPressed(); - } else if (!mSingleFolderMode) { - onAccounts(); - } else { - onShowFolderList(); - } + goBack(); return true; } case R.id.compose: { @@ -722,4 +713,18 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme // Remove action button for remote search configureMenu(mMenu); } + + @Override + public void goBack() { + FragmentManager fragmentManager = getSupportFragmentManager(); + if (fragmentManager.getBackStackEntryCount() > 0) { + fragmentManager.popBackStack(); + } else if (mMessageListFragment.isManualSearch()) { + onBackPressed(); + } else if (!mSingleFolderMode) { + onAccounts(); + } else { + onShowFolderList(); + } + } } diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index 8d9eced4e..98f2d3862 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -429,6 +429,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private static final int ACTION_REFRESH_TITLE = 2; private static final int ACTION_PROGRESS = 3; private static final int ACTION_REMOTE_SEARCH_FINISHED = 4; + private static final int ACTION_GO_BACK = 5; public void folderLoading(String folder, boolean loading) { @@ -462,6 +463,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick }); } + public void goBack() { + android.os.Message msg = android.os.Message.obtain(this, ACTION_GO_BACK); + sendMessage(msg); + } + @Override public void handleMessage(android.os.Message msg) { // The following messages don't need an attached activity. @@ -494,6 +500,10 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick MessageListFragment.this.progress(progress); break; } + case ACTION_GO_BACK: { + mFragmentListener.goBack(); + break; + } } } } @@ -2748,6 +2758,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick void onCompose(Account account); boolean startSearch(Account account, String folderName); void remoteSearchStarted(); + void goBack(); } public void onReverseSort() { @@ -3017,6 +3028,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick @Override public void onLoadFinished(Loader loader, Cursor data) { + if (mIsThreadDisplay && data.getCount() == 0) { + mHandler.goBack(); + return; + } + // Remove the "Loading..." view mPullToRefreshView.setEmptyView(null);