1
0
Fork 0

For 11889 - Fix snackbar for collection creation in browser fragment

master
David Walsh 2020-07-08 13:10:00 -05:00 committed by Mihai Branescu
parent 51cc9aec1e
commit 85cebf8796
1 changed files with 20 additions and 4 deletions

View File

@ -221,21 +221,37 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
private val collectionStorageObserver = object : TabCollectionStorage.Observer {
override fun onCollectionCreated(title: String, sessions: List<Session>) {
showTabSavedToCollectionSnackbar()
showTabSavedToCollectionSnackbar(sessions.size, true)
}
override fun onTabsAdded(tabCollection: TabCollection, sessions: List<Session>) {
showTabSavedToCollectionSnackbar()
showTabSavedToCollectionSnackbar(sessions.size)
}
private fun showTabSavedToCollectionSnackbar() {
private fun showTabSavedToCollectionSnackbar(tabSize: Int, isNewCollection: Boolean = false) {
view?.let { view ->
val messageStringRes = when {
isNewCollection -> {
R.string.create_collection_tabs_saved_new_collection
}
tabSize > 1 -> {
R.string.create_collection_tabs_saved
}
else -> {
R.string.create_collection_tab_saved
}
}
FenixSnackbar.make(
view = view,
duration = Snackbar.LENGTH_SHORT,
isDisplayedWithBrowserToolbar = true
)
.setText(view.context.getString(R.string.create_collection_tab_saved))
.setText(view.context.getString(messageStringRes))
.setAction(requireContext().getString(R.string.create_collection_view)) {
findNavController().navigate(
BrowserFragmentDirections.actionGlobalHome(focusOnAddressBar = false)
)
}
.show()
}
}