Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75f7bfdc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use localized hour when announcing selection for accessibility" into nyc-mr1-dev

parents f6fcb7b7 66a8562c
Loading
Loading
Loading
Loading
+31 −7
Original line number Diff line number Diff line
@@ -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;

+7 −11
Original line number Diff line number Diff line
@@ -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) {