mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Don't use LocalSearch object in launcher shortcut intents
This commit is contained in:
parent
cd3cc88fd4
commit
38e8fc182c
@ -7,7 +7,7 @@ import android.os.Parcelable;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.BaseAccount;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.search.SearchSpecification;
|
||||
import com.fsck.k9.search.SearchAccount;
|
||||
|
||||
public class LauncherShortcuts extends AccountList {
|
||||
@Override
|
||||
@ -30,9 +30,9 @@ public class LauncherShortcuts extends AccountList {
|
||||
protected void onAccountSelected(BaseAccount account) {
|
||||
Intent shortcutIntent = null;
|
||||
|
||||
if (account instanceof SearchSpecification) {
|
||||
shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account,
|
||||
false, true, true);
|
||||
if (account instanceof SearchAccount) {
|
||||
SearchAccount searchAccount = (SearchAccount) account;
|
||||
shortcutIntent = MessageList.shortcutIntent(this, searchAccount.getId());
|
||||
} else {
|
||||
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
||||
true);
|
||||
|
@ -33,6 +33,7 @@ import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.store.StorageManager;
|
||||
import com.fsck.k9.search.LocalSearch;
|
||||
import com.fsck.k9.search.SearchAccount;
|
||||
import com.fsck.k9.search.SearchSpecification;
|
||||
import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||
@ -51,6 +52,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private static final String EXTRA_SEARCH = "search";
|
||||
private static final String EXTRA_NO_THREADING = "no_threading";
|
||||
|
||||
private static final String ACTION_SHORTCUT = "shortcut";
|
||||
private static final String EXTRA_SPECIAL_FOLDER = "special_folder";
|
||||
|
||||
// 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";
|
||||
@ -82,6 +86,16 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent shortcutIntent(Context context, String specialFolder) {
|
||||
Intent intent = new Intent(context, MessageList.class);
|
||||
intent.setAction(ACTION_SHORTCUT);
|
||||
intent.putExtra(EXTRA_SPECIAL_FOLDER, specialFolder);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
|
||||
|
||||
@ -134,8 +148,16 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
}
|
||||
|
||||
private void decodeExtras(Intent intent) {
|
||||
if (ACTION_SHORTCUT.equals(intent.getAction())) {
|
||||
// Handle shortcut intents
|
||||
String specialFolder = intent.getStringExtra(EXTRA_SPECIAL_FOLDER);
|
||||
if (SearchAccount.UNIFIED_INBOX.equals(specialFolder)) {
|
||||
mSearch = SearchAccount.createUnifiedInboxAccount(this).getRelatedSearch();
|
||||
} else if (SearchAccount.ALL_MESSAGES.equals(specialFolder)) {
|
||||
mSearch = SearchAccount.createAllMessagesAccount(this).getRelatedSearch();
|
||||
}
|
||||
} else if (intent.getStringExtra(SearchManager.QUERY) != null) {
|
||||
// check if this intent comes from the system search ( remote )
|
||||
if (intent.getStringExtra(SearchManager.QUERY) != null) {
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
//Query was received from Search Dialog
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
|
@ -14,12 +14,15 @@ import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||
* an account. This is a meta-account containing all the e-mail that matches the search.
|
||||
*/
|
||||
public class SearchAccount implements BaseAccount {
|
||||
public static final String ALL_MESSAGES = "all_messages";
|
||||
public static final String UNIFIED_INBOX = "unified_inbox";
|
||||
|
||||
|
||||
// create the all messages search ( all accounts is default when none specified )
|
||||
public static SearchAccount createAllMessagesAccount(Context context) {
|
||||
String name = context.getString(R.string.search_all_messages_title);
|
||||
LocalSearch tmpSearch = new LocalSearch(name);
|
||||
return new SearchAccount(tmpSearch, name,
|
||||
return new SearchAccount(ALL_MESSAGES, tmpSearch, name,
|
||||
context.getString(R.string.search_all_messages_detail));
|
||||
}
|
||||
|
||||
@ -29,27 +32,33 @@ public class SearchAccount implements BaseAccount {
|
||||
String name = context.getString(R.string.integrated_inbox_title);
|
||||
LocalSearch tmpSearch = new LocalSearch(name);
|
||||
tmpSearch.and(Searchfield.INTEGRATE, "1", Attribute.EQUALS);
|
||||
return new SearchAccount(tmpSearch, name,
|
||||
return new SearchAccount(UNIFIED_INBOX, tmpSearch, name,
|
||||
context.getString(R.string.integrated_inbox_detail));
|
||||
}
|
||||
|
||||
private String mId;
|
||||
private String mEmail;
|
||||
private String mDescription;
|
||||
private LocalSearch mSearch;
|
||||
private String mFakeUuid;
|
||||
|
||||
public SearchAccount(LocalSearch search, String description, String email)
|
||||
public SearchAccount(String id, LocalSearch search, String description, String email)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
if (search == null) {
|
||||
throw new IllegalArgumentException("Provided LocalSearch was null");
|
||||
}
|
||||
|
||||
mId = id;
|
||||
mSearch = search;
|
||||
mDescription = description;
|
||||
mEmail = email;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String getEmail() {
|
||||
return mEmail;
|
||||
|
Loading…
Reference in New Issue
Block a user