2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

Bug 1820169 - Ensure shortcuts snackbars are shown

They must have the right parent to ensure they are shown on top of other Views
and that they are also scrollable in pair with the bottom toolbar.
This commit is contained in:
Mugurell 2023-03-06 11:53:10 +02:00 committed by mergify[bot]
parent c04ba6bf41
commit e03f8fb6dc
3 changed files with 13 additions and 13 deletions

View File

@ -390,7 +390,7 @@ abstract class BaseBrowserFragment :
readerModeController = readerMenuController,
sessionFeature = sessionFeature,
findInPageLauncher = { findInPageIntegration.withFeature { it.launch() } },
swipeRefresh = binding.swipeRefresh,
snackbarParent = binding.dynamicSnackbarContainer,
browserAnimator = browserAnimator,
customTabSessionId = customTabSessionId,
openInFenixIntent = openInFenixIntent,

View File

@ -5,10 +5,10 @@
package org.mozilla.fenix.components.toolbar
import android.content.Intent
import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AlertDialog
import androidx.navigation.NavController
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -67,7 +67,7 @@ class DefaultBrowserToolbarMenuController(
private val sessionFeature: ViewBoundFeatureWrapper<SessionFeature>,
private val findInPageLauncher: () -> Unit,
private val browserAnimator: BrowserAnimator,
private val swipeRefresh: SwipeRefreshLayout,
private val snackbarParent: ViewGroup,
private val customTabSessionId: String?,
private val openInFenixIntent: Intent,
private val bookmarkTapped: (String, String) -> Unit,
@ -251,12 +251,12 @@ class DefaultBrowserToolbarMenuController(
}
is ToolbarMenu.Item.AddToTopSites -> {
scope.launch {
val context = swipeRefresh.context
val context = snackbarParent.context
val numPinnedSites = topSitesStorage.cachedTopSites
.filter { it is TopSite.Default || it is TopSite.Pinned }.size
if (numPinnedSites >= settings.topSitesMaxLimit) {
AlertDialog.Builder(swipeRefresh.context).apply {
AlertDialog.Builder(snackbarParent.context).apply {
setTitle(R.string.shortcut_max_limit_title)
setMessage(R.string.shortcut_max_limit_content)
setPositiveButton(R.string.top_sites_max_limit_confirmation_button) { dialog, _ ->
@ -274,7 +274,7 @@ class DefaultBrowserToolbarMenuController(
}.join()
FenixSnackbar.make(
view = swipeRefresh,
view = snackbarParent,
duration = Snackbar.LENGTH_SHORT,
isDisplayedWithBrowserToolbar = true,
)
@ -378,12 +378,12 @@ class DefaultBrowserToolbarMenuController(
}
FenixSnackbar.make(
view = swipeRefresh,
view = snackbarParent,
duration = Snackbar.LENGTH_SHORT,
isDisplayedWithBrowserToolbar = true,
)
.setText(
swipeRefresh.context.getString(R.string.snackbar_top_site_removed),
snackbarParent.context.getString(R.string.snackbar_top_site_removed),
)
.show()
}

View File

@ -5,8 +5,8 @@
package org.mozilla.fenix.components.toolbar
import android.content.Intent
import android.view.ViewGroup
import androidx.navigation.NavController
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import io.mockk.MockKAnnotations
import io.mockk.Runs
import io.mockk.coEvery
@ -87,7 +87,7 @@ class DefaultBrowserToolbarMenuControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
@MockK private lateinit var swipeRefreshLayout: SwipeRefreshLayout
@MockK private lateinit var snackbarParent: ViewGroup
@RelaxedMockK private lateinit var activity: HomeActivity
@ -522,7 +522,7 @@ class DefaultBrowserToolbarMenuControllerTest {
every { topSitesUseCase.addPinnedSites } returns addPinnedSiteUseCase
every {
swipeRefreshLayout.context.getString(R.string.snackbar_added_to_shortcuts)
snackbarParent.context.getString(R.string.snackbar_added_to_shortcuts)
} returns "Added to shortcuts!"
val controller = createController(scope = this, store = browserStore)
@ -550,7 +550,7 @@ class DefaultBrowserToolbarMenuControllerTest {
coEvery { pinnedSiteStorage.getPinnedSites() } returns listOf(topSite)
every { topSitesUseCase.removeTopSites } returns removePinnedSiteUseCase
every {
swipeRefreshLayout.context.getString(R.string.snackbar_top_site_removed)
snackbarParent.context.getString(R.string.snackbar_top_site_removed)
} returns snackbarMessage
val controller = createController(scope = this, store = browserStore)
@ -821,7 +821,7 @@ class DefaultBrowserToolbarMenuControllerTest {
customTabSessionId = customTabSessionId,
openInFenixIntent = openInFenixIntent,
scope = scope,
swipeRefresh = swipeRefreshLayout,
snackbarParent = snackbarParent,
tabCollectionStorage = tabCollectionStorage,
bookmarkTapped = bookmarkTapped,
readerModeController = readerModeController,