Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3491b6b authored by Kenneth Andersson's avatar Kenneth Andersson Committed by Johan Redestig
Browse files

Title in DatePickerDialog used in Settings application not updated correctly

The DatePickerDialog in the Settings application is not updated correctly if you follow
the following step-by-step:
1. Enter Date option in settings application
2. Modify the values of the date, then cancel the changes
3. Once again enter the date option

and you can see that the title in the dialog has not been updated correctly. This is
due to a missing call to onDateChanged callback in the DatePicker class. Solution was
to add the notify call when updateTime has been called.
parent 7bb2581e
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -94,9 +94,7 @@ public class DatePicker extends FrameLayout {
        mDayPicker.setOnChangeListener(new OnChangedListener() {
            public void onChanged(NumberPicker picker, int oldVal, int newVal) {
                mDay = newVal;
                if (mOnDateChangedListener != null) {
                    mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
                }
                notifyDateChanged();
            }
        });
        mMonthPicker = (NumberPicker) findViewById(R.id.month);
@@ -114,9 +112,7 @@ public class DatePicker extends FrameLayout {
                mMonth = newVal - 1;
                // Adjust max day of the month
                adjustMaxDay();
                if (mOnDateChangedListener != null) {
                    mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
                }
                notifyDateChanged();
                updateDaySpinner();
            }
        });
@@ -127,9 +123,7 @@ public class DatePicker extends FrameLayout {
                mYear = newVal;
                // Adjust max day for leap years if needed
                adjustMaxDay();
                if (mOnDateChangedListener != null) {
                    mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
                }
                notifyDateChanged();
                updateDaySpinner();
            }
        });
@@ -230,11 +224,14 @@ public class DatePicker extends FrameLayout {
    }

    public void updateDate(int year, int monthOfYear, int dayOfMonth) {
        if (mYear != year || mMonth != monthOfYear || mDay != dayOfMonth) {
            mYear = year;
            mMonth = monthOfYear;
            mDay = dayOfMonth;
            updateSpinners();
            reorderPickers(new DateFormatSymbols().getShortMonths());
            notifyDateChanged();
        }
    }

    private static class SavedState extends BaseSavedState {
@@ -376,4 +373,10 @@ public class DatePicker extends FrameLayout {
            mDay = max;
        }
    }

    private void notifyDateChanged() {
        if (mOnDateChangedListener != null) {
            mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
        }
    }
}