Status Update
Comments
au...@gmail.com <au...@gmail.com> #2
si...@gmail.com <si...@gmail.com> #3
What is 'partially' exactly?
How do I see it?
Thanks!
si...@gmail.com <si...@gmail.com> #4
- Nesting scroll views with a scroll direction perpendicular to the ViewPager2's orientation inside ViewPager2 works
- Nesting scroll views with a scroll direction parallel to the ViewPager2's orientation inside ViewPager2 does not work
ye...@gmail.com <ye...@gmail.com> #5
Set a setNestedScrollingEnabled to the RecyclerView into the ViewPager2 (across reflection) resolves the problem
ye...@gmail.com <ye...@gmail.com> #6
ni...@gmail.com <ni...@gmail.com> #7
Verified that it works correctly on a:
- Nexus 4 emulator with API 17
- Nexus 5X emulator with API 28
- Pixel 2 device with API 29
To reproduce:
- Check out the Android Jetpack source (at commit 256899f482ff85cddfb050f37550be7b5ec927ef) (see steps in [1])
- Apply the patch (`git apply 0001-Add-sample-where-a-horizontal-ViewPager2-is-nested-i.patch`)
- Build and install viewpager2's integration-tests app: `./gradlew viewpager2:integration-tests:testapp:installDebug`
- Run it
Closing the issue for now, but please reopen if you have a minimal reproduction app
[1]
hu...@ril.com <hu...@ril.com> #8
jb...@google.com <jb...@google.com>
li...@gmail.com <li...@gmail.com> #9
I searched a lot for workarounds on Google and SO, but it seems no one really found a suitable solution yet.
The thing is that all other VerticalViewPagers out there have other problems that are similarly annoying. Most of them revolve around touch issues like "What's a click and what's a swipe" or "what's the fling threshold to snap to the next page".
So if someone knows of a working sample of VerticalViewPagers, I'd be happy to see a link :)
ca...@gmail.com <ca...@gmail.com> #10
One possible option for VerticalViewPager with nested scrolling in the same scroll direction is using a RecyclerView implementing NestedScrollingParent + PagerSnapHelper to get snapping.
You'd then have to implement the NestedScrollingParent/Child contract between parent/child RecyclerView instances.
st...@gmail.com <st...@gmail.com> #11
I will try implementing what you suggested and in case it is readable code, I will post it here as sample project or somthing similar.
il...@google.com <il...@google.com> #12
ap...@google.com <ap...@google.com> #13
But I figured out another way to achieve the same goal. I attached a demo project with the following setup:
1. A parent RecyclerView with PagerSnapHelper:
This vertical RecyclerView has two items/pages.
The upper page is just a simple TextView.
The lower page contains the nested RecyclerView.
Both pages are Fragments if that is of any concern.
2. A PagingLinearLayoutManager:
This is a LinearLayoutManager with the capability to enable/disable scrolling.
It is used for the parent RecyclerView.
3. A OnItemTouchListener:
This is also used for the parent RecyclerView.
It saved the initial y coordinate on ACTION_DOWN
During ACTION_MOVE event, it decides whether the PagingLinearLayoutManager is allowed to scroll (i.e. to switch between pages)
The important parts of the code are commented. Hope this helps someone else!
ap...@google.com <ap...@google.com> #14
ap...@google.com <ap...@google.com> #16
We're working on a solution that'll work reliably with ViewPager2 1.0. See
Not finalized at the time of writing, but might help some people already. Notice NestedScrollableHostLayout wrapping [1] a scrollable child.
[1]
ap...@google.com <ap...@google.com> #17
Branch: androidx-master-dev
commit 1316417bc87741ea9f739a453eb9e792512c9651
Author: Jelle Fresen <jellefresen@google.com>
Date: Tue Oct 01 16:58:57 2019
Add sample of nested scrolling in ViewPager2
This shows how nested scrolling can be achieved in ViewPager2. Every
child on a page that scrolls in the same direction as ViewPager2 must be
wrapped by a NestedScrollableHostLayout, and one must make sure that the
scrollable child implements canScrollHorizontally/Vertically in order
for this to work.
Bug: 123006042
Test: Manual, run ViewPager2 demo app
Change-Id: I79e24b7668cf7ff5c05c350ea3ab9134dd74b3a4
M viewpager2/integration-tests/testapp/src/main/AndroidManifest.xml
M viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/BrowseActivity.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/NestedScrollableHost.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/ParallelNestedScrollingActivity.kt
A viewpager2/integration-tests/testapp/src/main/res/layout/item_nested_recyclerviews.xml
M viewpager2/integration-tests/testapp/src/main/res/values/colors.xml
M viewpager2/integration-tests/testapp/src/main/res/values/strings.xml
ap...@google.com <ap...@google.com> #18
Notice how the scrollable children of ViewPager2 are wrapped in NestedScrollableHost -- optional for orthogonal elements, required for same-orientation elements.
ap...@google.com <ap...@google.com> #19
ap...@google.com <ap...@google.com> #20
We're keeping this bug open to track effort in the area.
ap...@google.com <ap...@google.com> #21
It worked just as I would expect it to work. A fling inside of the host flinged the recyclerview to the end. A second fling in the same direction changed the page in the viewpager. I had to lift my finger during a scroll all the way to the end of the recyclerview to get the viewpager to page. Great results.
ap...@google.com <ap...@google.com> #22
ap...@google.com <ap...@google.com> #23
To clarify, does the scrolling functionality work correctly with NestedScrollableHost (both: with 'pre-tap' and directly)?
ap...@google.com <ap...@google.com> #24
ap...@google.com <ap...@google.com> #25
To elaborate a little more, I initially added NestedScrollableHost after #21 reported that it solved the same problem we have. However, through elimination I discovered that the inclusion of NestedScrollableHost didn't seem to make a difference but the 'pre-tap' before attempting to scroll did.
ap...@google.com <ap...@google.com> #26
ViewPager2 (horizontal) > NestedScrollView (vertical) > ConstraintLayout > RecyclerView (horizontal)
ViewPager2 1.0.0
Core (NestedScrollView) 1.1.0
RecyclerView 1.1.0
ap...@google.com <ap...@google.com> #27
In the meantime, we still recommend NestedScrollableHost as per
ap...@google.com <ap...@google.com> #28
ap...@google.com <ap...@google.com> #29
Possibly you could override SeekBar's onInterceptTouchEvent similar to
ap...@google.com <ap...@google.com> #30
The good thing is it also allows my nested RV to recycle properly, compared to wrapping it in a NestedScrollView. Saved my day, thanks.
ap...@google.com <ap...@google.com> #31
ap...@google.com <ap...@google.com> #32
ap...@google.com <ap...@google.com> #33
Only the vertical scrolling of the map works, the horizontal scroll doesn't.
Any lead would be appreciated. Thanks.
ap...@google.com <ap...@google.com> #34
Re NestedScrollableHost
directly.
If that doesn't work, check out what it does and follow a similar pattern, the key is wrapping an element in a ViewGroup (e.g. FrameLayout
) and calling requestDisallowInterceptTouchEvent
when appropriate. In case it requires a custom solution like this, share it here so others can benefit.
ap...@google.com <ap...@google.com> #35
ap...@google.com <ap...@google.com> #36
Before recommending migration from ViewPager documentation must declare features removed - like nested scroll, scroll interpolators, ability to use Adapter not bound to RecyclerView. It's total pita to restore current functionality provided by ViewPager by default :(
ap...@google.com <ap...@google.com> #37
I tried the NestedScrollableHost solution but the problem is, if I use a wrapper on this ConstraintLayout, the code will break since the View that is defined as a BottomSheetBehaviour has to be a direct child of CoordinatorLayout (Which is the root view for the ViewPager).
ap...@google.com <ap...@google.com> #38
I was unable to get horizontal scrolls with NestedScrollableHost
to work when I had ViewPager2 (H) > ViewPager2 (V) > ViewPager2 (H)
because it would only check to see if the immediate ancestor ViewPager2
would scroll in the same direction. I made a modification to solve this issue, which checks all ancestor ViewPager2
s.
package live.spin.ui.main
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.widget.FrameLayout
import androidx.viewpager2.widget.ViewPager2
import androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL
import kotlin.math.absoluteValue
import kotlin.math.sign
/**
* Based on https://github.com/android/views-widgets-samples/blob/master/ViewPager2/app/src/main/java/androidx/viewpager2/integration/testapp/NestedScrollableHost.kt
* but modified by Seth Westphal (westy92@gmail.com) to support nested ViewPager2.
*/
/**
* Layout to wrap a scrollable component inside a ViewPager2. Provided as a solution to the problem
* where pages of ViewPager2 have nested scrollable elements that scroll in the same direction as
* ViewPager2. The scrollable element needs to be the immediate and only child of this host layout.
*
* This solution has limitations when using multiple levels of nested scrollable elements
* (e.g. a horizontal RecyclerView in a vertical RecyclerView in a horizontal ViewPager2).
*/
class NestedScrollableHost : FrameLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
private var touchSlop = 0
private var initialX = 0f
private var initialY = 0f
private val ancestorViewPagers: List<ViewPager2>
get() {
val ancestors = mutableListOf<ViewPager2>()
var v: View? = parent as? View
while (v != null) {
if (v is ViewPager2) ancestors.add(v)
v = v.parent as? View
}
return ancestors
}
private val child: View? get() = if (childCount > 0) getChildAt(0) else null
init {
touchSlop = ViewConfiguration.get(context).scaledTouchSlop
}
private fun canChildScroll(orientation: Int, delta: Float): Boolean {
val direction = -delta.sign.toInt()
return when (orientation) {
0 -> child?.canScrollHorizontally(direction) ?: false
1 -> child?.canScrollVertically(direction) ?: false
else -> throw IllegalArgumentException()
}
}
override fun onInterceptTouchEvent(e: MotionEvent): Boolean {
handleInterceptTouchEvent(e)
return super.onInterceptTouchEvent(e)
}
private fun handleInterceptTouchEvent(e: MotionEvent) {
for (ancestor in ancestorViewPagers) {
val orientation = ancestor.orientation
// Early return if child can't scroll in same direction as parent
if (!canChildScroll(orientation, -1f) && !canChildScroll(orientation, 1f)) {
continue
}
if (e.action == MotionEvent.ACTION_DOWN) {
initialX = e.x
initialY = e.y
parent.requestDisallowInterceptTouchEvent(true)
} else if (e.action == MotionEvent.ACTION_MOVE) {
val dx = e.x - initialX
val dy = e.y - initialY
val isVpHorizontal = orientation == ORIENTATION_HORIZONTAL
// assuming ViewPager2 touch-slop is 2x touch-slop of child
val scaledDx = dx.absoluteValue * if (isVpHorizontal) .5f else 1f
val scaledDy = dy.absoluteValue * if (isVpHorizontal) 1f else .5f
if (scaledDx > touchSlop || scaledDy > touchSlop) {
if (isVpHorizontal == (scaledDy > scaledDx)) {
// Gesture is perpendicular, allow all parents to intercept
parent.requestDisallowInterceptTouchEvent(false)
} else {
// Gesture is parallel, query child if movement in that direction is possible
if (canChildScroll(orientation, if (isVpHorizontal) dx else dy)) {
// Child can scroll, disallow all parents to intercept
parent.requestDisallowInterceptTouchEvent(true)
} else {
// Child cannot scroll, allow all parents to intercept
parent.requestDisallowInterceptTouchEvent(false)
}
}
}
}
}
}
}
ap...@google.com <ap...@google.com> #39
ap...@google.com <ap...@google.com> #40
Yes, I'd be happy to! Feel free to email me information on where to start that process.
ap...@google.com <ap...@google.com> #41
ap...@google.com <ap...@google.com> #42
ap...@google.com <ap...@google.com> #43
Unfortunately, the workaround #18 dose not suitable for the case that a ScrollerView or NestedScrollView that has the same orientation in a ViewPager2.
Any other solution will be appreciated.
ap...@google.com <ap...@google.com> #44
Re #43. Finally I found a workaround after some modifications.
It also suitable for the following case: ViewPager2(V) -> NestedScrollView(V) -> RecyclerView(H) (See
Just simply intercept events if child view do not need to scroll.
Also, don't change the touch slop since it seems that the ScrollView will consume the event which result in we can't receive enough move distance.
ap...@google.com <ap...@google.com> #45
ap...@google.com <ap...@google.com> #46
ap...@google.com <ap...@google.com> #47
ap...@google.com <ap...@google.com> #48
When sliding quickly, NestedScrollableHost.onInterceptTouchEvent will not be called, nested scrollable view cannot scroll to the edge.
If ViewPager2 is nested with an imageview that supports zooming/panning, and then quickly swipe after zooming in, the displayed image is only the width of the screen.
ap...@google.com <ap...@google.com> #49
Hi
st...@gmail.com <st...@gmail.com> #50
il...@google.com <il...@google.com> #51
ap...@google.com <ap...@google.com> #52
ap...@google.com <ap...@google.com> #53
ap...@google.com <ap...@google.com> #54
ap...@google.com <ap...@google.com> #55
ap...@google.com <ap...@google.com> #56
I have observed sometime the page is changed randomly also, while we are in scrolling recyclerview and suddenly the page is changed.
Any update on this issue? It's leading to some major app functioning issues
st...@gmail.com <st...@gmail.com> #57
The attached example works like a charm - and will have to do until Google solves this at a lower level...
ap...@google.com <ap...@google.com> #58
any update on this?
ap...@google.com <ap...@google.com> #59
As many have written here, NestedScrollableHost workaround doesn't work for fast scrolling (even on the newest version 1.1.0). This would annoy users, so I went back to ViewPager.
Why fix obvious flaws when you can work on AI, AI, AI...
ap...@google.com <ap...@google.com> #60
ap...@google.com <ap...@google.com> #61
ap...@google.com <ap...@google.com> #62
Branch: androidx-main
commit aa00c85529ad6c2a59b0dbbbea66247032d87877
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 04 11:00:43 2024
Update typeMap kdoc description
Update doc to reflect the fact that it is a non-nullable map but may be empty
Test: n/a
Bug: 188693139
Change-Id: If7c694dd05c8f68949287b99c069c81a967a5266
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/ComposeNavigatorDestinationBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogNavigatorDestinationBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavGraphBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt
ap...@google.com <ap...@google.com> #63
Branch: androidx-main
commit 3c6d402195136edc54ea845cfbc2dc474b87fb7e
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 04 13:19:46 2024
Update reified T upperbound for safe args API
Update upperbound from `Any?` to `Any` for safe arg APIs that have route: String counterparts where String is non-nullable.
Test: TH
Bug: 188693139
Change-Id: Idc8c6bd552fa7261fb1b81624ff2add42c469f73
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
ap...@google.com <ap...@google.com> #64
Branch: androidx-main
commit 5fdeb25b94eb1b2ccb462910d4493a32603c10d4
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 04 13:29:40 2024
Add experimental annotation on NavOption safe args field
Mark public safe arg fields `popUpToRouteClass` and `popUpToRouteObject` as ExperimentalSafeArgsApi. All safe args public methods / fields should be marked experimental at this point.
Test: TH
Bug: 188693139
Relnote: "New NavOptions fields popUpToRouteClass and popUpToRouteObject are marked ExperimentalSafeArgsApi and requires opt-in to use."
Change-Id: Iefd951a986bd24057701fa2be24298fe691e0929
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptions.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
ap...@google.com <ap...@google.com> #65
Branch: androidx-main
commit 30135e174b2d258832f997127a4e4655cc8fee16
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 04 13:33:32 2024
Update NavOptions equals and toString
Equals and toString now also factors in popUpToRouteObject field
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Change-Id: I7badbcaf4bfd1940887b29ed0e40d2634f4ecf23
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptions.kt
ap...@google.com <ap...@google.com> #66
Branch: androidx-main
commit 552d8c8d295268184ec2b9bd821a6bc757467432
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 05 07:26:11 2024
Add DynamicIncludeNavGraphBuilder safe args constructor
Add support to constrcut a DynamicIncludeNavGraph with route from a serializable KClass.
Also added #includeDynamic DSL to create DynamicIncludeNavGraphs.
Test: ./gradlew navigation:navigation-dynamic-features-runtime:cC
Bug: 188693139
Relnote: "Add support to constrcut a DynamicIncludeNavGraph with route from a serializable KClass."
Change-Id: Ib3aba24336deb730aabd222f37eaefefca8006cf
M navigation/navigation-dynamic-features-runtime/api/current.txt
M navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt
ap...@google.com <ap...@google.com> #67
Branch: androidx-main
commit 29074906d7407d17e7b46bb2c7ce169cef3a1eaa
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 05 06:57:03 2024
Add DynamicNavGraphBuilder safe args constructors
Add support to constrcut a DynamicNavGraph with route from a serializable KClass and startDestination from either an Object or a KClass.
Also added #navigation DSL to create root and nested DynamicNavGraphs.
Test: ./gradlew navigation:navigation-dynamic-features-runtime:cC
Bug: 188693139
Relnote: "Add support to constrcut a DynamicNavGraph with route from a serializable KClass and startDestination from either an Object or a KClass"
Change-Id: Ia668dffcae8b255bf5db75b6c149983d973d2b06
M navigation/navigation-dynamic-features-runtime/api/current.txt
M navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
M navigation/navigation-dynamic-features-runtime/build.gradle
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt
ap...@google.com <ap...@google.com> #68
Branch: androidx-main
commit b3b904a849a3c2f97e1c4357c4f829790906c11a
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 05 07:49:05 2024
Add DynamicNavGraphBuilder activity DSL
Add DSL to create a DynamicActivityNavigator.Destination with route from serializable KClass.
Test: ./gradlew navigation:navigation-dynamic-features-runtime:cC
Bug: 188693139
Relnote: "Add DSL to create a DynamicActivityNavigator.Destination with route from serializable KClass."
Change-Id: I9b73c5cafcb80ea92d6ecb03677a5128fb7fb944
M navigation/navigation-dynamic-features-runtime/api/current.txt
M navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt
st...@gmail.com <st...@gmail.com> #69
Will this feature support having parameters to your destinations which have lists internally?
@Serializable
data class FooDestination(
val firstParam: String,
val someList: List<String>,
)
This List<String>
is the problem here atm.
Currently with snapshot "11678588" trying to run an app with such lists I get the error message:
java.lang.IllegalArgumentException: Cannot cast someList of type kotlin.collections.ArrayList to a NavType. Make sure to provide custom NavType for this argument.
at androidx.navigation.serialization.RouteSerializerKt$generateNavArguments$2$1.invoke(RouteSerializer.kt:108)
at androidx.navigation.serialization.RouteSerializerKt$generateNavArguments$2$1.invoke(RouteSerializer.kt:103)
at androidx.navigation.NamedNavArgumentKt.navArgument(NamedNavArgument.kt:25)
at androidx.navigation.serialization.RouteSerializerKt.generateNavArguments(RouteSerializer.kt:103)
at androidx.navigation.NavDestinationBuilder.<init>(NavDestinationBuilder.kt:105)
at androidx.navigation.compose.ComposeNavigatorDestinationBuilder.<init>(ComposeNavigatorDestinationBuilder.kt:92)
...
But from my understanding, this should already be supported natively as I see here
ap...@google.com <ap...@google.com> #70
Branch: androidx-main
commit 3e773091a584711a9c94a648da21a53db84414c0
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 05 14:11:45 2024
Add DynamicFragmentNavigatorDestinationBuilder constructor
New constructor that takes a serializable KClass as the destination route.
Also added are:
1. DynamicNavGraphBuilder extension functions to create a fragment with reified KClass
2. NavHost createGraph extensions with startDestination from either KClass or Object to support DynamicNavGraphBuilder fragment DSL
Test: ./gradlew navigation:navigation-dynamic-features-fragment:cC
Bug: 188693139
Relnote: "DynamicFragmentNavigatorDestinationBuilder now takes a serializable KClass as route to create the NavDestination with type safety"
Change-Id: I554db9e95f298f0c0ca51d4b7dc76087c20f9272
M navigation/navigation-dynamic-features-fragment/api/current.txt
M navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
M navigation/navigation-dynamic-features-fragment/build.gradle
M navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt
M navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt
M navigation/navigation-dynamic-features-runtime/api/current.txt
M navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt
ap...@google.com <ap...@google.com> #71
Branch: androidx-main
commit b2c283af71255ecc1bc7a81590852c6c5ec41c8b
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 10 15:46:06 2024
RouteDecoder fallback to default value
If an argument value is missing from the bundle, the decoder will now fallback to default values (if present) that were declared in the destination's KClass.
For example, a deeplink used to navigate may have a required arugment missing from the deeplink uri. If there is a default value, the defavult value will be used to decode the uri back into the destination instance.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Change-Id: I26458eb605a3eb0c0dcb7968b4d15f821133efae
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteDecoderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteDecoder.kt
ap...@google.com <ap...@google.com> #72
Branch: androidx-main
commit 0455368c4af491258e583f08d0e0791b159cd371
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 10 19:05:18 2024
Make addInDefaultArg bypass unknown default values
addInDefaultArg is responsible for adding and verifying default args to a bundle. In the case of safe args where we have a default value but don't know what it is, addInDefaultArgs should just bypass the default value for that argument.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Change-Id: Ifaf6f7455e05c40ca48b83b23f3f9d7ca8b8b5f7
M navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavArgumentTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/NavArgumentGeneratorTest.kt
ap...@google.com <ap...@google.com> #73
Branch: androidx-main
commit 6e1a7fb89d23257873aadc862840ab388404087f
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 10 19:46:46 2024
Update criteria for required arguments
Arguments with unknown default values should not be considered a required argument
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Change-Id: I476509014a619b9436d91693e9ff03a7a05b06f0
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavArgument.kt
ap...@google.com <ap...@google.com> #74
Branch: androidx-main
commit b2e619bc73ec783eb143ab8014b2d274ffc96ebf
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 10 15:46:06 2024
Update RouteDecoder docs
Test: n/a
Bug: 188693139
Change-Id: I26131f30973c270c7a4d627276831f27fa6a90ae
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteDecoder.kt
ap...@google.com <ap...@google.com> #75
Branch: androidx-main
commit 25f29701f0e6f12d96cdfe01e1b8c4fb2e69542e
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 11 15:28:21 2024
Add DeepLink setUriPattern API with KClass
The new setUriPattern takes a uriPattern and a reified KClass. The uriPattern will be the deeplink uri's base path, and the arguments from the KClass will be generated and appended onto the uriPattern.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "Added NavDeepLink setUriPattern to set the deeplink uri based on a serializable KClass"
Change-Id: Id0e55c3e938d28c034aa2b6f2a23e815b0d8bfb9
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLink.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteBuilder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteSerializer.kt
ap...@google.com <ap...@google.com> #76
Branch: androidx-main
commit d1f355ca0ccd76618b753d39c081f8d06821bb5b
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 11 15:32:24 2024
Add navDeepLink DSL to create a NavDeepLink with KClass
Test: ./gradlew navigation:navigation-common:cC
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 188693139
Relnote: "Added navDeepLink DSL to create a NavDeepLink with a serializable KClass."
Change-Id: Ice0608f7b128f367760d4617d6b7f770d46618c7
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLinkDslBuilder.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
ap...@google.com <ap...@google.com> #77
Branch: androidx-main
commit c833e65d00feabf0dbb2eed7868ecb5815250d62
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 12 17:33:41 2024
RoutePattern generation should throw on unknown NavType
Route pattern generation appends argument as either path or query depending on NavType. Therefore it should throw if it cannot map an argument Type to a NavType
Test: ./gradlew navigation:navigation-common:cC
Test: ./gradlew navigation:navigation-common:test
Bug: 188693139
Change-Id: I378d171639963a23fe7c02872a95913478de0b8a
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteFilledTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/NavTypeConverter.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteSerializer.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/RoutePatternTest.kt
ap...@google.com <ap...@google.com> #78
Branch: androidx-main
commit 35fda1fb0d6677caad4731ba17b7c37baef801ad
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 12 16:06:45 2024
Clean up NavTypeConverter
Removed internal types for Maps, Sets and other types that do not have built-in support from NavType. This should clarify confusions on what types are natively supported by safe args and which types are not supported (aka required custom NavType).
These internal types should be re-added in the future if and when it gets native NavType support.
Test: TH
Bug: 188693139
Change-Id: Iabf112b941fd891c798ad451e4d298094978e4e4
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/NavTypeConverter.kt
ap...@google.com <ap...@google.com> #79
Branch: androidx-main
commit adb4385ad4844d7edc540c417f417e28e44acff1
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 12 15:47:34 2024
Fix KType mismatch with kotlin reflect
When mapping an argument Type to NavType, the matching used to be based on type names. However the type name varies depending on whether build dependency has kotlin reflect.
Refactorted implementation to be based on hashcode which is generated at runtime. This means the matching is independent of kotlin reflect and provides more reliable matching.
Test: ./gradlew navigatiion:navigation-common:test
Bug: 333965952
Bug: 188693139
Change-Id: Ia660ee2880558f19af58cd6fbe240946374eb7c4
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/NavTypeConverter.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteSerializer.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/NavTypeConverterTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/RoutePatternTest.kt
ap...@google.com <ap...@google.com> #80
Branch: androidx-main
commit cfcb4a7c315a46772d2ffa48144e07f189377a4f
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 12 17:36:05 2024
Add tests for CollectionNavType
Test: ./gradlew navigation:navigation-common:cC
Test: ./gradlew navigation:navigation-common:test
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 188693139
Change-Id: I9bb8e49046d7c8335e979f61044b4058653ecad4
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteDecoderTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteFilledTest.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/RoutePatternTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt
ap...@google.com <ap...@google.com> #81
Branch: androidx-main
commit 61fb8751b3f5b374df03f06e771edb4ef18843e6
Author: Clara Fok <clarafok@google.com>
Date: Mon Apr 15 15:17:23 2024
Add Safe Args native support for List NavTypes
Add native support for arguments that are Lists of:
Boolean
Float
Int
Stirng
Long
This includes derivatives of List, such as MutableList, ArrayList etc.
Test: ./gradlew navigation:navigation-common:cC
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 188693139
Relnote: "Safe Args now support the built-in List NavTypes"
Change-Id: Ia914c3739d9c3659909826b9eeaed7f74da39345
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteFilledTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/NavTypeConverter.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/NavArgumentGeneratorTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
ap...@google.com <ap...@google.com> #82
Branch: androidx-main
commit ccbada2bd96d3c09347e3763d32a3a77e08a447a
Author: Clara Fok <clarafok@google.com>
Date: Mon Apr 15 15:16:39 2024
Add built-in List NavTypes
Add built-in NavTypes for List of Int, String, Boolean, Float, and Long. This NavType can be used for Kotlin Collections extending List, such as MutableList, ArrayList etc.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "NavType now has built-in support for Lists of Int, String, Boolean, Float, and Long"
Change-Id: I4b6dd5ee05083c9b920eb886354384a9f55dc4aa
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavTypeTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavType.kt
ap...@google.com <ap...@google.com> #83
Branch: androidx-main
commit fe58bc6ee30bbf2b31a9bfb892853050ba650089
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 16 11:35:07 2024
Update setUriPattern param name
Test: TH
Bug: 188693139
Bug: 334995120
Relnote: "Update setUriPattern param name for uriPattern to basePath"
Change-Id: I95710b70ebbfa839f1809df21049d5c50ab74c4c
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLink.kt
ap...@google.com <ap...@google.com> #84
Branch: androidx-main
commit 978353a2fc285a51274efbd37061943865bd2513
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 16 11:21:31 2024
Update navDeepLink dsl to take basePath
This ensures basePath is set for safe args deeplinks. Any uriPattern that is set within the builder lambda will override the generated uriPattern.
The builder requires `noinline` or else IDE throws error `Illegal usage of inline-parameter 'deepLinkBuilder...`
Note on lint: navDeepLink must not have empty builder lambdas in the past. Now it is permitted if there is TypeParameter in the case of safe args where the base path for uriPattern is passed in as a param rather than set as a uriPattern within builder.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Bug: 334995120
Relnote: "Safe Args navDeepLink dsl now takes in basePath to ensure base path is set for the final generated uriPattern. Any uriPattern that is set within the builder lambda will override the generated uriPattern."
Change-Id: I8d3948948e68b65f05c5bb943daba3deda64db2e
M navigation/navigation-common-lint/src/main/java/androidx/navigation/common/lint/EmptyNavDeepLinkDetector.kt
M navigation/navigation-common-lint/src/test/java/androidx/navigation/common/lint/EmptyNavDeepLinkDetectorTest.kt
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLinkDslBuilder.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
ap...@google.com <ap...@google.com> #85
Branch: androidx-main
commit a19b813fae7ec73e86d97e059c0938014883433e
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 15:09:58 2024
Remove ExperimentalSafeArgsApi uses from navigation-dynamic-features-runtime
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-dynamic-features-runtime. These APIs no longer require opt-in"
Change-Id: If5380f1943f2a3dc1ff733ed3cfab5f1328c618a
M navigation/navigation-dynamic-features-runtime/api/current.txt
M navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt
M navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt
ap...@google.com <ap...@google.com> #86
Branch: androidx-main
commit 3ad765604152e08a54057843e02258ed607ca3a4
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 14:54:44 2024
Remove ExperimentalSafeArgsApi uses from navigation-runtime
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-runtime. These APIs no longer require opt-in"
Change-Id: Ia5c59da2d7d4e40db08e4fe29167ecc543df8a95
M navigation/navigation-runtime/api/current.txt
M navigation/navigation-runtime/api/restricted_current.txt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/ActivityNavigatorDestinationBuilderTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt
ap...@google.com <ap...@google.com> #87
Branch: androidx-main
commit c2270851e460d64c20e138e8274adcb6a5dc99c1
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 14:55:07 2024
Remove ExperimentalSafeArgsApi uses from navigation-compose
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-compose. These APIs no longer require opt-in"
Change-Id: I45f8b649fc3f5e9d738c432c4a53f23db7ab931e
M navigation/navigation-compose/api/current.txt
M navigation/navigation-compose/api/restricted_current.txt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/ComposeNavigatorDestinationBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogNavigatorDestinationBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavGraphBuilder.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
ap...@google.com <ap...@google.com> #88
Branch: androidx-main
commit 585ddc7855f040f72d860adb0b5032f7d9a475eb
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 14:51:18 2024
Remove ExperimentalSafeArgsApi uses from navigation-common
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-common. These APIs no longer require opt-in"
Change-Id: Ic30322fdcc6ab6abd383758d996d4007e1bf6375
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.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/androidTest/java/androidx/navigation/NavOptionsBuilderTest.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavBackStackEntry.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLink.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
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptions.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavOptionsBuilder.kt
M testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt
ap...@google.com <ap...@google.com> #89
Branch: androidx-main
commit 5a78bef90a694b82a4f59f763ec7292ad702a5f7
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 14:55:36 2024
Remove ExperimentalSafeArgsApi uses from navigation-fragment
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-fragment. These APIs no longer require opt-in"
Change-Id: I08b231168eaedeabcd4add210daa96a99dc5807e
M navigation/navigation-fragment/api/current.txt
M navigation/navigation-fragment/api/restricted_current.txt
M navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilderTest.kt
M navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
M navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/NavControllerWithFragmentTest.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
ap...@google.com <ap...@google.com> #90
Branch: androidx-main
commit 1870828f269fc32f994ef1be169ae43aaf181d43
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 15:10:22 2024
Delete ExperimentalSafeArgsApi
Test: TH
Bug: 188693139
Relnote: "Delete ExperimentalSafeArgsApi annotation. All safe args API are safe to use without opt-in."
Change-Id: I11f0bb08a3f2f220f3ba8ba2d72890cd16e56ef3
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
D navigation/navigation-common/src/main/java/androidx/navigation/ExperimentalSafeArgsApi.kt
ap...@google.com <ap...@google.com> #91
Branch: androidx-main
commit 92492a56a2cace5f691b7281f7cad5ed5d4e6100
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 15:09:27 2024
Remove ExperimentalSafeArgsApi uses from navigation-dynamic-features-fragment
In prepration for beta
Test: TH
Bug: 188693139
Relnote: "ExperimentalSafeArgsApi has been removed from safe args APIs in navigation-dynamic-features-fragment. These APIs no longer require opt-in"
Change-Id: Idcdaf353295d64d8162a8e2f792ccd2cdaccee4a
M navigation/navigation-dynamic-features-fragment/api/current.txt
M navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
M navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt
M navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt
ap...@google.com <ap...@google.com> #92
Branch: androidx-main
commit 501d6aa733a0866819a0ab1471f71de24ffa7e17
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 17 11:43:23 2024
Add hasRoute<T> API for NavDestination
Convenience method to check if the NavDestination's route is based on KClass<T>.
Internally, the implementation is based on destination ID which was set during its initialization. Therefore if the ID was later overridden with a custom ID, the function will always return false.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "Added hasRoute<T> API for NavDestination to check if the NavDestination's route is based on KClass<T>."
Change-Id: I6c3a2109d99a3c40102b8a81d7a8bc17746c6a93
M navigation/navigation-common/api/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
ap...@google.com <ap...@google.com> #93
Branch: androidx-main
commit bbf8d5ab440631c99c6ed5d8d0a101c042e5bc2d
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 16 12:45:23 2024
New add deepLink from KClass APIs for NavDestinationBuilder
NavDestinationBuilder supports adding deepLink from a reified serializable KClass by taking a base path and then appending arguments extracted from the KClass.
The deepLink does not take a typeMap and instead relies on the arguments that were added when initializing NavDestinationBuilder with route from KClass. As such, the deeplink is expected to have identital arguments (in name and type) as the destination KClass.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "Add NavDestinationBuilder deepLink APIs to add DeepLinks based on serializable KClass"
Change-Id: I3a64b21c11307c1cb409e2bb47e292021d55c0b7
M navigation/navigation-common/api/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
ap...@google.com <ap...@google.com> #94
Branch: androidx-main
commit a740327998fd2621a1e60314648bd1927c07eff2
Author: Clara Fok <clarafok@google.com>
Date: Thu Apr 18 10:27:20 2024
Add hasRoute<T> API for NavDestination
Previous merge was reverted aosp/3047794. ExperimentalSafeArgsApi annotations are now removed from tests.
Convenience method to check if the NavDestination's route is based on KClass<T>.
Internally, the implementation is based on destination ID which was set during its initialization. Therefore if the ID was later overridden with a custom ID, the function will always return false.
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "Added hasRoute<T> API for NavDestination to check if the NavDestination's route is based on KClass<T>."
Change-Id: I873b7d2beee8a589858e84f8e6f95f295c51e6b9
M navigation/navigation-common/api/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
ap...@google.com <ap...@google.com> #95
Branch: androidx-main
commit 3259e05a28c122d658f86ac65ccd74f0022e4f1a
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 19 09:47:15 2024
Add SavedStateHandle.toRoute() API
This recreates destination instance from a SavedStateHandle to read typed arugments from.
Refactored RouteDecoderTest into kmp-friendly parameterized test with argument source from Bundle or SavedStateHandle.
Test: ./gradlew navigation:navigation-compose:cC
Test: ./gradlew navigation:navigation-common:cC
Bug: 188693139
Relnote: "Added SavedStateHandle.toRoute() to recreate destination object with args."
Change-Id: I0eb0db9fe1dc51c25545d5ef2e915e181d3a9dae
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/serialization/RouteDecoderTest.kt
A navigation/navigation-common/src/main/java/androidx/navigation/SavedStateHandle.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteDecoder.kt
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteDeserializer.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt
ap...@google.com <ap...@google.com> #96
Branch: androidx-main
commit 35770e5dc11ff84cbf79e3dab977cf24ddda3c31
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 19 15:17:20 2024
Update compose demos
Refactored to use safe args
Test: manual
Bug: 188693139
Change-Id: I9ab7d2feb9f9fe3ce9ada075eeafb15a1afa9bc2
M navigation/navigation-compose/integration-tests/navigation-demos/build.gradle
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/BottomBarNavDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavByDeepLinkDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavPopUpToDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavSingleTopDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavWithArgsDemo.kt
ap...@google.com <ap...@google.com> #97
Branch: androidx-main
commit dc2cbe2b1ab95589cbdb84add3966d9e3c392289
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 19 16:55:46 2024
Add NavDestionation.hasRoute overload
Add an overload that takes a KClass<T> as parameter in the event where user only has access to the route kclass during runtime. Since KClass<T> cannot be passed as TypeParameter, we need an overload that takes a KClass.
Test: existing tests
Bug: 188693139
Relnote: "Add an overload that takes a KClass<T> as parameter in the case where users only have access to the route kclass during runtime."
Change-Id: Iea94de164795b79e99b8f1c2661e06ca6639b2bc
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDestination.kt
ap...@google.com <ap...@google.com> #98
Branch: androidx-main
commit 6d232ea3f9242d82e8d126e5d72932f75fdf8764
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 19 15:16:33 2024
Update compose samples
Refactored to use safe args
Test: manual
Bug: 188693139
Change-Id: I67d6dd74e93a9d3733f1bb91507b0656453a369b
M navigation/navigation-compose/samples/src/main/java/androidx/navigation/compose/samples/NavigationSamples.kt
M navigation/navigation-compose/samples/src/main/java/androidx/navigation/compose/samples/SizeTransformSample.kt
ap...@google.com <ap...@google.com> #99
Branch: androidx-main
commit 63ad7d7cc1613a6773531a828458c4719f4a1802
Author: Clara Fok <clarafok@google.com>
Date: Fri Apr 19 16:26:31 2024
Add new demo NavWithArgsInNestedGraphDemo
Test: manual
Bug: 188693139
Change-Id: I23f0178e28a7fff2a2149776a2d518e4e8040c35
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavWithArgsDemo.kt
A navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavWithArgsInNestedGraphDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavigationDemos.kt
M navigation/navigation-compose/samples/src/main/java/androidx/navigation/compose/samples/NavigationSamples.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavGraphBuilder.kt
ap...@google.com <ap...@google.com> #100
Branch: androidx-main
commit 153cc28e93e502aed8d4abe4941828bda5c4ce51
Author: Ian Lake <ilake@google.com>
Date: Mon Apr 22 20:30:15 2024
Remove Destination interface
Each Serializable destination can be a top
level object / data class, avoiding the need
for coupling all destinations to a single
interface, making it easier to later split
the navigation objects into separate modules.
Test: demos still compile
BUG: 188693139
Change-Id: I3fb109c642183df057bda825df524c83de3c2147
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/BottomBarNavDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavByDeepLinkDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavWithArgsDemo.kt
M navigation/navigation-compose/samples/src/main/java/androidx/navigation/compose/samples/NavigationSamples.kt
ap...@google.com <ap...@google.com> #101
Branch: androidx-main
commit ee9653e5370e114d849cb1984ddc42cbf752a4d8
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 23 14:05:05 2024
Use object instance instead of class
Since startDestination can take type Any, object instances should be passed in rather than object::class.
Test: manual demos
Bug: 188693139
Change-Id: I250d775fb1ead8bb5e7d83f0a7deac21dff1f4a5
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/BottomBarNavDemo.kt
M navigation/navigation-compose/integration-tests/navigation-demos/src/main/java/androidx/navigation/compose/demos/NavWithArgsDemo.kt
M navigation/navigation-compose/samples/src/main/java/androidx/navigation/compose/samples/NavigationSamples.kt
ap...@google.com <ap...@google.com> #102
Branch: androidx-main
commit fd7d0dc4a56c2aef65424db7986aa057f9717661
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 23 16:35:39 2024
GetBackStack to throw if route not in graph
Getting back stack with route from either serializable KClass or object will throw if route is not found in the root NavController.graph
As for the exception message when route is not in backstack:
1. For KClass, the message is updated to be based on route rather than id
2. For object, the message remains the same as the existing one for route: String
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 188693139
Change-Id: I3bcf0aa973795b04b4a8f82b9c41b4f0cfde053e
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
ap...@google.com <ap...@google.com> #103
Branch: androidx-main
commit bace4be6a3830afbcc72e816751a14568dac5195
Author: Clara Fok <clarafok@google.com>
Date: Tue Apr 23 16:17:27 2024
PopBackStack and Navigate to throw if route not in graph
Popping or navigating with route from either serializable KClass or object will throw if route is not found in the root NavController.graph
For popping, if route is not found in back stack, both overloads maintain existing behavior of returning false.
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 188693139
Change-Id: I0a8a5a5a779076f96dacae2c9569ed9638ea13c9
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraph.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
ap...@google.com <ap...@google.com> #104
Branch: androidx-main
commit 8598bbbd37042faa1fa46771da2f367c049018e3
Author: Clara Fok <clarafok@google.com>
Date: Wed Apr 24 12:14:57 2024
Replace deprecated EmptySerializersModule
With serialization in platform bumped to v1.6.3(aosp/3058343), we can update our implementation to use 1.6.3 api here.
Test: existing tests
Bug: 188693139
Change-Id: Ib276f8cac4823ccea7fab508baf29caaa08e43fc
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/RouteEncoder.kt
cl...@google.com <cl...@google.com> #105
Fixed, with first feature-complete release in navigation 2.8.0-alpha08
.
ka...@gmail.com <ka...@gmail.com> #106
Is this feature also expected to be available in androidx.compose.material.navigation
for the bottomSheet
?
ja...@gmail.com <ja...@gmail.com> #107
What about bottom sheets?
il...@google.com <il...@google.com> #108
Re androidx.compose.material
.
ka...@gmail.com <ka...@gmail.com> #109
See material ticket:
ph...@bankshift.com <ph...@bankshift.com> #110
Is there a non-reified overload of inline fun <reified T : Any> popBackStack(...)
?
fun <T : Any> popBackStack(route: T, ...)
appears to consider args and is not purely destinationId
-based.
With KSerializer<T>.generateHashCode()
annotated library-internal, it'd be useful to have popBackStack(route: KClass<T> ... )
for scenarios where args aren't important.
il...@google.com <il...@google.com> #111
Re
n....@gmail.com <n....@gmail.com> #112
Is it possible to get the destination data class from viewModel
's savedStateHandle
? Or is everybody relying on assisted injection for that?
n....@gmail.com <n....@gmail.com> #114
Is it possible to get the same thing but as a StateFlow
?
il...@google.com <il...@google.com> #115
Re MutableStateFlow(savedStateHandle.toRoute<YourClass>())
if you'd find a StateFlow of a single value easier to work with.
n....@gmail.com <n....@gmail.com> #116
thank you
Description
Component used: Navigation
Version used: 1.0.0-alpha01
Devices/Android versions reproduced on: All
Provide a way for typesafe arguments similar to Jetpack-Navigation-Safeargs in Jetpack-Navigation-Compose. Both in navigating to a destination and in retrieving the arguments at that destination.