Commit 348e775c authored by Hussein's avatar Hussein

Merge branch 'bug/P4A-893' into develop

parents 1c53c2df d70aff48
...@@ -186,6 +186,7 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -186,6 +186,7 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
private Account lastUsedAccount; private Account lastUsedAccount;
private SearchAccount unifiedInboxAccount; private SearchAccount unifiedInboxAccount;
private SearchAccount allMessagesAccount; private SearchAccount allMessagesAccount;
private String specialAccountUuid;
public static void actionDisplaySearch(Context context, SearchSpecification search, public static void actionDisplaySearch(Context context, SearchSpecification search,
boolean noThreading, boolean newTask, boolean isFolder) { boolean noThreading, boolean newTask, boolean isFolder) {
...@@ -261,6 +262,7 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -261,6 +262,7 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
} }
private void updateMessagesForSpecificInbox(SearchAccount searchAccount) { private void updateMessagesForSpecificInbox(SearchAccount searchAccount) {
specialAccountUuid = searchAccount.getUuid();
LocalSearch search = searchAccount.getRelatedSearch(); LocalSearch search = searchAccount.getRelatedSearch();
MessageListFragment fragment = MessageListFragment.newInstance(search, false, false); MessageListFragment fragment = MessageListFragment.newInstance(search, false, false);
addMessageListFragment(fragment, !isHomeScreen(search)); addMessageListFragment(fragment, !isHomeScreen(search));
...@@ -420,8 +422,14 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -420,8 +422,14 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
public void search(String query) { public void search(String query) {
if (mAccount != null && query != null) { if (mAccount != null && query != null) {
final Bundle appData = new Bundle(); final Bundle appData = new Bundle();
appData.putString(EXTRA_SEARCH_ACCOUNT, mAccount.getUuid()); if(isUnifiedInbox(mSearch)) specialAccountUuid = SearchAccount.UNIFIED_INBOX;
appData.putString(EXTRA_SEARCH_FOLDER, mFolderName); if(specialAccountUuid != null) {
appData.putString(EXTRA_SEARCH_ACCOUNT, specialAccountUuid);
}
else {
appData.putString(EXTRA_SEARCH_ACCOUNT, mAccount.getUuid());
appData.putString(EXTRA_SEARCH_FOLDER, mFolderName);
}
triggerSearch(query, appData); triggerSearch(query, appData);
} }
} }
...@@ -1191,8 +1199,16 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -1191,8 +1199,16 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
if (!hasMessageListFragment) { if (!hasMessageListFragment) {
FragmentTransaction ft = fragmentManager.beginTransaction(); FragmentTransaction ft = fragmentManager.beginTransaction();
mMessageListFragment = MessageListFragment.newInstance(mSearch, false, if(mSearch.searchAllAccounts() && specialAccountUuid != null) {
(K9.isThreadedViewEnabled() && !mNoThreading)); if(specialAccountUuid.equals(SearchAccount.UNIFIED_INBOX) || specialAccountUuid.equals(SearchAccount.ALL_MESSAGES)) {
mMessageListFragment = MessageListFragment.newInstance(mSearch, false, false);
}
specialAccountUuid = null;
}
else {
mMessageListFragment = MessageListFragment.newInstance(mSearch, false,
(K9.isThreadedViewEnabled() && !mNoThreading));
}
ft.add(R.id.message_list_container, mMessageListFragment); ft.add(R.id.message_list_container, mMessageListFragment);
ft.commit(); ft.commit();
} }
...@@ -1324,25 +1340,31 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -1324,25 +1340,31 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
//Query was received from Search Dialog //Query was received from Search Dialog
String query = intent.getStringExtra(SearchManager.QUERY).trim(); String query = intent.getStringExtra(SearchManager.QUERY).trim();
mSearch = new LocalSearch(getString(R.string.search_results));
mSearch.setManualSearch(true);
mNoThreading = true;
mSearch.or(new SearchCondition(SearchField.SENDER, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.SUBJECT, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.MESSAGE_CONTENTS, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.TO, Attribute.CONTAINS, query));
Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA);
if (appData != null) { if (appData != null) {
mSearch.addAccountUuid(appData.getString(EXTRA_SEARCH_ACCOUNT)); String accountExtra = appData.getString(EXTRA_SEARCH_ACCOUNT);
// searches started from a folder list activity will provide an account, but no folder mSearch = new LocalSearch(getString(R.string.search_results));
if (appData.getString(EXTRA_SEARCH_FOLDER) != null) { if(accountExtra.equals(SearchAccount.UNIFIED_INBOX)) {
mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER)); prepareSpecialManualSearch(accountExtra, query, SearchField.INTEGRATE);
} }
} else { else if(accountExtra.equals(SearchAccount.ALL_MESSAGES)) {
prepareSpecialManualSearch(accountExtra, query,SearchField.SEARCHABLE);
}
else {
mSearch.addAccountUuid(appData.getString(EXTRA_SEARCH_ACCOUNT));
addManualSearchConditions(query);
if (appData.getString(EXTRA_SEARCH_FOLDER) != null) {
mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER));
}
}
}
else {
mSearch.addAccountUuid(LocalSearch.ALL_ACCOUNTS); mSearch.addAccountUuid(LocalSearch.ALL_ACCOUNTS);
} }
mSearch.setManualSearch(true);
mNoThreading = true;
} }
} else if (intent.hasExtra(EXTRA_SEARCH_OLD)) { } else if (intent.hasExtra(EXTRA_SEARCH_OLD)) {
mSearch = intent.getParcelableExtra(EXTRA_SEARCH_OLD); mSearch = intent.getParcelableExtra(EXTRA_SEARCH_OLD);
...@@ -1408,6 +1430,21 @@ public class MessageList extends PepActivity implements MessageListFragmentListe ...@@ -1408,6 +1430,21 @@ public class MessageList extends PepActivity implements MessageListFragmentListe
return true; return true;
} }
private void prepareSpecialManualSearch(String accountExtra, String query, SearchField searchField) {
specialAccountUuid = accountExtra;
mSearch.addAccountUuid(LocalSearch.ALL_ACCOUNTS);
addManualSearchConditions(query);
mSearch.and(searchField, "1", Attribute.EQUALS);
}
private void addManualSearchConditions(String query) {
mSearch.or(new SearchCondition(SearchField.SENDER, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.SUBJECT, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.MESSAGE_CONTENTS, Attribute.CONTAINS, query));
mSearch.or(new SearchCondition(SearchField.TO, Attribute.CONTAINS, query));
}
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
......
...@@ -755,6 +755,11 @@ public class MessageListFragment extends PEpFragment implements ConfirmationDial ...@@ -755,6 +755,11 @@ public class MessageListFragment extends PEpFragment implements ConfirmationDial
} }
private void getFolderInfoHolder(String folderName, Account account) { private void getFolderInfoHolder(String folderName, Account account) {
if(!preferences.getAccounts().contains(account)) {
Timber.e("Account is null in Preferences because we just deleted it, " +
"this should only happen coming from FragmentManager.popBackStack from MessageList.onNewIntent");
return;
}
try { try {
MlfUtils.getOpenFolderWithCallback(folderName, account, localFolder -> { MlfUtils.getOpenFolderWithCallback(folderName, account, localFolder -> {
if(isResumed()) { if(isResumed()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment