From 90e20d3c6dec163199cd6428894eb3c63ab01d75 Mon Sep 17 00:00:00 2001 From: Beverly Date: Fri, 10 Apr 2020 13:51:40 -0400 Subject: [PATCH] Fix notification snooze a11y issues - Set minimum height and width on the snooze "undo" button - Update logic in performAccessibilityActionInternal in ExpandableNotificationRow so that snoozing a notification from Talkback/switch access/voice access actually performs the snooze action - After a user selects a new snooze time option for a notification, the snooze options close. Focus should remain on the snooze time, since that element was just changed. - Once a user snoozes a notification, it should focus on the child SnoozeView instead of the greater NotificationSnooze view because only the SnoozeView is actionable. So if focus is requested on the NotificationSnooze view and the options aren't expanded, then focus just on the SnoozeView. Test: manual, use a11y scanner Fixes: 152730944 Fixes: 152820361 Fixes: 152720315 Fixes: 152718852 Change-Id: I7e43bddfdaa3b5a1741645f7bb54af42bc953fc3 Change-Id: I4672654d4ca2eb2cf68539efb7cfb0c8f5dfb00b --- .../res/layout/notification_snooze.xml | 3 ++- packages/SystemUI/res/values/dimens.xml | 3 +++ .../row/ExpandableNotificationRow.java | 4 +-- .../notification/row/NotificationSnooze.java | 26 ++++++++++--------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/res/layout/notification_snooze.xml b/packages/SystemUI/res/layout/notification_snooze.xml index c350ed22b765c..253bc328c5b81 100644 --- a/packages/SystemUI/res/layout/notification_snooze.xml +++ b/packages/SystemUI/res/layout/notification_snooze.xml @@ -20,7 +20,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:clickable="true" android:background="@color/notification_material_background_color" android:theme="@style/Theme.SystemUI"> @@ -55,6 +54,8 @@ android:layout_marginEnd="@dimen/notification_guts_button_side_margin" android:layout_alignParentEnd="true" android:layout_centerVertical="true" + android:minWidth="@dimen/min_clickable_item_size" + android:minHeight="@dimen/min_clickable_item_size" android:text="@string/snooze_undo" style="@style/TextAppearance.NotificationInfo.Button" /> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 2a4d5ef921f7a..e7ef8ccf4ebaa 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -16,6 +16,9 @@ */ --> + + 48dp + -12dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 5c578dfc57441..998230f205ab0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -3001,9 +3001,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView default: if (action == R.id.action_snooze) { NotificationMenuRowPlugin provider = getProvider(); - if (provider == null && mMenuRow != null) { - provider = createMenu(); - } else { + if (provider == null) { return false; } MenuItem snoozeMenu = provider.getSnoozeMenuItem(getContext()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSnooze.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSnooze.java index d65f2c53598c3..e56771c62bb5d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSnooze.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSnooze.java @@ -79,6 +79,7 @@ public class NotificationSnooze extends LinearLayout private NotificationSwipeActionHelper mSnoozeListener; private StatusBarNotification mSbn; + private View mSnoozeView; private TextView mSelectedOptionText; private TextView mUndoButton; private ImageView mExpandButton; @@ -122,7 +123,8 @@ public class NotificationSnooze extends LinearLayout protected void onFinishInflate() { super.onFinishInflate(); mCollapsedHeight = getResources().getDimensionPixelSize(R.dimen.snooze_snackbar_min_height); - findViewById(R.id.notification_snooze).setOnClickListener(this); + mSnoozeView = findViewById(R.id.notification_snooze); + mSnoozeView.setOnClickListener(this); mSelectedOptionText = (TextView) findViewById(R.id.snooze_option_default); mUndoButton = (TextView) findViewById(R.id.undo); mUndoButton.setOnClickListener(this); @@ -146,16 +148,6 @@ public class NotificationSnooze extends LinearLayout logOptionSelection(MetricsEvent.NOTIFICATION_SNOOZE_CLICKED, mDefaultOption); } - @Override - public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(event); - if (mGutsContainer != null && mGutsContainer.isExposed()) { - if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - event.getText().add(mSelectedOptionText.getText()); - } - } - } - @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); @@ -341,12 +333,22 @@ public class NotificationSnooze extends LinearLayout mSelectedOptionText.setText(option.getConfirmation()); showSnoozeOptions(false); hideSelectedOption(); - sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (userAction) { + mSnoozeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); logOptionSelection(MetricsEvent.NOTIFICATION_SELECT_SNOOZE, option); } } + @Override + public boolean requestAccessibilityFocus() { + if (mExpanded) { + return super.requestAccessibilityFocus(); + } else { + mSnoozeView.requestAccessibilityFocus(); + return false; + } + } + private void logOptionSelection(int category, SnoozeOption option) { int index = mSnoozeOptions.indexOf(option); long duration = TimeUnit.MINUTES.toMillis(option.getMinutesToSnoozeFor());