|
29 | 29 | import android.util.Log; |
30 | 30 | import android.util.SparseArray; |
31 | 31 | import android.view.LayoutInflater; |
32 | | -import android.view.View; |
33 | 32 | import android.view.accessibility.AccessibilityEvent; |
| 33 | +import android.view.accessibility.AccessibilityManager; |
34 | 34 | import android.view.accessibility.AccessibilityNodeInfo; |
35 | 35 | import android.view.inputmethod.EditorInfo; |
36 | 36 | import android.view.inputmethod.InputMethodManager; |
@@ -280,7 +280,9 @@ public void onSelectedDayChange(CalendarView view, int year, int month, int mont |
280 | 280 | reorderSpinners(); |
281 | 281 |
|
282 | 282 | // set content descriptions |
283 | | - setContentDescriptions(); |
| 283 | + if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 284 | + setContentDescriptions(); |
| 285 | + } |
284 | 286 | } |
285 | 287 |
|
286 | 288 | /** |
@@ -715,27 +717,20 @@ private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIn |
715 | 717 |
|
716 | 718 | private void setContentDescriptions() { |
717 | 719 | // Day |
718 | | - trySetContentDescription(mDaySpinner, R.id.increment, |
719 | | - R.string.date_picker_increment_day_button); |
720 | | - trySetContentDescription(mDaySpinner, R.id.decrement, |
721 | | - R.string.date_picker_decrement_day_button); |
| 720 | + String text = mContext.getString(R.string.date_picker_increment_day_button); |
| 721 | + mDaySpinner.findViewById(R.id.increment).setContentDescription(text); |
| 722 | + text = mContext.getString(R.string.date_picker_decrement_day_button); |
| 723 | + mDaySpinner.findViewById(R.id.decrement).setContentDescription(text); |
722 | 724 | // Month |
723 | | - trySetContentDescription(mMonthSpinner, R.id.increment, |
724 | | - R.string.date_picker_increment_month_button); |
725 | | - trySetContentDescription(mMonthSpinner, R.id.decrement, |
726 | | - R.string.date_picker_decrement_month_button); |
| 725 | + text = mContext.getString(R.string.date_picker_increment_month_button); |
| 726 | + mMonthSpinner.findViewById(R.id.increment).setContentDescription(text); |
| 727 | + text = mContext.getString(R.string.date_picker_decrement_month_button); |
| 728 | + mMonthSpinner.findViewById(R.id.decrement).setContentDescription(text); |
727 | 729 | // Year |
728 | | - trySetContentDescription(mYearSpinner, R.id.increment, |
729 | | - R.string.date_picker_increment_year_button); |
730 | | - trySetContentDescription(mYearSpinner, R.id.decrement, |
731 | | - R.string.date_picker_decrement_year_button); |
732 | | - } |
733 | | - |
734 | | - private void trySetContentDescription(View root, int viewId, int contDescResId) { |
735 | | - View target = root.findViewById(viewId); |
736 | | - if (target != null) { |
737 | | - target.setContentDescription(mContext.getString(contDescResId)); |
738 | | - } |
| 730 | + text = mContext.getString(R.string.date_picker_increment_year_button); |
| 731 | + mYearSpinner.findViewById(R.id.increment).setContentDescription(text); |
| 732 | + text = mContext.getString(R.string.date_picker_decrement_year_button); |
| 733 | + mYearSpinner.findViewById(R.id.decrement).setContentDescription(text); |
739 | 734 | } |
740 | 735 |
|
741 | 736 | private void updateInputState() { |
|
0 commit comments