Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f57b5cbd142016a2d95fd7bf736262049b085aeb
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Nov 09 13:23:07 2020
Move FloatingWindow interface to Kotlin
Converted the FloatingWindow inferface to koltin and added the kotlin
std library dependency to navigation-common.
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I98af40e5c9bc747d792180990f1654d6353aa4b5
M navigation/navigation-common/build.gradle
M navigation/navigation-common/src/main/java/androidx/navigation/FloatingWindow.kt
https://android-review.googlesource.com/1492738
Branch: androidx-master-dev
commit f57b5cbd142016a2d95fd7bf736262049b085aeb
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Nov 09 13:23:07 2020
Move FloatingWindow interface to Kotlin
Converted the FloatingWindow inferface to koltin and added the kotlin
std library dependency to navigation-common.
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I98af40e5c9bc747d792180990f1654d6353aa4b5
M navigation/navigation-common/build.gradle
M navigation/navigation-common/src/main/java/androidx/navigation/FloatingWindow.kt
an...@gmail.com <an...@gmail.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit b637fdfd6b937d19d4e419c4bfba9b437af6378c
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 01 16:13:27 2021
Merge Navigation Compose version back into Navigation
Rather than run Navigation Compose as a separate,
parallel project from the other Navigation artifacts,
merge the versions together so that we can better
integrate the artifacts together and leverage new
alpha features.
Test: ./gradlew bOS, ran Studio in FLAN and COMPOSE configs
BUG: 172823546
Change-Id: I139a44d95c91dc3cf2e951225aabbc2581914e95
M buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
M navigation/navigation-compose/build.gradle
M navigation/navigation-compose/samples/build.gradle
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-runtime/build.gradle
M settings.gradle
M testutils/testutils-navigation/build.gradle
https://android-review.googlesource.com/1662999
Branch: androidx-main
commit b637fdfd6b937d19d4e419c4bfba9b437af6378c
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 01 16:13:27 2021
Merge Navigation Compose version back into Navigation
Rather than run Navigation Compose as a separate,
parallel project from the other Navigation artifacts,
merge the versions together so that we can better
integrate the artifacts together and leverage new
alpha features.
Test: ./gradlew bOS, ran Studio in FLAN and COMPOSE configs
BUG: 172823546
Change-Id: I139a44d95c91dc3cf2e951225aabbc2581914e95
M buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
M navigation/navigation-compose/build.gradle
M navigation/navigation-compose/samples/build.gradle
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-runtime/build.gradle
M settings.gradle
M testutils/testutils-navigation/build.gradle
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 51769b7a8d6d3e2032e45b3ec1e3cfe29e718ab6
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 10:59:25 2021
Add routes to NavDestination
This change introduces the concept of a route to NavDestination. A route
is String that defines the path to the Destination. Setting the route on
a NavDestination will replace the any id that was set previously and
adds a deep link to the destination. You can set a route on the
NavDestination programatically, or through xml.
RelNote: "You can now add a route to your NavDestination"
Test: NavDestinationTest
Bug: 172823546
Change-Id: I77daf563f480ae54b9728a78e7696ea96d19f264
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-common/src/main/res-public/values/public_attrs.xml
M navigation/navigation-common/src/main/res/values/attrs.xml
https://android-review.googlesource.com/1660682
Branch: androidx-main
commit 51769b7a8d6d3e2032e45b3ec1e3cfe29e718ab6
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 10:59:25 2021
Add routes to NavDestination
This change introduces the concept of a route to NavDestination. A route
is String that defines the path to the Destination. Setting the route on
a NavDestination will replace the any id that was set previously and
adds a deep link to the destination. You can set a route on the
NavDestination programatically, or through xml.
RelNote: "You can now add a route to your NavDestination"
Test: NavDestinationTest
Bug: 172823546
Change-Id: I77daf563f480ae54b9728a78e7696ea96d19f264
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-common/src/main/res-public/values/public_attrs.xml
M navigation/navigation-common/src/main/res/values/attrs.xml
jb...@google.com <jb...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit df16e2452d8333af236a9e5203b396b98f1056be
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Apr 05 17:19:54 2021
Add routes to NavDestination Kotlin DSL
You can now add a route to your NavDestination when using the Kotlin
DSL.
RelNote: "You can now add a route to your NavDestination via the Kotlin
DSL"
Test: NavDestinationBuilderTest
Bug: 172823546
Change-Id: I1276418c8ca0b22eb420c0be6b97f0a5d41de0f9
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
https://android-review.googlesource.com/1660683
Branch: androidx-main
commit df16e2452d8333af236a9e5203b396b98f1056be
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Apr 05 17:19:54 2021
Add routes to NavDestination Kotlin DSL
You can now add a route to your NavDestination when using the Kotlin
DSL.
RelNote: "You can now add a route to your NavDestination via the Kotlin
DSL"
Test: NavDestinationBuilderTest
Bug: 172823546
Change-Id: I1276418c8ca0b22eb420c0be6b97f0a5d41de0f9
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
an...@gmail.com <an...@gmail.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit e6ad7e497c3006c7c1fbe701c36d45f3906c33b0
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon May 03 17:50:16 2021
Deprecated getStartDestination
Deprecating getStartDestination in favor of getStartDestinationId to
make the API more explicit.
RelNote: "The `getStartDestination()` API has been deprecated in favor
of `getStartDestinationId()`."
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I0887ffe673bea453b69dff286d5dc142ce4ef462
M compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphNavigator.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavDestinationTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavGraphNavigatorTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavGraphTest.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/BottomBarNavDemo.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavInflaterTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-ui/src/main/java/androidx/navigation/ui/NavigationUI.kt
https://android-review.googlesource.com/1695087
Branch: androidx-main
commit e6ad7e497c3006c7c1fbe701c36d45f3906c33b0
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon May 03 17:50:16 2021
Deprecated getStartDestination
Deprecating getStartDestination in favor of getStartDestinationId to
make the API more explicit.
RelNote: "The `getStartDestination()` API has been deprecated in favor
of `getStartDestinationId()`."
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I0887ffe673bea453b69dff286d5dc142ce4ef462
M compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphNavigator.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavDestinationTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavGraphNavigatorTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/NavGraphTest.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/BottomBarNavDemo.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavInflaterTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-ui/src/main/java/androidx/navigation/ui/NavigationUI.kt
ra...@gmail.com <ra...@gmail.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 81aaeccc3cd3530b790317e0488380464f29023e
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed May 05 13:08:11 2021
Deprecate popUpTo in NavOptions
This deprecates popUpTo properties in by NavOptions and the
NavOptionsBuilder DSL in favor of popUpToId. Setting the popUpToId
should be done by using the popUpTo functions without passing in a
builder.
RelNote: "The `popUpTo` kotlin property has been deprecated in favor of
`popUpToId`."
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I59c73c383b84eb2b36472966aedff1b53957e26d
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavOptionsBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptions.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptionsBuilder.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
https://android-review.googlesource.com/1697773
Branch: androidx-main
commit 81aaeccc3cd3530b790317e0488380464f29023e
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed May 05 13:08:11 2021
Deprecate popUpTo in NavOptions
This deprecates popUpTo properties in by NavOptions and the
NavOptionsBuilder DSL in favor of popUpToId. Setting the popUpToId
should be done by using the popUpTo functions without passing in a
builder.
RelNote: "The `popUpTo` kotlin property has been deprecated in favor of
`popUpToId`."
Test: ./gradlew checkApi
Bug: 172823546
Change-Id: I59c73c383b84eb2b36472966aedff1b53957e26d
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavOptionsBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptions.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptionsBuilder.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
jb...@google.com <jb...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-main
commit fc9a744da1fd9cc99aaf92ec679bd01bb7b4564f
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 19:09:29 2021
Add routes to NavGraph
This add routes to NavGraph. You can set a route and
startDestinationRoute as an alternative to an id and
startDestinationId.
Passing a blank route of startDestinationRoute is equivalent to passing
0 meaning you can have a NavGraph with a blank route, but you cannot
have a NavGraph with a blank startDestinationRoute.
This change also includes the addition of routes to the NavGraphBuilder
Kotlin DSL
RelNote: "Navigation now supports adding NavGraphs by using a route."
Test: NavGraphTest, NavGraphAndroidTest, NavGraphBuilderTest
Bug: 172823546
Change-Id: I36c68144318ac23785c9178e847b677c0ef1cd8d
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
https://android-review.googlesource.com/1661700
Branch: androidx-main
commit fc9a744da1fd9cc99aaf92ec679bd01bb7b4564f
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 19:09:29 2021
Add routes to NavGraph
This add routes to NavGraph. You can set a route and
startDestinationRoute as an alternative to an id and
startDestinationId.
Passing a blank route of startDestinationRoute is equivalent to passing
0 meaning you can have a NavGraph with a blank route, but you cannot
have a NavGraph with a blank startDestinationRoute.
This change also includes the addition of routes to the NavGraphBuilder
Kotlin DSL
RelNote: "Navigation now supports adding NavGraphs by using a route."
Test: NavGraphTest, NavGraphAndroidTest, NavGraphBuilderTest
Bug: 172823546
Change-Id: I36c68144318ac23785c9178e847b677c0ef1cd8d
M navigation/navigation-common/api/api_lint.ignore
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
Description
Version used: 2.1.0-rc01
Devices/Android versions reproduced on:
Proposal: Safe Arg generated Builder Classes should have default values inside.
This is actually not a bug for navigation component but a kind of side effect which can make this feature more versatile.
In my scenario, we were trying to use generated safe arg Builder classes to pass arguments to the fragments in our project, as the normal bundle arguments are not type safe and kinda messy to work with.
The project I'm working on is relative large, in our team we decided to migrate gradually to navigation component.
As a first step we wanted to put the fragment in a nav graph just to generate safe args so that we can use those classes to safely pass arguments to our existing fragment with fragment transaction and eventually use the graph in future point. So we are trying to use Safe arg as mentioned below:
ChoosePackageFragmentArgs args =
new ChoosePackageFragmentArgs.Builder("testName", "testPackage")
.setIsExtend(true)
.build();
ChoosePackageFragment fragment = new ChoosePackageFragment();
fragment.setArguments(args.toBundle());
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, fragment)
.addToBackStack(null)
.commit();
As you can see from the above example the "isExtend" property is optional and has a default value false which is set in the graph like this,
<argument
android:name="isExtend"
app:argType="boolean"
android:defaultValue="false" />
However if we use the generated safe arg builder class (ChoosePackageFragmentArgs) to pass the arguments to ChoosePackageFragment, without setting "isExtend" the ChoosePackageFragmentArgs.fromBundle(requireArguments()).getIsExtend() throws a NullPointerException because the builder doesn't set the default value when we call the args.toBundle() on the builder instance.
Moreover, when we try to call the getter method it can't find a value from the map, so it tries to cast a null value to (boolean), thus throwing the NullPointerException. Remember we're not using a NavController, just trying to take advantage of SafeArg feature.
This is the code from ChoosePackageFragmentArgs.Builder:
public class ChoosePackageFragmentArgs implements NavArgs {
....
@SuppressWarnings("unchecked")
public boolean getIsExtend() {
return (boolean) arguments.get("isExtend");
}
...
}
We were wondering why the default value is not present in the object. After digging for a while we've found that NavController.navigate() pulls the default values from NavAction.getDefaultArguments(); as we're not using NavComponent we're actually not getting the default value from Builder. Here's the code that pulls default args in NavComponent Library.
Code from NavController.java:
final NavAction navAction = currentNode.getAction(resId);
Bundle combinedArgs = null;
if (navAction != null) {
if (navOptions == null) {
navOptions = navAction.getNavOptions();
}
destId = navAction.getDestinationId();
Bundle navActionArgs = navAction.getDefaultArguments();
if (navActionArgs != null) {
combinedArgs = new Bundle();
combinedArgs.putAll(navActionArgs);
}
}
Suggestion:
If the safe arg plugin added the default values to the Builder while generating those SafeArgs Builder classes, the conventional fragment approach could get huge benefit out of it, and as these classes are accessible apis, I believe it makes more sense to have predictable behaviour for Builder classes as that seems like a standard predictable behaviour.