roomorama / Caldroid

A better calendar for Android
Other
1.42k stars 532 forks source link

MonthTitleTextView to LowerCase #414

Open PedroMobile opened 8 years ago

PedroMobile commented 8 years ago

How can I set MonthTitleTextView to LowerCase ?

Chris59160 commented 8 years ago

I wondered the same thing myself...and as far as I understand, the issue is the text itself is set as all caps :/. so Unless you change the text for month yourself, I am not sure it's doable.

An alternative is to modify the source code yourself

Chris59160 commented 8 years ago

The issue comes from the function refreshMonthTitleTextView in CaldroidFragment. Its last line is :

monthTitleTextView.setText(monthTitle.toUpperCase(Locale.getDefault()));

I managed to display the month title with first letter UpperCase and rest lowercase. But the only way was to extends CaldroidFragment and override refreshMonthTitleTextView.

If you are interested, this is what I have done:

`public class CaldroidCustomFragment extends CaldroidFragment { private static final int MONTH_YEAR_FLAG = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_MONTH_DAY | DateUtils.FORMAT_SHOW_YEAR;

private final StringBuilder monthYearStringBuilder = new StringBuilder(50);
private Formatter monthYearFormatter = new Formatter(
        monthYearStringBuilder, Locale.getDefault());

private Time firstMonthTime = new Time();
@Override
protected void refreshMonthTitleTextView()
{
    // Refresh title view
    firstMonthTime.year = year;
    firstMonthTime.month = month - 1;
    firstMonthTime.monthDay = 15;
    long millis = firstMonthTime.toMillis(true);

    // This is the method used by the platform Calendar app to get a
    // correctly localized month name for display on a wall calendar
    monthYearStringBuilder.setLength(0);
    String monthTitle = DateUtils.formatDateRange(getActivity(),
            monthYearFormatter, millis, millis, MONTH_YEAR_FLAG).toString();

    monthTitle = monthTitle.substring(0, 1).toUpperCase() + monthTitle.substring(1);

    getMonthTitleTextView().setText(monthTitle);
}

}`