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

Commit 8a75c839 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Improve content description

This CL adjust content description to match legacy code and makes accessibility behavior similar to the original volume ringer drawer.

Flag: com.android.systemui.volume_redesign
Bug: 369993851
Test: UI checked.
Change-Id: If01c3c28fbf075e116176c82f7bd509f901f564c
parent 4ec596d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1812,6 +1812,7 @@

    <string name="volume_ringer_change">Tap to change ringer mode</string>
    <string name="volume_ringer_mode">ringer mode</string>
    <string name="volume_ringer_drawer_closed_content_description"><xliff:g id="volume ringer status" example="Ring">%1$s</xliff:g>, tap to change ringer mode </string>

    <!-- Hint for accessibility. For example: double tap to mute [CHAR_LIMIT=NONE] -->
    <string name="volume_ringer_hint_mute">mute</string>
+15 −3
Original line number Diff line number Diff line
@@ -196,15 +196,17 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
        uiModel.availableButtons.fastForEachIndexed { index, ringerButton ->
            ringerButton?.let {
                val view = getChildAt(count - index - 1)
                val isOpen = uiModel.drawerState is RingerDrawerState.Open
                if (index == uiModel.currentButtonIndex) {
                    view.bindDrawerButton(
                        uiModel.selectedButton,
                        if (isOpen) it else uiModel.selectedButton,
                        viewModel,
                        isOpen,
                        isSelected = true,
                        isAnimated = isAnimated,
                    )
                } else {
                    view.bindDrawerButton(it, viewModel, isAnimated)
                    view.bindDrawerButton(it, viewModel, isOpen, isAnimated = isAnimated)
                }
            }
        }
@@ -214,12 +216,22 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
    private fun View.bindDrawerButton(
        buttonViewModel: RingerButtonViewModel,
        viewModel: VolumeDialogRingerDrawerViewModel,
        isOpen: Boolean,
        isSelected: Boolean = false,
        isAnimated: Boolean = false,
    ) {
        val ringerContentDesc = context.getString(buttonViewModel.contentDescriptionResId)
        with(requireViewById<ImageButton>(R.id.volume_drawer_button)) {
            setImageResource(buttonViewModel.imageResId)
            contentDescription = context.getString(buttonViewModel.contentDescriptionResId)
            contentDescription =
                if (isSelected && !isOpen) {
                    context.getString(
                        R.string.volume_ringer_drawer_closed_content_description,
                        ringerContentDesc,
                    )
                } else {
                    ringerContentDesc
                }
            if (isSelected && !isAnimated) {
                setBackgroundResource(R.drawable.volume_drawer_selection_bg)
                setColorFilter(