From 395723d420fd12a7a47158fa60b0e33a82aca48a Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Fri, 12 Jun 2020 13:56:48 -0400 Subject: [PATCH] Controls a11y - Fix status change update Content description was being updated before the status animation. Make sure it's set after. Also, don't specify a range value if the control is not enabled. Fixes: 158542017 Test: talkback Change-Id: I94a07c1fc2b46c6fbdf197d8903e7581122e5d08 --- .../com/android/systemui/controls/ui/ControlViewHolder.kt | 5 +++-- .../com/android/systemui/controls/ui/ToggleRangeBehavior.kt | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt index e8530272a5c81..5dd8accbc7bd3 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt @@ -218,13 +218,11 @@ class ControlViewHolder( cancelUpdate = uiExecutor.executeDelayed({ animateStatusChange(/* animated */ true, { setStatusText(previousText, /* immediately */ true) - updateContentDescription() }) }, UPDATE_DELAY_IN_MILLIS) animateStatusChange(/* animated */ true, { setStatusText(tempStatus, /* immediately */ true) - updateContentDescription() }) } @@ -296,6 +294,7 @@ class ControlViewHolder( if (immediately) { status.alpha = STATUS_ALPHA_ENABLED status.text = text + updateContentDescription() } nextStatusText = text } @@ -412,6 +411,8 @@ class ControlViewHolder( setEnabled(enabled) status.text = text + updateContentDescription() + status.setTextColor(color) control?.getCustomIcon()?.let { diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt index 02f80e842516e..04881af6ed45c 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt @@ -163,8 +163,10 @@ class ToggleRangeBehavior : Behavior { AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_FLOAT } - val rangeInfo = AccessibilityNodeInfo.RangeInfo.obtain(type, min, max, current) - info.setRangeInfo(rangeInfo) + if (isChecked) { + val rangeInfo = AccessibilityNodeInfo.RangeInfo.obtain(type, min, max, current) + info.setRangeInfo(rangeInfo) + } info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS) }