a11y edits to dnd dialog and volume ring toggle
- don't use announce in the dnd enable dialog - instead make the radio
button content a live region
- add hints to volume dialog ring button and edit content descriptions
Change-Id: I4b0db5e9d8dc6df3f48a4eccad1045d7baca4031
Fixes: 78914992
Fixes: 76385188
Test: manual
diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/EnableZenModeDialog.java b/packages/SettingsLib/src/com/android/settingslib/notification/EnableZenModeDialog.java
index b98f27e..f14def1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/notification/EnableZenModeDialog.java
+++ b/packages/SettingsLib/src/com/android/settingslib/notification/EnableZenModeDialog.java
@@ -185,6 +185,7 @@
@VisibleForTesting
protected void bind(final Condition condition, final View row, final int rowId) {
if (condition == null) throw new IllegalArgumentException("condition must not be null");
+
final boolean enabled = condition.state == Condition.STATE_TRUE;
final ConditionTag tag = row.getTag() != null ? (ConditionTag) row.getTag() :
new ConditionTag();
@@ -207,7 +208,6 @@
MetricsLogger.action(mContext,
MetricsProto.MetricsEvent.QS_DND_CONDITION_SELECT);
updateAlarmWarningText(tag.condition);
- announceConditionSelection(tag);
}
}
});
@@ -328,6 +328,7 @@
boolean enabled, int rowId, Uri conditionId) {
if (tag.lines == null) {
tag.lines = row.findViewById(android.R.id.content);
+ tag.lines.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
}
if (tag.line1 == null) {
tag.line1 = (TextView) row.findViewById(android.R.id.text1);
@@ -450,16 +451,6 @@
bind(newCondition, row, rowId);
updateAlarmWarningText(tag.condition);
tag.rb.setChecked(true);
- announceConditionSelection(tag);
- }
-
- private void announceConditionSelection(ConditionTag tag) {
- // condition will always be priority-only
- String modeText = mContext.getString(R.string.zen_interruption_level_priority);
- if (tag.line1 != null) {
- mZenRadioGroupContent.announceForAccessibility(mContext.getString(
- R.string.zen_mode_and_condition, modeText, tag.line1.getText()));
- }
}
private void updateAlarmWarningText(Condition condition) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
index 7369ba8..adf49aa 100644
--- a/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
+++ b/packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java
@@ -203,8 +203,14 @@
private void setupUi(ConditionTag tag, View row) {
- tag.lines = row.findViewById(android.R.id.content);
- tag.line1 = (TextView) row.findViewById(android.R.id.text1);
+ if (tag.lines == null) {
+ tag.lines = row.findViewById(android.R.id.content);
+ tag.lines.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
+ }
+
+ if (tag.line1 == null) {
+ tag.line1 = (TextView) row.findViewById(android.R.id.text1);
+ }
// text2 is not used in zen duration dialog
row.findViewById(android.R.id.text2).setVisibility(View.GONE);
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index f1f80c7..2c5b11c 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1360,6 +1360,13 @@
<string name="volume_stream_content_description_vibrate_a11y">%1$s. Tap to set to vibrate.</string>
<string name="volume_stream_content_description_mute_a11y">%1$s. Tap to mute.</string>
+ <!-- Hint for accessibility. For example: double tap to mute [CHAR_LIMIT=NONE] -->
+ <string name="volume_ringer_hint_mute">mute</string>
+ <!-- Hint for accessibility. For example: double tap to unmute [CHAR_LIMIT=NONE] -->
+ <string name="volume_ringer_hint_unmute">unmute</string>
+ <!-- Hint for accessibility. For example: double tap to vibrate [CHAR_LIMIT=NONE] -->
+ <string name="volume_ringer_hint_vibrate">vibrate</string>
+
<string name="volume_dialog_title">%s volume controls</string>
<string name="volume_dialog_ringer_guidance_ring">Calls and notifications will ring (<xliff:g id="volume level" example="56">%1$s</xliff:g>)</string>
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
index b5071de..b0e40fc 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java
@@ -71,6 +71,7 @@
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -627,35 +628,32 @@
switch (mState.ringerModeInternal) {
case AudioManager.RINGER_MODE_VIBRATE:
mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_vibrate);
+ addAccessibilityDescription(mRingerIcon, RINGER_MODE_VIBRATE,
+ mContext.getString(R.string.volume_ringer_hint_mute));
mRingerIcon.setTag(Events.ICON_STATE_VIBRATE);
break;
case AudioManager.RINGER_MODE_SILENT:
mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
- mRingerIcon.setContentDescription(mContext.getString(
- R.string.volume_stream_content_description_unmute,
- getStreamLabelH(ss)));
mRingerIcon.setTag(Events.ICON_STATE_MUTE);
+ addAccessibilityDescription(mRingerIcon, RINGER_MODE_SILENT,
+ mContext.getString(R.string.volume_ringer_hint_unmute));
break;
case AudioManager.RINGER_MODE_NORMAL:
default:
boolean muted = (mAutomute && ss.level == 0) || ss.muted;
if (!isZenMuted && muted) {
mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
- mRingerIcon.setContentDescription(mContext.getString(
- R.string.volume_stream_content_description_unmute,
- getStreamLabelH(ss)));
+ addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL,
+ mContext.getString(R.string.volume_ringer_hint_unmute));
mRingerIcon.setTag(Events.ICON_STATE_MUTE);
} else {
mRingerIcon.setImageResource(R.drawable.ic_volume_ringer);
if (mController.hasVibrator()) {
- mRingerIcon.setContentDescription(mContext.getString(
- mShowA11yStream
- ? R.string.volume_stream_content_description_vibrate_a11y
- : R.string.volume_stream_content_description_vibrate,
- getStreamLabelH(ss)));
-
+ addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL,
+ mContext.getString(R.string.volume_ringer_hint_vibrate));
} else {
- mRingerIcon.setContentDescription(getStreamLabelH(ss));
+ addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL,
+ mContext.getString(R.string.volume_ringer_hint_mute));
}
mRingerIcon.setTag(Events.ICON_STATE_UNMUTE);
}
@@ -664,6 +662,31 @@
}
}
+ private void addAccessibilityDescription(View view, int currState, String hintLabel) {
+ int currStateResId;
+ switch (currState) {
+ case RINGER_MODE_SILENT:
+ currStateResId = R.string.volume_ringer_status_silent;
+ break;
+ case RINGER_MODE_VIBRATE:
+ currStateResId = R.string.volume_ringer_status_vibrate;
+ break;
+ case RINGER_MODE_NORMAL:
+ default:
+ currStateResId = R.string.volume_ringer_status_normal;
+ }
+
+ view.setContentDescription(mContext.getString(currStateResId));
+
+ view.setAccessibilityDelegate(new AccessibilityDelegate() {
+ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ info.addAction(new AccessibilityNodeInfo.AccessibilityAction(
+ AccessibilityNodeInfo.ACTION_CLICK, hintLabel));
+ }
+ });
+ }
+
/**
* Toggles enable state of views in a VolumeRow (not including seekbar or icon)
* Hides/shows zen icon