Don't put serialized `LocalSearch` instance in account shortcut Intent
@@ -426,9 +426,26 @@ open class MessageList :
if (action == ACTION_SHORTCUT) {
// Handle shortcut intents
val specialFolder = intent.getStringExtra(EXTRA_SPECIAL_FOLDER)
- if (SearchAccount.UNIFIED_INBOX == specialFolder) {
+ if (specialFolder == SearchAccount.UNIFIED_INBOX) {
return LaunchData(search = SearchAccount.createUnifiedInboxAccount().relatedSearch)
}
+
+ val accountUuid = intent.getStringExtra(EXTRA_ACCOUNT)
+ if (accountUuid != null) {
+ val account = preferences.getAccount(accountUuid)
+ if (account == null) {
+ Timber.d("Account %s not found.", accountUuid)
+ return LaunchData(createDefaultLocalSearch())
+ }
+
+ val folderId = defaultFolderProvider.getDefaultFolder(account)
+ val search = LocalSearch().apply {
+ addAccountUuid(accountUuid)
+ addAllowedFolder(folderId)
+ }
+
+ return LaunchData(search = search)
+ }
} else if (action == Intent.ACTION_SEARCH && queryString != null) {
// Query was received from Search Dialog
val query = queryString.trim()
@@ -1493,14 +1510,14 @@ open class MessageList :
@JvmStatic
fun shortcutIntentForAccount(context: Context?, account: Account): Intent {
- val folderId = defaultFolderProvider.getDefaultFolder(account)
+ return Intent(context, MessageList::class.java).apply {
+ action = ACTION_SHORTCUT
+ putExtra(EXTRA_ACCOUNT, account.uuid)
- val search = LocalSearch().apply {
- addAccountUuid(account.uuid)
- addAllowedFolder(folderId)
+ addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
-
- return intentDisplaySearch(context, search, noThreading = false, newTask = true, clearTop = true)
}
fun actionDisplayMessageIntent(
