Fix a11y issues in the schedule editor
* Don't read start / end time as separate labels.
* Fix content description of day buttons (ToggleButton's stateDescription is textOn/textOff -- which are the same for this particular button, thus it wasn't possible to know whether a day was selected or not).
Fixes: 346396147
Test: manual, with Talkback
Flag: android.app.modes_ui
Change-Id: If73a791cf9bd62cf17e058c81a8051b3e7fd82ea
diff --git a/res/layout/modes_set_schedule_layout.xml b/res/layout/modes_set_schedule_layout.xml
index ebb349e..d53e2e4 100644
--- a/res/layout/modes_set_schedule_layout.xml
+++ b/res/layout/modes_set_schedule_layout.xml
@@ -48,7 +48,8 @@
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Medium"
- android:text="@string/zen_mode_start_time" />
+ android:text="@string/zen_mode_start_time"
+ android:importantForAccessibility="no" />
<!-- Start time display + setter -->
<TextView
@@ -85,7 +86,8 @@
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Medium"
- android:text="@string/zen_mode_end_time" />
+ android:text="@string/zen_mode_end_time"
+ android:importantForAccessibility="no" />
<!-- End time setter; right-aligned -->
<TextView
diff --git a/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceController.java b/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceController.java
index 878a508..e4c3f32 100644
--- a/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceController.java
+++ b/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceController.java
@@ -67,12 +67,18 @@
LayoutPreference layoutPref = (LayoutPreference) preference;
TextView start = layoutPref.findViewById(R.id.start_time);
- start.setText(timeString(mSchedule.startHour, mSchedule.startMinute));
+ String startTimeString = timeString(mSchedule.startHour, mSchedule.startMinute);
+ start.setText(startTimeString);
+ start.setContentDescription(
+ mContext.getString(R.string.zen_mode_start_time) + "\n" + startTimeString);
start.setOnClickListener(
timePickerLauncher(mSchedule.startHour, mSchedule.startMinute, mStartSetter));
TextView end = layoutPref.findViewById(R.id.end_time);
- end.setText(timeString(mSchedule.endHour, mSchedule.endMinute));
+ String endTimeString = timeString(mSchedule.endHour, mSchedule.endMinute);
+ end.setText(endTimeString);
+ end.setContentDescription(
+ mContext.getString(R.string.zen_mode_end_time) + "\n" + endTimeString);
end.setOnClickListener(
timePickerLauncher(mSchedule.endHour, mSchedule.endMinute, mEndSetter));
@@ -198,7 +204,10 @@
// day label.
dayToggle.setTextOn(mShortDayFormat.format(c.getTime()));
dayToggle.setTextOff(mShortDayFormat.format(c.getTime()));
- dayToggle.setContentDescription(mLongDayFormat.format(c.getTime()));
+ String state = dayEnabled
+ ? mContext.getString(com.android.internal.R.string.capital_on)
+ : mContext.getString(com.android.internal.R.string.capital_off);
+ dayToggle.setStateDescription(mLongDayFormat.format(c.getTime()) + ", " + state);
dayToggle.setChecked(dayEnabled);
dayToggle.setOnCheckedChangeListener((buttonView, isChecked) -> {