Status Update
Comments
gg...@google.com <gg...@google.com>
il...@google.com <il...@google.com>
yb...@google.com <yb...@google.com>
at...@gmail.com <at...@gmail.com> #2
ma...@gmail.com <ma...@gmail.com> #3
Branch: androidx-main
commit 812fe658e564bb57b0bea0ae79946d04e2b85610
Author: Simon Marquis <contact@simon-marquis.fr>
Date: Tue Dec 19 21:46:01 2023
[GH] Fix regression in dynamic labels with non-string typed arguments
Regression introduced in
Test: ./gradlew navigation:navigation-ui:cC
Fixes: 316676794
[AndroidX Navigation 2.6.0 broke dynamic app bar title for non String arguments](
This is an imported pull request from
Resolves #636
Github-Pr-Head-Sha: f455c6d1e641cc72cc1bd371b1f47b7d87ec8eff
GitOrigin-RevId: 3ad8f763f17acb22678f1a87e183ef4e7dac5a9d
Change-Id: I94b4e28bb847632663be32b11e481d13789e8c1b
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/NavigationUITest.kt
at...@gmail.com <at...@gmail.com> #4
Thanks for pointing this out and putting up the PR to fix this! We'll look at doing a Navigation 2.7.7 release with this fix.
il...@google.com <il...@google.com> #5
Awesome, thanks for the quick merge 😀
ma...@gmail.com <ma...@gmail.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-common:2.8.0-alpha01
androidx.navigation:navigation-ui:2.8.0-alpha01
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #7
I can confirm the issue reported here is fixed in 2.8.0-alpha01
.
Not sure why there is no mention of it in the release notes though.
I should have added a RelNotes
trailer to the git commit message, or can it be added afterwards?
ap...@google.com <ap...@google.com> #8
You would have had to add a Relnote
if you wanted it mentioned in the release notes, yes.
We can manually add it to the release notes though.
ma...@gmail.com <ma...@gmail.com> #9
Understood!
We can manually add it to the release notes though.
It's up to you to decide if it's worth mentioning :)
at...@gmail.com <at...@gmail.com> #10
We've added it to the
il...@google.com <il...@google.com> #11
juma
at...@gmail.com <at...@gmail.com> #12
at...@gmail.com <at...@gmail.com> #13
if (parent instanceof DrawerLayout) {
((DrawerLayout) parent).closeDrawer(navigationView);
} else {
BottomSheetBehavior bottomSheetBehavior =
BottomSheetBehavior.from((View) navigationView.getParent().getParent());
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}
}
but only
BottomSheetBehavior bottomSheetBehavior =
BottomSheetBehavior.from(navigationView);
would expect, that the navigationView is a direct child of a CoordinatorLayout and would have the app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" attribute. That can't work or did I miss something?
il...@google.com <il...@google.com> #14
ap...@google.com <ap...@google.com> #15
Branch: androidx-master-dev
commit 4fb1acaf8ee002979bc161e362c1e83f89195205
Author: Ian Lake <ilake@google.com>
Date: Tue Sep 18 13:38:07 2018
Fix NavigationUI for use with BottomSheetDialogFragment
Replace using BottomSheetBehavior.from() which
throws IllegalArgumentExceptions to a safe
method that searches up the view hierarchy
for a CoordinatorLayout to determine if the
NavigationView is within a bottom sheet.
Test: example added to the integration-tests/testapp
BUG: 112158843
Change-Id: I774991ef1b23085e075e6bac6fa820ee3e001a31
M navigation/integration-tests/testapp/build.gradle
M navigation/integration-tests/testapp/src/main/java/androidx/navigation/testapp/HelpActivity.kt
M navigation/integration-tests/testapp/src/main/res/layout/activity_help.xml
A navigation/integration-tests/testapp/src/main/res/layout/bottom_bar_menu.xml
M navigation/ui/src/main/java/androidx/navigation/ui/NavigationUI.java
Description
The Navigation Component has this very useful function to sync up menu items from a NavigationView with the NavController. It makes sure that the selected item is checked, can close the navigation drawer on selection if a DrawerLayout is used, or set the title of an ActionBar/Toolbar according to the current destination.
With the addition of the bottom app bar in Material Design we've also begun using the bottom navigation drawer (
public class BottomDrawerFragment extends BottomSheetDialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bottom_drawer, container, false);
NavigationView navigationView = view.findViewById(R.id.bottom_drawer_navigation);
NavigationUI.setupWithNavController(navigationView, Navigation.findNavController(getActivity(), R.id.nav_host_fragment));
return view;
}
}
This works well, but because NavigationUI currently doesn't dismiss the BottomSheetDialogFragment when a menu item has been selected like it closes the DrawerLayout, the bottom navigation drawer remains open and needs to be dismissed in another way (which comes with additional code overhead and issues).
Since AndroidX is now part of AOSP, I took a look at the implementation and I think that support for this could be added with two lines of code (see '+' characters at beginning of lines below) by doing for the DialogFragment what is already done for the DrawerLayout (excerpt from androidx-master-dev/navigation/ui/src/main/java/androidx/navigation/ui/NavigationUI.java).
public static void setupWithNavController(@NonNull final NavigationView navigationView,
@NonNull final NavController navController) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
boolean handled = onNavDestinationSelected(item, navController, true);
if (handled) {
ViewParent parent = navigationView.getParent();
if (parent instanceof DrawerLayout) {
((DrawerLayout) parent).closeDrawer(navigationView);
+ } else if (parent instanceof BottomSheetDialogFragment) {
+ ((DialogFragment) parent).dismiss();
}
}
return handled;
}
});
navController.addOnNavigatedListener(new NavController.OnNavigatedListener() {
@Override
public void onNavigated(@NonNull NavController controller,
@NonNull NavDestination destination) {
Menu menu = navigationView.getMenu();
for (int h = 0, size = menu.size(); h < size; h++) {
MenuItem item = menu.getItem(h);
item.setChecked(matchDestination(destination, item.getItemId()));
}
}
});
}
The most active owner of the Navigation Component is Ian Lake and it he's been adding support for more and more UI components to the NavigationUI class in the past months, so I think he's the person to talk to about this. Assuming this doesn't introduce any issues, he could probably get it done in a couple of minutes.
Alternatively, I could implement this and the accompanying test myself, contribute it and try to get it reviewed.