Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75518118 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[A11y][Keyboard shortcuts] Update Magnification dialog strings" into main

parents 39a48b89 1d50eb66
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class AccessibilityShortcutsRepositoryImplTest : SysuiTestCase() {
                )

            assertThat(titleToContent).isNotNull()
            assertThat(titleToContent?.first).isEqualTo("Turn on Magnification?")
            assertThat(titleToContent?.first).isEqualTo("Magnification keyboard shortcut turned on")
            val contentText = titleToContent?.second
            assertThat(hasExpectedAnnotation(contentText)).isTrue()
            // `contentText` here is an instance of SpannableStringBuilder, so we only need to
@@ -116,7 +116,8 @@ class AccessibilityShortcutsRepositoryImplTest : SysuiTestCase() {
            assertThat(contentText?.toString())
                .isEqualTo(
                    "Action icon + Alt + M is the keyboard shortcut to use Magnification." +
                        " This allows you to quickly zoom in on the screen to make content larger."
                        " This allows you to quickly zoom in on the screen to make content larger." +
                        " Press Action icon + Alt and \"+\" or \"-\" to adjust zoom."
                )
        }
    }
+10 −3
Original line number Diff line number Diff line
@@ -2893,9 +2893,7 @@
    <!-- Text for the dialog title. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_dialog_title">Turn on <xliff:g name="feature_name" example="Magnification">%1$s</xliff:g>?</string>
    <!-- Text for showing inside the dialog. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_dialog_content">Action <annotation id="action_key_icon">icon</annotation> + <xliff:g name="secondary_key" example="Alt">^1</xliff:g> + <xliff:g name="key_code" example="M">^2</xliff:g> is the keyboard shortcut to use <xliff:g name="feature_name" example="Magnification">^3</xliff:g>. <xliff:g name="feature_intro" example="Magnification intro">^4</xliff:g></string>
    <!-- The text for the Magnification introduction. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_dialog_magnifier_intro">This allows you to quickly zoom in on the screen to make content larger.</string>
    <string name="accessibility_key_gesture_dialog_content">Action <annotation id="action_key_icon">icon</annotation> + <xliff:g name="secondary_key" example="Alt">^1</xliff:g> + <xliff:g name="key_code" example="M">^2</xliff:g> is the keyboard shortcut to use <xliff:g name="feature_name" example="Voice Access">^3</xliff:g>. <xliff:g name="feature_intro" example="Voice Access intro">^4</xliff:g></string>
    <!-- The text for the TalkBack introduction. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_dialog_talkback_intro"><xliff:g name="feature_name" example="TalkBack">%1$s</xliff:g> is a screen reader that allows you to hear items spoken aloud. It can be helpful for people who have difficulty seeing the screen.</string>
    <!-- The text for the Voice Access introduction. [CHAR LIMIT=NONE] -->
@@ -2903,6 +2901,15 @@
    <!-- Positive button text for the dialog. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_dialog_positive_button_text">Turn on</string>

    <!-- Text for the Magnification dialog title. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_magnification_dialog_title"><xliff:g name="feature_name" example="Magnification">%1$s</xliff:g> keyboard shortcut turned on</string>
    <!-- Text for showing inside the Magnification dialog. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_magnification_dialog_content">Action <annotation id="action_key_icon">icon</annotation> + <xliff:g name="secondary_key" example="Alt">^1</xliff:g> + <xliff:g name="key_code" example="M">^2</xliff:g> is the keyboard shortcut to use <xliff:g name="feature_name" example="Magnification">^3</xliff:g>. This allows you to quickly zoom in on the screen to make content larger. Press Action <annotation id="action_key_icon">icon</annotation> + <xliff:g name="secondary_key" example="Alt">^1</xliff:g> and \"+\" or \"-\" to adjust zoom.</string>
    <!-- Negative button text for the Magnification dialog. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_magnification_dialog_negative_button_text">Turn off shortcut</string>
    <!-- Positive button text for the Magnification dialog. [CHAR LIMIT=NONE] -->
    <string name="accessibility_key_gesture_magnification_dialog_positive_button_text">Keep on</string>

    <!-- Plugin control section of the tuner. Non-translatable since it should
         not appear on production builds ever. -->
    <string name="plugins" translatable="false">Plugins</string>
+46 −27
Original line number Diff line number Diff line
@@ -79,12 +79,37 @@ constructor(
        keyCode: Int,
        targetName: String,
    ): Pair<String, CharSequence>? {
        val featureNameToIntro = getFeatureNameToIntro(keyGestureType, targetName)

        // TODO: b/419026315 - Update the secondary modifier key label.
        val secondaryModifierLabel = ShortcutHelperKeys.modifierLabels[MODIFIER_KEY xor metaState]
        val keyCodeLabel = keyCodeMap[keyCode]
        if (featureNameToIntro == null || secondaryModifierLabel == null || keyCodeLabel == null) {

        if (secondaryModifierLabel == null || keyCodeLabel == null) {
            return null
        }

        if (keyGestureType == KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION) {
            val featureName =
                resources.getString(
                    com.android.settingslib.R.string.accessibility_screen_magnification_title
                )
            val title =
                resources.getString(
                    R.string.accessibility_key_gesture_magnification_dialog_title,
                    featureName,
                )
            val content =
                TextUtils.expandTemplate(
                    resources.getText(
                        R.string.accessibility_key_gesture_magnification_dialog_content
                    ),
                    secondaryModifierLabel.invoke(context),
                    keyCodeLabel,
                    featureName,
                )
            return Pair(title, content)
        } else {
            val featureNameToIntro = getFeatureNameToIntro(keyGestureType, targetName)
            if (featureNameToIntro == null) {
                return null
            }

@@ -93,7 +118,7 @@ constructor(
                    R.string.accessibility_key_gesture_dialog_title,
                    featureNameToIntro.first,
                )
        val contentText =
            val content =
                TextUtils.expandTemplate(
                    resources.getText(R.string.accessibility_key_gesture_dialog_content),
                    secondaryModifierLabel.invoke(context),
@@ -102,7 +127,8 @@ constructor(
                    featureNameToIntro.second,
                )

        return Pair(title, contentText)
            return Pair(title, content)
        }
    }

    override fun getActionKeyIconResId(): Int {
@@ -125,13 +151,6 @@ constructor(
        targetName: String,
    ): Pair<CharSequence, CharSequence>? {
        return when (keyGestureType) {
            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION ->
                Pair(
                    resources.getString(
                        com.android.settingslib.R.string.accessibility_screen_magnification_title
                    ),
                    resources.getString(R.string.accessibility_key_gesture_dialog_magnifier_intro),
                )
            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS,
            KeyGestureEvent.KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK,
            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER -> {
@@ -146,7 +165,7 @@ constructor(
                    null
                } else {
                    val featureName =
                        getFeatureName(
                        formatFeatureName(
                            accessibilityServiceInfo.resolveInfo.loadLabel(packageManager)
                        )

@@ -165,7 +184,7 @@ constructor(
    }

    // Get the service name and bidi wrap it to protect from bidi side effects.
    private fun getFeatureName(label: CharSequence): CharSequence {
    private fun formatFeatureName(label: CharSequence): CharSequence {
        val locale = context.resources.configuration.getLocales().get(0)
        return BidiFormatter.getInstance(locale).unicodeWrap(label)
    }
+22 −8
Original line number Diff line number Diff line
@@ -90,6 +90,26 @@ constructor(
            return
        }

        val negativeButtonTextId =
            if (
                keyGestureConfirmInfo.keyGestureType ==
                    KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION
            ) {
                R.string.accessibility_key_gesture_magnification_dialog_negative_button_text
            } else {
                android.R.string.cancel
            }

        val positiveButtonTextId =
            if (
                keyGestureConfirmInfo.keyGestureType ==
                    KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION
            ) {
                R.string.accessibility_key_gesture_magnification_dialog_positive_button_text
            } else {
                R.string.accessibility_key_gesture_dialog_positive_button_text
            }

        currentDialog =
            dialogFactory.create { dialog ->
                PlatformTheme {
@@ -103,7 +123,7 @@ constructor(
                        },
                        negativeButton = {
                            PlatformOutlinedButton(onClick = { dialog.dismiss() }) {
                                Text(stringResource(id = android.R.string.cancel))
                                Text(stringResource(id = negativeButtonTextId))
                            }
                        },
                        positiveButton = {
@@ -115,13 +135,7 @@ constructor(
                                    dialog.dismiss()
                                }
                            ) {
                                Text(
                                    stringResource(
                                        id =
                                            R.string
                                                .accessibility_key_gesture_dialog_positive_button_text
                                    )
                                )
                                Text(stringResource(id = positiveButtonTextId))
                            }
                        },
                    )