summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/strings.xml6
-rw-r--r--core/res/res/values/symbols.xml3
-rw-r--r--packages/SystemUI/res/values/strings.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationSnooze.java64
4 files changed, 68 insertions, 8 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index bd3a5e4fe67c..558bae727415 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -5307,6 +5307,12 @@
<!-- Content description of the expand button icon in the notification when expanded.-->
<string name="expand_button_content_description_expanded">Collapse</string>
+ <!-- A11y announcement when a view is collapsed. -->
+ <string name="content_description_collapsed">Collapsed</string>
+
+ <!-- A11y announcement when a view is expanded. -->
+ <string name="content_description_expanded">Expanded</string>
+
<!-- Accessibility action description on the expand button. -->
<string name="expand_action_accessibility">toggle expansion</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3c1a42feef25..dc2f74bb76fe 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3826,6 +3826,9 @@
<java-symbol type="string" name="expand_button_content_description_collapsed" />
<java-symbol type="string" name="expand_button_content_description_expanded" />
+ <java-symbol type="string" name="content_description_collapsed" />
+ <java-symbol type="string" name="content_description_expanded" />
+
<!-- Colon separated list of package names that should be granted Notification Listener access -->
<java-symbol type="string" name="config_defaultListenerAccessPackages" />
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 47ac96ca7960..370b05f8dcc7 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1750,6 +1750,9 @@
<!-- Notification: Snooze panel: Snooze undo button label. [CHAR LIMIT=50]-->
<string name="snooze_undo">Undo</string>
+ <!-- Notification: Snooze panel: Snooze undo content description for a11y. [CHAR LIMIT=NONE]-->
+ <string name="snooze_undo_content_description">Undo notification snooze</string>
+
<!-- Notification: Snooze panel: message indicating how long the notification was snoozed for. [CHAR LIMIT=100]-->
<string name="snoozed_for_time">Snoozed for <xliff:g id="time_amount" example="15 minutes">%1$s</xliff:g></string>
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 3443da19895e..6ad460bd8aa7 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
@@ -45,13 +45,15 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+
import com.android.app.animation.Interpolators;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.systemui.res.R;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
+import com.android.systemui.res.R;
import java.util.ArrayList;
import java.util.List;
@@ -77,6 +79,9 @@ public class NotificationSnooze extends LinearLayout
private static final LogMaker UNDO_LOG =
new LogMaker(MetricsEvent.NOTIFICATION_UNDO_SNOOZE)
.setType(MetricsEvent.TYPE_ACTION);
+
+ private static final String PARAGRAPH_SEPARATOR = "\u2029";
+
private NotificationGuts mGutsContainer;
private NotificationSwipeActionHelper mSnoozeListener;
private StatusBarNotification mSbn;
@@ -111,8 +116,7 @@ public class NotificationSnooze extends LinearLayout
}
@VisibleForTesting
- SnoozeOption getDefaultOption()
- {
+ SnoozeOption getDefaultOption() {
return mDefaultOption;
}
@@ -130,6 +134,8 @@ public class NotificationSnooze extends LinearLayout
mSelectedOptionText = (TextView) findViewById(R.id.snooze_option_default);
mUndoButton = (TextView) findViewById(R.id.undo);
mUndoButton.setOnClickListener(this);
+ mUndoButton.setContentDescription(
+ getContext().getString(R.string.snooze_undo_content_description));
mExpandButton = (ImageView) findViewById(R.id.expand_button);
mDivider = findViewById(R.id.divider);
mDivider.setAlpha(0f);
@@ -163,6 +169,46 @@ public class NotificationSnooze extends LinearLayout
info.addAction(action);
}
}
+
+ mSnoozeView.setAccessibilityDelegate(new AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ // Replace "Double tap to activate" prompt with "Double tap to expand/collapse"
+ AccessibilityAction customClick = new AccessibilityAction(
+ AccessibilityNodeInfo.ACTION_CLICK, getExpandActionString());
+ info.addAction(customClick);
+ }
+ });
+ }
+
+ /**
+ * Update the content description of the snooze view based on the snooze option and whether the
+ * snooze options are expanded or not.
+ * For example, this will be something like "Collapsed\u2029Snooze for 1 hour". The paragraph
+ * separator is added to introduce a break in speech, to match what TalkBack does by default
+ * when you e.g. press on a notification.
+ */
+ private void updateContentDescription() {
+ mSnoozeView.setContentDescription(
+ getExpandStateString() + PARAGRAPH_SEPARATOR + mSelectedOptionText.getText());
+ }
+
+ /** Returns "collapse" if the snooze options are expanded, or "expand" otherwise. */
+ @NonNull
+ private String getExpandActionString() {
+ return mContext.getString(mExpanded
+ ? com.android.internal.R.string.expand_button_content_description_expanded
+ : com.android.internal.R.string.expand_button_content_description_collapsed);
+ }
+
+
+ /** Returns "expanded" if the snooze options are expanded, or "collapsed" otherwise. */
+ @NonNull
+ private String getExpandStateString() {
+ return mContext.getString(
+ (mExpanded ? com.android.internal.R.string.content_description_expanded
+ : com.android.internal.R.string.content_description_collapsed));
}
@Override
@@ -290,11 +336,10 @@ public class NotificationSnooze extends LinearLayout
int drawableId = show ? com.android.internal.R.drawable.ic_collapse_notification
: com.android.internal.R.drawable.ic_expand_notification;
mExpandButton.setImageResource(drawableId);
- mExpandButton.setContentDescription(mContext.getString(show
- ? com.android.internal.R.string.expand_button_content_description_expanded
- : com.android.internal.R.string.expand_button_content_description_collapsed));
+ mExpandButton.setContentDescription(getExpandActionString());
if (mExpanded != show) {
mExpanded = show;
+ updateContentDescription();
animateSnoozeOptions(show);
if (mGutsContainer != null) {
mGutsContainer.onHeightChanged();
@@ -335,8 +380,11 @@ public class NotificationSnooze extends LinearLayout
}
private void setSelected(SnoozeOption option, boolean userAction) {
- mSelectedOption = option;
- mSelectedOptionText.setText(option.getConfirmation());
+ if (option != mSelectedOption) {
+ mSelectedOption = option;
+ mSelectedOptionText.setText(option.getConfirmation());
+ updateContentDescription();
+ }
showSnoozeOptions(false);
hideSelectedOption();
if (userAction) {