From 7eef9a1adfa002b7ca9721bf6b7e603479635ac8 Mon Sep 17 00:00:00 2001 From: yingleiw Date: Fri, 18 Oct 2019 16:31:09 -0700 Subject: [PATCH] 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 --- core/java/android/widget/SimpleMonthView.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/java/android/widget/SimpleMonthView.java b/core/java/android/widget/SimpleMonthView.java index 562cc4ffeeaa1..217693eed686b 100644 --- a/core/java/android/widget/SimpleMonthView.java +++ b/core/java/android/widget/SimpleMonthView.java @@ -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);