Status Update
Comments
ap...@google.com <ap...@google.com> #2
Branch: androidx-main
commit c16a5f617f5007dc4e976a9cd4834c3efeed1134
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue Mar 29 22:18:03 2022
Have AppCompat Toolbar call onPrepareMenu
Ensuring that AppCompat Toolbar always calls
MenuHostHelper's onPrepareMenu API now that
MenuProvider contains the optional API
RelNote: "AppCompat `Toolbar` now calls
`MenuHostHelper`'s `onPrepareMenu()` API."
Test: providedOnPrepareMenu
Bug: 227376894
Change-Id: I9b9b57a4ffcfb94bc24a881705ec5ea4d42736da
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/ToolbarMenuHostTest.kt
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/Toolbar.java
M core/core/src/androidTest/java/androidx/core/view/MenuHostHelperTest.kt
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #3
This has been fixed internally and will be available in AppCompat 1.5.0-alpha01.
to...@yahoo.com <to...@yahoo.com> #4
urm... that's not a proper fix?
Please may I remind you about the contract for onPrepareMenu: called when the menu is first shown
But in your code, you now simply call onPrepareMenu during the onCreateMenu phase.
I realise that Toolbar did/does not implement onPrepareMenu properly up to now, but it never promised to do, so that was ok up to now.
However, if you're adding support for MenuProvider (thank you!) then it has to be implemented such that it's contract is fulfilled. Right now, the contract of the MenuProvider is broken in Toolbar.
gr...@gmail.com <gr...@gmail.com> #5
Hello. Why do you write than the contract for onPrepareMenu
is "called when the menu is first shown"?
From documentation:
Called by the MenuHost right before the Menu is shown. This should be called when the menu has been dynamically updated.
There aren't mentions about first showing. For example ComponentActivity
implementation of MenuHost
call onPrepareMenu
before every show of menu. And, imho, this behaviour makes much more sense.
For now Toolbar
implementation is inconsistent and misleading.
to...@yahoo.com <to...@yahoo.com> #6
#5 : badly worded I guess (been a while)
but it's been fixed properly now in
gr...@gmail.com <gr...@gmail.com> #7
Great, thanks for answer!
Description
Now that the
MenuProvider
interface contains the optionalonPrepareMenu()
API to maintain 1:1 compatibility, we want to make sure thatToolbar
'sMenuHostHelper
utilizes this API in case developers choose to implement it when adding aMenuProvider
.