Use localized hour when announcing selection for accessibility
am: 66a8562c58
Change-Id: Ieffd33d1e33fdd38e2383396b18dce8031fb1538
This commit is contained in:
@@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.widget.ExploreByTouchHelper;
|
||||||
|
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.annotation.IntDef;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -43,9 +47,8 @@ import android.view.accessibility.AccessibilityEvent;
|
|||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import java.lang.annotation.Retention;
|
||||||
import com.android.internal.widget.ExploreByTouchHelper;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -55,11 +58,16 @@ import java.util.Locale;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class RadialTimePickerView extends View {
|
public class RadialTimePickerView extends View {
|
||||||
|
|
||||||
private static final String TAG = "RadialTimePickerView";
|
private static final String TAG = "RadialTimePickerView";
|
||||||
|
|
||||||
public static final int HOURS = 0;
|
public static final int HOURS = 0;
|
||||||
public static final int MINUTES = 1;
|
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 HOURS_INNER = 2;
|
||||||
|
|
||||||
private static final int SELECTOR_CIRCLE = 0;
|
private static final int SELECTOR_CIRCLE = 0;
|
||||||
@@ -185,8 +193,24 @@ public class RadialTimePickerView extends View {
|
|||||||
|
|
||||||
private boolean mInputEnabled = true;
|
private boolean mInputEnabled = true;
|
||||||
|
|
||||||
public interface OnValueSelectedListener {
|
interface OnValueSelectedListener {
|
||||||
void onValueSelected(int pickerIndex, int newValue, boolean autoAdvance);
|
/**
|
||||||
|
* 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.
|
// Ensure we're showing the correct picker.
|
||||||
animatePicker(mShowHours, ANIM_DURATION_TOUCH);
|
animatePicker(mShowHours, ANIM_DURATION_TOUCH);
|
||||||
|
|
||||||
final int type;
|
final @PickerType int type;
|
||||||
final int newValue;
|
final int newValue;
|
||||||
final boolean valueChanged;
|
final boolean valueChanged;
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate {
|
|||||||
private static final int HOUR_INDEX = RadialTimePickerView.HOURS;
|
private static final int HOUR_INDEX = RadialTimePickerView.HOURS;
|
||||||
private static final int MINUTE_INDEX = RadialTimePickerView.MINUTES;
|
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_TEXT_COLOR = new int[] {R.attr.textColor};
|
||||||
private static final int[] ATTRS_DISABLED_ALPHA = new int[] {R.attr.disabledAlpha};
|
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. */
|
/** Listener for RadialTimePickerView interaction. */
|
||||||
private final OnValueSelectedListener mOnValueSelectedListener = new OnValueSelectedListener() {
|
private final OnValueSelectedListener mOnValueSelectedListener = new OnValueSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(int pickerIndex, int newValue, boolean autoAdvance) {
|
public void onValueSelected(int pickerType, int newValue, boolean autoAdvance) {
|
||||||
switch (pickerIndex) {
|
switch (pickerType) {
|
||||||
case HOUR_INDEX:
|
case RadialTimePickerView.HOURS:
|
||||||
final boolean isTransition = mAllowAutoAdvance && autoAdvance;
|
final boolean isTransition = mAllowAutoAdvance && autoAdvance;
|
||||||
setHourInternal(newValue, true, !isTransition);
|
setHourInternal(newValue, true, !isTransition);
|
||||||
if (isTransition) {
|
if (isTransition) {
|
||||||
setCurrentItemShowing(MINUTE_INDEX, true, false);
|
setCurrentItemShowing(MINUTE_INDEX, true, false);
|
||||||
mDelegator.announceForAccessibility(newValue + ". " + mSelectMinutes);
|
|
||||||
|
final int localizedHour = getLocalizedHour(newValue);
|
||||||
|
mDelegator.announceForAccessibility(localizedHour + ". " + mSelectMinutes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MINUTE_INDEX:
|
case RadialTimePickerView.MINUTES:
|
||||||
setMinuteInternal(newValue, true);
|
setMinuteInternal(newValue, true);
|
||||||
break;
|
break;
|
||||||
case AMPM_INDEX:
|
|
||||||
updateAmPmLabelStates(newValue);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOnTimeChangedListener != null) {
|
if (mOnTimeChangedListener != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user