Fixed
Status Update
Comments
so...@gmail.com <so...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 1e5efa0794e826bc1b3b153796ed5659fb97fca2
Author: Ian Lake <ilake@google.com>
Date: Fri Feb 08 10:23:54 2019
Prefer exact matching deep links
Instead of only taking into account the
number of matching arguments for deep link
matching, always prefer exact matches.
Test: updated tests
BUG: 123969518
Change-Id: Ibd8ab5b6ba251991fa994ebd297bcb9ffb5851bd
M navigation/common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
M navigation/common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/common/src/main/java/androidx/navigation/NavDeepLink.java
M navigation/common/src/main/java/androidx/navigation/NavDestination.java
https://android-review.googlesource.com/898367
https://goto.google.com/android-sha1/1e5efa0794e826bc1b3b153796ed5659fb97fca2
Branch: androidx-master-dev
commit 1e5efa0794e826bc1b3b153796ed5659fb97fca2
Author: Ian Lake <ilake@google.com>
Date: Fri Feb 08 10:23:54 2019
Prefer exact matching deep links
Instead of only taking into account the
number of matching arguments for deep link
matching, always prefer exact matches.
Test: updated tests
BUG: 123969518
Change-Id: Ibd8ab5b6ba251991fa994ebd297bcb9ffb5851bd
M navigation/common/src/androidTest/java/androidx/navigation/NavDestinationAndroidTest.kt
M navigation/common/src/androidTest/java/androidx/navigation/NavGraphAndroidTest.kt
M navigation/common/src/main/java/androidx/navigation/NavDeepLink.java
M navigation/common/src/main/java/androidx/navigation/NavDestination.java
il...@google.com <il...@google.com> #3
This is fixed internally and will be available in Navigation 1.0.0-beta02 - we'll always prefer an exact deep match link (where exact means your deep link does not contain any .* or {param} tags)
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #4
This allows you to solve your problem by:
- Adding your Toolbar to Fragment B
- Call:
toolbar.setupWithNavController(innerNavController, AppBarConfiguration(setOf()) {
findNavController().navigateUp()
})
By using an empty set of top level destinations, the Up button will always appear. When the innerNavController is on its own start destination, the fallback will be called, allowing you to pass the navigateUp() call to the outer NavController. The reason the Toolbar in your FragmentB is the right place to do this is so that it has a reference to both your inner NavController and a reference to your outer NavController.
This will be available in 1.0.0-alpha09.
See also the related issue for activities:
ka...@gmail.com <ka...@gmail.com> #5
Re #4 - In my use case I have single activity and single (global) toolbar setup with it. So it doesn't make sense for my application to add additional toolbar for my nested fragments. I just want to work them with existing activity's toolbar. I would like to use nested fragments to use ViewModels shared with parentFragment. Can you consider supporting my use case?
Description
Version used: 1.0.0-alpha08
Devices/Android versions reproduced on:
Assuming:
- Main Activity has a NavHostFragment, which navigates between Fragment A & Fragment B
- Main activity handles going back with onSupportNavigateUp
- Fragment B has it's own NavHostFragment, which navigated between InnerFragmentB1 & InnerFragmentB2
- Parent NavHostFragment navigates from A -> B (which starts with B1)
- Sub NavHostFragment navigates from B1 -> B2
- Press up: Sub NavHostFragment returns to B1
- Press up: Parent NavHostFragment returns from B to A
What's the proper way of handling these types of situations where we'd like the back button to handle backing out of Inner Fragments first and then Outer Fragments after?
Details here:
Sample Code: