Bug 1887126 - Add Extra to Toggle State for Page Settings and Improve Show Original r=android-reviewers,ayeddi,ohall

Differential Revision: https://phabricator.services.mozilla.com/D207341
This commit is contained in:
iorgamgabriel 2024-05-02 08:46:05 +00:00
parent 838aaeeba5
commit e95677bb53
2 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
@ -282,6 +283,8 @@ class TranslationsDialogFragment : BottomSheetDialogFragment() {
onSettingClicked: () -> Unit,
onShowDownloadLanguageFileDialog: () -> Unit,
) {
val localView = LocalView.current
TranslationsDialog(
translationsDialogState = translationsDialogState,
learnMoreUrl = learnMoreUrl,
@ -297,6 +300,11 @@ class TranslationsDialogFragment : BottomSheetDialogFragment() {
},
onNegativeButtonClicked = {
if (translationsDialogState.isTranslated) {
localView.announceForAccessibility(
requireContext().getString(
R.string.translations_bottom_sheet_restore_accessibility_announcement,
),
)
translationsDialogStore.dispatch(TranslationsDialogAction.RestoreTranslation)
}
dismiss()
@ -393,6 +401,8 @@ class TranslationsDialogFragment : BottomSheetDialogFragment() {
state.translationEngine.offerTranslation
}.value
val localView = LocalView.current
TranslationsOptionsDialog(
context = requireContext(),
translationPageSettings = pageSettingsState,
@ -409,6 +419,10 @@ class TranslationsDialogFragment : BottomSheetDialogFragment() {
checked,
),
)
if (checked) {
localView.announceForAccessibility(type.descriptionId?.let { getString(it) })
}
},
onBackClicked = onBackClicked,
onTranslationSettingsClicked = {

View File

@ -2427,6 +2427,8 @@
<string name="translations_bottom_sheet_negative_button">Not now</string>
<!-- Button text on the translations dialog to restore the translated website back to the original untranslated version. -->
<string name="translations_bottom_sheet_negative_button_restore">Show original</string>
<!-- Accessibility announcement (not visible, for screen readers etc.) for the translations dialog after restore button was pressed that indicates the original untranslated page was loaded. -->
<string name="translations_bottom_sheet_restore_accessibility_announcement">Original untranslated page loaded</string>
<!-- Button text on the translations dialog when a translation error appears, used to dismiss the dialog and return to the browser. -->
<string name="translations_bottom_sheet_negative_button_error">Done</string>
<!-- Button text on the translations dialog to begin a translation of the website. -->