From 9054e09c7fd60062bfca7247d7634c69b55f70d1 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Fri, 27 Apr 2018 16:28:50 -0700 Subject: [PATCH] Make system dialogs' a11y events like Activity's The window_state_changed events are populated by Activity with the Activity title. Replicating that behavior for volume and power dialogs. Bug: 78775496 Test: Used a test a11y service to observe events, and started TalkBack, which was less consistent about announcing them. Change-Id: Icd4cd8317544c127e44e403162512e2385ff4176 --- .../systemui/globalactions/GlobalActionsDialog.java | 9 +++++++++ .../src/com/android/systemui/volume/VolumeDialogImpl.java | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index a7975d7e4595..087d481a61f2 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -1380,6 +1380,15 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, mHardwareLayout = HardwareUiLayout.get(mListView); mHardwareLayout.setOutsideTouchListener(view -> dismiss()); setTitle(R.string.global_actions); + mListView.setAccessibilityDelegate(new View.AccessibilityDelegate() { + @Override + public boolean dispatchPopulateAccessibilityEvent( + View host, AccessibilityEvent event) { + // Populate the title here, just as Activity does + event.getText().add(mContext.getString(R.string.global_actions)); + return true; + } + }); } private void updateList() { diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 5c7ce59c1065..5d21391060e6 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -724,8 +724,11 @@ public class VolumeDialogImpl implements VolumeDialog { updateVolumeRowH(row); } updateRingerH(); - mWindow.setTitle(mContext.getString(R.string.volume_dialog_title, - getStreamLabelH(getActiveRow().ss))); + mWindow.setTitle(composeWindowTitle()); + } + + CharSequence composeWindowTitle() { + return mContext.getString(R.string.volume_dialog_title, getStreamLabelH(getActiveRow().ss)); } private void updateVolumeRowH(VolumeRow row) { @@ -1196,6 +1199,13 @@ public class VolumeDialogImpl implements VolumeDialog { } @Override + public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) { + // Activities populate their title here. Follow that example. + event.getText().add(composeWindowTitle()); + return true; + } + + @Override public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) { rescheduleTimeoutH(); -- 2.11.0