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

Commit 932991cd authored by Fabián Kozynski's avatar Fabián Kozynski Committed by Fabian Kozynski
Browse files

Include on/off state if dual target

If the tile is dual target, it means it can be switched, so add the
corresponding on/off text to the stateDescription. This will be used in
the large part of the tile and in the toggle target.

Test: manual, Talkback
Test: atest TileUiStateTest
Fixes: 412321390
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Change-Id: Ica9dfa594cf7fdb4a0c9564183827a4e64666e4c
parent 71572aa7
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -267,6 +267,32 @@ class TileUiStateTest : SysuiTestCase() {
            .contains(resources.getString(R.string.tile_unavailable))
    }

    @Test
    fun dualTarget_inactive_hasStateDescriptionOff() {
        val state =
            QSTile.State().apply {
                state = Tile.STATE_INACTIVE
                handlesSecondaryClick = true
            }

        val uiState = state.toUiState()
        assertThat(uiState.accessibilityUiState.stateDescription)
            .contains(context.getString(R.string.switch_bar_off))
    }

    @Test
    fun dualTarget_active_hasStateDescriptionOn() {
        val state =
            QSTile.State().apply {
                state = Tile.STATE_ACTIVE
                handlesSecondaryClick = true
            }

        val uiState = state.toUiState()
        assertThat(uiState.accessibilityUiState.stateDescription)
            .contains(context.getString(R.string.switch_bar_on))
    }

    private fun QSTile.State.toUiState() = toUiState(resources)
}

+5 −1
Original line number Diff line number Diff line
@@ -63,7 +63,11 @@ fun QSTile.State.toUiState(resources: Resources): TileUiState {
    // State handling and description
    val stateDescription = StringBuilder()
    val stateText =
        if (accessibilityRole == Role.Switch || state == Tile.STATE_UNAVAILABLE) {
        if (
            accessibilityRole == Role.Switch ||
                state == Tile.STATE_UNAVAILABLE ||
                handlesSecondaryClick
        ) {
            getStateText(resources)
        } else {
            ""