2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-05 21:20:45 +00:00

For #561 - Fixes snackbar placement on homeview

This commit is contained in:
Jeff Boek 2019-09-24 16:24:19 -07:00 committed by Sawyer Blatz
parent 32c506121e
commit c592a69aad
2 changed files with 22 additions and 8 deletions

View File

@ -239,6 +239,10 @@ class HomeFragment : Fragment() {
}
}
view.wordmark.setOnClickListener {
showSavedSnackbar(2)
}
view.menuButton.setOnClickListener {
homeMenu?.menuBuilder?.build(requireContext())?.show(
anchor = it,
@ -327,9 +331,10 @@ class HomeFragment : Fragment() {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (authType != AuthType.Existing) {
view?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT).setText(
it.context.getString(R.string.onboarding_firefox_account_sync_is_on)
).show()
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
.setAnchorView(bottom_bar)
.show()
}
}
}
@ -723,7 +728,8 @@ class HomeFragment : Fragment() {
deleteAllSessionsJob = null
emitSessionChanges()
},
operation = deleteOperation
operation = deleteOperation,
anchorView = bottom_bar
)
}
@ -746,7 +752,8 @@ class HomeFragment : Fragment() {
pendingSessionDeletion = null
emitSessionChanges()
},
operation = deleteOperation
operation = deleteOperation,
anchorView = bottom_bar
)
// Update the UI with the tab removed, but don't remove it from storage yet
@ -905,7 +912,9 @@ class HomeFragment : Fragment() {
R.string.create_collection_tab_saved
}
FenixSnackbar.make(view, Snackbar.LENGTH_LONG)
.setText(view.context.getString(stringRes)).show()
.setText(view.context.getString(stringRes))
.setAnchorView(bottom_bar)
.show()
}
}
}
@ -913,7 +922,10 @@ class HomeFragment : Fragment() {
private fun showRenamedSnackbar() {
view?.let { view ->
val string = view.context.getString(R.string.snackbar_collection_renamed)
FenixSnackbar.make(view, Snackbar.LENGTH_LONG).setText(string).show()
FenixSnackbar.make(view, Snackbar.LENGTH_LONG)
.setText(string)
.setAnchorView(bottom_bar)
.show()
}
}

View File

@ -31,7 +31,8 @@ fun CoroutineScope.allowUndo(
message: String,
undoActionTitle: String,
onCancel: suspend () -> Unit = {},
operation: suspend () -> Unit
operation: suspend () -> Unit,
anchorView: View? = null
) {
// By using an AtomicBoolean, we achieve memory effects of reading and
// writing a volatile variable.
@ -41,6 +42,7 @@ fun CoroutineScope.allowUndo(
val snackbar = FenixSnackbar
.make(view, FenixSnackbar.LENGTH_INDEFINITE)
.setText(message)
.setAnchorView(anchorView)
.setAction(undoActionTitle) {
requestedUndo.set(true)
launch {