1
0
Fork 0

For #2931: Show browser snackbar above quick action sheet

master
Sawyer Blatz 2019-05-30 11:43:11 -07:00
parent 5e0771a6f0
commit 9e0e5d95d9
3 changed files with 17 additions and 7 deletions

View File

@ -430,11 +430,15 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
is SearchAction.ToolbarLongClicked -> {
getSessionById()?.let { session ->
session.copyUrl(requireContext())
view?.rootView?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_LONG)
.setAnchorView(toolbarComponent.uiView.view)
view?.let {
val snackbar = FenixSnackbar.make(it, Snackbar.LENGTH_LONG)
.setText(resources.getString(R.string.url_copied))
.show()
if (!session.isCustomTabSession()) {
snackbar.anchorView = nestedScrollQuickAction
}
snackbar.show()
}
}
}
@ -520,7 +524,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
it.rootView,
Snackbar.LENGTH_LONG
)
.setAnchorView(toolbarComponent.uiView.view)
.setAnchorView(nestedScrollQuickAction)
.setAction(getString(R.string.edit_bookmark_snackbar_action)) {
Navigation.findNavController(
requireActivity(),
@ -696,6 +700,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
viewModel?.selectedTabs = selectedSet
viewModel?.saveCollectionStep = SaveCollectionStep.SelectCollection
viewModel?.tabCollections = requireComponents.core.tabCollectionStorage.cachedTabCollections.reversed()
viewModel?.snackbarAnchorView = nestedScrollQuickAction
view?.let {
val directions = BrowserFragmentDirections.actionBrowserFragmentToCreateCollectionFragment()
Navigation.findNavController(it).navigate(directions)

View File

@ -173,8 +173,11 @@ class CreateCollectionFragment : DialogFragment(), CoroutineScope {
val string =
if (tabSize > 1) context.getString(R.string.create_collection_tabs_saved) else
context.getString(R.string.create_collection_tab_saved)
FenixSnackbar.make(view, Snackbar.LENGTH_LONG).setText(string)
.show()
val snackbar = FenixSnackbar.make(view, Snackbar.LENGTH_LONG).setText(string)
viewModel.snackbarAnchorView?.let {
snackbar.setAnchorView(it)
}
snackbar.show()
}
}
}

View File

@ -4,6 +4,7 @@ package org.mozilla.fenix.collections
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import android.view.View
import androidx.lifecycle.ViewModel
import org.mozilla.fenix.home.sessioncontrol.Tab
import org.mozilla.fenix.home.sessioncontrol.TabCollection
@ -14,4 +15,5 @@ class CreateCollectionViewModel : ViewModel() {
var saveCollectionStep: SaveCollectionStep = SaveCollectionStep.SelectTabs
var tabCollections = listOf<TabCollection>()
var selectedTabCollection: TabCollection? = null
var snackbarAnchorView: View? = null
}