Skip to content

Commit ca07bc1

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Revamp of the NumberPicker widget."
2 parents 0084322 + 912ab85 commit ca07bc1

File tree

89 files changed

+820
-901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+820
-901
lines changed

api/current.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26958,7 +26958,6 @@ package android.widget {
2695826958
method public void setOnValueChangedListener(android.widget.NumberPicker.OnValueChangeListener);
2695926959
method public void setValue(int);
2696026960
method public void setWrapSelectorWheel(boolean);
26961-
field public static final int SELECTOR_WHEEL_ITEM_COUNT = 5; // 0x5
2696226961
}
2696326962

2696426963
public static abstract interface NumberPicker.Formatter {

core/java/android/view/ViewGroup.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,15 +2679,6 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
26792679
return child.draw(canvas, this, drawingTime);
26802680
}
26812681

2682-
@Override
2683-
public void requestLayout() {
2684-
if (mChildrenCount > 0 && getAccessibilityNodeProvider() != null) {
2685-
throw new IllegalStateException("Views with AccessibilityNodeProvider"
2686-
+ " can't have children.");
2687-
}
2688-
super.requestLayout();
2689-
}
2690-
26912682
/**
26922683
*
26932684
* @param enabled True if children should be drawn with layers, false otherwise.
@@ -3109,11 +3100,6 @@ protected void cleanupLayoutState(View child) {
31093100
private void addViewInner(View child, int index, LayoutParams params,
31103101
boolean preventRequestLayout) {
31113102

3112-
if (getAccessibilityNodeProvider() != null) {
3113-
throw new IllegalStateException("Views with AccessibilityNodeProvider"
3114-
+ " can't have children.");
3115-
}
3116-
31173103
if (mTransition != null) {
31183104
// Don't prevent other add transitions from completing, but cancel remove
31193105
// transitions to let them complete the process before we add to the container

core/java/android/widget/DatePicker.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import android.util.Log;
3030
import android.util.SparseArray;
3131
import android.view.LayoutInflater;
32+
import android.view.View;
3233
import android.view.accessibility.AccessibilityEvent;
33-
import android.view.accessibility.AccessibilityManager;
3434
import android.view.accessibility.AccessibilityNodeInfo;
3535
import android.view.inputmethod.EditorInfo;
3636
import android.view.inputmethod.InputMethodManager;
@@ -280,9 +280,7 @@ public void onSelectedDayChange(CalendarView view, int year, int month, int mont
280280
reorderSpinners();
281281

282282
// set content descriptions
283-
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
284-
setContentDescriptions();
285-
}
283+
setContentDescriptions();
286284
}
287285

288286
/**
@@ -717,20 +715,27 @@ private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIn
717715

718716
private void setContentDescriptions() {
719717
// 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);
724722
// 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);
729727
// 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+
}
734739
}
735740

736741
private void updateInputState() {

0 commit comments

Comments
 (0)