Status Update
Comments
il...@google.com <il...@google.com> #2
Branch: androidx-main
commit f0dc0968ae703e34aba39b2c6c836077c340d2a5
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 01 15:34:41 2021
Make argument default params last
When generating an argument in kotlin from safe args, default parameters
should always come after none defaults in the argument's constructor.
RelNote: "When generating arguments, safe args now puts parameters
without default values before those with default values."
Test: ./gradlew --rerun-tasks
navigation:navigation-safe-args-generator:test
Bug: 198493585
Change-Id: I8970968c48deb3a1437437df9a3db696ed497372
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
M navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/MainFragmentArgs.kt
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the Navigation 2.4.0-alpha09
release.
sk...@gmail.com <sk...@gmail.com> #4
al...@gmail.com <al...@gmail.com> #5
Re
In the future, please always file regressions as new bugs with a sample project that reproduces your issue rather than commenting on issues already marked as fixed - that way we can properly track those fixes for the next release.
il...@google.com <il...@google.com>
j....@gmail.com <j....@gmail.com> #6
xa...@gmail.com <xa...@gmail.com> #7
xa...@gmail.com <xa...@gmail.com> #8
[Deleted User] <[Deleted User]> #9
il...@google.com <il...@google.com>
be...@gmail.com <be...@gmail.com> #10
da...@khol.me <da...@khol.me> #11
The workaround to put an <argument>
directly to the root of the <navigation>
holding the destination <fragment>
does not work, at least not in version 2.3.0
.
The other workaround to copy <argument>
to the source <fragment>
's <action>
works but it defeats the purpose of SafeArgs being safe. With that approach, you potentially have to update arguments in multiple source <fragment>
s that navigate to the same destination <fragment>
. If you forget to update some of the sources, the app will compile just fine but crash at runtime. That's just UnsafeArgs.
je...@gmail.com <je...@gmail.com> #12
og...@gmail.com <og...@gmail.com> #13
mt...@parsyl.com <mt...@parsyl.com> #14
Any updates on this? This has been open for 2.5 years.
g....@gmail.com <g....@gmail.com> #15
I recently got rid of all the optional arguments and default values, replacing them with Parcelable
classes that offer the same functionality leveraging Kotlin's type system. Since there are no compile time checks for start destinations and I had to touch some of them, I quickly put together a python script that checks the arguments of the actions that have a <navigation>
as destination.
I wrote the script with my use-case in mind, so the code makes some assumptions that are not generally true. These assumption should only cause false positives, but I really didn't think this through and I could be wrong. It's not perfect and there's definitely room for improvement, but it is enough for me for now.
Please remember that many are watching this issue and not everyone here care about this script. The source code is enough to seek for help elsewhere.
nv...@gmail.com <nv...@gmail.com> #16
A major fuck up for a documented use case.
nv...@gmail.com <nv...@gmail.com> #17
From this
- Copy
<argument>
to inside the<navigation>
tag, i.e. make it a sibling of other<fragment>
- Copy
<argument>
to inside the<action>
of the start fragment. Yes normally<action>
is a self close tag, and<argument>
is for<fragment>
.
And the workaround breaks navArgs()
, because StartFragmentOfNestedGraphArgs
is not generated.
ca...@gmail.com <ca...@gmail.com> #18
We actually just had a crash in our app, fortunately detected by qa, due to using the unsafe workaround.
[Deleted User] <[Deleted User]> #19
ju...@gmail.com <ju...@gmail.com> #20
That's even more annoying since putting the arguments directly inside de <navigation> tag doesn't work. (using 2.4.1)
[Deleted User] <[Deleted User]> #21
sp...@gmail.com <sp...@gmail.com> #22
sh...@gmail.com <sh...@gmail.com> #23
[Deleted User] <[Deleted User]> #24
ap...@google.com <ap...@google.com> #25
Branch: androidx-main
commit d1e16c5abced31a3738c9686121f3a2a50c3404e
Author: Clara Fok <clarafok@google.com>
Date: Mon Feb 26 12:18:38 2024
Fix startDestination route args not processed
Filled-in arguments in the route that is passed as a NavGraph's startDestination will now be processed and stored in the bundle.
These start route arguments will overwrite default values but not the others. The priority of args is as follows:
Restored/StartDestinationArgs > Start route args > Default args
Relnote: "You can now pass arguments to NavGraph's startDestination directly in the startDestination route without relying on defaultValue. This applies to nesteded NavGraph startDestinations as well."
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 109505019
Bug: 188693139
Change-Id: I0e0b5a7c2bf2e77a8d7a46c91974509104e742a9
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphNavigator.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
cl...@google.com <cl...@google.com> #26
Fixed internally, available in navigation-2.8.0-alpha05
jb...@google.com <jb...@google.com>
pr...@google.com <pr...@google.com> #27
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-common:2.8.0-alpha05
androidx.navigation:navigation-runtime:2.8.0-alpha05
Description
Version used: 1.0.0-alpha01
Devices/Android versions reproduced on: N/A
To reproduce:
1. Construct a navigation graph with a fragment and mark it as the startDestination for the graph.
2. Construct a subgraph with another fragment that requires an argument and mark it as the startDestination for the subgraph.
3. Construct an action from the first fragment to the subgraph.
4. Use the generated classes to construct the action. Observe that the argument is not required.
5. Move the argument from the fragment to the subgraph.
4. Use the generated classes to construct the action. Observe that the argument *is* required.
I believe that in both cases, the argument should be required because the purpose of the SafeArgs generated classes is to prevent missing arguments, which would occur if the subgraph did not require the arguments of its startDestination.