tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4048b918337adc9106b9fc10198a0b28a2e08223
parent df1bd9de36101f9e9fb4da49c9a5bd1d8d9f2c54
Author: Atila Butkovits <abutkovits@mozilla.com>
Date:   Thu, 20 Nov 2025 09:31:29 +0200

Revert "Bug 1993856 - Part 13: Migrate WallpaperState to M3 Acorn color tokens r=android-reviewers,007" for causing lint failures.

This reverts commit df1bd9de36101f9e9fb4da49c9a5bd1d8d9f2c54.

Revert "Bug 1993856 - Part 12: Migrate SetupChecklist and ChecklistView to M3 Acorn color tokens r=android-reviewers,007"

This reverts commit 3c16aeaf4c367ad1bbdb5543eab23f68c0d5938e.

Revert "Bug 1993856 - Part 11: Migrate RecentlyVisited to M3 Acorn color tokens r=android-reviewers,007"

This reverts commit 5f24a39fe002077697b75fda8c8e7ee5b730b2fc.

Revert "Bug 1993856 - Part 10: Migrate MessageCard to use the M3 Acorn color tokens r=android-reviewers,007"

This reverts commit 5d95dc98b791ee238632a3307418e00c651c10c0.

Revert "Bug 1993856 - Part 9: Migrate Collections Placeholder to use the M3 Acorn color tokens r=android-reviewers,007"

This reverts commit 85fca1e921b9a197b1ee6d9dd9591b51744df9ca.

Diffstat:
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/MessageCard.kt | 53+++++++++++++++++++++++++++++++++--------------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/PlaceholderCard.kt | 56++++++++++++++++++++++++++++----------------------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/collections/CollectionsState.kt | 28+++++++++++++++-------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/recentvisits/view/RecentlyVisited.kt | 20+++++++++++++-------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/ChecklistView.kt | 22+++++++++++++++-------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/SetupChecklist.kt | 20++++++++++++++++----
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/ui/CollectionsPlaceholder.kt | 2+-
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperState.kt | 30+++++++++++++++++++++---------
8 files changed, 142 insertions(+), 89 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/MessageCard.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/MessageCard.kt @@ -4,8 +4,10 @@ package org.mozilla.fenix.compose -import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -14,15 +16,13 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource @@ -102,8 +102,7 @@ fun MessageCard( Modifier }, ), - shape = RoundedCornerShape(16.dp), - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant), + shape = RoundedCornerShape(8.dp), colors = CardDefaults.cardColors(containerColor = messageColors.backgroundColor), ) { Column( @@ -218,13 +217,14 @@ data class MessageCardColors( * Builder function used to construct an instance of [MessageCardColors]. */ @Composable + @ReadOnlyComposable fun buildMessageCardColors( - backgroundColor: Color = MaterialTheme.colorScheme.surfaceContainerLowest, - titleTextColor: Color = MaterialTheme.colorScheme.onSurface, - messageTextColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, - iconColor: Color = MaterialTheme.colorScheme.onSurface, - buttonColor: Color = ButtonDefaults.buttonColors().containerColor, - buttonTextColor: Color = ButtonDefaults.buttonColors().contentColor, + backgroundColor: Color = FirefoxTheme.colors.layer2, + titleTextColor: Color = FirefoxTheme.colors.textPrimary, + messageTextColor: Color = FirefoxTheme.colors.textSecondary, + iconColor: Color = FirefoxTheme.colors.iconPrimary, + buttonColor: Color = FirefoxTheme.colors.actionPrimary, + buttonTextColor: Color = FirefoxTheme.colors.textActionPrimary, ): MessageCardColors { return MessageCardColors( backgroundColor = backgroundColor, @@ -242,10 +242,13 @@ data class MessageCardColors( @PreviewLightDark private fun MessageCardPreview() { FirefoxTheme { - Surface { + Box( + Modifier + .background(FirefoxTheme.colors.layer1) + .padding(all = 16.dp), + ) { MessageCard( messageCardState = FakeHomepagePreview.messageCardState(), - modifier = Modifier.padding(all = 16.dp), onClick = {}, onCloseButtonClick = {}, ) @@ -257,10 +260,13 @@ private fun MessageCardPreview() { @PreviewLightDark private fun MessageCardWithoutTitlePreview() { FirefoxTheme { - Surface { + Box( + modifier = Modifier + .background(FirefoxTheme.colors.layer1) + .padding(all = 16.dp), + ) { MessageCard( messageText = stringResource(id = R.string.default_browser_experiment_card_text), - modifier = Modifier.padding(all = 16.dp), onClick = {}, onCloseButtonClick = {}, ) @@ -272,10 +278,13 @@ private fun MessageCardWithoutTitlePreview() { @PreviewLightDark private fun MessageCardWithButtonLabelPreview() { FirefoxTheme { - Surface { + Box( + modifier = Modifier + .background(FirefoxTheme.colors.layer1) + .padding(all = 16.dp), + ) { MessageCard( messageText = stringResource(id = R.string.default_browser_experiment_card_text), - modifier = Modifier.padding(all = 16.dp), titleText = stringResource(id = R.string.default_browser_experiment_card_title), buttonText = stringResource(id = R.string.preferences_set_as_default_browser), onClick = {}, @@ -314,6 +323,7 @@ data class MessageCardState( * @param wallpaperState [WallpaperState] specifying the colors to be used. */ @Composable + @ReadOnlyComposable fun build(message: Message, wallpaperState: WallpaperState): MessageCardState { val isWallpaperNotDefault = !Wallpaper.nameIsDefault(wallpaperState.currentWallpaper.name) @@ -321,8 +331,11 @@ data class MessageCardState( var (_, _, _, _, buttonColor, buttonTextColor) = MessageCardColors.buildMessageCardColors() if (isWallpaperNotDefault) { - buttonColor = MaterialTheme.colorScheme.surface - buttonTextColor = MaterialTheme.colorScheme.onSurface + buttonColor = FirefoxTheme.colors.layer1 + + if (!isSystemInDarkTheme()) { + buttonTextColor = FirefoxTheme.colors.textActionSecondary + } } val messageCardColors = MessageCardColors.buildMessageCardColors( diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/PlaceholderCard.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/PlaceholderCard.kt @@ -17,7 +17,7 @@ import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.IconButton import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -29,7 +29,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import mozilla.components.compose.base.button.FilledButton -import mozilla.components.compose.base.button.IconButton import mozilla.components.compose.base.modifier.dashedBorder import org.mozilla.fenix.R import org.mozilla.fenix.theme.FirefoxTheme @@ -48,27 +47,27 @@ fun PlaceholderCard( description: @Composable () -> Unit, modifier: Modifier = Modifier, ) { - Card( - modifier = Modifier - .dashedBorder( - color = MaterialTheme.colorScheme.outlineVariant, - cornerRadius = 8.dp, - dashHeight = 2.dp, - dashWidth = 4.dp, - ) - .then(modifier), - colors = CardDefaults.cardColors(containerColor = Color.Transparent), - ) { - Column( - Modifier - .padding(16.dp) - .fillMaxWidth(), + FirefoxTheme { + Card( + modifier = Modifier + .dashedBorder( + color = FirefoxTheme.colors.borderPrimary, + cornerRadius = 8.dp, + dashHeight = 2.dp, + dashWidth = 4.dp, + ) + .then(modifier), + colors = CardDefaults.cardColors(containerColor = Color.Transparent), ) { - title() - - Spacer(modifier = Modifier.height(4.dp)) - - description() + Column( + Modifier + .padding(16.dp) + .fillMaxWidth(), + ) { + title() + Spacer(modifier = Modifier.height(4.dp)) + description() + } } } } @@ -90,19 +89,20 @@ private fun PlaceholderCardPreview() { ) { Text( text = stringResource(R.string.collections_header), + color = FirefoxTheme.colors.textPrimary, style = FirefoxTheme.typography.headline7, ) IconButton( onClick = {}, - contentDescription = stringResource( - R.string.remove_home_collection_placeholder_content_description, - ), modifier = Modifier.size(20.dp), ) { Icon( painter = painterResource(iconsR.drawable.mozac_ic_cross_20), - contentDescription = null, + contentDescription = stringResource( + R.string.remove_home_collection_placeholder_content_description, + ), + tint = FirefoxTheme.colors.textPrimary, ) } } @@ -110,7 +110,7 @@ private fun PlaceholderCardPreview() { description = { Text( text = stringResource(R.string.no_collections_description2), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = FirefoxTheme.colors.textSecondary, style = FirefoxTheme.typography.body2, ) @@ -121,7 +121,7 @@ private fun PlaceholderCardPreview() { modifier = Modifier .fillMaxWidth() .wrapContentHeight(), - icon = painterResource(iconsR.drawable.mozac_ic_collection_24), + icon = painterResource(R.drawable.ic_tab_collection), onClick = {}, ) }, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/collections/CollectionsState.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/collections/CollectionsState.kt @@ -4,8 +4,7 @@ package org.mozilla.fenix.home.collections -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.MaterialTheme +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import mozilla.components.browser.state.selector.normalTabs @@ -14,6 +13,7 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.feature.tab.collections.TabCollection import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager import org.mozilla.fenix.components.appstate.AppState +import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.wallpapers.WallpaperState /** @@ -109,10 +109,10 @@ data class CollectionColors( */ @Composable fun colors( - buttonBackgroundColor: Color = ButtonDefaults.buttonColors().containerColor, - buttonTextColor: Color = ButtonDefaults.buttonColors().contentColor, - titleTextColor: Color = MaterialTheme.colorScheme.onSurface, - descriptionTextColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + buttonBackgroundColor: Color = FirefoxTheme.colors.actionPrimary, + buttonTextColor: Color = FirefoxTheme.colors.textActionPrimary, + titleTextColor: Color = FirefoxTheme.colors.textPrimary, + descriptionTextColor: Color = FirefoxTheme.colors.textSecondary, ) = CollectionColors( buttonBackgroundColor = buttonBackgroundColor, buttonTextColor = buttonTextColor, @@ -129,22 +129,24 @@ data class CollectionColors( val textColor = wallpaperState.currentWallpaper.textColor val titleTextColor: Color val descriptionTextColor: Color - if (textColor == null) { - titleTextColor = MaterialTheme.colorScheme.onSurface - descriptionTextColor = MaterialTheme.colorScheme.onSurfaceVariant + titleTextColor = FirefoxTheme.colors.textPrimary + descriptionTextColor = FirefoxTheme.colors.textSecondary } else { val color = Color(textColor) titleTextColor = color descriptionTextColor = color } - var buttonColor = ButtonDefaults.buttonColors().containerColor - var buttonTextColor = ButtonDefaults.buttonColors().contentColor + var buttonColor = FirefoxTheme.colors.actionPrimary + var buttonTextColor = FirefoxTheme.colors.textActionPrimary wallpaperState.ComposeRunIfWallpaperCardColorsAreAvailable { _, _ -> - buttonColor = MaterialTheme.colorScheme.surface - buttonTextColor = MaterialTheme.colorScheme.onSurface + buttonColor = FirefoxTheme.colors.layer1 + + if (!isSystemInDarkTheme()) { + buttonTextColor = FirefoxTheme.colors.textActionSecondary + } } return CollectionColors( diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/recentvisits/view/RecentlyVisited.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/recentvisits/view/RecentlyVisited.kt @@ -4,6 +4,7 @@ package org.mozilla.fenix.home.recentvisits.view +import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement @@ -18,8 +19,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue @@ -49,7 +48,6 @@ import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight import org.mozilla.fenix.theme.FirefoxTheme -import mozilla.components.ui.icons.R as iconsR // Number of recently visited items per column. private const val VISITS_PER_COLUMN = 3 @@ -74,7 +72,7 @@ private val contentPadding = 16.dp fun RecentlyVisited( recentVisits: List<RecentlyVisitedItem>, menuItems: List<RecentVisitMenuItem>, - backgroundColor: Color = MaterialTheme.colorScheme.surfaceContainerLowest, + backgroundColor: Color = FirefoxTheme.colors.layer2, onRecentVisitClick: (RecentlyVisitedItem, pageNumber: Int) -> Unit = { _, _ -> }, ) { val isSingleColumn by remember(recentVisits) { derivedStateOf { recentVisits.size <= VISITS_PER_COLUMN } } @@ -177,7 +175,7 @@ private fun RecentlyVisitedHistoryGroup( onClick = { onRecentVisitClick(recentVisit) }, onLongClick = { isMenuExpanded = true }, ), - beforeIconPainter = painterResource(iconsR.drawable.mozac_ic_tab_tray_24), + beforeIconPainter = painterResource(R.drawable.ic_multiple_tabs), description = stringResource(id = captionId, recentVisit.historyMetadata.size), ) @@ -239,7 +237,11 @@ private fun RecentlyVisitedHistoryHighlight( @PreviewLightDark private fun RecentlyVisitedMultipleColumnsPreview() { FirefoxTheme { - Surface { + Box( + modifier = Modifier + .background(color = FirefoxTheme.colors.layer1) + .padding(vertical = contentPadding), + ) { RecentlyVisited( recentVisits = listOf( RecentHistoryGroup(title = "running shoes"), @@ -258,7 +260,11 @@ private fun RecentlyVisitedMultipleColumnsPreview() { @PreviewLightDark private fun RecentlyVisitedSingleColumnPreview() { FirefoxTheme { - Surface { + Box( + modifier = Modifier + .background(color = FirefoxTheme.colors.layer1) + .padding(vertical = contentPadding), + ) { RecentlyVisited( recentVisits = listOf( RecentHistoryGroup(title = "running shoes"), diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/ChecklistView.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/ChecklistView.kt @@ -4,7 +4,9 @@ package org.mozilla.fenix.home.setup.ui +import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -14,8 +16,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -95,12 +95,14 @@ private fun Task( .weight(1f) .semantics { heading() }, style = FirefoxTheme.typography.subtitle1, + color = FirefoxTheme.colors.textPrimary, ) Icon( painter = painterResource(task.icon), contentDescription = stringResource(R.string.a11y_task_icon_description), modifier = Modifier.padding(16.dp), + tint = FirefoxTheme.colors.iconPrimary, ) } } @@ -145,22 +147,24 @@ private fun Group( Text( text = stringResource(group.title, stringResource(R.string.firefox)), style = FirefoxTheme.typography.subtitle1, + color = FirefoxTheme.colors.textPrimary, modifier = Modifier.semantics { heading() }, ) Text( text = "${group.progress.completedTasks}/${group.progress.totalTasks}", style = FirefoxTheme.typography.body2, - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = FirefoxTheme.colors.textSecondary, ) } Icon( - painter = painterResource(id = iconsR.drawable.mozac_ic_chevron_down_24), + painter = painterResource(id = R.drawable.ic_arrowhead_down), contentDescription = "", modifier = Modifier .padding(16.dp) .rotate(if (group.isExpanded) ROTATE_180 else 0f), + tint = FirefoxTheme.colors.iconPrimary, ) } } @@ -169,18 +173,22 @@ private fun Group( @Composable private fun TasksChecklistPreview() { FirefoxTheme { - Surface { + Box( + modifier = Modifier + .background(color = FirefoxTheme.colors.layer1) + .padding(top = 16.dp), + ) { val tasks = listOf( ChecklistItem.Task( type = ChecklistItem.Task.Type.EXPLORE_EXTENSION, title = R.string.setup_checklist_task_explore_extensions, - icon = iconsR.drawable.mozac_ic_extension_24, + icon = R.drawable.ic_addons_extensions, isCompleted = true, ), ChecklistItem.Task( type = ChecklistItem.Task.Type.INSTALL_SEARCH_WIDGET, title = R.string.setup_checklist_task_search_widget_2, - icon = iconsR.drawable.mozac_ic_search_24, + icon = R.drawable.ic_search, isCompleted = false, ), ) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/SetupChecklist.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/setup/ui/SetupChecklist.kt @@ -4,18 +4,21 @@ package org.mozilla.fenix.home.setup.ui +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -54,7 +57,7 @@ fun SetupChecklist(setupChecklistState: SetupChecklistState, interactor: SetupCh Card( modifier = Modifier.padding(16.dp), shape = shapeChecklist, - colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLowest), + colors = CardDefaults.cardColors(containerColor = FirefoxTheme.colors.layer1), elevation = CardDefaults.cardElevation(defaultElevation = elevation), ) { Column( @@ -96,6 +99,7 @@ private fun Header(state: SetupChecklistState) { allTasksCompleted = progress.allTasksCompleted(), ), style = FirefoxTheme.typography.headline7, + color = FirefoxTheme.colors.textPrimary, modifier = Modifier.semantics { heading() }, ) @@ -108,6 +112,7 @@ private fun Header(state: SetupChecklistState) { Text( text = it, style = FirefoxTheme.typography.body2, + color = FirefoxTheme.colors.textPrimary, ) } @@ -224,7 +229,14 @@ private fun SetupChecklistPreview( @PreviewParameter(SetupChecklistPreviewParameterProvider::class) initialState: SetupChecklistState, ) { FirefoxTheme { - Surface { + Spacer(Modifier.height(16.dp)) + + Box( + modifier = Modifier + .background(color = FirefoxTheme.colors.layer1) + .fillMaxHeight() + .padding(16.dp), + ) { SetupChecklist( setupChecklistState = initialState, interactor = object : SetupChecklistInteractor { diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/ui/CollectionsPlaceholder.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/ui/CollectionsPlaceholder.kt @@ -117,7 +117,7 @@ internal fun CollectionsPlaceholder( @Composable private fun CollectionsPlaceholderPreview() { FirefoxTheme { - Surface { + Surface(color = FirefoxTheme.colors.layer1) { Column(modifier = Modifier.padding(16.dp)) { CollectionsPlaceholder( interactor = FakeHomepagePreview.collectionInteractor, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperState.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperState.kt @@ -5,11 +5,10 @@ package org.mozilla.fenix.wallpapers import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.graphics.Color +import org.mozilla.fenix.theme.FirefoxTheme /** * Represents all state related to the Wallpapers feature. @@ -44,7 +43,7 @@ data class WallpaperState( Color(currentWallpaper.cardColorLight) } } - else -> MaterialTheme.colorScheme.surfaceContainerLowest + else -> FirefoxTheme.colors.layer2 } /** @@ -52,10 +51,11 @@ data class WallpaperState( */ val buttonBackgroundColor: Color @Composable + @ReadOnlyComposable get() = if (isCurrentWallpaperDefault()) { - ButtonDefaults.buttonColors().containerColor + FirefoxTheme.colors.actionSecondary } else { - MaterialTheme.colorScheme.surface + FirefoxTheme.colors.layer1 } /** @@ -63,10 +63,11 @@ data class WallpaperState( */ val buttonTextColor: Color @Composable - get() = if (isCurrentWallpaperDefault()) { - ButtonDefaults.buttonColors().contentColor - } else { - MaterialTheme.colorScheme.onSurface + @ReadOnlyComposable + get() = when { + currentWallpaper.cardColorDark != null && + isSystemInDarkTheme() -> FirefoxTheme.colors.textPrimary + else -> FirefoxTheme.colors.textActionSecondary } private fun isCurrentWallpaperDefault(): Boolean = Wallpaper.nameIsDefault(currentWallpaper.name) @@ -82,4 +83,15 @@ data class WallpaperState( run(Color(currentWallpaper.cardColorLight), Color(currentWallpaper.cardColorDark)) } } + + /** + * Run the [run] block only if the current wallpaper's card colors are available. + */ + fun runIfWallpaperCardColorsAreAvailable( + run: (cardColorLight: Int, cardColorDark: Int) -> Unit, + ) { + if (currentWallpaper.cardColorLight != null && currentWallpaper.cardColorDark != null) { + run(currentWallpaper.cardColorLight.toInt(), currentWallpaper.cardColorDark.toInt()) + } + } }