Set "today" and "selected" for Datepicker when using Calender

Set the stateDescription to "today" if the date is today. Set selected
if the date is selected. Note that we didn't remove any information, so
this change doesn't need to wait until talkback changes get in.

Bug: 142361188, 141454158
Test: tested with date picker in calender mode. When the focus goes to
today, it announces "today, Oct. 22". When the focus goes to selected
date, it announces "selected, Oct. 22". When it is both today and
selected, it announces "select, today, Oct. 22".

Change-Id: Id210e22ec5ae2bc070c260c9632a605cf2a6236f
This commit is contained in:
yingleiw
2019-10-18 16:31:09 -07:00
parent b9e31e10a4
commit 7eef9a1adf

View File

@@ -28,6 +28,7 @@ import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.icu.text.DisplayContext;
import android.icu.text.RelativeDateTimeFormatter;
import android.icu.text.SimpleDateFormat;
import android.icu.util.Calendar;
import android.os.Bundle;
@@ -1095,6 +1096,14 @@ class SimpleMonthView extends View {
node.setText(getDayText(virtualViewId));
node.setContentDescription(getDayDescription(virtualViewId));
if (virtualViewId == mToday) {
RelativeDateTimeFormatter fmt = RelativeDateTimeFormatter.getInstance();
node.setStateDescription(fmt.format(RelativeDateTimeFormatter.Direction.THIS,
RelativeDateTimeFormatter.AbsoluteUnit.DAY));
}
if (virtualViewId == mActivatedDay) {
node.setSelected(true);
}
node.setBoundsInParent(mTempRect);
final boolean isDayEnabled = isDayEnabled(virtualViewId);