Bug 1876594 - Refactor `ThumbnailStorage` to be an implicit dependency

fenix/125.0
Noah Bond 3 months ago committed by mergify[bot]
parent a9b83fb300
commit 0c7c7a7333

@ -16,12 +16,10 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.concept.base.images.ImageLoadRequest
import org.mozilla.fenix.theme.FirefoxTheme
@ -32,7 +30,6 @@ private const val FALLBACK_ICON_SIZE = 36
* will be displayed until the thumbnail is loaded.
*
* @param tab The given [TabSessionState] to render a thumbnail for.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param size Size of the thumbnail.
* @param modifier [Modifier] used to draw the image content.
* @param backgroundColor [Color] used for the background of the favicon.
@ -44,7 +41,6 @@ private const val FALLBACK_ICON_SIZE = 36
@Composable
fun TabThumbnail(
tab: TabSessionState,
storage: ThumbnailStorage,
size: Int,
modifier: Modifier = Modifier,
backgroundColor: Color = FirefoxTheme.colors.layer2,
@ -62,8 +58,6 @@ fun TabThumbnail(
size = size,
isPrivate = tab.content.private,
),
storage = storage,
modifier = modifier,
contentScale = contentScale,
alignment = alignment,
) {
@ -100,7 +94,6 @@ private fun ThumbnailCardPreview() {
TabThumbnail(
tab = createTab(url = "www.mozilla.com", title = "Mozilla"),
size = 108,
storage = ThumbnailStorage(LocalContext.current),
modifier = Modifier
.size(108.dp, 80.dp)
.clip(RoundedCornerShape(8.dp)),

@ -16,13 +16,11 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import mozilla.components.browser.icons.compose.Loader
import mozilla.components.browser.icons.compose.Placeholder
import mozilla.components.browser.icons.compose.WithIcon
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.concept.base.images.ImageLoadRequest
import org.mozilla.fenix.components.components
import org.mozilla.fenix.theme.FirefoxTheme
@ -36,7 +34,6 @@ private const val FALLBACK_ICON_SIZE = 36
*
* @param url Url to display thumbnail for.
* @param request [ImageLoadRequest] used to fetch the thumbnail bitmap.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param modifier [Modifier] used to draw the image content.
* @param backgroundColor [Color] used for the background of the favicon.
* @param contentDescription Text used by accessibility services
@ -48,7 +45,6 @@ private const val FALLBACK_ICON_SIZE = 36
fun ThumbnailCard(
url: String,
request: ImageLoadRequest,
storage: ThumbnailStorage,
modifier: Modifier = Modifier,
backgroundColor: Color = FirefoxTheme.colors.layer2,
contentDescription: String? = null,
@ -61,8 +57,6 @@ fun ThumbnailCard(
) {
ThumbnailImage(
request = request,
storage = storage,
modifier = modifier,
contentScale = contentScale,
alignment = alignment,
) {
@ -98,7 +92,6 @@ private fun ThumbnailCardPreview() {
ThumbnailCard(
url = "https://mozilla.com",
request = ImageLoadRequest("123", THUMBNAIL_SIZE, false),
storage = ThumbnailStorage(LocalContext.current),
modifier = Modifier
.size(THUMBNAIL_SIZE.dp)
.clip(RoundedCornerShape(8.dp)),

@ -8,6 +8,7 @@ import android.graphics.Bitmap
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
@ -20,37 +21,36 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.concept.base.images.ImageLoadRequest
import org.mozilla.fenix.components.components
import org.mozilla.fenix.theme.FirefoxTheme
/**
* Thumbnail belonging to a [ImageLoadRequest]. Asynchronously fetches the bitmap from storage.
*
* @param request [ImageLoadRequest] used to fetch the thumbnail bitmap.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param modifier [Modifier] used to draw the image content.
* @param contentScale [ContentScale] used to draw image content.
* @param alignment [Alignment] used to draw the image content.
* @param modifier [Modifier] used to draw the image content.
* @param fallbackContent The content to display with a thumbnail is unable to be loaded.
*/
@Composable
fun ThumbnailImage(
request: ImageLoadRequest,
storage: ThumbnailStorage,
modifier: Modifier,
contentScale: ContentScale,
alignment: Alignment,
modifier: Modifier = Modifier,
fallbackContent: @Composable () -> Unit,
) {
if (inComposePreview) {
Box(modifier = Modifier.background(color = FirefoxTheme.colors.layer3))
Box(modifier = modifier.background(color = FirefoxTheme.colors.layer3))
} else {
var state by remember { mutableStateOf(ThumbnailImageState(null, false)) }
val scope = rememberCoroutineScope()
val storage = components.core.thumbnailStorage
DisposableEffect(Unit) {
if (!state.hasLoaded) {
@ -102,15 +102,14 @@ private data class ThumbnailImageState(
/**
* This preview does not demo anything. This is to ensure that [ThumbnailImage] does not break other previews.
*/
*/
@Preview
@Composable
private fun ThumbnailImagePreview() {
FirefoxTheme {
ThumbnailImage(
request = ImageLoadRequest("1", 1, false),
storage = ThumbnailStorage(LocalContext.current),
modifier = Modifier,
modifier = Modifier.size(50.dp),
contentScale = ContentScale.Crop,
alignment = Alignment.Center,
fallbackContent = {},

@ -42,7 +42,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
@ -58,7 +57,6 @@ import androidx.compose.ui.zIndex
import androidx.core.text.BidiFormatter
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.support.ktx.kotlin.MAX_URI_LENGTH
import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.R
@ -76,7 +74,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
* long clicks, multiple selection, and media controls.
*
* @param tab The given tab to be render as view a grid item.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param thumbnailSize Size of tab's thumbnail.
* @param isSelected Indicates if the item should be render as selected.
* @param multiSelectionEnabled Indicates if the item should be render with multi selection options,
@ -94,7 +91,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
@Suppress("MagicNumber", "LongMethod")
fun TabGridItem(
tab: TabSessionState,
storage: ThumbnailStorage,
thumbnailSize: Int,
isSelected: Boolean = false,
multiSelectionEnabled: Boolean = false,
@ -243,7 +239,6 @@ fun TabGridItem(
Thumbnail(
tab = tab,
size = thumbnailSize,
storage = storage,
multiSelectionSelected = multiSelectionSelected,
)
}
@ -273,14 +268,12 @@ private fun clickableColor() = when (isSystemInDarkTheme()) {
*
* @param tab Tab, containing the thumbnail to be displayed.
* @param size Size of the thumbnail.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param multiSelectionSelected Whether or not the multiple selection is enabled.
*/
@Composable
private fun Thumbnail(
tab: TabSessionState,
size: Int,
storage: ThumbnailStorage,
multiSelectionSelected: Boolean,
) {
Box(
@ -294,7 +287,6 @@ private fun Thumbnail(
TabThumbnail(
tab = tab,
size = size,
storage = storage,
modifier = Modifier.fillMaxSize(),
)
@ -335,7 +327,6 @@ private fun TabGridItemPreview() {
title = "Mozilla Domain",
),
thumbnailSize = 108,
storage = ThumbnailStorage(LocalContext.current),
onCloseClick = {},
onMediaClick = {},
onClick = {},
@ -350,7 +341,6 @@ private fun TabGridItemSelectedPreview() {
TabGridItem(
tab = createTab(url = "www.mozilla.com", title = "Mozilla"),
thumbnailSize = 108,
storage = ThumbnailStorage(LocalContext.current),
isSelected = true,
onCloseClick = {},
onMediaClick = {},
@ -367,7 +357,6 @@ private fun TabGridItemMultiSelectedPreview() {
TabGridItem(
tab = createTab(url = "www.mozilla.com", title = "Mozilla"),
thumbnailSize = 108,
storage = ThumbnailStorage(LocalContext.current),
multiSelectionEnabled = true,
multiSelectionSelected = true,
onCloseClick = {},

@ -32,7 +32,6 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
@ -43,7 +42,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.support.ktx.kotlin.MAX_URI_LENGTH
import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.R
@ -60,7 +58,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
* long clicks, multiselection, and media controls.
*
* @param tab The given tab to be render as view a grid item.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param thumbnailSize Size of tab's thumbnail.
* @param isSelected Indicates if the item should be render as selected.
* @param multiSelectionEnabled Indicates if the item should be render with multi selection options,
@ -78,7 +75,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
@Suppress("MagicNumber", "LongMethod")
fun TabListItem(
tab: TabSessionState,
storage: ThumbnailStorage,
thumbnailSize: Int,
isSelected: Boolean = false,
multiSelectionEnabled: Boolean = false,
@ -150,7 +146,6 @@ fun TabListItem(
Thumbnail(
tab = tab,
size = thumbnailSize,
storage = storage,
multiSelectionEnabled = multiSelectionEnabled,
isSelected = multiSelectionSelected,
onMediaIconClicked = { onMediaClick(it) },
@ -212,7 +207,6 @@ private fun clickableColor() = when (isSystemInDarkTheme()) {
private fun Thumbnail(
tab: TabSessionState,
size: Int,
storage: ThumbnailStorage,
multiSelectionEnabled: Boolean,
isSelected: Boolean,
onMediaIconClicked: ((TabSessionState) -> Unit),
@ -222,7 +216,6 @@ private fun Thumbnail(
TabThumbnail(
tab = tab,
size = size,
storage = storage,
modifier = Modifier
.size(width = 92.dp, height = 72.dp)
.semantics(mergeDescendants = true) {
@ -275,7 +268,6 @@ private fun TabListItemPreview() {
TabListItem(
tab = createTab(url = "www.mozilla.com", title = "Mozilla"),
thumbnailSize = 108,
storage = ThumbnailStorage(LocalContext.current),
onCloseClick = {},
onMediaClick = {},
onClick = {},
@ -290,7 +282,6 @@ private fun SelectedTabListItemPreview() {
TabListItem(
tab = createTab(url = "www.mozilla.com", title = "Mozilla"),
thumbnailSize = 108,
storage = ThumbnailStorage(LocalContext.current),
onCloseClick = {},
onMediaClick = {},
onClick = {},

@ -33,7 +33,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@ -41,7 +40,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.concept.base.images.ImageLoadRequest
import mozilla.components.concept.sync.DeviceType
import mozilla.components.support.ktx.kotlin.trimmed
@ -60,7 +58,6 @@ private const val THUMBNAIL_SIZE = 108
* A recent synced tab card.
*
* @param tab The [RecentSyncedTab] to display.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param backgroundColor The background [Color] of the item.
* @param buttonBackgroundColor The background [Color] of the item's button.
* @param buttonTextColor The [Color] of the button's text.
@ -73,7 +70,6 @@ private const val THUMBNAIL_SIZE = 108
@Composable
fun RecentSyncedTab(
tab: RecentSyncedTab?,
storage: ThumbnailStorage,
backgroundColor: Color = FirefoxTheme.colors.layer2,
buttonBackgroundColor: Color = FirefoxTheme.colors.actionSecondary,
buttonTextColor: Color = FirefoxTheme.colors.textActionSecondary,
@ -122,7 +118,6 @@ fun RecentSyncedTab(
size = LocalDensity.current.run { THUMBNAIL_SIZE.dp.toPx().toInt() },
isPrivate = false,
),
storage = storage,
modifier = imageModifier,
)
}
@ -259,7 +254,6 @@ private fun LoadedRecentSyncedTab() {
FirefoxTheme {
RecentSyncedTab(
tab = tab,
storage = ThumbnailStorage(LocalContext.current),
onRecentSyncedTabClick = {},
onSeeAllSyncedTabsButtonClick = {},
onRemoveSyncedTab = {},
@ -273,7 +267,6 @@ private fun LoadingRecentSyncedTab() {
FirefoxTheme {
RecentSyncedTab(
tab = null,
storage = ThumbnailStorage(LocalContext.current),
buttonBackgroundColor = FirefoxTheme.colors.layer3,
onRecentSyncedTabClick = {},
onSeeAllSyncedTabsButtonClick = {},

@ -72,7 +72,6 @@ class RecentSyncedTabViewHolder(
RecentSyncedTab(
tab = syncedTab,
storage = components.core.thumbnailStorage,
backgroundColor = wallpaperState.wallpaperCardColor,
buttonBackgroundColor = buttonBackgroundColor,
buttonTextColor = buttonTextColor,

@ -48,7 +48,6 @@ class RecentTabViewHolder(
RecentTabs(
recentTabs = recentTabs.value ?: emptyList(),
storage = components.core.thumbnailStorage,
backgroundColor = wallpaperState.wallpaperCardColor,
onRecentTabClick = { recentTabInteractor.onRecentTabClicked(it) },
menuItems = listOf(

@ -39,7 +39,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
@ -52,7 +51,6 @@ import mozilla.components.browser.icons.compose.Placeholder
import mozilla.components.browser.icons.compose.WithIcon
import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.support.ktx.kotlin.trimmed
import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.components.components
@ -72,7 +70,6 @@ private const val THUMBNAIL_SIZE = 108
*
* @param recentTabs List of [RecentTab] to display.
* @param menuItems List of [RecentTabMenuItem] shown long clicking a [RecentTab].
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param backgroundColor The background [Color] of each item.
* @param onRecentTabClick Invoked when the user clicks on a recent tab.
*/
@ -81,7 +78,6 @@ private const val THUMBNAIL_SIZE = 108
fun RecentTabs(
recentTabs: List<RecentTab>,
menuItems: List<RecentTabMenuItem>,
storage: ThumbnailStorage,
backgroundColor: Color = FirefoxTheme.colors.layer2,
onRecentTabClick: (String) -> Unit = {},
) {
@ -99,7 +95,6 @@ fun RecentTabs(
is RecentTab.Tab -> {
RecentTabItem(
tab = tab,
storage = storage,
menuItems = menuItems,
backgroundColor = backgroundColor,
onRecentTabClick = onRecentTabClick,
@ -114,7 +109,6 @@ fun RecentTabs(
* A recent tab item.
*
* @param tab [RecentTab.Tab] that was recently viewed.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param menuItems List of [RecentTabMenuItem] to be shown in a menu.
* @param backgroundColor The background [Color] of the item.
* @param onRecentTabClick Invoked when the user clicks on a recent tab.
@ -127,7 +121,6 @@ fun RecentTabs(
@Suppress("LongMethod")
private fun RecentTabItem(
tab: RecentTab.Tab,
storage: ThumbnailStorage,
menuItems: List<RecentTabMenuItem>,
backgroundColor: Color,
onRecentTabClick: (String) -> Unit = {},
@ -152,7 +145,6 @@ private fun RecentTabItem(
) {
RecentTabImage(
tab = tab,
storage = storage,
modifier = Modifier
.size(108.dp, 80.dp)
.clip(RoundedCornerShape(8.dp)),
@ -220,14 +212,12 @@ private fun RecentTabItem(
* A recent tab image.
*
* @param tab [RecentTab] that was recently viewed.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param modifier [Modifier] used to draw the image content.
* @param contentScale [ContentScale] used to draw image content.
*/
@Composable
fun RecentTabImage(
tab: RecentTab.Tab,
storage: ThumbnailStorage,
modifier: Modifier = Modifier,
contentScale: ContentScale = ContentScale.FillWidth,
) {
@ -244,7 +234,6 @@ fun RecentTabImage(
TabThumbnail(
tab = tab.state,
size = LocalDensity.current.run { THUMBNAIL_SIZE.dp.toPx().toInt() },
storage = storage,
modifier = modifier,
contentScale = contentScale,
)
@ -254,7 +243,6 @@ fun RecentTabImage(
else -> TabThumbnail(
tab = tab.state,
size = LocalDensity.current.run { THUMBNAIL_SIZE.dp.toPx().toInt() },
storage = storage,
modifier = modifier,
contentScale = contentScale,
)
@ -345,7 +333,6 @@ private fun RecentTabsPreview() {
recentTabs = listOf(
tab,
),
storage = ThumbnailStorage(LocalContext.current),
menuItems = listOf(
RecentTabMenuItem(
title = "Menu item",

@ -27,7 +27,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
@ -37,7 +36,6 @@ import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.browser.storage.sync.TabEntry
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.R
import org.mozilla.fenix.components.AppStore
@ -57,7 +55,6 @@ import mozilla.components.browser.storage.sync.Tab as SyncTab
* @param appStore [AppStore] used to listen for changes to [AppState].
* @param browserStore [BrowserStore] used to listen for changes to [BrowserState].
* @param tabsTrayStore [TabsTrayStore] used to listen for changes to [TabsTrayState].
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param displayTabsInGrid Whether the normal and private tabs should be displayed in a grid.
* @param isInDebugMode True for debug variant or if secret menu is enabled for this session.
* @param shouldShowTabAutoCloseBanner Whether the tab auto closer banner should be displayed.
@ -103,7 +100,6 @@ fun TabsTray(
appStore: AppStore,
browserStore: BrowserStore,
tabsTrayStore: TabsTrayStore,
storage: ThumbnailStorage,
displayTabsInGrid: Boolean,
isInDebugMode: Boolean,
shouldShowTabAutoCloseBanner: Boolean,
@ -200,7 +196,6 @@ fun TabsTray(
appStore = appStore,
browserStore = browserStore,
tabsTrayStore = tabsTrayStore,
storage = storage,
displayTabsInGrid = displayTabsInGrid,
onTabClose = onTabClose,
onTabMediaClick = onTabMediaClick,
@ -222,7 +217,6 @@ fun TabsTray(
PrivateTabsPage(
browserStore = browserStore,
tabsTrayStore = tabsTrayStore,
storage = storage,
displayTabsInGrid = displayTabsInGrid,
onTabClose = onTabClose,
onTabMediaClick = onTabMediaClick,
@ -250,7 +244,6 @@ private fun NormalTabsPage(
appStore: AppStore,
browserStore: BrowserStore,
tabsTrayStore: TabsTrayStore,
storage: ThumbnailStorage,
displayTabsInGrid: Boolean,
onTabClose: (TabSessionState) -> Unit,
onTabMediaClick: (TabSessionState) -> Unit,
@ -312,7 +305,6 @@ private fun NormalTabsPage(
TabLayout(
tabs = normalTabs,
storage = storage,
displayTabsInGrid = displayTabsInGrid,
selectedTabId = selectedTabId,
selectionMode = selectionMode,
@ -335,7 +327,6 @@ private fun NormalTabsPage(
private fun PrivateTabsPage(
browserStore: BrowserStore,
tabsTrayStore: TabsTrayStore,
storage: ThumbnailStorage,
displayTabsInGrid: Boolean,
onTabClose: (TabSessionState) -> Unit,
onTabMediaClick: (TabSessionState) -> Unit,
@ -353,7 +344,6 @@ private fun PrivateTabsPage(
if (privateTabs.isNotEmpty()) {
TabLayout(
tabs = privateTabs,
storage = storage,
displayTabsInGrid = displayTabsInGrid,
selectedTabId = selectedTabId,
selectionMode = selectionMode,
@ -531,7 +521,6 @@ private fun TabsTrayPreviewRoot(
appStore = appStore,
browserStore = browserStore,
tabsTrayStore = tabsTrayStore,
storage = ThumbnailStorage(LocalContext.current),
displayTabsInGrid = displayTabsInGrid,
isInDebugMode = false,
shouldShowInactiveTabsAutoCloseDialog = { true },

@ -243,7 +243,6 @@ class TabsTrayFragment : AppCompatDialogFragment() {
appStore = requireComponents.appStore,
browserStore = requireComponents.core.store,
tabsTrayStore = tabsTrayStore,
storage = requireComponents.core.thumbnailStorage,
displayTabsInGrid = requireContext().settings().gridTabView,
isInDebugMode = Config.channel.isDebug ||
requireComponents.settings.showSecretDebugMenuThisSession,

@ -33,7 +33,6 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.compose.tabstray.TabGridItem
@ -58,7 +57,6 @@ const val HEADER_ITEM_KEY = "header"
* Top-level UI for displaying a list of tabs.
*
* @param tabs The list of [TabSessionState] to display.
* @param storage [ThumbnailStorage] to obtain tab thumbnail bitmaps from.
* @param displayTabsInGrid Whether the tabs should be displayed in a grid.
* @param selectedTabId The ID of the currently selected tab.
* @param selectionMode [TabsTrayState.Mode] indicating whether the Tabs Tray is in single selection
@ -76,7 +74,6 @@ const val HEADER_ITEM_KEY = "header"
@Composable
fun TabLayout(
tabs: List<TabSessionState>,
storage: ThumbnailStorage,
displayTabsInGrid: Boolean,
selectedTabId: String?,
selectionMode: TabsTrayState.Mode,
@ -102,7 +99,6 @@ fun TabLayout(
if (displayTabsInGrid) {
TabGrid(
tabs = tabs,
storage = storage,
selectedTabId = selectedTabId,
selectedTabIndex = selectedTabIndex,
selectionMode = selectionMode,
@ -118,7 +114,6 @@ fun TabLayout(
} else {
TabList(
tabs = tabs,
storage = storage,
selectedTabId = selectedTabId,
selectedTabIndex = selectedTabIndex,
selectionMode = selectionMode,
@ -139,7 +134,6 @@ fun TabLayout(
@Composable
private fun TabGrid(
tabs: List<TabSessionState>,
storage: ThumbnailStorage,
selectedTabId: String?,
selectedTabIndex: Int,
selectionMode: TabsTrayState.Mode,
@ -213,7 +207,6 @@ private fun TabGrid(
TabGridItem(
tab = tab,
thumbnailSize = tabThumbnailSize,
storage = storage,
isSelected = tab.id == selectedTabId,
multiSelectionEnabled = isInMultiSelectMode,
multiSelectionSelected = selectionMode.selectedTabs.contains(tab),
@ -236,7 +229,6 @@ private fun TabGrid(
@Composable
private fun TabList(
tabs: List<TabSessionState>,
storage: ThumbnailStorage,
selectedTabId: String?,
selectedTabIndex: Int,
selectionMode: TabsTrayState.Mode,
@ -308,7 +300,6 @@ private fun TabList(
TabListItem(
tab = tab,
thumbnailSize = tabThumbnailSize,
storage = storage,
isSelected = tab.id == selectedTabId,
multiSelectionEnabled = isInMultiSelectMode,
multiSelectionSelected = selectionMode.selectedTabs.contains(tab),
@ -339,7 +330,6 @@ private fun TabListPreview() {
) {
TabLayout(
tabs = tabs,
storage = ThumbnailStorage(LocalContext.current),
selectedTabId = tabs[1].id,
selectionMode = TabsTrayState.Mode.Normal,
displayTabsInGrid = false,
@ -367,7 +357,6 @@ private fun TabGridPreview() {
) {
TabLayout(
tabs = tabs,
storage = ThumbnailStorage(LocalContext.current),
selectedTabId = tabs[0].id,
selectionMode = TabsTrayState.Mode.Normal,
displayTabsInGrid = false,
@ -397,7 +386,6 @@ private fun TabGridSmallPreview() {
) {
TabLayout(
tabs = tabs,
storage = ThumbnailStorage(LocalContext.current),
selectedTabId = tabs[0].id,
selectionMode = TabsTrayState.Mode.Normal,
displayTabsInGrid = true,
@ -427,7 +415,6 @@ private fun TabGridMultiSelectPreview() {
) {
TabLayout(
tabs = tabs,
storage = ThumbnailStorage(LocalContext.current),
selectedTabId = tabs[0].id,
selectionMode = TabsTrayState.Mode.Select(selectedTabs.toSet()),
displayTabsInGrid = false,

@ -15,7 +15,6 @@ import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.tabstray.TabsTray
import mozilla.components.browser.tabstray.TabsTrayStyling
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.tabstray.TabGridItem
import org.mozilla.fenix.tabstray.TabsTrayInteractor
import org.mozilla.fenix.tabstray.TabsTrayState
@ -80,7 +79,6 @@ class ComposeGridViewHolder(
TabGridItem(
tab = tab,
thumbnailSize = 108,
storage = components.core.thumbnailStorage,
isSelected = isSelectedTab,
multiSelectionEnabled = multiSelectionEnabled,
multiSelectionSelected = isMultiSelectionSelected,

@ -15,7 +15,6 @@ import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.tabstray.TabsTray
import mozilla.components.browser.tabstray.TabsTrayStyling
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.tabstray.TabListItem
import org.mozilla.fenix.tabstray.TabsTrayInteractor
import org.mozilla.fenix.tabstray.TabsTrayState
@ -84,7 +83,6 @@ class ComposeListViewHolder(
TabListItem(
tab = tab,
thumbnailSize = 108,
storage = components.core.thumbnailStorage,
isSelected = isSelectedTabState,
multiSelectionEnabled = multiSelectionEnabled,
multiSelectionSelected = multiSelectionSelected,

Loading…
Cancel
Save