From 957c6dc43a71e9772490902c6b03dedf141c98b6 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 20 Oct 2022 17:07:20 +0200 Subject: [PATCH 1/2] Don't put serialized `LocalSearch` instance in account shortcut Intent --- .../java/com/fsck/k9/activity/MessageList.kt | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index e8eba7304..ab3fe015e 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -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( From f0b369711b60456d6ef9346152e90b561fc81bc1 Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 20 Oct 2022 17:59:25 +0200 Subject: [PATCH 2/2] Remove support for old launcher shortcuts --- app/k9mail/src/main/AndroidManifest.xml | 14 -------------- .../java/com/fsck/k9/activity/MessageList.kt | 18 ------------------ 2 files changed, 32 deletions(-) diff --git a/app/k9mail/src/main/AndroidManifest.xml b/app/k9mail/src/main/AndroidManifest.xml index 9f9169d07..4a246df16 100644 --- a/app/k9mail/src/main/AndroidManifest.xml +++ b/app/k9mail/src/main/AndroidManifest.xml @@ -59,13 +59,6 @@ - - - - @@ -158,13 +151,6 @@ android:label="@string/ac_transfer_title" /> - - - -