Commit fabb27e9 authored by shaktisahu's avatar shaktisahu Committed by Commit bot

Updated time picker to use new clock UI format

For setting time in an webpage (<input type=time>), clank currently
displays a spinner to set the time. This CL updates it to show the
standard clock UI provided by android. However the clock UI doesn't
have precision for seconds and milliseconds. In those cases, the
multi-field spinner will be displayed.

BUG=541353

Review-Url: https://codereview.chromium.org/2569943002
Cr-Commit-Position: refs/heads/master@{#438988}
parent f58de349
......@@ -6,6 +6,8 @@ package org.chromium.content.browser.picker;
import android.app.AlertDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
......@@ -210,12 +212,16 @@ public class InputDialogContainer {
dialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
mDialog = dialog;
} else if (dialogType == TextInputType.TIME) {
mDialog = new MultiFieldTimePickerDialog(
mContext, 0 /* theme */ ,
hourOfDay, minute, second, millis,
(int) min, (int) max, stepTime,
DateFormat.is24HourFormat(mContext),
new FullTimeListener(dialogType));
// If user doesn't need to set seconds and milliseconds, show the default clock style
// time picker dialog. Otherwise, show a full spinner style time picker.
if (stepTime < 0 || stepTime >= 60000 /* milliseconds in a minute */) {
mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType), hourOfDay,
minute, DateFormat.is24HourFormat(mContext));
} else {
mDialog = new MultiFieldTimePickerDialog(mContext, 0 /* theme */, hourOfDay, minute,
second, millis, (int) min, (int) max, stepTime,
DateFormat.is24HourFormat(mContext), new FullTimeListener(dialogType));
}
} else if (dialogType == TextInputType.DATE_TIME
|| dialogType == TextInputType.DATE_TIME_LOCAL) {
mDialog = new DateTimePickerDialog(mContext,
......@@ -285,6 +291,18 @@ public class InputDialogContainer {
}
}
private class TimeListener implements OnTimeSetListener {
private final int mDialogType;
TimeListener(int dialogType) {
mDialogType = dialogType;
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
setFieldDateTimeValue(mDialogType, 0, 0, 0, hourOfDay, minute, 0, 0, 0);
}
}
private class FullTimeListener implements OnMultiFieldTimeSetListener {
private final int mDialogType;
FullTimeListener(int dialogType) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment