1
0
Fork 0

For #11044 - Sets the anchorView of the snackbar to be the new tab fab (#11930)

master
Jeff Boek 2020-06-26 17:56:56 -07:00 committed by GitHub
parent f89b157c23
commit a18c1befd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -10,11 +10,13 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.component_tabstray.view.*
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
import kotlinx.android.synthetic.main.fragment_tab_tray_dialog.*
import kotlinx.android.synthetic.main.fragment_tab_tray_dialog.view.*
import mozilla.components.browser.session.Session
@ -43,6 +45,10 @@ class TabTrayDialogFragment : AppCompatDialogFragment() {
private val tabTrayView: TabTrayView
get() = _tabTrayView!!
private val snackbarAnchor: View?
get() = if (tabTrayView.fabView.new_tab_button.isVisible) tabTrayView.fabView.new_tab_button
else null
private val collectionStorageObserver = object : TabCollectionStorage.Observer {
override fun onCollectionCreated(title: String, sessions: List<Session>) {
showCollectionSnackbar()
@ -188,7 +194,8 @@ class TabTrayDialogFragment : AppCompatDialogFragment() {
sessionManager.add(snapshot.session, isSelected, engineSessionState = state)
},
operation = { },
elevation = ELEVATION
elevation = ELEVATION,
anchorView = snackbarAnchor
)
}
}
@ -232,7 +239,8 @@ class TabTrayDialogFragment : AppCompatDialogFragment() {
context?.components?.core?.sessionManager?.restore(snapshot)
},
operation = { },
elevation = ELEVATION
elevation = ELEVATION,
anchorView = snackbarAnchor
)
}
}
@ -245,6 +253,7 @@ class TabTrayDialogFragment : AppCompatDialogFragment() {
isDisplayedWithBrowserToolbar = true,
view = (view as View)
)
.setAnchorView(snackbarAnchor)
.setText(requireContext().getString(R.string.create_collection_tabs_saved))
.setAction(requireContext().getString(R.string.create_collection_view)) {
dismissAllowingStateLoss()