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
This commit is contained in:
Matías Hernández
2024-07-29 19:58:17 +02:00
parent 441a202444
commit a463b0af7b
2 changed files with 16 additions and 5 deletions

View File

@@ -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

View File

@@ -67,12 +67,18 @@ class ZenModeSetSchedulePreferenceController extends AbstractZenModePreferenceCo
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 @@ class ZenModeSetSchedulePreferenceController extends AbstractZenModePreferenceCo
// 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) -> {