diff options
| author | 2016-08-04 13:24:14 -0400 | |
|---|---|---|
| committer | 2016-08-04 13:24:14 -0400 | |
| commit | 66a8562c58507c52d0b9924aa0c7c246b1c723e8 (patch) | |
| tree | 4a9533a6a13f4d92b867bfc9e29dfcb8f95aab41 | |
| parent | c9682ab5b508a242f0d569857ee9f6a3b82578de (diff) | |
Use localized hour when announcing selection for accessibility
Bug: 30451273
Change-Id: I04276dc12d479ff5336799ebb32ff4cf5d66068a
| -rw-r--r-- | core/java/android/widget/RadialTimePickerView.java | 38 | ||||
| -rw-r--r-- | core/java/android/widget/TimePickerClockDelegate.java | 18 |
2 files changed, 38 insertions, 18 deletions
diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java index 02ee2df18aaf..6f198e78df8a 100644 --- a/core/java/android/widget/RadialTimePickerView.java +++ b/core/java/android/widget/RadialTimePickerView.java @@ -16,7 +16,11 @@ package android.widget; +import com.android.internal.R; +import com.android.internal.widget.ExploreByTouchHelper; + import android.animation.ObjectAnimator; +import android.annotation.IntDef; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; @@ -43,9 +47,8 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; -import com.android.internal.R; -import com.android.internal.widget.ExploreByTouchHelper; - +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Calendar; import java.util.Locale; @@ -55,11 +58,16 @@ import java.util.Locale; * @hide */ public class RadialTimePickerView extends View { - private static final String TAG = "RadialTimePickerView"; public static final int HOURS = 0; public static final int MINUTES = 1; + + /** @hide */ + @IntDef({HOURS, MINUTES}) + @Retention(RetentionPolicy.SOURCE) + @interface PickerType {} + private static final int HOURS_INNER = 2; private static final int SELECTOR_CIRCLE = 0; @@ -185,8 +193,24 @@ public class RadialTimePickerView extends View { private boolean mInputEnabled = true; - public interface OnValueSelectedListener { - void onValueSelected(int pickerIndex, int newValue, boolean autoAdvance); + interface OnValueSelectedListener { + /** + * Called when the selected value at a given picker index has changed. + * + * @param pickerType the type of value that has changed, one of: + * <ul> + * <li>{@link #MINUTES} + * <li>{@link #HOURS} + * </ul> + * @param newValue the new value as minute in hour (0-59) or hour in + * day (0-23) + * @param autoAdvance when the picker type is {@link #HOURS}, + * {@code true} to switch to the {@link #MINUTES} + * picker or {@code false} to stay on the current + * picker. No effect when picker type is + * {@link #MINUTES}. + */ + void onValueSelected(@PickerType int pickerType, int newValue, boolean autoAdvance); } /** @@ -977,7 +1001,7 @@ public class RadialTimePickerView extends View { // Ensure we're showing the correct picker. animatePicker(mShowHours, ANIM_DURATION_TOUCH); - final int type; + final @PickerType int type; final int newValue; final boolean valueChanged; diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java index c21f1dfe0ed1..aa0b93d76a15 100644 --- a/core/java/android/widget/TimePickerClockDelegate.java +++ b/core/java/android/widget/TimePickerClockDelegate.java @@ -61,9 +61,6 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate { private static final int HOUR_INDEX = RadialTimePickerView.HOURS; private static final int MINUTE_INDEX = RadialTimePickerView.MINUTES; - // NOT a real index for the purpose of what's showing. - private static final int AMPM_INDEX = 2; - private static final int[] ATTRS_TEXT_COLOR = new int[] {R.attr.textColor}; private static final int[] ATTRS_DISABLED_ALPHA = new int[] {R.attr.disabledAlpha}; @@ -701,22 +698,21 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate { /** Listener for RadialTimePickerView interaction. */ private final OnValueSelectedListener mOnValueSelectedListener = new OnValueSelectedListener() { @Override - public void onValueSelected(int pickerIndex, int newValue, boolean autoAdvance) { - switch (pickerIndex) { - case HOUR_INDEX: + public void onValueSelected(int pickerType, int newValue, boolean autoAdvance) { + switch (pickerType) { + case RadialTimePickerView.HOURS: final boolean isTransition = mAllowAutoAdvance && autoAdvance; setHourInternal(newValue, true, !isTransition); if (isTransition) { setCurrentItemShowing(MINUTE_INDEX, true, false); - mDelegator.announceForAccessibility(newValue + ". " + mSelectMinutes); + + final int localizedHour = getLocalizedHour(newValue); + mDelegator.announceForAccessibility(localizedHour + ". " + mSelectMinutes); } break; - case MINUTE_INDEX: + case RadialTimePickerView.MINUTES: setMinuteInternal(newValue, true); break; - case AMPM_INDEX: - updateAmPmLabelStates(newValue); - break; } if (mOnTimeChangedListener != null) { |