From a7fcf9f607258f311f6c7b405b31cfaf1869421a Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 25 Oct 2022 11:49:45 +0200 Subject: [PATCH] Only let the active message view update the toolbar menu --- .../com/fsck/k9/ui/messageview/MessageViewFragment.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt index 944e4e6cb..e2d39f565 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt @@ -107,6 +107,12 @@ class MessageViewFragment : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + // Hide the toolbar menu when first creating this fragment. The menu will be set to visible once this fragment + // becomes the active page of the view pager in MessageViewContainerFragment. + if (savedInstanceState == null) { + setMenuVisibility(false) + } + setHasOptionsMenu(true) messageReference = MessageReference.parse(arguments?.getString(ARG_REFERENCE)) @@ -178,9 +184,10 @@ class MessageViewFragment : } override fun setMenuVisibility(menuVisible: Boolean) { - super.setMenuVisibility(menuVisible) isActive = menuVisible + super.setMenuVisibility(menuVisible) + if (menuVisible) { messageLoaderHelper.resumeCryptoOperationIfNecessary() } else { @@ -207,6 +214,8 @@ class MessageViewFragment : } override fun onPrepareOptionsMenu(menu: Menu) { + if (!isActive) return + menu.findItem(R.id.delete).apply { isVisible = K9.isMessageViewDeleteActionVisible isEnabled = !isDeleteMenuItemDisabled