Search code examples
androidtimepicker

TimePicker accepts values higher than 24h


I'm using TimePicker and on newer devices, there is an option to set values from the keyboard:

TimePicker

The problem is that, input accepts values way above 24h. User can put there any 2 digits number (e.g. 82) and still can click "OK".

TimePicker with keyboard input

Because of obvious reasons, it is not acceptable behavior. Is there any way to restrict what values are accepted or at least block the possibility to use the keyboard to input hours/minutes?

Ps. I'm using Afollestad's material dialogs, but as far as I know, he is using default TimePicker below, the only differences are styles and few extensions. I tried without this library, just by using TimePickerDialog and it's exactly the same. If a user sets input higher than 23/59 it's just set to 23/59 accordingly.

Edit: My bad, now I can see that, dialog from this library is not validating the input. With the default implementation, click validates input.


Solution

  • The problem was with the library I've used. I made a PR that fixes this issue. Hopefully, it will be merged in the close future.