|
29 | 29 | import android.util.Log; |
30 | 30 | import android.util.SparseArray; |
31 | 31 | import android.view.LayoutInflater; |
| 32 | +import android.view.View; |
32 | 33 | 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,9 +280,7 @@ public void onSelectedDayChange(CalendarView view, int year, int month, int mont |
280 | 280 | reorderSpinners(); |
281 | 281 |
|
282 | 282 | // set content descriptions |
283 | | - if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
284 | | - setContentDescriptions(); |
285 | | - } |
| 283 | + setContentDescriptions(); |
286 | 284 | } |
287 | 285 |
|
288 | 286 | /** |
@@ -717,20 +715,27 @@ private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIn |
717 | 715 |
|
718 | 716 | private void setContentDescriptions() { |
719 | 717 | // Day |
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); |
| 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); |
724 | 722 | // Month |
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); |
| 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); |
729 | 727 | // Year |
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); |
| 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 | + } |
734 | 739 | } |
735 | 740 |
|
736 | 741 | private void updateInputState() { |
|
0 commit comments