tor-browser

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

commit 186140180542237de6944c64136d88e1e8c734c7
parent 5650eb6b5c7e9c99b4416df5dcdcba21a6231c3f
Author: Gabriel Luong <gabriel.luong@gmail.com>
Date:   Wed, 10 Dec 2025 15:33:05 +0000

Bug 2004511 - Part 2: Migrate the Password Generator Dialog to use M3 color tokens r=android-reviewers,007

Differential Revision: https://phabricator.services.mozilla.com/D275379

Diffstat:
Mmobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogBottomSheet.kt | 63+++++++++++++++++++--------------------------------------------
Mmobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogColors.kt | 11++++++-----
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt | 15---------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/theme/ThemeManager.kt | 9++++++++-
4 files changed, 33 insertions(+), 65 deletions(-)

diff --git a/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogBottomSheet.kt b/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogBottomSheet.kt @@ -12,28 +12,25 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text -import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import mozilla.components.compose.base.button.FilledButton +import mozilla.components.compose.base.button.TextButton +import mozilla.components.compose.base.theme.AcornTheme import mozilla.components.feature.prompts.R -import mozilla.components.feature.prompts.identitycredential.previews.DialogPreviewMaterialTheme import mozilla.components.ui.icons.R as iconsR private val FONT_SIZE = 16.sp @@ -81,14 +78,13 @@ fun PasswordGeneratorBottomSheet( @Composable private fun StrongPasswordBottomSheetTitle(colors: PasswordGeneratorDialogColors) { - Row { + Row(modifier = Modifier.fillMaxWidth()) { Image( painter = painterResource(id = iconsR.drawable.mozac_ic_login_24), contentDescription = null, contentScale = ContentScale.FillWidth, colorFilter = ColorFilter.tint(colors.title), - modifier = Modifier - .align(Alignment.CenterVertically), + modifier = Modifier.align(Alignment.CenterVertically), ) Text( @@ -159,51 +155,30 @@ private fun StrongPasswordBottomSheetButtons( horizontalArrangement = Arrangement.spacedBy(4.dp, Alignment.End), modifier = Modifier .fillMaxWidth() - .padding(horizontal = 12.dp, vertical = 16.dp) - .height(48.dp), + .padding(horizontal = 12.dp, vertical = 16.dp), ) { TextButton( + text = stringResource(id = R.string.mozac_feature_prompt_not_now), onClick = { onCancelDialog() }, - shape = RectangleShape, - colors = ButtonDefaults.buttonColors(containerColor = colors.background), - modifier = Modifier.height(48.dp), - ) { - Text( - text = stringResource(id = R.string.mozac_feature_prompt_not_now), - style = TextStyle( - fontSize = 16.sp, - lineHeight = 24.sp, - color = colors.cancelText, - letterSpacing = 0.15.sp, - fontWeight = FontWeight.Bold, - ), - ) - } + colors = ButtonDefaults.buttonColors( + containerColor = colors.background, + contentColor = colors.cancelText, + ), + ) - Button( - onClick = { onUsePassword() }, - shape = RectangleShape, - colors = ButtonDefaults.buttonColors(containerColor = colors.confirmButton), - modifier = Modifier.height(48.dp), + FilledButton( + text = stringResource(id = R.string.mozac_feature_prompts_suggest_strong_password_use_password), + containerColor = colors.confirmButton, ) { - Text( - text = stringResource(id = R.string.mozac_feature_prompts_suggest_strong_password_use_password), - style = TextStyle( - fontSize = 16.sp, - lineHeight = 24.sp, - color = Color.White, - letterSpacing = 0.15.sp, - fontWeight = FontWeight.Bold, - ), - ) + onUsePassword() } } } @Composable -@Preview +@PreviewLightDark private fun GenerateStrongPasswordDialogPreview() { - DialogPreviewMaterialTheme { + AcornTheme { PasswordGeneratorBottomSheet( generatedStrongPassword = "StrongPassword123#", onUsePassword = {}, diff --git a/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogColors.kt b/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/login/PasswordGeneratorDialogColors.kt @@ -4,6 +4,7 @@ package mozilla.components.feature.prompts.login +import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color @@ -39,11 +40,11 @@ data class PasswordGeneratorDialogColors( fun default( title: Color = MaterialTheme.colorScheme.onSurface, description: Color = MaterialTheme.colorScheme.onSurfaceVariant, - background: Color = MaterialTheme.colorScheme.primary, - cancelText: Color = MaterialTheme.colorScheme.primary, - confirmButton: Color = MaterialTheme.colorScheme.primary, - passwordBox: Color = MaterialTheme.colorScheme.primary, - boxBorder: Color = MaterialTheme.colorScheme.primary, + background: Color = MaterialTheme.colorScheme.surface, + cancelText: Color = ButtonDefaults.textButtonColors().contentColor, + confirmButton: Color = ButtonDefaults.buttonColors().containerColor, + passwordBox: Color = MaterialTheme.colorScheme.surfaceContainerLowest, + boxBorder: Color = MaterialTheme.colorScheme.outline, ) = PasswordGeneratorDialogColors( title = title, description = description, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -107,8 +107,6 @@ import mozilla.components.feature.prompts.identitycredential.DialogColors import mozilla.components.feature.prompts.identitycredential.DialogColorsProvider import mozilla.components.feature.prompts.login.LoginDelegate import mozilla.components.feature.prompts.login.LoginSelectBar -import mozilla.components.feature.prompts.login.PasswordGeneratorDialogColors -import mozilla.components.feature.prompts.login.PasswordGeneratorDialogColorsProvider import mozilla.components.feature.prompts.login.SuggestStrongPasswordBar import mozilla.components.feature.prompts.login.SuggestStrongPasswordDelegate import mozilla.components.feature.prompts.share.ShareDelegate @@ -954,18 +952,6 @@ abstract class BaseBrowserFragment : }, ) - val passwordGeneratorColorsProvider = PasswordGeneratorDialogColorsProvider { - PasswordGeneratorDialogColors( - title = ThemeManager.resolveAttributeColor(attribute = R.attr.textPrimary), - description = ThemeManager.resolveAttributeColor(attribute = R.attr.textSecondary), - background = ThemeManager.resolveAttributeColor(attribute = materialR.attr.colorSurface), - cancelText = ThemeManager.resolveAttributeColor(attribute = R.attr.textAccent), - confirmButton = ThemeManager.resolveAttributeColor(attribute = R.attr.actionPrimary), - passwordBox = ThemeManager.resolveAttributeColor(attribute = R.attr.layer2), - boxBorder = ThemeManager.resolveAttributeColor(attribute = R.attr.textDisabled), - ) - } - val bottomToolbarHeight = getBottomToolbarHeight( includeNavBarIfEnabled = customTabSessionId == null, ) @@ -1148,7 +1134,6 @@ abstract class BaseBrowserFragment : password = password, ) }, - passwordGeneratorColorsProvider = passwordGeneratorColorsProvider, hideUpdateFragmentAfterSavingGeneratedPassword = { username, password -> hideUpdateFragmentAfterSavingGeneratedPassword( username, diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/theme/ThemeManager.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/theme/ThemeManager.kt @@ -13,6 +13,7 @@ import android.view.Window import androidx.annotation.AnyRes import androidx.annotation.StyleRes import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.colorResource import mozilla.components.support.ktx.android.content.getColorFromAttr @@ -97,8 +98,14 @@ abstract class ThemeManager { return typedValue.resourceId } + /** + * Resolves the attribute to a color. + * + * @param attribute The attribute to resolve. + * @return The [Color] of the resolved attribute. + */ @Composable - fun resolveAttributeColor(attribute: Int): androidx.compose.ui.graphics.Color { + fun resolveAttributeColor(attribute: Int): Color { val resourceId = resolveAttribute(attribute, LocalContext.current) return colorResource(resourceId) }