Bug 1882572 - Instrumenting Translations Nimbus Feature Release

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

@ -375,6 +375,50 @@ features:
type: Int
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:
objects: {}

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

@ -198,7 +198,8 @@ open class DefaultToolbarMenu(
*/
@VisibleForTesting(otherwise = PRIVATE)
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
// End of predicates //

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

@ -22,6 +22,7 @@ import org.mozilla.fenix.compose.Divider
import org.mozilla.fenix.compose.SwitchWithLabel
import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.compose.list.TextListItem
import org.mozilla.fenix.nimbus.FxNimbus
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 onDownloadLanguageClicked Invoked when the user clicks on the "Download Language" button.
*/
@Suppress("LongMethod")
@Composable
fun TranslationSettings(
translationSwitchList: List<TranslationSwitchItem>,
@ -79,38 +81,44 @@ fun TranslationSettings(
)
}
item {
TextListItem(
label = stringResource(id = R.string.translation_settings_automatic_translation),
modifier = Modifier
.fillMaxWidth()
.padding(start = 56.dp),
onClick = { onAutomaticTranslationClicked() },
)
if (FxNimbus.features.translations.value().globalLangSettingsEnabled) {
item {
TextListItem(
label = stringResource(id = R.string.translation_settings_automatic_translation),
modifier = Modifier
.fillMaxWidth()
.padding(start = 56.dp),
onClick = { onAutomaticTranslationClicked() },
)
}
}
item {
TextListItem(
label = stringResource(
id = R.string.translation_settings_automatic_never_translate_sites,
),
modifier = Modifier
.fillMaxWidth()
.padding(start = 56.dp),
onClick = { onNeverTranslationClicked() },
)
if (FxNimbus.features.translations.value().globalSiteSettingsEnabled) {
item {
TextListItem(
label = stringResource(
id = R.string.translation_settings_automatic_never_translate_sites,
),
modifier = Modifier
.fillMaxWidth()
.padding(start = 56.dp),
onClick = { onNeverTranslationClicked() },
)
}
}
item {
TextListItem(
label = stringResource(
id = R.string.translation_settings_download_language,
),
modifier = Modifier
.fillMaxWidth()
.padding(start = 56.dp),
onClick = { onDownloadLanguageClicked() },
)
if (FxNimbus.features.translations.value().downloadsEnabled) {
item {
TextListItem(
label = stringResource(
id = R.string.translation_settings_download_language,
),
modifier = Modifier
.fillMaxWidth()
.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.TranslationPageSettings
import org.mozilla.fenix.R
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.theme.FirefoxTheme
private const val BOTTOM_SHEET_HANDLE_WIDTH_PERCENT = 0.1f
@ -143,6 +144,7 @@ internal fun TranslationsDialog(
onFromSelected: (Language) -> Unit,
onToSelected: (Language) -> Unit,
) {
FxNimbus.features.translations.recordExposure()
TranslationsDialogBottomSheet(
translationsDialogState = translationsDialogState,
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.TertiaryButton
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.ReviewQualityCheckInfoType
import org.mozilla.fenix.theme.FirefoxTheme
@ -455,15 +456,17 @@ private fun TranslationsDialogHeader(
Spacer(modifier = Modifier.width(4.dp))
IconButton(
onClick = { onSettingClicked() },
modifier = Modifier.size(24.dp),
) {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_settings_24),
contentDescription = stringResource(id = R.string.translation_option_bottom_sheet_title),
tint = FirefoxTheme.colors.iconPrimary,
)
if (FxNimbus.features.translations.value().pageSettingsEnabled) {
IconButton(
onClick = { onSettingClicked() },
modifier = Modifier.size(24.dp),
) {
Icon(
painter = painterResource(id = R.drawable.mozac_ic_settings_24),
contentDescription = stringResource(id = R.string.translation_option_bottom_sheet_title),
tint = FirefoxTheme.colors.iconPrimary,
)
}
}
}
}

Loading…
Cancel
Save