Bug 1882572 - Instrumenting Translations Nimbus Feature Release

This patch adds instrumentation for releasing separate sections of the
translations feature.
fenix/125.0
ohall-m 4 months ago committed by mergify[bot]
parent 146b63c137
commit ea3ef40d0d

@ -375,6 +375,50 @@ features:
type: Int type: Int
default: 1 default: 1
translations:
description: The feature that allows on-device translations of web content.
variables:
main-flow-toolbar-enabled:
description: >
Show the primary toolbar entry point into the translations feature. (Translations icon on URL toolbar.)
type: Boolean
default: true
main-flow-browser-menu-enabled:
description: >
Show the browser menu entry point into the translations feature. ('Translate Page' on browser menu.)
type: Boolean
default: true
page-settings-enabled:
description: >
Show the page settings entry point within the translations feature. (Gear icon on the translations main flow page.)
'main-flow-toolbar-enabled' or 'main-flow-browser-menu-enabled' must also be enabled for users to access this feature.
type: Boolean
default: true
global-settings-enabled:
description: >
Show the global settings entry point within the translations feature. ('Translation Settings' on the page settings view.)
'page-settings-enabled' must also be enabled for users to access this feature.
type: Boolean
default: true
global-lang-settings-enabled:
description: >
Show the global language options entry point for automatically translating. ('Automatic Translation' on the global settings view.)
'global-settings-enabled' must also be enabled for users to access this feature.
type: Boolean
default: true
global-site-settings-enabled:
description: >
Show the global never translate this site options entry point for site management. ('Never translate these sites' on the global settings view.)
'global-settings-enabled' must also be enabled for users to access this feature.
type: Boolean
default: true
downloads-enabled:
description: >
Show the global language model download options entry point for translations. ('Download languages' on the global settings view.)
'global-settings-enabled' must also be enabled for users to access this feature.
type: Boolean
default: true
types: types:
objects: {} objects: {}

@ -309,12 +309,10 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
private fun initTranslationsAction(context: Context, view: View) { private fun initTranslationsAction(context: Context, view: View) {
val isEngineSupported = val isEngineSupported =
context.components.core.store.state.translationEngine.isEngineSupported context.components.core.store.state.translationEngine.isEngineSupported
if (
!context.settings().enableTranslations && if (isEngineSupported != true ||
( !context.settings().enableTranslations ||
isEngineSupported == null || !FxNimbus.features.translations.value().mainFlowToolbarEnabled
isEngineSupported == false
)
) { ) {
return return
} }

@ -198,7 +198,8 @@ open class DefaultToolbarMenu(
*/ */
@VisibleForTesting(otherwise = PRIVATE) @VisibleForTesting(otherwise = PRIVATE)
fun shouldShowTranslations(): Boolean = selectedSession?.let { fun shouldShowTranslations(): Boolean = selectedSession?.let {
context.settings().enableTranslations && store.state.translationEngine.isEngineSupported == true context.settings().enableTranslations && store.state.translationEngine.isEngineSupported == true &&
FxNimbus.features.translations.value().mainFlowBrowserMenuEnabled
} ?: false } ?: false
// End of predicates // // End of predicates //

@ -29,6 +29,7 @@ import org.mozilla.fenix.compose.Divider
import org.mozilla.fenix.compose.SwitchWithLabel import org.mozilla.fenix.compose.SwitchWithLabel
import org.mozilla.fenix.compose.annotation.LightDarkPreview import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.compose.list.TextListItem import org.mozilla.fenix.compose.list.TextListItem
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
import java.util.Locale import java.util.Locale
@ -65,14 +66,16 @@ fun TranslationOptionsDialog(
) )
} }
item { if (FxNimbus.features.translations.value().globalSettingsEnabled) {
TextListItem( item {
label = stringResource(id = R.string.translation_option_bottom_sheet_translation_settings), TextListItem(
modifier = Modifier label = stringResource(id = R.string.translation_option_bottom_sheet_translation_settings),
.fillMaxWidth() modifier = Modifier
.padding(start = 56.dp), .fillMaxWidth()
onClick = { onTranslationSettingsClicked() }, .padding(start = 56.dp),
) onClick = { onTranslationSettingsClicked() },
)
}
} }
item { item {

@ -22,6 +22,7 @@ import org.mozilla.fenix.compose.Divider
import org.mozilla.fenix.compose.SwitchWithLabel import org.mozilla.fenix.compose.SwitchWithLabel
import org.mozilla.fenix.compose.annotation.LightDarkPreview import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.compose.list.TextListItem import org.mozilla.fenix.compose.list.TextListItem
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
/** /**
@ -32,6 +33,7 @@ import org.mozilla.fenix.theme.FirefoxTheme
* @param onNeverTranslationClicked Invoked when the user clicks on the "Never Translation" button. * @param onNeverTranslationClicked Invoked when the user clicks on the "Never Translation" button.
* @param onDownloadLanguageClicked Invoked when the user clicks on the "Download Language" button. * @param onDownloadLanguageClicked Invoked when the user clicks on the "Download Language" button.
*/ */
@Suppress("LongMethod")
@Composable @Composable
fun TranslationSettings( fun TranslationSettings(
translationSwitchList: List<TranslationSwitchItem>, translationSwitchList: List<TranslationSwitchItem>,
@ -79,38 +81,44 @@ fun TranslationSettings(
) )
} }
item { if (FxNimbus.features.translations.value().globalLangSettingsEnabled) {
TextListItem( item {
label = stringResource(id = R.string.translation_settings_automatic_translation), TextListItem(
modifier = Modifier label = stringResource(id = R.string.translation_settings_automatic_translation),
.fillMaxWidth() modifier = Modifier
.padding(start = 56.dp), .fillMaxWidth()
onClick = { onAutomaticTranslationClicked() }, .padding(start = 56.dp),
) onClick = { onAutomaticTranslationClicked() },
)
}
} }
item { if (FxNimbus.features.translations.value().globalSiteSettingsEnabled) {
TextListItem( item {
label = stringResource( TextListItem(
id = R.string.translation_settings_automatic_never_translate_sites, label = stringResource(
), id = R.string.translation_settings_automatic_never_translate_sites,
modifier = Modifier ),
.fillMaxWidth() modifier = Modifier
.padding(start = 56.dp), .fillMaxWidth()
onClick = { onNeverTranslationClicked() }, .padding(start = 56.dp),
) onClick = { onNeverTranslationClicked() },
)
}
} }
item { if (FxNimbus.features.translations.value().downloadsEnabled) {
TextListItem( item {
label = stringResource( TextListItem(
id = R.string.translation_settings_download_language, label = stringResource(
), id = R.string.translation_settings_download_language,
modifier = Modifier ),
.fillMaxWidth() modifier = Modifier
.padding(start = 56.dp), .fillMaxWidth()
onClick = { onDownloadLanguageClicked() }, .padding(start = 56.dp),
) onClick = { onDownloadLanguageClicked() },
)
}
} }
} }
} }

@ -31,6 +31,7 @@ import androidx.compose.ui.unit.dp
import mozilla.components.concept.engine.translate.Language import mozilla.components.concept.engine.translate.Language
import mozilla.components.concept.engine.translate.TranslationPageSettings import mozilla.components.concept.engine.translate.TranslationPageSettings
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
private const val BOTTOM_SHEET_HANDLE_WIDTH_PERCENT = 0.1f private const val BOTTOM_SHEET_HANDLE_WIDTH_PERCENT = 0.1f
@ -143,6 +144,7 @@ internal fun TranslationsDialog(
onFromSelected: (Language) -> Unit, onFromSelected: (Language) -> Unit,
onToSelected: (Language) -> Unit, onToSelected: (Language) -> Unit,
) { ) {
FxNimbus.features.translations.recordExposure()
TranslationsDialogBottomSheet( TranslationsDialogBottomSheet(
translationsDialogState = translationsDialogState, translationsDialogState = translationsDialogState,
learnMoreUrl = learnMoreUrl, learnMoreUrl = learnMoreUrl,

@ -57,6 +57,7 @@ import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.compose.button.PrimaryButton import org.mozilla.fenix.compose.button.PrimaryButton
import org.mozilla.fenix.compose.button.TertiaryButton import org.mozilla.fenix.compose.button.TertiaryButton
import org.mozilla.fenix.compose.button.TextButton import org.mozilla.fenix.compose.button.TextButton
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.shopping.ui.ReviewQualityCheckInfoCard import org.mozilla.fenix.shopping.ui.ReviewQualityCheckInfoCard
import org.mozilla.fenix.shopping.ui.ReviewQualityCheckInfoType import org.mozilla.fenix.shopping.ui.ReviewQualityCheckInfoType
import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.theme.FirefoxTheme
@ -455,15 +456,17 @@ private fun TranslationsDialogHeader(
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
IconButton( if (FxNimbus.features.translations.value().pageSettingsEnabled) {
onClick = { onSettingClicked() }, IconButton(
modifier = Modifier.size(24.dp), onClick = { onSettingClicked() },
) { modifier = Modifier.size(24.dp),
Icon( ) {
painter = painterResource(id = R.drawable.mozac_ic_settings_24), Icon(
contentDescription = stringResource(id = R.string.translation_option_bottom_sheet_title), painter = painterResource(id = R.drawable.mozac_ic_settings_24),
tint = FirefoxTheme.colors.iconPrimary, contentDescription = stringResource(id = R.string.translation_option_bottom_sheet_title),
) tint = FirefoxTheme.colors.iconPrimary,
)
}
} }
} }
} }

Loading…
Cancel
Save