Skip to content

Commit

Permalink
fix: date time picker minute step support
Browse files Browse the repository at this point in the history
Previously the minute step setting was ignored in the picker for DateTime types.  This is corrected now.
#3737
  • Loading branch information
shannah committed Oct 21, 2023
1 parent 0f340e2 commit 39f3132
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
22 changes: 15 additions & 7 deletions CodenameOne/src/com/codename1/ui/spinner/DateTimeSpinner3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ class DateTimeSpinner3D extends Container implements InternalPickerWidget {
/**
* Default constructor
*/
public DateTimeSpinner3D() {
public DateTimeSpinner3D(int minuteStep) {
off = 0;
initSpinner();
initSpinner(minuteStep);
}

public DateTimeSpinner3D() {
this(TimeSpinner3D.DEFAULT_MINUTE_STEP);
}

void initSpinner() {
void initSpinner(int minuteStep) {
if(date == null) {
date = Spinner3D.createDate(startDate.getTime() + off, endDate.getTime() + off, currentDate.getTime());
date.setPreferredW((int)(new Label("Thu Dec 27", "Spinner3DRow").getPreferredW() * 1.5f ));
Expand All @@ -76,13 +80,17 @@ void initSpinner() {
this.setStartDate(startDate);
this.setEndDate(endDate);

time = new TimeSpinner3D();
//getUnselectedStyle().setBgColor(date.getUnselectedStyle().getBgColor());
//getUnselectedStyle().setBgTransparency(255);
time = new TimeSpinner3D(minuteStep);
addComponents();

}
}

public int getMinuteStep() {
return time.getMinuteStep();
}

public void setMinuteStep(int minuteStep) {
time.setMinuteStep(minuteStep);
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions CodenameOne/src/com/codename1/ui/spinner/Picker.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ private CalendarPicker createCalendarPicker() {
}

private TimeSpinner3D createTimePicker3D() {
TimeSpinner3D out = new TimeSpinner3D();
out.setMinuteStep(minuteStep);
TimeSpinner3D out = new TimeSpinner3D(minuteStep);
out.setShowMeridiem(showMeridiem);
if (minHour >= 0 && minHour < 24 && maxHour > minHour) {
out.setHourRange(minHour, maxHour);
Expand All @@ -542,7 +541,7 @@ private TimeSpinner3D createTimePicker3D() {
}

private DateTimeSpinner3D createDateTimePicker3D() {
DateTimeSpinner3D out = new DateTimeSpinner3D();
DateTimeSpinner3D out = new DateTimeSpinner3D(minuteStep);
out.setShowMeridiem(showMeridiem);
if (startDate != null) {
out.setStartDate(startDate);
Expand Down
11 changes: 9 additions & 2 deletions CodenameOne/src/com/codename1/ui/spinner/TimeSpinner3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* @author Steve Hannah
*/
class TimeSpinner3D extends Container implements InternalPickerWidget {

static final int DEFAULT_MINUTE_STEP = 5;
private Spinner3D hour;
private Spinner3D minute;
private Spinner3D amPM;
Expand All @@ -55,7 +57,7 @@ class TimeSpinner3D extends Container implements InternalPickerWidget {

private int startHour = 1;
private int endHour = 12;
private int minuteStep = 5;
private int minuteStep = DEFAULT_MINUTE_STEP;

private boolean durationMode;
private boolean showHours=true;
Expand All @@ -68,9 +70,14 @@ class TimeSpinner3D extends Container implements InternalPickerWidget {
/**
* Default constructor
*/
public TimeSpinner3D() {
public TimeSpinner3D(int minuteStep) {
this.minuteStep = minuteStep;
initSpinner();
}

public TimeSpinner3D() {
this(DEFAULT_MINUTE_STEP);
}

/**
* Default constructor
Expand Down

0 comments on commit 39f3132

Please sign in to comment.