1
0
Fork 0

For #8128 - Do not use activity root view for fragment snackbars

master
Emily Kager 2020-02-06 16:03:15 +01:00 committed by Jeff Boek
parent 2ead67a531
commit eec8ea980b
1 changed files with 26 additions and 20 deletions

View File

@ -146,15 +146,15 @@ class DefaultBrowserToolbarController(
currentSession?.let { currentSession?.let {
topSiteStorage.addTopSite(it.title, it.url) topSiteStorage.addTopSite(it.title, it.url)
} }
MainScope().launch {
activity.getRootView()?.let { val appName = swipeRefresh.context.getString(R.string.app_name)
FenixSnackbar.makeWithToolbarPadding(swipeRefresh, Snackbar.LENGTH_SHORT)
val appName = it.context.getString(R.string.app_name) .setText(
FenixSnackbar.makeWithToolbarPadding(it, Snackbar.LENGTH_SHORT) swipeRefresh.context.getString(
.setText(it.context.getString( R.string.snackbar_added_to_firefox_home,
R.string.snackbar_added_to_firefox_home, appName
appName )
)) )
.show() .show()
} }
} }
@ -174,7 +174,12 @@ class DefaultBrowserToolbarController(
} }
ToolbarMenu.Item.Share -> { ToolbarMenu.Item.Share -> {
val directions = NavGraphDirections.actionGlobalShareFragment( val directions = NavGraphDirections.actionGlobalShareFragment(
data = arrayOf(ShareData(url = currentSession?.url, title = currentSession?.title)), data = arrayOf(
ShareData(
url = currentSession?.url,
title = currentSession?.title
)
),
showPage = true showPage = true
) )
navController.navigate(directions) navController.navigate(directions)
@ -219,16 +224,17 @@ class DefaultBrowserToolbarController(
.track(Event.CollectionSaveButtonPressed(TELEMETRY_BROWSER_IDENTIFIER)) .track(Event.CollectionSaveButtonPressed(TELEMETRY_BROWSER_IDENTIFIER))
currentSession?.let { currentSession -> currentSession?.let { currentSession ->
val directions = BrowserFragmentDirections.actionBrowserFragmentToCreateCollectionFragment( val directions =
previousFragmentId = R.id.browserFragment, BrowserFragmentDirections.actionBrowserFragmentToCreateCollectionFragment(
tabIds = arrayOf(currentSession.id), previousFragmentId = R.id.browserFragment,
selectedTabIds = arrayOf(currentSession.id), tabIds = arrayOf(currentSession.id),
saveCollectionStep = if (tabCollectionStorage.cachedTabCollections.isEmpty()) { selectedTabIds = arrayOf(currentSession.id),
SaveCollectionStep.NameCollection saveCollectionStep = if (tabCollectionStorage.cachedTabCollections.isEmpty()) {
} else { SaveCollectionStep.NameCollection
SaveCollectionStep.SelectCollection } else {
} SaveCollectionStep.SelectCollection
) }
)
navController.nav(R.id.browserFragment, directions) navController.nav(R.id.browserFragment, directions)
} }
} }