diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2013-12-18 12:51:22 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-01-03 17:00:43 -0800 |
commit | 014b8cfcf87507e629a728582b196b62aee71e37 (patch) | |
tree | e2d60e74e978c6130a2ada4558fa7790da0123b6 | |
parent | 638fcf0df696fc582e5dd06b2e020972e286cc6e (diff) | |
download | frameworks_base-014b8cfcf87507e629a728582b196b62aee71e37.zip frameworks_base-014b8cfcf87507e629a728582b196b62aee71e37.tar.gz frameworks_base-014b8cfcf87507e629a728582b196b62aee71e37.tar.bz2 |
Fix new TimePicker accessibility
- make AM/PM TextView accessible
- fix accessibility node loop (which is making the TalkBack service to crash)
Change-Id: Iea2152f0ab223039a6d92eafcd92f86c4055b316
-rw-r--r-- | core/java/android/widget/TimePickerDelegate.java | 29 | ||||
-rw-r--r-- | core/res/res/layout/time_header_label.xml | 3 |
2 files changed, 26 insertions, 6 deletions
diff --git a/core/java/android/widget/TimePickerDelegate.java b/core/java/android/widget/TimePickerDelegate.java index 182d370..c9a9894 100644 --- a/core/java/android/widget/TimePickerDelegate.java +++ b/core/java/android/widget/TimePickerDelegate.java @@ -27,6 +27,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.text.format.DateFormat; +import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.util.TypedValue; @@ -44,6 +45,7 @@ import com.android.internal.R; import java.text.DateFormatSymbols; import java.util.ArrayList; import java.util.Calendar; +import java.util.Locale; /** * A view for selecting the time of day, in either 24 hour or AM/PM mode. @@ -120,6 +122,8 @@ class TimePickerDelegate extends TimePicker.AbstractTimePickerDelegate implement private String mMinutePickerDescription; private String mSelectMinutes; + private Calendar mTempCalendar; + public TimePickerDelegate(TimePicker delegator, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(delegator, context); @@ -506,23 +510,40 @@ class TimePickerDelegate extends TimePicker.AbstractTimePickerDelegate implement } @Override + public void setCurrentLocale(Locale locale) { + super.setCurrentLocale(locale); + mTempCalendar = Calendar.getInstance(locale); + } + + @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - return mRadialTimePickerView.dispatchPopulateAccessibilityEvent(event); + onPopulateAccessibilityEvent(event); + return true; } @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { - mRadialTimePickerView.onPopulateAccessibilityEvent(event); + int flags = DateUtils.FORMAT_SHOW_TIME; + if (mIs24HourView) { + flags |= DateUtils.FORMAT_24HOUR; + } else { + flags |= DateUtils.FORMAT_12HOUR; + } + mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); + mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); + String selectedDate = DateUtils.formatDateTime(mContext, + mTempCalendar.getTimeInMillis(), flags); + event.getText().add(selectedDate); } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { - mRadialTimePickerView.onInitializeAccessibilityEvent(event); + event.setClassName(TimePicker.class.getName()); } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { - mRadialTimePickerView.onInitializeAccessibilityNodeInfo(info); + info.setClassName(TimePicker.class.getName()); } /** diff --git a/core/res/res/layout/time_header_label.xml b/core/res/res/layout/time_header_label.xml index 00cb81b..f5f4a04 100644 --- a/core/res/res/layout/time_header_label.xml +++ b/core/res/res/layout/time_header_label.xml @@ -54,7 +54,6 @@ android:paddingRight="@dimen/timepicker_ampm_left_padding" android:layout_toRightOf="@+id/separator" android:layout_alignBaseline="@+id/separator" - android:textAppearance="?android:attr/timePickerHeaderAmPmLabelTextAppearance" - android:importantForAccessibility="no" /> + android:textAppearance="?android:attr/timePickerHeaderAmPmLabelTextAppearance" /> </RelativeLayout> |