From 508e9e8aa669075852a2e5906d3613177fcd0730 Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 24 Oct 2012 05:28:38 +0200 Subject: [PATCH] Don't display threaded message list for filtered views --- src/com/fsck/k9/activity/Accounts.java | 6 ++-- src/com/fsck/k9/activity/FolderList.java | 4 +-- .../fsck/k9/activity/LauncherShortcuts.java | 3 +- src/com/fsck/k9/activity/MessageList.java | 28 ++++++++++++++----- .../k9/controller/MessagingController.java | 4 +-- .../k9/provider/UnreadWidgetProvider.java | 3 +- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 9d6482a64..f45f908e3 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -620,7 +620,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { private boolean onOpenAccount(BaseAccount account) { if (account instanceof SearchAccount) { SearchAccount searchAccount = (SearchAccount)account; - MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false); + MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false, false); } else { Account realAccount = (Account)account; if (!realAccount.isEnabled()) { @@ -640,7 +640,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderName()); search.addAllowedFolder(realAccount.getAutoExpandFolderName()); search.addAccountUuid(realAccount.getUuid()); - MessageList.actionDisplaySearch(this, search, true);} + MessageList.actionDisplaySearch(this, search, false, true);} } return true; } @@ -1797,7 +1797,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { search.allRequiredFlags(searchModifier.requiredFlags); search.allForbiddenFlags(searchModifier.forbiddenFlags); - MessageList.actionDisplaySearch(Accounts.this, search, false); + MessageList.actionDisplaySearch(Accounts.this, search, true, false); } } diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 487e8f44e..28eab3ec7 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -625,7 +625,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { LocalSearch search = new LocalSearch(folder); search.addAccountUuid(mAccount.getUuid()); search.addAllowedFolder(folder); - MessageList.actionDisplaySearch(this, search, false); + MessageList.actionDisplaySearch(this, search, false, false); } private void onCompact(Account account) { @@ -1276,7 +1276,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { } search.addAllowedFolder(folderName); search.addAccountUuid(account.getUuid()); - MessageList.actionDisplaySearch(FolderList.this, search, false); + MessageList.actionDisplaySearch(FolderList.this, search, true, false); } } diff --git a/src/com/fsck/k9/activity/LauncherShortcuts.java b/src/com/fsck/k9/activity/LauncherShortcuts.java index f302051dc..94e6a4ff8 100644 --- a/src/com/fsck/k9/activity/LauncherShortcuts.java +++ b/src/com/fsck/k9/activity/LauncherShortcuts.java @@ -31,7 +31,8 @@ public class LauncherShortcuts extends AccountList { Intent shortcutIntent = null; if (account instanceof SearchSpecification) { - shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account, true, true); + shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account, + false, true, true); } else { shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null, true); diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 020e07110..67f065da8 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -49,22 +49,28 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme // for this activity private static final String EXTRA_SEARCH = "search"; + private static final String EXTRA_NO_THREADING = "no_threading"; // used for remote search private static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account"; private static final String EXTRA_SEARCH_FOLDER = "com.fsck.k9.search_folder"; - public static void actionDisplaySearch(Context context, SearchSpecification search, boolean newTask) { - actionDisplaySearch(context, search, newTask, true); + public static void actionDisplaySearch(Context context, SearchSpecification search, + boolean noThreading, boolean newTask) { + actionDisplaySearch(context, search, noThreading, newTask, true); } - public static void actionDisplaySearch(Context context, SearchSpecification search, boolean newTask, boolean clearTop) { - context.startActivity(intentDisplaySearch(context, search, newTask, clearTop)); + public static void actionDisplaySearch(Context context, SearchSpecification search, + boolean noThreading, boolean newTask, boolean clearTop) { + context.startActivity( + intentDisplaySearch(context, search, noThreading, newTask, clearTop)); } - public static Intent intentDisplaySearch(Context context, SearchSpecification search, boolean newTask, boolean clearTop) { + public static Intent intentDisplaySearch(Context context, SearchSpecification search, + boolean noThreading, boolean newTask, boolean clearTop) { Intent intent = new Intent(context, MessageList.class); intent.putExtra(EXTRA_SEARCH, search); + intent.putExtra(EXTRA_NO_THREADING, noThreading); if (clearTop) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); @@ -95,6 +101,13 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme private boolean mIsRemote; private boolean mThreadViewEnabled = true; //TODO: this should be a setting + /** + * {@code true} if the message list should be displayed as flat list (i.e. no threading) + * regardless whether or not message threading was enabled in the settings. This is used for + * filtered views, e.g. when only displaying the unread messages in a folder. + */ + private boolean mNoThreading; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -115,8 +128,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme if (mMessageListFragment == null) { FragmentTransaction ft = fragmentManager.beginTransaction(); - mMessageListFragment = MessageListFragment.newInstance(mSearch, mThreadViewEnabled, - mIsRemote); + mMessageListFragment = MessageListFragment.newInstance(mSearch, + (mThreadViewEnabled && !mNoThreading), mIsRemote); ft.add(R.id.message_list_container, mMessageListFragment); ft.commit(); } @@ -143,6 +156,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme } else { // regular LocalSearch object was passed mSearch = intent.getParcelableExtra(EXTRA_SEARCH); + mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false); } String[] accounts = mSearch.getAccountUuids(); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 2c3ee24ea..4d0dcf2cc 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -3053,7 +3053,7 @@ public class MessagingController implements Runnable { LocalSearch search = new LocalSearch(account.getInboxFolderName()); search.addAllowedFolder(account.getInboxFolderName()); search.addAccountUuid(account.getUuid()); - Intent intent = MessageList.intentDisplaySearch(mApplication, search, true, true); + Intent intent = MessageList.intentDisplaySearch(mApplication, search, false, true, true); PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0); builder.setContentIntent(pi); @@ -3139,7 +3139,7 @@ public class MessagingController implements Runnable { LocalSearch search = new LocalSearch(account.getInboxFolderName()); search.addAllowedFolder(account.getInboxFolderName()); search.addAccountUuid(account.getUuid()); - Intent intent = MessageList.intentDisplaySearch(mApplication, search, true, true); + Intent intent = MessageList.intentDisplaySearch(mApplication, search, false, true, true); PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0); builder.setContentIntent(pi); diff --git a/src/com/fsck/k9/provider/UnreadWidgetProvider.java b/src/com/fsck/k9/provider/UnreadWidgetProvider.java index 180b8c22a..75acd1073 100644 --- a/src/com/fsck/k9/provider/UnreadWidgetProvider.java +++ b/src/com/fsck/k9/provider/UnreadWidgetProvider.java @@ -66,7 +66,8 @@ public class UnreadWidgetProvider extends AppWidgetProvider { LocalSearch search = new LocalSearch(account.getAutoExpandFolderName()); search.addAllowedFolder(account.getAutoExpandFolderName()); search.addAccountUuid(account.getUuid()); - clickIntent = MessageList.intentDisplaySearch(context, search, true, true); + clickIntent = MessageList.intentDisplaySearch(context, search, false, true, + true); } clickIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); }