Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1667)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java

Issue 15533003: [Android] Implement min/max on all supported date types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java b/content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java
index 11189c5ac8fff0fe37807e8fef8ed3fd549e438b..f1839eabf068617c60cbbb5fafe94d3725c35188 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java
@@ -102,26 +102,40 @@ public class InputDialogContainer {
}
void showDialog(final int dialogType, int year, int month, int monthDay,
- int hour, int minute, int second) {
+ int hour, int minute, int second, double min, double max) {
if (isDialogShowing()) mDialog.dismiss();
+ // Java Date dialogs like longs but Blink prefers doubles..
+ // Both parameters mean different things depending on the type
+ // For input type=month min and max come as number on months since 1970
+ // For other types (including type=time) they are just milliseconds since 1970
+ // In any case the cast here is safe given the above restrictions.
+ long minTime = (long) min;
+ long maxTime = (long) max;
+
Time time = normalizeTime(year, month, monthDay, hour, minute, second);
if (dialogType == sTextInputTypeDate) {
- mDialog = new DatePickerDialog(mContext, new DateListener(dialogType),
+ DatePickerDialog dialog = new DatePickerDialog(mContext, new DateListener(dialogType),
time.year, time.month, time.monthDay);
- mDialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
+ DateDialogNormalizer.normalize(dialog.getDatePicker(), dialog,
bulach 2013/05/21 17:26:35 could this be done inside DatePickerDialog constru
Miguel Garcia 2013/05/23 12:16:48 Well DatePickerDialog is an Android system class,
+ time.year, time.month, time.monthDay, minTime, maxTime);
+
+ dialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
+ mDialog = dialog;
} else if (dialogType == sTextInputTypeTime) {
- mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType),
- time.hour, time.minute, DateFormat.is24HourFormat(mContext));
+ mDialog = TimeDialog.create(mContext, new TimeListener(dialogType),
+ 1970, 0, 1, time.hour, time.minute, DateFormat.is24HourFormat(mContext),
+ minTime, maxTime);
} else if (dialogType == sTextInputTypeDateTime ||
dialogType == sTextInputTypeDateTimeLocal) {
mDialog = new DateTimePickerDialog(mContext,
new DateTimeListener(dialogType),
time.year, time.month, time.monthDay,
- time.hour, time.minute, DateFormat.is24HourFormat(mContext));
+ time.hour, time.minute, DateFormat.is24HourFormat(mContext),
+ minTime, maxTime);
} else if (dialogType == sTextInputTypeMonth) {
mDialog = new MonthPickerDialog(mContext, new MonthListener(dialogType),
- time.year, time.month);
+ time.year, time.month, minTime, maxTime);
}
mDialog.setButton(DialogInterface.BUTTON_POSITIVE,

Powered by Google App Engine
This is Rietveld 408576698