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.Account;
|
||||||
import com.fsck.k9.BaseAccount;
|
import com.fsck.k9.BaseAccount;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.search.SearchSpecification;
|
import com.fsck.k9.search.SearchAccount;
|
||||||
|
|
||||||
public class LauncherShortcuts extends AccountList {
|
public class LauncherShortcuts extends AccountList {
|
||||||
@Override
|
@Override
|
||||||
@ -30,9 +30,9 @@ public class LauncherShortcuts extends AccountList {
|
|||||||
protected void onAccountSelected(BaseAccount account) {
|
protected void onAccountSelected(BaseAccount account) {
|
||||||
Intent shortcutIntent = null;
|
Intent shortcutIntent = null;
|
||||||
|
|
||||||
if (account instanceof SearchSpecification) {
|
if (account instanceof SearchAccount) {
|
||||||
shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account,
|
SearchAccount searchAccount = (SearchAccount) account;
|
||||||
false, true, true);
|
shortcutIntent = MessageList.shortcutIntent(this, searchAccount.getId());
|
||||||
} else {
|
} else {
|
||||||
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
||||||
true);
|
true);
|
||||||
|
@ -33,6 +33,7 @@ import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener;
|
|||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.store.StorageManager;
|
import com.fsck.k9.mail.store.StorageManager;
|
||||||
import com.fsck.k9.search.LocalSearch;
|
import com.fsck.k9.search.LocalSearch;
|
||||||
|
import com.fsck.k9.search.SearchAccount;
|
||||||
import com.fsck.k9.search.SearchSpecification;
|
import com.fsck.k9.search.SearchSpecification;
|
||||||
import com.fsck.k9.search.SearchSpecification.Attribute;
|
import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||||
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
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_SEARCH = "search";
|
||||||
private static final String EXTRA_NO_THREADING = "no_threading";
|
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
|
// used for remote search
|
||||||
private static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account";
|
private static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account";
|
||||||
private static final String EXTRA_SEARCH_FOLDER = "com.fsck.k9.search_folder";
|
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;
|
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();
|
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
|
||||||
|
|
||||||
@ -134,8 +148,16 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void decodeExtras(Intent intent) {
|
private void decodeExtras(Intent intent) {
|
||||||
// check if this intent comes from the system search ( remote )
|
if (ACTION_SHORTCUT.equals(intent.getAction())) {
|
||||||
if (intent.getStringExtra(SearchManager.QUERY) != null) {
|
// 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.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);
|
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.
|
* an account. This is a meta-account containing all the e-mail that matches the search.
|
||||||
*/
|
*/
|
||||||
public class SearchAccount implements BaseAccount {
|
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 )
|
// create the all messages search ( all accounts is default when none specified )
|
||||||
public static SearchAccount createAllMessagesAccount(Context context) {
|
public static SearchAccount createAllMessagesAccount(Context context) {
|
||||||
String name = context.getString(R.string.search_all_messages_title);
|
String name = context.getString(R.string.search_all_messages_title);
|
||||||
LocalSearch tmpSearch = new LocalSearch(name);
|
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));
|
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);
|
String name = context.getString(R.string.integrated_inbox_title);
|
||||||
LocalSearch tmpSearch = new LocalSearch(name);
|
LocalSearch tmpSearch = new LocalSearch(name);
|
||||||
tmpSearch.and(Searchfield.INTEGRATE, "1", Attribute.EQUALS);
|
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));
|
context.getString(R.string.integrated_inbox_detail));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String mId;
|
||||||
private String mEmail;
|
private String mEmail;
|
||||||
private String mDescription;
|
private String mDescription;
|
||||||
private LocalSearch mSearch;
|
private LocalSearch mSearch;
|
||||||
private String mFakeUuid;
|
private String mFakeUuid;
|
||||||
|
|
||||||
public SearchAccount(LocalSearch search, String description, String email)
|
public SearchAccount(String id, LocalSearch search, String description, String email)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
if (search == null) {
|
if (search == null) {
|
||||||
throw new IllegalArgumentException("Provided LocalSearch was null");
|
throw new IllegalArgumentException("Provided LocalSearch was null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mId = id;
|
||||||
mSearch = search;
|
mSearch = search;
|
||||||
mDescription = description;
|
mDescription = description;
|
||||||
mEmail = email;
|
mEmail = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized String getEmail() {
|
public synchronized String getEmail() {
|
||||||
return mEmail;
|
return mEmail;
|
||||||
|
Loading…
Reference in New Issue
Block a user