com.wdullaer.materialdatetimepicker.Utils Java Examples

The following examples show how to use com.wdullaer.materialdatetimepicker.Utils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
private void setHour(int value, boolean announce) {
    String format;
    if (mIs24HourMode) {
        format = "%02d";
    } else {
        format = "%d";
        value = value % 12;
        if (value == 0) {
            value = 12;
        }
    }

    CharSequence text = String.format(mLocale, format, value);
    mHourView.setText(text);
    mHourSpaceView.setText(text);
    if (announce) {
        Utils.tryAccessibilityAnnounce(mTimePicker, text);
    }
}
 
Example #2
Source File: DefaultDateRangeLimiterPropertyTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Property
public void setToNearestShouldNeverBeAboveMaxDate(
        @InRange(min = "01/01/1800", max = "12/31/2099", format = "MM/dd/yyyy") Date date,
        @InRange(min = "01/01/1800", max = "12/31/2099", format = "MM/dd/yyyy") Date maxDate
) {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();

    Calendar day = Calendar.getInstance();
    day.setTime(date);

    Calendar minDay = Calendar.getInstance();
    minDay.set(Calendar.YEAR, 1800);
    minDay.set(Calendar.MONTH, Calendar.JANUARY);
    minDay.set(Calendar.DAY_OF_MONTH, 1);
    Utils.trimToMidnight(minDay);

    Calendar maxDay = Calendar.getInstance();
    maxDay.setTime(maxDate);

    limiter.setMinDate(minDay);
    limiter.setMaxDate(maxDay);
    Assert.assertTrue(Utils.trimToMidnight(maxDay).getTimeInMillis() >= limiter.setToNearestDate(day).getTimeInMillis());
}
 
Example #3
Source File: DefaultDateRangeLimiterPropertyTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Property
public void setToNearestShouldNeverBeBelowMinDate(
        @InRange(min = "01/01/1900", max = "12/31/2099", format = "MM/dd/yyyy") Date date,
        @InRange(min = "01/01/1900", max = "12/31/2099", format = "MM/dd/yyyy") Date minDate
) {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();

    Calendar day = Calendar.getInstance();
    day.setTime(date);

    Calendar minDay = Calendar.getInstance();
    minDay.setTime(minDate);

    limiter.setMinDate(minDay);
    Assert.assertTrue(Utils.trimToMidnight(minDay).getTimeInMillis() <= limiter.setToNearestDate(day).getTimeInMillis());
}
 
Example #4
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Test
public void setToNearestShouldReturn31stDecOfMaxYearWhenAfterMax() {
    // Case with just year range and no other restrictions
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();

    limiter.setYearRange(1900, 1950);
    Calendar day = Calendar.getInstance();
    day.set(Calendar.YEAR, 1970);

    Calendar expectedDay = Calendar.getInstance();
    expectedDay.set(Calendar.YEAR, 1950);
    expectedDay.set(Calendar.MONTH, Calendar.DECEMBER);
    expectedDay.set(Calendar.DAY_OF_MONTH, 31);

    Assert.assertEquals(
            Utils.trimToMidnight(expectedDay).getTimeInMillis(),
            limiter.setToNearestDate(day).getTimeInMillis()
    );
}
 
Example #5
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Test
public void setToNearestShouldRoundToFirstJanOfMinYearWhenBeforeMin() {
    // Case with just year range and no other restrictions
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();

    limiter.setYearRange(1980, 2100);
    Calendar day = Calendar.getInstance();
    day.set(Calendar.YEAR, 1970);

    Calendar expectedDay = Calendar.getInstance();
    expectedDay.set(Calendar.YEAR, 1980);
    expectedDay.set(Calendar.MONTH, Calendar.JANUARY);
    expectedDay.set(Calendar.DAY_OF_MONTH, 1);

    Assert.assertEquals(
            Utils.trimToMidnight(expectedDay).getTimeInMillis(),
            limiter.setToNearestDate(day).getTimeInMillis()
    );
}
 
Example #6
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Test
public void setToNearestShouldRoundToMaxDate() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    Calendar maxDate = Calendar.getInstance();
    maxDate.set(Calendar.YEAR, 1999);

    limiter.setMaxDate(maxDate);

    Calendar day = Calendar.getInstance();
    day.set(Calendar.YEAR, 2000);

    Assert.assertEquals(
            limiter.setToNearestDate(day).getTimeInMillis(),
            Utils.trimToMidnight(maxDate).getTimeInMillis()
    );
}
 
Example #7
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
@Test
public void setToNearestShouldRoundToMinDate() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    Calendar minDate = Calendar.getInstance();
    minDate.set(Calendar.YEAR, 1999);

    limiter.setMinDate(minDate);

    Calendar day = Calendar.getInstance();
    day.set(Calendar.YEAR, 1998);

    Assert.assertEquals(
            limiter.setToNearestDate(day).getTimeInMillis(),
            Utils.trimToMidnight(minDate).getTimeInMillis()
    );
}
 
Example #8
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
private void updateAmPmDisplay(int amOrPm) {
    if (mVersion == Version.VERSION_2) {
        if (amOrPm == AM) {
            mAmTextView.setTextColor(mSelectedColor);
            mPmTextView.setTextColor(mUnselectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
        } else {
            mAmTextView.setTextColor(mUnselectedColor);
            mPmTextView.setTextColor(mSelectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
        }
    } else {
        if (amOrPm == AM) {
            mPmTextView.setText(mAmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
            mPmTextView.setContentDescription(mAmText);
        } else if (amOrPm == PM){
            mPmTextView.setText(mPmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
            mPmTextView.setContentDescription(mPmText);
        } else {
            mPmTextView.setText(mDoublePlaceholderText);
        }
    }
}
 
Example #9
Source File: TimePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 6 votes vote down vote up
private void updateAmPmDisplay(int amOrPm) {
    if (mVersion == Version.VERSION_2) {
        if (amOrPm == AM) {
            mAmTextView.setTextColor(mSelectedColor);
            mPmTextView.setTextColor(mUnselectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
        } else {
            mAmTextView.setTextColor(mUnselectedColor);
            mPmTextView.setTextColor(mSelectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
        }
    } else {
        if (amOrPm == AM) {
            mPmTextView.setText(mAmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
            mPmTextView.setContentDescription(mAmText);
        } else if (amOrPm == PM){
            mPmTextView.setText(mPmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
            mPmTextView.setContentDescription(mPmText);
        } else {
            mPmTextView.setText(mDoublePlaceholderText);
        }
    }
}
 
Example #10
Source File: TimePickerDialog.java    From AlarmOn with Apache License 2.0 6 votes vote down vote up
private void setHour(int value, boolean announce) {
    String format;
    if (mIs24HourMode) {
        format = "%02d";
    } else {
        format = "%d";
        value = value % 12;
        if (value == 0) {
            value = 12;
        }
    }

    CharSequence text = String.format(format, value);
    mHourView.setText(text);
    mHourSpaceView.setText(text);
    if (announce) {
        Utils.tryAccessibilityAnnounce(mTimePicker, text);
    }
}
 
Example #11
Source File: TimePickerDialog.java    From Blackbulb with GNU General Public License v3.0 6 votes vote down vote up
private void setHour(int value, boolean announce) {
    String format;
    if (mIs24HourMode) {
        format = "%02d";
    } else {
        format = "%d";
        value = value % 12;
        if (value == 0) {
            value = 12;
        }
    }

    CharSequence text = String.format(format, value);
    mHourView.setText(text);
    mHourSpaceView.setText(text);
    if (announce) {
        Utils.tryAccessibilityAnnounce(mTimePicker, text);
    }
}
 
Example #12
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
private void setHour(int value, boolean announce) {
    String format;
    if (mIs24HourMode) {
        format = "%02d";
    } else {
        format = "%d";
        value = value % 12;
        if (value == 0) {
            value = 12;
        }
    }

    CharSequence text = String.format(format, value);
    mHourView.setText(text);
    mHourSpaceView.setText(text);
    if (announce) {
        Utils.tryAccessibilityAnnounce(mTimePicker, text);
    }
}
 
Example #13
Source File: TimePickerDialog.java    From Blackbulb with GNU General Public License v3.0 6 votes vote down vote up
private void updateAmPmDisplay(int amOrPm) {
    if (mVersion == Version.VERSION_2) {
        if (amOrPm == AM) {
            mAmTextView.setTextColor(mSelectedColor);
            mPmTextView.setTextColor(mUnselectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
        } else {
            mAmTextView.setTextColor(mUnselectedColor);
            mPmTextView.setTextColor(mSelectedColor);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
        }
    } else {
        if (amOrPm == AM) {
            mPmTextView.setText(mAmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mAmText);
            mPmTextView.setContentDescription(mAmText);
        } else if (amOrPm == PM){
            mPmTextView.setText(mPmText);
            Utils.tryAccessibilityAnnounce(mTimePicker, mPmText);
            mPmTextView.setContentDescription(mPmText);
        } else {
            mPmTextView.setText(mDoublePlaceholderText);
        }
    }
}
 
Example #14
Source File: TimePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
private void setMinute(int value) {
    if (value == 60) {
        value = 0;
    }
    CharSequence text = String.format(mLocale, "%02d", value);
    Utils.tryAccessibilityAnnounce(mTimePicker, text);
    mMinuteView.setText(text);
    mMinuteSpaceView.setText(text);
}
 
Example #15
Source File: TimePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
private boolean addKeyIfLegal(int keyCode) {
    // If we're in 24hour mode, we'll need to check if the input is full. If in AM/PM mode,
    // we'll need to see if AM/PM have been typed.
    int textSize = 6;
    if (mEnableMinutes && !mEnableSeconds) textSize = 4;
    if (!mEnableMinutes && !mEnableSeconds) textSize = 2;
    if ((mIs24HourMode && mTypedTimes.size() == textSize) ||
            (!mIs24HourMode && isTypedTimeFullyLegal())) {
        return false;
    }

    mTypedTimes.add(keyCode);
    if (!isTypedTimeLegalSoFar()) {
        deleteLastTypedKey();
        return false;
    }

    int val = getValFromKeyCode(keyCode);
    Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mLocale, "%d", val));
    // Automatically fill in 0's if AM or PM was legally entered.
    if (isTypedTimeFullyLegal()) {
        if (!mIs24HourMode && mTypedTimes.size() <= (textSize - 1)) {
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
        }
        mOkButton.setEnabled(true);
    }

    return true;
}
 
Example #16
Source File: TimePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
private void setSecond(int value) {
    if(value == 60) {
        value = 0;
    }
    CharSequence text = String.format(mLocale, "%02d", value);
    Utils.tryAccessibilityAnnounce(mTimePicker, text);
    mSecondView.setText(text);
    mSecondSpaceView.setText(text);
}
 
Example #17
Source File: DayPickerView.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
void accessibilityAnnouncePageChanged() {
    MonthView mv = getMostVisibleMonth();
    if (mv != null) {
        String monthYear = getMonthAndYearString(mv.mMonth, mv.mYear, mController.getLocale());
        Utils.tryAccessibilityAnnounce(this, monthYear);
    } else {
        Log.w("DayPickerView", "Tried to announce before layout was initialized");
    }
}
 
Example #18
Source File: DatePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
public void initialize(OnDateSetListener callBack, Calendar initialSelection) {
    mCallBack = callBack;
    mCalendar = Utils.trimToMidnight((Calendar) initialSelection.clone());
    mScrollOrientation = null;
    //noinspection deprecation
    setTimeZone(mCalendar.getTimeZone());

    mVersion = Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? Version.VERSION_1 : Version.VERSION_2;
}
 
Example #19
Source File: DatePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
private void updateDisplay(boolean announce) {
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));

    if (mVersion == Version.VERSION_1) {
        if (mDatePickerHeaderView != null) {
            if (mTitle != null)
                mDatePickerHeaderView.setText(mTitle);
            else {
                mDatePickerHeaderView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG,
                        mLocale));
            }
        }
        mSelectedMonthTextView.setText(MONTH_FORMAT.format(mCalendar.getTime()));
        mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    }

    if (mVersion == Version.VERSION_2) {
        mSelectedDayTextView.setText(VERSION_2_FORMAT.format(mCalendar.getTime()));
        if (mTitle != null)
            mDatePickerHeaderView.setText(mTitle.toUpperCase(mLocale));
        else
            mDatePickerHeaderView.setVisibility(View.GONE);
    }

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}
 
Example #20
Source File: DatePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an array of dates which should be highlighted when the picker is drawn
 *
 * @param highlightedDays an Array of Calendar objects containing the dates to be highlighted
 */
@SuppressWarnings("unused")
public void setHighlightedDays(Calendar[] highlightedDays) {
    for (Calendar highlightedDay : highlightedDays) {
        this.highlightedDays.add(Utils.trimToMidnight((Calendar) highlightedDay.clone()));
    }
    if (mDayPickerView != null) mDayPickerView.onChange();
}
 
Example #21
Source File: DatePickerDialog.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isHighlighted(int year, int month, int day) {
    Calendar date = Calendar.getInstance(getTimeZone());
    date.set(Calendar.YEAR, year);
    date.set(Calendar.MONTH, month);
    date.set(Calendar.DAY_OF_MONTH, day);
    Utils.trimToMidnight(date);
    return highlightedDays.contains(date);
}
 
Example #22
Source File: DayPickerGroup.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
private void init() {
    dayPickerView = new SimpleDayPickerView(getContext(), controller);
    addView(dayPickerView);

    final LayoutInflater inflater = LayoutInflater.from(getContext());
    final ViewGroup content = (ViewGroup) inflater.inflate(R.layout.mdtp_daypicker_group, this, false);

    // Transfer all children from the content to this
    while (content.getChildCount() > 0) {
        final View view = content.getChildAt(0);
        content.removeViewAt(0);
        addView(view);
    }

    prevButton = findViewById(R.id.mdtp_previous_month_arrow);
    nextButton = findViewById(R.id.mdtp_next_month_arrow);

    if (controller.getVersion() == DatePickerDialog.Version.VERSION_1) {
        int size = Utils.dpToPx(16f, getResources());
        prevButton.setMinimumHeight(size);
        prevButton.setMinimumWidth(size);
        nextButton.setMinimumHeight(size);
        nextButton.setMinimumWidth(size);
    }

    if (controller.isThemeDark()) {
        int color = ContextCompat.getColor(getContext(), R.color.mdtp_date_picker_text_normal_dark_theme);
        prevButton.setColorFilter(color);
        nextButton.setColorFilter(color);
    }

    prevButton.setOnClickListener(this);
    nextButton.setOnClickListener(this);

    dayPickerView.setOnPageListener(this);
}
 
Example #23
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Test
public void getStartDateShouldReturnMinDate() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    Calendar minDate = Calendar.getInstance();

    limiter.setMinDate(minDate);
    minDate = Utils.trimToMidnight(minDate);

    Assert.assertEquals(limiter.getStartDate().getTimeInMillis(), minDate.getTimeInMillis());
}
 
Example #24
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Test
public void getStartDateShouldReturnMinDateWhenAControllerIsSet() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    limiter.setController(controller);
    Calendar minDate = Calendar.getInstance();

    limiter.setMinDate(minDate);
    minDate = Utils.trimToMidnight(minDate);

    Assert.assertEquals(limiter.getStartDate().getTimeInMillis(), minDate.getTimeInMillis());
}
 
Example #25
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Test
public void getEndDateShouldReturnMaxDate() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    Calendar maxDate = Calendar.getInstance();

    limiter.setMaxDate(maxDate);
    maxDate = Utils.trimToMidnight(maxDate);

    Assert.assertEquals(limiter.getEndDate().getTimeInMillis(), maxDate.getTimeInMillis());
}
 
Example #26
Source File: DefaultDateRangeLimiterTest.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Test
public void getEndDateShouldReturnMaxDateWhenAControllerIsSet() {
    DefaultDateRangeLimiter limiter = new DefaultDateRangeLimiter();
    limiter.setController(controller);
    Calendar maxDate = Calendar.getInstance();

    limiter.setMaxDate(maxDate);
    maxDate = Utils.trimToMidnight(maxDate);

    Assert.assertEquals(limiter.getEndDate().getTimeInMillis(), maxDate.getTimeInMillis());
}
 
Example #27
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private boolean addKeyIfLegal(int keyCode) {
    // If we're in 24hour mode, we'll need to check if the input is full. If in AM/PM mode,
    // we'll need to see if AM/PM have been typed.
    int textSize = 6;
    if (mEnableMinutes && !mEnableSeconds) textSize = 4;
    if (!mEnableMinutes && !mEnableSeconds) textSize = 2;
    if ((mIs24HourMode && mTypedTimes.size() == textSize) ||
            (!mIs24HourMode && isTypedTimeFullyLegal())) {
        return false;
    }

    mTypedTimes.add(keyCode);
    if (!isTypedTimeLegalSoFar()) {
        deleteLastTypedKey();
        return false;
    }

    int val = getValFromKeyCode(keyCode);
    Utils.tryAccessibilityAnnounce(mTimePicker, String.format(Locale.getDefault(), "%d", val));
    // Automatically fill in 0's if AM or PM was legally entered.
    if (isTypedTimeFullyLegal()) {
        if (!mIs24HourMode && mTypedTimes.size() <= (textSize - 1)) {
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
        }
        mOkButton.setEnabled(true);
    }

    return true;
}
 
Example #28
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private void setSecond(int value) {
    if(value == 60) {
        value = 0;
    }
    CharSequence text = String.format(Locale.getDefault(), "%02d", value);
    Utils.tryAccessibilityAnnounce(mTimePicker, text);
    mSecondView.setText(text);
    mSecondSpaceView.setText(text);
}
 
Example #29
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private void setMinute(int value) {
    if (value == 60) {
        value = 0;
    }
    CharSequence text = String.format(Locale.getDefault(), "%02d", value);
    Utils.tryAccessibilityAnnounce(mTimePicker, text);
    mMinuteView.setText(text);
    mMinuteSpaceView.setText(text);
}
 
Example #30
Source File: TimePickerDialog.java    From Blackbulb with GNU General Public License v3.0 5 votes vote down vote up
private boolean addKeyIfLegal(int keyCode) {
    // If we're in 24hour mode, we'll need to check if the input is full. If in AM/PM mode,
    // we'll need to see if AM/PM have been typed.
    int textSize = 6;
    if (mEnableMinutes && !mEnableSeconds) textSize = 4;
    if (!mEnableMinutes && !mEnableSeconds) textSize = 2;
    if ((mIs24HourMode && mTypedTimes.size() == textSize) ||
            (!mIs24HourMode && isTypedTimeFullyLegal())) {
        return false;
    }

    mTypedTimes.add(keyCode);
    if (!isTypedTimeLegalSoFar()) {
        deleteLastTypedKey();
        return false;
    }

    int val = getValFromKeyCode(keyCode);
    Utils.tryAccessibilityAnnounce(mTimePicker, String.format(Locale.getDefault(), "%d", val));
    // Automatically fill in 0's if AM or PM was legally entered.
    if (isTypedTimeFullyLegal()) {
        if (!mIs24HourMode && mTypedTimes.size() <= (textSize - 1)) {
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
            mTypedTimes.add(mTypedTimes.size() - 1, KeyEvent.KEYCODE_0);
        }
        mOkButton.setEnabled(true);
    }

    return true;
}