Loading core/java/android/app/DatePickerDialog.java +4 −3 Original line number Diff line number Diff line Loading @@ -91,13 +91,14 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, mCallBack = callBack; setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), (OnClickListener) null); Context themeContext = getContext(); setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, themeContext.getText(R.string.cancel), (OnClickListener) null); setIcon(0); setTitle(R.string.date_picker_dialog_title); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.date_picker_dialog, null); setView(view); mDatePicker = (DatePicker) view.findViewById(R.id.datePicker); Loading core/java/android/app/TimePickerDialog.java +4 −4 Original line number Diff line number Diff line Loading @@ -92,16 +92,16 @@ public class TimePickerDialog extends AlertDialog mInitialMinute = minute; mIs24HourView = is24HourView; setCanceledOnTouchOutside(false); setIcon(0); setTitle(R.string.time_picker_dialog_title); setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), Context themeContext = getContext(); setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, themeContext.getText(R.string.cancel), (OnClickListener) null); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.time_picker_dialog, null); setView(view); mTimePicker = (TimePicker) view.findViewById(R.id.timePicker); Loading core/java/android/widget/NumberPicker.java +43 −10 Original line number Diff line number Diff line Loading @@ -164,6 +164,11 @@ public class NumberPicker extends LinearLayout { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; /** * Constant for unspecified size. */ private static final int SIZE_UNSPECIFIED = -1; /** * Use a custom NumberPicker formatting callback to use two-digit minutes * strings like "01". Keeping a static formatter etc. is the most efficient Loading Loading @@ -542,16 +547,20 @@ public class NumberPicker extends LinearLayout { getResources().getDisplayMetrics()); mSelectionDividerHeight = attributesArray.getDimensionPixelSize( R.styleable.NumberPicker_selectionDividerHeight, defSelectionDividerHeight); mMinHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minHeight, 0); mMinHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minHeight, SIZE_UNSPECIFIED); mMaxHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxHeight, Integer.MAX_VALUE); if (mMinHeight > mMaxHeight) { SIZE_UNSPECIFIED); if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) { throw new IllegalArgumentException("minHeight > maxHeight"); } mMinWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minWidth, 0); mMinWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minWidth, SIZE_UNSPECIFIED); mMaxWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxWidth, Integer.MAX_VALUE); if (mMinWidth > mMaxWidth) { SIZE_UNSPECIFIED); if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) { throw new IllegalArgumentException("minWidth > maxWidth"); } mComputeMaxWidth = (mMaxWidth == Integer.MAX_VALUE); Loading Loading @@ -746,10 +755,10 @@ public class NumberPicker extends LinearLayout { final int newHeightMeasureSpec = makeMeasureSpec(heightMeasureSpec, mMaxHeight); super.onMeasure(newWidthMeasureSpec, newHeightMeasureSpec); // Flag if we are measured with width or height less than the respective min. final int desiredWidth = Math.max(mMinWidth, getMeasuredWidth()); final int desiredHeight = Math.max(mMinHeight, getMeasuredHeight()); final int widthSize = resolveSizeAndState(desiredWidth, newWidthMeasureSpec, 0); final int heightSize = resolveSizeAndState(desiredHeight, newHeightMeasureSpec, 0); final int widthSize = resolveSizeAndStateRespectingMinSize(mMinWidth, getMeasuredWidth(), widthMeasureSpec); final int heightSize = resolveSizeAndStateRespectingMinSize(mMinHeight, getMeasuredHeight(), heightMeasureSpec); setMeasuredDimension(widthSize, heightSize); } Loading Loading @@ -1243,6 +1252,7 @@ public class NumberPicker extends LinearLayout { } updateInputTextView(); initializeSelectorWheelIndices(); tryComputeMaxWidth(); } @Override Loading Loading @@ -1368,6 +1378,9 @@ public class NumberPicker extends LinearLayout { * @return A measure spec greedily imposing the max size. */ private int makeMeasureSpec(int measureSpec, int maxSize) { if (maxSize == SIZE_UNSPECIFIED) { return measureSpec; } final int size = MeasureSpec.getSize(measureSpec); final int mode = MeasureSpec.getMode(measureSpec); switch (mode) { Loading @@ -1382,6 +1395,26 @@ public class NumberPicker extends LinearLayout { } } /** * Utility to reconcile a desired size and state, with constraints imposed by * a MeasureSpec. Tries to respect the min size, unless a different size is * imposed by the constraints. * * @param minSize The minimal desired size. * @param measuredSize The currently measured size. * @param measureSpec The current measure spec. * @return The resolved size and state. */ private int resolveSizeAndStateRespectingMinSize(int minSize, int measuredSize, int measureSpec) { if (minSize != SIZE_UNSPECIFIED) { final int desiredWidth = Math.max(minSize, measuredSize); return resolveSizeAndState(desiredWidth, measureSpec, 0); } else { return measuredSize; } } /** * Resets the selector indices and clear the cached * string representation of these indices. Loading core/res/res/layout/date_picker.xml +1 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ <LinearLayout android:id="@+id/pickers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="22dip" android:layout_weight="1" android:orientation="horizontal" android:gravity="center"> Loading Loading @@ -77,7 +76,7 @@ android:id="@+id/calendar_view" android:layout_width="245dip" android:layout_height="280dip" android:layout_marginLeft="22dip" android:layout_marginLeft="44dip" android:layout_weight="1" android:focusable="true" android:focusableInTouchMode="true" Loading Loading
core/java/android/app/DatePickerDialog.java +4 −3 Original line number Diff line number Diff line Loading @@ -91,13 +91,14 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener, mCallBack = callBack; setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), (OnClickListener) null); Context themeContext = getContext(); setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, themeContext.getText(R.string.cancel), (OnClickListener) null); setIcon(0); setTitle(R.string.date_picker_dialog_title); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.date_picker_dialog, null); setView(view); mDatePicker = (DatePicker) view.findViewById(R.id.datePicker); Loading
core/java/android/app/TimePickerDialog.java +4 −4 Original line number Diff line number Diff line Loading @@ -92,16 +92,16 @@ public class TimePickerDialog extends AlertDialog mInitialMinute = minute; mIs24HourView = is24HourView; setCanceledOnTouchOutside(false); setIcon(0); setTitle(R.string.time_picker_dialog_title); setButton(BUTTON_POSITIVE, context.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, context.getText(R.string.cancel), Context themeContext = getContext(); setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this); setButton(BUTTON_NEGATIVE, themeContext.getText(R.string.cancel), (OnClickListener) null); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.time_picker_dialog, null); setView(view); mTimePicker = (TimePicker) view.findViewById(R.id.timePicker); Loading
core/java/android/widget/NumberPicker.java +43 −10 Original line number Diff line number Diff line Loading @@ -164,6 +164,11 @@ public class NumberPicker extends LinearLayout { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; /** * Constant for unspecified size. */ private static final int SIZE_UNSPECIFIED = -1; /** * Use a custom NumberPicker formatting callback to use two-digit minutes * strings like "01". Keeping a static formatter etc. is the most efficient Loading Loading @@ -542,16 +547,20 @@ public class NumberPicker extends LinearLayout { getResources().getDisplayMetrics()); mSelectionDividerHeight = attributesArray.getDimensionPixelSize( R.styleable.NumberPicker_selectionDividerHeight, defSelectionDividerHeight); mMinHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minHeight, 0); mMinHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minHeight, SIZE_UNSPECIFIED); mMaxHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxHeight, Integer.MAX_VALUE); if (mMinHeight > mMaxHeight) { SIZE_UNSPECIFIED); if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) { throw new IllegalArgumentException("minHeight > maxHeight"); } mMinWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minWidth, 0); mMinWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_minWidth, SIZE_UNSPECIFIED); mMaxWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxWidth, Integer.MAX_VALUE); if (mMinWidth > mMaxWidth) { SIZE_UNSPECIFIED); if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) { throw new IllegalArgumentException("minWidth > maxWidth"); } mComputeMaxWidth = (mMaxWidth == Integer.MAX_VALUE); Loading Loading @@ -746,10 +755,10 @@ public class NumberPicker extends LinearLayout { final int newHeightMeasureSpec = makeMeasureSpec(heightMeasureSpec, mMaxHeight); super.onMeasure(newWidthMeasureSpec, newHeightMeasureSpec); // Flag if we are measured with width or height less than the respective min. final int desiredWidth = Math.max(mMinWidth, getMeasuredWidth()); final int desiredHeight = Math.max(mMinHeight, getMeasuredHeight()); final int widthSize = resolveSizeAndState(desiredWidth, newWidthMeasureSpec, 0); final int heightSize = resolveSizeAndState(desiredHeight, newHeightMeasureSpec, 0); final int widthSize = resolveSizeAndStateRespectingMinSize(mMinWidth, getMeasuredWidth(), widthMeasureSpec); final int heightSize = resolveSizeAndStateRespectingMinSize(mMinHeight, getMeasuredHeight(), heightMeasureSpec); setMeasuredDimension(widthSize, heightSize); } Loading Loading @@ -1243,6 +1252,7 @@ public class NumberPicker extends LinearLayout { } updateInputTextView(); initializeSelectorWheelIndices(); tryComputeMaxWidth(); } @Override Loading Loading @@ -1368,6 +1378,9 @@ public class NumberPicker extends LinearLayout { * @return A measure spec greedily imposing the max size. */ private int makeMeasureSpec(int measureSpec, int maxSize) { if (maxSize == SIZE_UNSPECIFIED) { return measureSpec; } final int size = MeasureSpec.getSize(measureSpec); final int mode = MeasureSpec.getMode(measureSpec); switch (mode) { Loading @@ -1382,6 +1395,26 @@ public class NumberPicker extends LinearLayout { } } /** * Utility to reconcile a desired size and state, with constraints imposed by * a MeasureSpec. Tries to respect the min size, unless a different size is * imposed by the constraints. * * @param minSize The minimal desired size. * @param measuredSize The currently measured size. * @param measureSpec The current measure spec. * @return The resolved size and state. */ private int resolveSizeAndStateRespectingMinSize(int minSize, int measuredSize, int measureSpec) { if (minSize != SIZE_UNSPECIFIED) { final int desiredWidth = Math.max(minSize, measuredSize); return resolveSizeAndState(desiredWidth, measureSpec, 0); } else { return measuredSize; } } /** * Resets the selector indices and clear the cached * string representation of these indices. Loading
core/res/res/layout/date_picker.xml +1 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ <LinearLayout android:id="@+id/pickers" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="22dip" android:layout_weight="1" android:orientation="horizontal" android:gravity="center"> Loading Loading @@ -77,7 +76,7 @@ android:id="@+id/calendar_view" android:layout_width="245dip" android:layout_height="280dip" android:layout_marginLeft="22dip" android:layout_marginLeft="44dip" android:layout_weight="1" android:focusable="true" android:focusableInTouchMode="true" Loading