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

Commit 2295035a authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am b17fef80: am 02e23fb0: Merge "Clamp date setting for the SetupWizard as well as Settings."

* commit 'b17fef80':
  Clamp date setting for the SetupWizard as well as Settings.
parents 11f5f984 b17fef80
Loading
Loading
Loading
Loading
+23 −29
Original line number Diff line number Diff line
@@ -233,44 +233,38 @@ public class DateTimeSettings extends SettingsPreferenceFragment

    @Override
    public Dialog onCreateDialog(int id) {
        Dialog d;

        switch (id) {
        case DIALOG_DATEPICKER: {
        final Calendar calendar = Calendar.getInstance();
            d = new DatePickerDialog(
        switch (id) {
        case DIALOG_DATEPICKER:
            DatePickerDialog d = new DatePickerDialog(
                    getActivity(),
                    this,
                    calendar.get(Calendar.YEAR),
                    calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            // The system clock can't represent dates outside this range.
            DatePickerDialog datePicker = (DatePickerDialog)d;
            Calendar t = Calendar.getInstance();
            t.clear();
            t.set(1970, Calendar.JANUARY, 1);
            datePicker.getDatePicker().setMinDate(t.getTimeInMillis());
            t.clear();
            t.set(2037, Calendar.DECEMBER, 31);
            datePicker.getDatePicker().setMaxDate(t.getTimeInMillis());
            break;
        }
        case DIALOG_TIMEPICKER: {
            final Calendar calendar = Calendar.getInstance();
            d = new TimePickerDialog(
            configureDatePicker(d.getDatePicker());
            return d;
        case DIALOG_TIMEPICKER:
            return new TimePickerDialog(
                    getActivity(),
                    this,
                    calendar.get(Calendar.HOUR_OF_DAY),
                    calendar.get(Calendar.MINUTE),
                    DateFormat.is24HourFormat(getActivity()));
            break;
        }
        default:
            d = null;
            break;
            throw new IllegalArgumentException();
        }
    }

        return d;
    static void configureDatePicker(DatePicker datePicker) {
        // The system clock can't represent dates outside this range.
        Calendar t = Calendar.getInstance();
        t.clear();
        t.set(1970, Calendar.JANUARY, 1);
        datePicker.setMinDate(t.getTimeInMillis());
        t.clear();
        t.set(2037, Calendar.DECEMBER, 31);
        datePicker.setMaxDate(t.getTimeInMillis());
    }

    /*
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ public class DateTimeSettingsSetupWizard extends Activity
        mDatePicker = (DatePicker)findViewById(R.id.date_picker);
        mDatePicker.setEnabled(!autoDateTimeEnabled);
        mDatePicker.setCalendarViewShown(false);
        DateTimeSettings.configureDatePicker(mDatePicker);

        mInputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);