Skip to content

Commit 52c1055

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Revert "Revamp of the NumberPicker widget.""
2 parents 485932f + efd1c67 commit 52c1055

File tree

89 files changed

+901
-820
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

+901
-820
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26958,6 +26958,7 @@ 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
2696126962
}
2696226963

2696326964
public static abstract interface NumberPicker.Formatter {

core/java/android/view/ViewGroup.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,15 @@ 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+
26822691
/**
26832692
*
26842693
* @param enabled True if children should be drawn with layers, false otherwise.
@@ -3100,6 +3109,11 @@ protected void cleanupLayoutState(View child) {
31003109
private void addViewInner(View child, int index, LayoutParams params,
31013110
boolean preventRequestLayout) {
31023111

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

core/java/android/widget/DatePicker.java

Lines changed: 16 additions & 21 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;
3332
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,7 +280,9 @@ public void onSelectedDayChange(CalendarView view, int year, int month, int mont
280280
reorderSpinners();
281281

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

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

716718
private void setContentDescriptions() {
717719
// 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);
722724
// 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);
727729
// 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);
739734
}
740735

741736
private void updateInputState() {

0 commit comments

Comments
 (0)