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

Commit 66ccdfc0 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Modes tile & dialog a11y adjustments

Using a11y type button (instead of switch) to better represent how the
tile works. In the same vein, also moved away from using BooleanState
since it wasn't entirely accurate.

For the tiles in the dialog, the content description is already accurate
without any customization needed, so I removed that extra field.

Bug: 346519570
Test: manually tested with TalkBack, no major changes
Flag: android.app.modes_ui
Change-Id: I674db920b1b7d38711ec58448d5fa63821f8b513
parent 41f1fa5f
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -23,13 +23,14 @@ import android.os.Looper
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.coroutineScope
import androidx.lifecycle.repeatOnLifecycle
import com.android.internal.R.attr.contentDescription
import com.android.internal.logging.MetricsLogger
import com.android.systemui.animation.Expandable
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.qs.QSTile.BooleanState
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QsEventLogger
@@ -63,7 +64,7 @@ constructor(
    private val tileMapper: ModesTileMapper,
    private val userActionInteractor: ModesTileUserActionInteractor,
) :
    QSTileImpl<BooleanState>(
    QSTileImpl<QSTile.State>(
        host,
        uiEventLogger,
        backgroundLooper,
@@ -90,7 +91,7 @@ constructor(

    override fun getTileLabel(): CharSequence = tileState.label

    override fun newTileState() = BooleanState()
    override fun newTileState() = QSTile.State()

    override fun handleClick(expandable: Expandable?) = runBlocking {
        userActionInteractor.handleClick(expandable)
@@ -98,17 +99,17 @@ constructor(

    override fun getLongClickIntent(): Intent = userActionInteractor.longClickIntent

    override fun handleUpdateState(booleanState: BooleanState?, arg: Any?) {
    override fun handleUpdateState(state: QSTile.State?, arg: Any?) {
        if (arg is ModesTileModel) {
            tileState = tileMapper.map(config, arg)

            booleanState?.apply {
                state = tileState.activationState.legacyState
            state?.apply {
                this.state = tileState.activationState.legacyState
                icon = ResourceIcon.get(tileState.iconRes ?: R.drawable.qs_dnd_icon_off)
                label = tileLabel
                secondaryLabel = tileState.secondaryLabel
                contentDescription = tileState.contentDescription
                forceExpandIcon = true
                expandedAccessibilityClassName = tileState.expandedAccessibilityClassName
            }
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.qs.tiles.impl.modes.ui

import android.content.res.Resources
import android.icu.text.MessageFormat
import android.widget.Button
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.qs.tiles.base.interactor.QSTileDataToStateMapper
@@ -62,6 +63,7 @@ constructor(
                    QSTileState.UserAction.LONG_CLICK,
                )
            sideViewIcon = QSTileState.SideViewIcon.Chevron
            expandedAccessibilityClass = Button::class
        }

    private fun getModesStatus(data: ModesTileModel, resources: Resources): String {
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ data class ModeTileViewModel(
    val text: String,
    val subtext: String,
    val enabled: Boolean,
    val contentDescription: String,
    val onClick: () -> Unit,
    val onLongClick: () -> Unit,
)
+0 −3
Original line number Diff line number Diff line
@@ -84,9 +84,6 @@ constructor(
                        text = mode.rule.name,
                        subtext = getTileSubtext(mode),
                        enabled = mode.isActive,
                        // TODO(b/346519570): This should be some combination of the above, e.g.
                        //  "ON: Do Not Disturb, Until Mon 08:09"; see DndTile.
                        contentDescription = "",
                        onClick = {
                            if (!mode.rule.isEnabled) {
                                openSettings(mode)