From 86dabe09c83dcbf832e7416c25c0340e13052086 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 12 May 2020 10:02:29 -0500 Subject: [PATCH] For 10503 - Update save to collection flow in tab tray (#10523) --- .../org/mozilla/fenix/tabtray/TabTrayFragment.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayFragment.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayFragment.kt index ad0b4708c..e63fb4681 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayFragment.kt @@ -177,8 +177,12 @@ class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer, val tabs = getListOfSessions() val tabIds = tabs.map { it.id }.toList().toTypedArray() val tabCollectionStorage = (activity as HomeActivity).components.core.tabCollectionStorage + val navController = findNavController() val step = when { + // Show the SelectTabs fragment if there are multiple opened tabs to select which tabs + // you want to save to a collection. + tabs.size > 1 -> SaveCollectionStep.SelectTabs // If there is an existing tab collection, show the SelectCollection fragment to save // the selected tab to a collection of your choice. tabCollectionStorage.cachedTabCollections.isNotEmpty() -> SaveCollectionStep.SelectCollection @@ -186,17 +190,15 @@ class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer, else -> SaveCollectionStep.NameCollection } + if (navController.currentDestination?.id == R.id.collectionCreationFragment) return + val directions = TabTrayFragmentDirections.actionTabTrayFragmentToCreateCollectionFragment( tabIds = tabIds, previousFragmentId = R.id.tabTrayFragment, saveCollectionStep = step, - selectedTabIds = tabIds, - selectedTabCollectionId = -1 + selectedTabIds = tabIds ) - - view?.let { - findNavController().navigate(directions) - } + navController.nav(R.id.tabTrayFragment, directions) } override fun onStart() {