Only let the active message view update the toolbar menu

This commit is contained in:
cketti 2022-10-25 11:49:45 +02:00
parent 2d3f3e9668
commit a7fcf9f607

View file

@ -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