vikramkakkar / SublimePicker

A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.
Apache License 2.0
2.31k stars 407 forks source link

setMinTime, setMaxTime? #9

Open adammbalogh opened 9 years ago

adammbalogh commented 9 years ago

Do you plan a min/max time implementation for hours and minutes?

Rainer-Lang commented 9 years ago

And please also for dates.

adammbalogh commented 9 years ago

@Rainer-Lang I've not used this library yet, but I guess you can do this now with setMinDate

Rainer-Lang commented 9 years ago

Will try.

vikramkakkar commented 9 years ago

@Rainer-Lang Date range can be set using SublimeOption#setDateRange(long, long):

https://github.com/vikramkakkar/SublimePicker/blob/master/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/helpers/SublimeOptions.java#L121

@adammbalogh I haven't planned for such a feature. Are we only talking about a time range, for example: User can only pick between 16:00 hrs - 18:00 hrs. Or do we also need to define valid & invalid times?

adammbalogh commented 9 years ago

@vikramkakkar Only a time range, yes. Anyway does this library handle minutes as well?

Rainer-Lang commented 9 years ago

I need that the user can only select now and future time.

Rainer-Lang commented 9 years ago

so parameter are "now" for minDate and -1L for maxDate?

vikramkakkar commented 9 years ago

@Rainer-Lang Yes. "new Date().getTime()" should work fine for minDate. Passing Long.MIN_VALUE for maxDate will tell SublimePicker to keep future dates open for selection.

Note: The comment above setDateRange(long, long) is wrong. Passing -1L will not work as intended. The relevant check is performed here: https://github.com/vikramkakkar/SublimePicker/blob/master/sublimepickerlibrary/src/main/java/com/appeaser/sublimepickerlibrary/SublimePicker.java#L515

Pass Long.MIN_VALUE for whichever bound you wish to keep open: minDate/maxDate.

Rainer-Lang commented 9 years ago

I need the time range also: from now (time) to future. No past time.

@vikramkakkar minDate/maxDate is working - thanks.

Rainer-Lang commented 9 years ago

The problem here is, if there is also minDate or maxDate defined - AND both date and time picker are shown. So the date and time picker min/max are associated.

eg all dates from now are allowed: now we have 28/07/2015 09:10 AM -> minDate=28/07/2015; minTime=09:10 AM But allowed is eg 30/07/2015 08:00 AM. Do you know what I mean? That's a bit tricky ;-) But I "nice" problem to solve and to make SublimePicker better and better!

Qw4z1 commented 9 years ago

@Rainer-Lang Let me see if I understand you correctly: You want to be able to set a date range, e.g. now to same day next week and set a time range, eg. 4AM to 12PM that applies to all dates? That is something that I would like to have. I would also like to have the TimePicker to respect the range so that it overrides the hypothetical setTimeRage so that the first date in the range can have a later startTime and the last date in the range can have an earlier endTime then the rest of the dates.

Tricky indeed, but I think I will implement this for the project I'm working on right now, but since I need to set this dynamically I will probably also add setters to SublimePicker delegating to the Time and Date pickers. Don't know if this is something that you want to have included if/when I make a pull request.

Rainer-Lang commented 9 years ago

@Qw4z1 For me it would be enough if I could set a minTime, so the user could no set a time earlier than this time. Same for maxTime - and this independent of dates.

And what I also need is the possibilty to set a minDateTime (also maxDateTime) - so the user could not set a date or time earlier than the minDateTime.

I hope you understand me. :-)

Is it right that you want to get or the user can set: Mo 4AM-12PM, Tu 4AM-12PM, ...?

Qw4z1 commented 9 years ago

@Rainer-Lang Cool. So I guess we're basically on the same page here. Difference here being that I proposed setting a range (say 4AM - 12PM) and you want to be able to set them individually, which I can agree makes for a better API.

I'm building a parking app here so when I think about it, what I really would want is the ability to set multiple constraints on a week, such as Mo-Th 10-18, Fri 11-15, Sa-Su no times available. And I would also like to have an arbitrary time range which takes both time and date into account, pretty much exactly like the minDateTime and maxDateTime that you proposed. I think the constraint part is a bit to complex for the first version, so I'll have to think about that, but min- and maxTimeDate is definitely happening. =)

Rainer-Lang commented 9 years ago

@Qw4z1 What we - you and I ;-) - need are separated methods for min/maxDate (already done), min/maxTime and min/maxDateTime. min/maxTime is also needed if the TimePicker is started without the DatePicker.

Rainer-Lang commented 9 years ago

@Qw4z1 For ranges and an idea to do it look here: https://github.com/yesidlazaro/DateRangePicker

Rainer-Lang commented 9 years ago

Any news?