Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4809e01d4153a5ba68cb68f36544baa1b90738c0
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Apr 13 12:37:58 2020
Ensure child fragments consider parent menu visibility
Setting the menu visibility of a parent fragment to false should cause
children fragment menu visibility to be false. If the parent visibility
is set back to true, the child fragment should return to its previous
state. This also means that setting the menu visibility of the parent to
false will cause the child to get no callback from the
onCreateOptionsMenu() method.
Test: Added MenuVisibilityFragmentTest and OptionsMenuFragmentTest
Bug: 153593580
Change-Id: Icc41610f7a7dd4f7f181806035e6c6ca96aa2dba
A fragment/fragment/src/androidTest/java/androidx/fragment/app/MenuVisibilityFragmentTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/OptionsMenuFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/1285577
Branch: androidx-master-dev
commit 4809e01d4153a5ba68cb68f36544baa1b90738c0
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Apr 13 12:37:58 2020
Ensure child fragments consider parent menu visibility
Setting the menu visibility of a parent fragment to false should cause
children fragment menu visibility to be false. If the parent visibility
is set back to true, the child fragment should return to its previous
state. This also means that setting the menu visibility of the parent to
false will cause the child to get no callback from the
onCreateOptionsMenu() method.
Test: Added MenuVisibilityFragmentTest and OptionsMenuFragmentTest
Bug: 153593580
Change-Id: Icc41610f7a7dd4f7f181806035e6c6ca96aa2dba
A fragment/fragment/src/androidTest/java/androidx/fragment/app/MenuVisibilityFragmentTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/OptionsMenuFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the Fragment 1.3.0-alpha04 release.
lu...@ozrunways.com <lu...@ozrunways.com> #4
I've confirmed the fix in a snapshot build of androidx fragment with that change. Thanks for the quick turnaround!
an...@google.com <an...@google.com> #5
il...@google.com <il...@google.com> #6
We've decided to release a Fragment 1.2.5 bug fix release and will be including this change in that release.
Description
Current behavior: calling setMenuVisibility(false) suppresses calls to that fragment's onCreateOptionsMenu, but still dispatches calls to child fragments' onCreateOptionsMenu methods.
Desired behavior: calling setMenuVisibility(false) also suppresses calls to child fragments' onCreateOptionsMenu methods.
This would simplify using FragmentStateAdapter with nested fragments. Currently we have to manually propagate setMenuVisibility calls down from the parent fragment in the adapter, to it's children. Without doing that, menu items from the child fragments are not removed as the active item changes. I found a bug report with a similar workaround for this here:
If this behavior isn't changed, can I suggest changing the documentation for the setMenuVisibility method to make it clear that it doesn't include child fragments.
Component used: Fragment
Version used: 1.3.0-alpha03
Devices/Android versions reproduced on: Emulator, Android API 29