Fixed
Status Update
Comments
co...@gmail.com <co...@gmail.com> #2
Shoud be a feature request.
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
il...@google.com <il...@google.com>
cl...@google.com <cl...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit b1ac7d68d42621667805bc2849dadbec8e8e2af0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jun 15 17:45:31 2022
Support string reference parsing in AbstractAppBarOnDestinationChangedListener
Previously, the #onDestinationChanged implementation would parse NavType.ReferenceType as an integer.
It would now correctly parse string ReferenceType into its String value.
Test: ./gradlew navigation:navigation-ui:cC
Fixes: 167959935
Relnote: "The `setupWithNavController` integrations in `NavigationUI` for working with the top app bar will now parse `R.string` values for `ReferenceType` arguments found in your `android:label` into their String values instead of outputting the auto-generated resource integer."
Change-Id: I5f803f69cb9820f7be85cb7642c8fb0f475285f7
M navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/NavigationUITest.kt
M navigation/navigation-ui/build.gradle
M navigation/navigation-ui/src/main/java/androidx/navigation/ui/AbstractAppBarOnDestinationChangedListener.kt
M navigation/navigation-ui/src/main/res/values/strings.xml
https://android-review.googlesource.com/2128718
Branch: androidx-main
commit b1ac7d68d42621667805bc2849dadbec8e8e2af0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jun 15 17:45:31 2022
Support string reference parsing in AbstractAppBarOnDestinationChangedListener
Previously, the #onDestinationChanged implementation would parse NavType.ReferenceType as an integer.
It would now correctly parse string ReferenceType into its String value.
Test: ./gradlew navigation:navigation-ui:cC
Fixes: 167959935
Relnote: "The `setupWithNavController` integrations in `NavigationUI` for working with the top app bar will now parse `R.string` values for `ReferenceType` arguments found in your `android:label` into their String values instead of outputting the auto-generated resource integer."
Change-Id: I5f803f69cb9820f7be85cb7642c8fb0f475285f7
M navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/NavigationUITest.kt
M navigation/navigation-ui/build.gradle
M navigation/navigation-ui/src/main/java/androidx/navigation/ui/AbstractAppBarOnDestinationChangedListener.kt
M navigation/navigation-ui/src/main/res/values/strings.xml
co...@gmail.com <co...@gmail.com> #4
Many thanks !
cl...@google.com <cl...@google.com> #5
Thanks for filing this!
il...@google.com <il...@google.com> #6
This will be available in Navigation 2.6.0-alpha01.
na...@google.com <na...@google.com> #7
This bug was linked in a change in the following release(s):
androidx.navigation:navigation-ui:2.6.0-alpha01
Description
In order navigate using "NavDirection" directly created from a ViewModel would it be possible to pass R.string.id as argument?
Imagine a case where multiple errors leads you to a fragment that differs only by its text. Same behavior inside but only information change sightly. You would try to re-use that common part and avoid duplication.
If you try to generate a direction from your ViewModel with argument you won't be able to retrieve context assosiated string to fill the label. So would it be possible to parse a dynamic label's id instead of applying a toString() on it?
Currently if I send a NavDirection with an argument in it which is also {label} it will just apply a toString() and show id in place of toolbar title. Expected is the localised string as title to not resolve it using getString by myself (in a fragment, before or after navigation)
Some snippets from the way I would otherwise do it.
Current work around would be to create one destination per string_id reusing the same fragment "name" attribute and duplicate actions.
This would also remove the need of "getString()" logic from fragment or hook the "onDestinationChanged" as suggested some places just to update a title.