diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt index 935a49bdd..327257cd2 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt @@ -13,7 +13,7 @@ import com.x8bit.bitwarden.ui.auth.feature.landing.navigateToLanding import com.x8bit.bitwarden.ui.auth.feature.login.loginDestinations import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin -const val AUTH_ROUTE: String = "auth" +private const val AUTH_ROUTE: String = "auth" /** * Add auth destinations to the nav graph. diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt index fcb87afa2..5c66dd506 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt @@ -4,18 +4,15 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.navigation.NavDestination import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions -import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_ROUTE import com.x8bit.bitwarden.ui.auth.feature.auth.authDestinations import com.x8bit.bitwarden.ui.auth.feature.auth.navigateToAuth import com.x8bit.bitwarden.ui.platform.feature.splash.SPLASH_ROUTE import com.x8bit.bitwarden.ui.platform.feature.splash.navigateToSplash import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestinations -import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_ROUTE import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlocked import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedDestinations @@ -49,45 +46,9 @@ fun RootNavScreen( restoreState = true } - // This workaround is for an issue where "launchSingleTop" flag does not work correctly - // and we "re-navigate" after rotation or process death. To prevent this, we are currently - // checking the root level route and no-opping the navigation, because we are already there. - // When upgrading to the latest compose nav version (which we currently aren't doing for - // other reasons), we can test that this workaround is no longer needed and remove it. - // To test, remove the (currentRoute == targetRoute) and test that state is saved - // on process death and rotation (BIT-201). - val targetRoute = when (state) { - RootNavState.Auth -> AUTH_ROUTE - RootNavState.Splash -> SPLASH_ROUTE - RootNavState.VaultUnlocked -> VAULT_UNLOCKED_ROUTE - } - val currentRoute = navController.currentDestination?.routeLevelRoute() - - // Don't navigate if we are already at the correct root: - if (currentRoute == targetRoute) { - return - } - when (state) { RootNavState.Auth -> navController.navigateToAuth(rootNavOptions) RootNavState.Splash -> navController.navigateToSplash(rootNavOptions) RootNavState.VaultUnlocked -> navController.navigateToVaultUnlocked(rootNavOptions) } } - -/** - * Helper method that returns the highest level route for the given [NavDestination]. - * - * As noted above, this can be removed after upgrading to latest compose navigation, since - * the nav args can prevent us from having to do this check. - */ -@Suppress("ReturnCount") -private fun NavDestination?.routeLevelRoute(): String? { - if (this == null) { - return null - } - if (parent?.route == null) { - return route - } - return parent.routeLevelRoute() -} diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt index cee74237e..aa8e1d151 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt @@ -7,7 +7,7 @@ import androidx.navigation.navigation import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.VAULT_UNLOCKED_NAV_BAR_ROUTE import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.vaultUnlockedNavBarDestination -const val VAULT_UNLOCKED_ROUTE: String = "VaultUnlocked" +private const val VAULT_UNLOCKED_ROUTE: String = "VaultUnlocked" /** * Navigate to the vault unlocked screen. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 448818f18..4e5569d33 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,11 +14,7 @@ androidxComposeBom = "2023.06.01" androidxCore = "1.10.1" androidxHiltNavigationCompose = "1.0.0" androidxLifecycle = "2.6.1" -# Currently holding navigation at this version because of this bug: -# https://issuetracker.google.com/issues/298059596 -# When updating, ensure that rememeberSaveable works correctly through process death in -# child navigation destinations (BIT-201). -androidxNavigation = "2.5.3" +androidxNavigation = "2.7.2" androidxRoom = "2.5.2" # Once the app and SDK reach a critical point of completeness we should begin fixing the version # here (BIT-311).