Loading core/java/android/widget/DatePicker.java +31 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.NumberPicker.OnValueChangeListener; import com.android.internal.R; Loading Loading @@ -264,6 +265,11 @@ public class DatePicker extends FrameLayout { // re-order the number spinners to match the current date format reorderSpinners(); // set content descriptions if (AccessibilityManager.getInstance(mContext).isEnabled()) { setContentDescriptions(); } } /** Loading Loading @@ -356,12 +362,17 @@ public class DatePicker extends FrameLayout { return mIsEnabled; } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { onPopulateAccessibilityEvent(event); return true; } @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR; final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; String selectedDateUtterance = DateUtils.formatDateTime(mContext, mCurrentDate.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); Loading Loading @@ -709,5 +720,22 @@ public class DatePicker extends FrameLayout { } }; } } private void setContentDescriptions() { // Day String text = mContext.getString(R.string.date_picker_increment_day_button); mDaySpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_day_button); mDaySpinner.findViewById(R.id.decrement).setContentDescription(text); // Month text = mContext.getString(R.string.date_picker_increment_month_button); mMonthSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_month_button); mMonthSpinner.findViewById(R.id.decrement).setContentDescription(text); // Year text = mContext.getString(R.string.date_picker_increment_year_button); mYearSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_year_button); mYearSpinner.findViewById(R.id.decrement).setContentDescription(text); } } core/java/android/widget/NumberPicker.java +31 −7 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Paint.Align; import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.text.InputFilter; import android.text.InputType; import android.text.Spanned; Loading @@ -48,6 +49,8 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.LayoutInflater.Filter; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -471,7 +474,7 @@ public class NumberPicker extends LinearLayout { // the fading edge effect implemented by View and we need our // draw() method to be called. Therefore, we declare we will draw. setWillNotDraw(false); setDrawSelectorWheel(false); setDrawScrollWheel(false); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); Loading Loading @@ -561,7 +564,7 @@ public class NumberPicker extends LinearLayout { public void onAnimationEnd(Animator animation) { if (!mCanceled) { // if canceled => we still want the wheel drawn setDrawSelectorWheel(false); setDrawScrollWheel(false); } mCanceled = false; mSelectorPaint.setAlpha(255); Loading @@ -587,7 +590,7 @@ public class NumberPicker extends LinearLayout { // Start with shown selector wheel and hidden controls. When made // visible hide the selector and fade-in the controls to suggest // fling interaction. setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); } } Loading Loading @@ -630,7 +633,7 @@ public class NumberPicker extends LinearLayout { || (!mDecrementButton.isShown() && isEventInViewHitRect(event, mDecrementButton))) { mAdjustScrollerOnUpEvent = false; setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); return true; } Loading @@ -641,7 +644,7 @@ public class NumberPicker extends LinearLayout { if (deltaDownY > mTouchSlop) { mBeginEditOnUpEvent = false; onScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL); setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); return true; } Loading Loading @@ -678,7 +681,7 @@ public class NumberPicker extends LinearLayout { break; case MotionEvent.ACTION_UP: if (mBeginEditOnUpEvent) { setDrawSelectorWheel(false); setDrawScrollWheel(false); showInputControls(mShowInputControlsAnimimationDuration); mInputText.requestFocus(); InputMethodManager imm = (InputMethodManager) getContext().getSystemService( Loading Loading @@ -1135,6 +1138,12 @@ public class NumberPicker extends LinearLayout { } } @Override public void sendAccessibilityEvent(int eventType) { // Do not send accessibility events - we want the user to // perceive this widget as several controls rather as a whole. } /** * Resets the selector indices and clear the cached * string representation of these indices. Loading Loading @@ -1192,10 +1201,19 @@ public class NumberPicker extends LinearLayout { /** * Sets if to <code>drawSelectionWheel</code>. */ private void setDrawSelectorWheel(boolean drawSelectorWheel) { private void setDrawScrollWheel(boolean drawSelectorWheel) { mDrawSelectorWheel = drawSelectorWheel; // do not fade if the selector wheel not shown setVerticalFadingEdgeEnabled(drawSelectorWheel); if (mFlingable && mDrawSelectorWheel && AccessibilityManager.getInstance(mContext).isEnabled()) { AccessibilityManager.getInstance(mContext).interrupt(); String text = mContext.getString(R.string.number_picker_increment_scroll_action); mInputText.setContentDescription(text); mInputText.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); mInputText.setContentDescription(null); } } private void initializeScrollWheel() { Loading Loading @@ -1429,6 +1447,12 @@ public class NumberPicker extends LinearLayout { mInputText.setText(mDisplayedValues[mValue - mMinValue]); } mInputText.setSelection(mInputText.getText().length()); if (mFlingable && AccessibilityManager.getInstance(mContext).isEnabled()) { String text = mContext.getString(R.string.number_picker_increment_scroll_mode, mInputText.getText()); mInputText.setContentDescription(text); } } /** Loading core/java/android/widget/TimePicker.java +30 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.NumberPicker.OnValueChangeListener; import java.text.DateFormatSymbols; Loading Loading @@ -227,6 +228,11 @@ public class TimePicker extends FrameLayout { if (!isEnabled()) { setEnabled(false); } // set the content descriptions if (AccessibilityManager.getInstance(mContext).isEnabled()) { setContentDescriptions(); } } @Override Loading Loading @@ -432,6 +438,12 @@ public class TimePicker extends FrameLayout { return mHourSpinner.getBaseline(); } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { onPopulateAccessibilityEvent(event); return true; } @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); Loading Loading @@ -487,4 +499,22 @@ public class TimePicker extends FrameLayout { mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute()); } } private void setContentDescriptions() { // Minute String text = mContext.getString(R.string.time_picker_increment_minute_button); mMinuteSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_minute_button); mMinuteSpinner.findViewById(R.id.decrement).setContentDescription(text); // Hour text = mContext.getString(R.string.time_picker_increment_hour_button); mHourSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_hour_button); mHourSpinner.findViewById(R.id.decrement).setContentDescription(text); // AM/PM text = mContext.getString(R.string.time_picker_increment_set_pm_button); mAmPmSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_set_am_button); mAmPmSpinner.findViewById(R.id.decrement).setContentDescription(text); } } core/res/res/values/strings.xml +32 −0 Original line number Diff line number Diff line Loading @@ -3091,6 +3091,38 @@ <string name="number_picker_increment_button">Increment</string> <!-- Description of the button to decrement the NumberPicker value. [CHAR LIMIT=NONE] --> <string name="number_picker_decrement_button">Decrement</string> <!-- Description of the tap and hold action to get into scroll mode in NumberPicker. [CHAR LIMIT=NONE] --> <string name="number_picker_increment_scroll_mode"><xliff:g id="value" example="3">%s</xliff:g> tap and hold.</string> <!-- Description of the scrolling action in NumberPicker. [CHAR LIMIT=NONE] --> <string name="number_picker_increment_scroll_action">Slide up to increment and down to decrement.</string> <!-- TimePicker - accessibility support --> <!-- Description of the button to increment the TimePicker's minute value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_minute_button">Increment minute</string> <!-- Description of the button to decrement the TimePicker's minute value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_minute_button">Decrement minute</string> <!-- Description of the button to increment the TimePicker's hour value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_hour_button">Increment hour</string> <!-- Description of the button to decrement the TimePicker's hour value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_hour_button">Decrement hour</string> <!-- Description of the button to increment the TimePicker's set PM value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_set_pm_button">Set PM</string> <!-- Description of the button to decrement the TimePicker's set AM value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_set_am_button">Set AM</string> <!-- DatePicker - accessibility support --> <!-- Description of the button to increment the DatePicker's month value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_month_button">Increment month</string> <!-- Description of the button to decrement the DatePicker's month value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_month_button">Decrement month</string> <!-- Description of the button to increment the DatePicker's day value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_day_button">Increment day</string> <!-- Description of the button to decrement the DatePicker's day value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_day_button">Decrement day</string> <!-- Description of the button to increment the DatePicker's year value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_year_button">Increment year</string> <!-- Description of the button to decrement the DatePicker's year value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_year_button">Decrement year</string> <!-- CheckBox - accessibility support --> <!-- Description of the checked state of a CheckBox. [CHAR LIMIT=NONE] --> Loading Loading
core/java/android/widget/DatePicker.java +31 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.NumberPicker.OnValueChangeListener; import com.android.internal.R; Loading Loading @@ -264,6 +265,11 @@ public class DatePicker extends FrameLayout { // re-order the number spinners to match the current date format reorderSpinners(); // set content descriptions if (AccessibilityManager.getInstance(mContext).isEnabled()) { setContentDescriptions(); } } /** Loading Loading @@ -356,12 +362,17 @@ public class DatePicker extends FrameLayout { return mIsEnabled; } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { onPopulateAccessibilityEvent(event); return true; } @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR; final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; String selectedDateUtterance = DateUtils.formatDateTime(mContext, mCurrentDate.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); Loading Loading @@ -709,5 +720,22 @@ public class DatePicker extends FrameLayout { } }; } } private void setContentDescriptions() { // Day String text = mContext.getString(R.string.date_picker_increment_day_button); mDaySpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_day_button); mDaySpinner.findViewById(R.id.decrement).setContentDescription(text); // Month text = mContext.getString(R.string.date_picker_increment_month_button); mMonthSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_month_button); mMonthSpinner.findViewById(R.id.decrement).setContentDescription(text); // Year text = mContext.getString(R.string.date_picker_increment_year_button); mYearSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.date_picker_decrement_year_button); mYearSpinner.findViewById(R.id.decrement).setContentDescription(text); } }
core/java/android/widget/NumberPicker.java +31 −7 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Paint.Align; import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.text.InputFilter; import android.text.InputType; import android.text.Spanned; Loading @@ -48,6 +49,8 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.LayoutInflater.Filter; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -471,7 +474,7 @@ public class NumberPicker extends LinearLayout { // the fading edge effect implemented by View and we need our // draw() method to be called. Therefore, we declare we will draw. setWillNotDraw(false); setDrawSelectorWheel(false); setDrawScrollWheel(false); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); Loading Loading @@ -561,7 +564,7 @@ public class NumberPicker extends LinearLayout { public void onAnimationEnd(Animator animation) { if (!mCanceled) { // if canceled => we still want the wheel drawn setDrawSelectorWheel(false); setDrawScrollWheel(false); } mCanceled = false; mSelectorPaint.setAlpha(255); Loading @@ -587,7 +590,7 @@ public class NumberPicker extends LinearLayout { // Start with shown selector wheel and hidden controls. When made // visible hide the selector and fade-in the controls to suggest // fling interaction. setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); } } Loading Loading @@ -630,7 +633,7 @@ public class NumberPicker extends LinearLayout { || (!mDecrementButton.isShown() && isEventInViewHitRect(event, mDecrementButton))) { mAdjustScrollerOnUpEvent = false; setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); return true; } Loading @@ -641,7 +644,7 @@ public class NumberPicker extends LinearLayout { if (deltaDownY > mTouchSlop) { mBeginEditOnUpEvent = false; onScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL); setDrawSelectorWheel(true); setDrawScrollWheel(true); hideInputControls(); return true; } Loading Loading @@ -678,7 +681,7 @@ public class NumberPicker extends LinearLayout { break; case MotionEvent.ACTION_UP: if (mBeginEditOnUpEvent) { setDrawSelectorWheel(false); setDrawScrollWheel(false); showInputControls(mShowInputControlsAnimimationDuration); mInputText.requestFocus(); InputMethodManager imm = (InputMethodManager) getContext().getSystemService( Loading Loading @@ -1135,6 +1138,12 @@ public class NumberPicker extends LinearLayout { } } @Override public void sendAccessibilityEvent(int eventType) { // Do not send accessibility events - we want the user to // perceive this widget as several controls rather as a whole. } /** * Resets the selector indices and clear the cached * string representation of these indices. Loading Loading @@ -1192,10 +1201,19 @@ public class NumberPicker extends LinearLayout { /** * Sets if to <code>drawSelectionWheel</code>. */ private void setDrawSelectorWheel(boolean drawSelectorWheel) { private void setDrawScrollWheel(boolean drawSelectorWheel) { mDrawSelectorWheel = drawSelectorWheel; // do not fade if the selector wheel not shown setVerticalFadingEdgeEnabled(drawSelectorWheel); if (mFlingable && mDrawSelectorWheel && AccessibilityManager.getInstance(mContext).isEnabled()) { AccessibilityManager.getInstance(mContext).interrupt(); String text = mContext.getString(R.string.number_picker_increment_scroll_action); mInputText.setContentDescription(text); mInputText.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); mInputText.setContentDescription(null); } } private void initializeScrollWheel() { Loading Loading @@ -1429,6 +1447,12 @@ public class NumberPicker extends LinearLayout { mInputText.setText(mDisplayedValues[mValue - mMinValue]); } mInputText.setSelection(mInputText.getText().length()); if (mFlingable && AccessibilityManager.getInstance(mContext).isEnabled()) { String text = mContext.getString(R.string.number_picker_increment_scroll_mode, mInputText.getText()); mInputText.setContentDescription(text); } } /** Loading
core/java/android/widget/TimePicker.java +30 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.NumberPicker.OnValueChangeListener; import java.text.DateFormatSymbols; Loading Loading @@ -227,6 +228,11 @@ public class TimePicker extends FrameLayout { if (!isEnabled()) { setEnabled(false); } // set the content descriptions if (AccessibilityManager.getInstance(mContext).isEnabled()) { setContentDescriptions(); } } @Override Loading Loading @@ -432,6 +438,12 @@ public class TimePicker extends FrameLayout { return mHourSpinner.getBaseline(); } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { onPopulateAccessibilityEvent(event); return true; } @Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); Loading Loading @@ -487,4 +499,22 @@ public class TimePicker extends FrameLayout { mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute()); } } private void setContentDescriptions() { // Minute String text = mContext.getString(R.string.time_picker_increment_minute_button); mMinuteSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_minute_button); mMinuteSpinner.findViewById(R.id.decrement).setContentDescription(text); // Hour text = mContext.getString(R.string.time_picker_increment_hour_button); mHourSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_hour_button); mHourSpinner.findViewById(R.id.decrement).setContentDescription(text); // AM/PM text = mContext.getString(R.string.time_picker_increment_set_pm_button); mAmPmSpinner.findViewById(R.id.increment).setContentDescription(text); text = mContext.getString(R.string.time_picker_decrement_set_am_button); mAmPmSpinner.findViewById(R.id.decrement).setContentDescription(text); } }
core/res/res/values/strings.xml +32 −0 Original line number Diff line number Diff line Loading @@ -3091,6 +3091,38 @@ <string name="number_picker_increment_button">Increment</string> <!-- Description of the button to decrement the NumberPicker value. [CHAR LIMIT=NONE] --> <string name="number_picker_decrement_button">Decrement</string> <!-- Description of the tap and hold action to get into scroll mode in NumberPicker. [CHAR LIMIT=NONE] --> <string name="number_picker_increment_scroll_mode"><xliff:g id="value" example="3">%s</xliff:g> tap and hold.</string> <!-- Description of the scrolling action in NumberPicker. [CHAR LIMIT=NONE] --> <string name="number_picker_increment_scroll_action">Slide up to increment and down to decrement.</string> <!-- TimePicker - accessibility support --> <!-- Description of the button to increment the TimePicker's minute value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_minute_button">Increment minute</string> <!-- Description of the button to decrement the TimePicker's minute value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_minute_button">Decrement minute</string> <!-- Description of the button to increment the TimePicker's hour value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_hour_button">Increment hour</string> <!-- Description of the button to decrement the TimePicker's hour value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_hour_button">Decrement hour</string> <!-- Description of the button to increment the TimePicker's set PM value. [CHAR LIMIT=NONE] --> <string name="time_picker_increment_set_pm_button">Set PM</string> <!-- Description of the button to decrement the TimePicker's set AM value. [CHAR LIMIT=NONE] --> <string name="time_picker_decrement_set_am_button">Set AM</string> <!-- DatePicker - accessibility support --> <!-- Description of the button to increment the DatePicker's month value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_month_button">Increment month</string> <!-- Description of the button to decrement the DatePicker's month value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_month_button">Decrement month</string> <!-- Description of the button to increment the DatePicker's day value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_day_button">Increment day</string> <!-- Description of the button to decrement the DatePicker's day value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_day_button">Decrement day</string> <!-- Description of the button to increment the DatePicker's year value. [CHAR LIMIT=NONE] --> <string name="date_picker_increment_year_button">Increment year</string> <!-- Description of the button to decrement the DatePicker's year value. [CHAR LIMIT=NONE] --> <string name="date_picker_decrement_year_button">Decrement year</string> <!-- CheckBox - accessibility support --> <!-- Description of the checked state of a CheckBox. [CHAR LIMIT=NONE] --> Loading