Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary downgrade navitation to 2.7.* #1315

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ artifactRedirecting.androidx.annotation.version=1.8.0-alpha02
artifactRedirecting.androidx.annotation.targetVersions=jvm=1.7.1,default=1.8.0-alpha02
# Lifecycle group and modules versions are set according to https://youtrack.jetbrains.com/issue/COMPOSE-1306
artifactRedirecting.androidx.lifecycle.version=2.8.0-beta01
artifactRedirecting.androidx.navigation.version=2.8.0-alpha05
artifactRedirecting.androidx.navigation.version=2.7.7
artifactRedirecting.androidx.savedstate.version=1.2.1

# For the purpose of substituteForRedirectedPublishedDependencies (look for it in the code)
Expand Down
2 changes: 1 addition & 1 deletion libraryversions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MEDIA = "1.7.0-rc01"
MEDIA2 = "1.3.0-alpha01"
MEDIAROUTER = "1.7.0-alpha01"
METRICS = "1.0.0-alpha05"
NAVIGATION = "2.8.0-alpha05"
NAVIGATION = "2.7.7"
PAGING = "3.3.0-alpha03"
PALETTE = "1.1.0-alpha01"
PERCENTLAYOUT = "1.1.0-alpha01"
Expand Down
11 changes: 4 additions & 7 deletions navigation/navigation-common/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ package androidx.navigation {
method public androidx.navigation.NavDestination getDestination();
method public String getId();
method public androidx.lifecycle.Lifecycle getLifecycle();
method @MainThread public androidx.lifecycle.SavedStateHandle getSavedStateHandle();
method public androidx.lifecycle.SavedStateHandle getSavedStateHandle();
method public androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
method public androidx.lifecycle.ViewModelStore getViewModelStore();
property public final android.os.Bundle? arguments;
Expand All @@ -125,7 +125,7 @@ package androidx.navigation {
property public final androidx.navigation.NavDestination destination;
property public final String id;
property public androidx.lifecycle.Lifecycle lifecycle;
property @MainThread public final androidx.lifecycle.SavedStateHandle savedStateHandle;
property public final androidx.lifecycle.SavedStateHandle savedStateHandle;
property public androidx.savedstate.SavedStateRegistry savedStateRegistry;
property public androidx.lifecycle.ViewModelStore viewModelStore;
field public static final androidx.navigation.NavBackStackEntry.Companion Companion;
Expand Down Expand Up @@ -406,7 +406,6 @@ package androidx.navigation {
method public T parseValue(String value, T previousValue);
method public abstract void put(android.os.Bundle bundle, String key, T value);
method public String serializeAsValue(T value);
method public boolean valueEquals(T value, T other);
property public boolean isNullableAllowed;
property public String name;
field public static final androidx.navigation.NavType<boolean[]?> BoolArrayType;
Expand All @@ -432,12 +431,11 @@ package androidx.navigation {
property public String name;
}

public static final class NavType.ParcelableArrayType<D extends android.os.Parcelable> extends androidx.navigation.NavType<D[]> {
public static final class NavType.ParcelableArrayType<D extends android.os.Parcelable> extends androidx.navigation.NavType<D[]?> {
ctor public NavType.ParcelableArrayType(Class<D> type);
method public D[]? get(android.os.Bundle bundle, String key);
method public D[] parseValue(String value);
method public void put(android.os.Bundle bundle, String key, D[]? value);
method public boolean valueEquals(D[]? value, D[]? other);
property public String name;
}

Expand All @@ -449,12 +447,11 @@ package androidx.navigation {
property public String name;
}

public static final class NavType.SerializableArrayType<D extends java.io.Serializable> extends androidx.navigation.NavType<D[]> {
public static final class NavType.SerializableArrayType<D extends java.io.Serializable> extends androidx.navigation.NavType<D[]?> {
ctor public NavType.SerializableArrayType(Class<D> type);
method public D[]? get(android.os.Bundle bundle, String key);
method public D[] parseValue(String value);
method public void put(android.os.Bundle bundle, String key, D[]? value);
method public boolean valueEquals(D[]? value, D[]? other);
property public String name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ public abstract class androidx/navigation/NavType {
public abstract fun put (Landroidx/core/bundle/Bundle;Ljava/lang/String;Ljava/lang/Object;)V
public fun serializeAsValue (Ljava/lang/Object;)Ljava/lang/String;
public fun toString ()Ljava/lang/String;
public fun valueEquals (Ljava/lang/Object;Ljava/lang/Object;)Z
}

public final class androidx/navigation/NavType$Companion {
Expand Down
11 changes: 4 additions & 7 deletions navigation/navigation-common/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ package androidx.navigation {
method public androidx.navigation.NavDestination getDestination();
method public String getId();
method public androidx.lifecycle.Lifecycle getLifecycle();
method @MainThread public androidx.lifecycle.SavedStateHandle getSavedStateHandle();
method public androidx.lifecycle.SavedStateHandle getSavedStateHandle();
method public androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
method public androidx.lifecycle.ViewModelStore getViewModelStore();
property public final android.os.Bundle? arguments;
Expand All @@ -125,7 +125,7 @@ package androidx.navigation {
property public final androidx.navigation.NavDestination destination;
property public final String id;
property public androidx.lifecycle.Lifecycle lifecycle;
property @MainThread public final androidx.lifecycle.SavedStateHandle savedStateHandle;
property public final androidx.lifecycle.SavedStateHandle savedStateHandle;
property public androidx.savedstate.SavedStateRegistry savedStateRegistry;
property public androidx.lifecycle.ViewModelStore viewModelStore;
field public static final androidx.navigation.NavBackStackEntry.Companion Companion;
Expand Down Expand Up @@ -406,7 +406,6 @@ package androidx.navigation {
method public T parseValue(String value, T previousValue);
method public abstract void put(android.os.Bundle bundle, String key, T value);
method public String serializeAsValue(T value);
method public boolean valueEquals(T value, T other);
property public boolean isNullableAllowed;
property public String name;
field public static final androidx.navigation.NavType<boolean[]?> BoolArrayType;
Expand All @@ -432,12 +431,11 @@ package androidx.navigation {
property public String name;
}

public static final class NavType.ParcelableArrayType<D extends android.os.Parcelable> extends androidx.navigation.NavType<D[]> {
public static final class NavType.ParcelableArrayType<D extends android.os.Parcelable> extends androidx.navigation.NavType<D[]?> {
ctor public NavType.ParcelableArrayType(Class<D> type);
method public D[]? get(android.os.Bundle bundle, String key);
method public D[] parseValue(String value);
method public void put(android.os.Bundle bundle, String key, D[]? value);
method public boolean valueEquals(D[]? value, D[]? other);
property public String name;
}

Expand All @@ -449,12 +447,11 @@ package androidx.navigation {
property public String name;
}

public static final class NavType.SerializableArrayType<D extends java.io.Serializable> extends androidx.navigation.NavType<D[]> {
public static final class NavType.SerializableArrayType<D extends java.io.Serializable> extends androidx.navigation.NavType<D[]?> {
ctor public NavType.SerializableArrayType(Class<D> type);
method public D[]? get(android.os.Bundle bundle, String key);
method public D[] parseValue(String value);
method public void put(android.os.Bundle bundle, String key, D[]? value);
method public boolean valueEquals(D[]? value, D[]? other);
property public String name;
}

Expand Down
2 changes: 0 additions & 2 deletions navigation/navigation-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.jetbrains.kotlin.konan.target.Family
plugins {
id("AndroidXPlugin")
id("com.android.library")
alias(libs.plugins.kotlinSerialization)
id("JetbrainsAndroidXPlugin")
}

Expand Down Expand Up @@ -81,7 +80,6 @@ kotlin {
api project(":savedstate:savedstate")

api(libs.kotlinStdlib)
implementation(libs.kotlinSerializationCore)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,4 @@ class NavArgumentTest {
assertThat(intArrArgument.verify("intArrayArg", bundle)).isTrue()
assertThat(intArrNonNullArgument.verify("intArrayArg", bundle)).isFalse()
}

@Test
fun setDefaultValuePresent() {
val argument = NavArgument.Builder()
.setType(NavType.IntType)
.setIsNullable(false)
.setUnknownDefaultValuePresent(true)
.build()

assertThat(argument.isDefaultValuePresent).isTrue()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class NavDeepLinkTest {

// Ensure case when matching the exact argument query (i.e. param names in braces) is handled
@Test
fun deepLinkQueryParamNullableStringArgumentMatchParamsInBraces() {
fun deepLinkQueryParamNullableArgumentMatchParamsInBraces() {
val deepLinkArgument = "$DEEP_LINK_EXACT_HTTPS/users?myarg={myarg}"
val deepLink = NavDeepLink(deepLinkArgument)

Expand All @@ -391,30 +391,6 @@ class NavDeepLinkTest {
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
// We allow {argName} values for String types
assertWithMessage("Args should contain the argument")
.that(matchArgs?.getString("myarg"))
.isEqualTo("{myarg}")
}

// Ensure case when matching the exact argument query (i.e. param names in braces) is handled
@Test
fun deepLinkQueryParamNullableNonStringArgumentMatchParamsInBraces() {
val deepLinkArgument = "$DEEP_LINK_EXACT_HTTPS/users?myarg={myarg}"
val deepLink = NavDeepLink(deepLinkArgument)
val intArrayArg = NavArgument.Builder().setType(NavType.IntArrayType)
.setIsNullable(true)
.setDefaultValue(null)
.build()

val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkArgument),
mapOf("myarg" to intArrayArg)
)
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
// For non-strings, {argName} values are invalid and considered lack of argument value
assertWithMessage("Args should not contain the argument")
.that(matchArgs?.containsKey("myarg"))
.isFalse()
Expand All @@ -436,7 +412,7 @@ class NavDeepLinkTest {
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args should contain the argument and it should not be null")
assertWithMessage("Args should contain the argument and it should be null")
.that(matchArgs?.getString("myarg"))
.isEqualTo("myarg")
}
Expand Down Expand Up @@ -472,14 +448,15 @@ class NavDeepLinkTest {
val deepLink = NavDeepLink(deepLinkArgument)

val id = 2
val optional = "test"
val matchArgs = deepLink.getMatchingArguments(
Uri.parse(
"$DEEP_LINK_EXACT_HTTPS/users?optional={optional}&id={id}"
.replace("{id}", id.toString())
),
mapOf(
"id" to intArgument(),
"optional" to stringArrayArgument(arrayOf("theArg"))
"optional" to stringArgument(optional)
)
)
assertWithMessage("Args should not be null")
Expand All @@ -488,9 +465,9 @@ class NavDeepLinkTest {
assertWithMessage("Args should contain the id")
.that(matchArgs?.getInt("id"))
.isEqualTo(id)
assertWithMessage("Args should not contain optional")
.that(matchArgs?.getStringArray("optional"))
.isEqualTo(arrayOf("{optional}"))
assertWithMessage("Args should contain optional")
.that(matchArgs?.containsKey("optional"))
.isFalse()
}

@Test
Expand Down Expand Up @@ -883,9 +860,9 @@ class NavDeepLinkTest {
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
assertWithMessage("Args should contain the argument")
.that(matchArgs?.getString("myarg"))
.isEqualTo("{myarg}")
assertWithMessage("Args should not contain the argument")
.that(matchArgs?.containsKey("myarg"))
.isFalse()
}

// Handle the case were the input is wild card and separator with no argument
Expand Down Expand Up @@ -1263,15 +1240,14 @@ class NavDeepLinkTest {

val matchArgs = deepLink.getMatchingArguments(
Uri.parse(deepLinkString),
mapOf("myarg" to stringArrayArgument(arrayOf("theArg")))
mapOf("myarg" to nullableStringArgument())
)
assertWithMessage("Args should not be null")
.that(matchArgs)
.isNotNull()
// We allow {argName} values for String types
assertWithMessage("Args bundle should contain arg value")
.that(matchArgs?.getStringArray("myarg"))
.isEqualTo(arrayOf("{myarg}"))
assertWithMessage("Args bundle should be empty")
.that(matchArgs?.isEmpty)
.isTrue()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,6 @@ class NavDestinationTest {
}
}
}

@Test
fun navDestinationDefaultValuePresent() {
val destination = provider.navDestination(DESTINATION_ID) {
argument("arg1") {
type = NavType.StringType
unknownDefaultValuePresent = true
}
argument("arg2") {
type = NavType.StringType
unknownDefaultValuePresent = false
}
}
val arg1 = destination.arguments["arg1"]
assertThat(arg1?.isDefaultValuePresent).isTrue()

val arg2 = destination.arguments["arg2"]
assertThat(arg2?.isDefaultValuePresent).isFalse()
}
}

private const val DESTINATION_ID = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import android.os.Parcel
import android.os.Parcelable
import androidx.navigation.common.test.R
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
Expand Down Expand Up @@ -257,45 +255,6 @@ class NavTypeTest {
.isEqualTo(en)
}

@Test
fun parcelableArrayValueEquals() {
val type = NavType.ParcelableArrayType(TestParcelable::class.java)
val array1 = arrayOf(TestParcelable(1), TestParcelable(2))
val array2 = arrayOf(TestParcelable(1), TestParcelable(2))
assertThat(type.valueEquals(array1, array2)).isTrue()

// deep comparison, order matters
val array3 = arrayOf(TestParcelable(2), TestParcelable(1))
val array4 = arrayOf(TestParcelable(1), TestParcelable(2))
assertThat(type.valueEquals(array3, array4)).isFalse()
}

@Test
fun serializableArrayValueEquals() {
val type = NavType.SerializableArrayType(TestSerializable::class.java)
val array1 = arrayOf(TestSerializable(1), TestSerializable(2))
val array2 = arrayOf(TestSerializable(1), TestSerializable(2))
assertThat(type.valueEquals(array1, array2)).isTrue()

// deep comparison, order matters
val array3 = arrayOf(TestSerializable(2), TestSerializable(1))
val array4 = arrayOf(TestSerializable(1), TestSerializable(2))
assertThat(type.valueEquals(array3, array4)).isFalse()
}

@Test
fun primitiveArrayValueEquals() {
val type = NavType.IntArrayType
val array1 = intArrayOf(1, 2)
val array2 = intArrayOf(1, 2)
assertThat(type.valueEquals(array1, array2)).isTrue()

// deep comparison, order matters
val array3 = intArrayOf(2, 1)
val array4 = intArrayOf(1, 2)
assertThat(type.valueEquals(array3, array4)).isFalse()
}

@Test
fun customType_defaultSerializeAsValue() {
val testItemType = object : NavType<TestItem> (false) {
Expand Down Expand Up @@ -379,10 +338,3 @@ private class TestItem {
return "TestItem"
}
}

private data class TestParcelable(val arg: Int) : Parcelable {
override fun describeContents(): Int = 0
override fun writeToParcel(dest: Parcel, flags: Int) {}
}

private data class TestSerializable(val arg: Int) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package androidx.navigation
import android.app.Application
import android.content.Context
import android.os.Bundle
import androidx.annotation.MainThread
import androidx.annotation.RestrictTo
import androidx.lifecycle.AbstractSavedStateViewModelFactory
import androidx.lifecycle.DEFAULT_ARGS_KEY
Expand Down Expand Up @@ -49,9 +48,7 @@ import java.util.UUID
* destination is popped off the back stack, the lifecycle will be destroyed, state
* will no longer be saved, and ViewModels will be cleared.
*/
public actual class NavBackStackEntry
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
private constructor(
public actual class NavBackStackEntry private constructor(
private val context: Context?,
/**
* The destination associated with this entry
Expand Down Expand Up @@ -128,7 +125,6 @@ private constructor(
/**
* The [SavedStateHandle] for this entry.
*/
@get:MainThread
public actual val savedStateHandle: SavedStateHandle by lazy {
check(savedStateRegistryAttached) {
"You cannot access the NavBackStackEntry's SavedStateHandle until it is added to " +
Expand Down
Loading
Loading