alamkanak / Android-Week-View

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Apache License 2.0
3.42k stars 1.23k forks source link

Bug: shortened day text is almost the same for all days in Hebrew, and days don't change direction #495

Open AndroidDeveloperLB opened 6 years ago

AndroidDeveloperLB commented 6 years ago

Suppose you take this when on English:

image

When I switch to Hebrew, I get this:

image

Almost all days here have the same letter, which is wrong because it's not how it should be on Hebrew. I think it's because the library truncates a longer text here, as you will see below.

Pressing "Today" will get it right:

image

However, only the days are ok. The order of them is incorrect, because Hebrew is an RTL language. This means that you are supposed to see the days from right to left.

See Google Calendar for example:

device-2018-05-03-100330

Sunday ("יום א" - first day) is on the right, then Monday, then Tuesday, then Wednesday, then Thursday (which is today - "יום ה" - the 5th day of the week) , then Friday, then Saturday ("שבת" - Sabbath, last day of the week) .

This is how it should have been.

AndroidDeveloperLB commented 6 years ago

Correct way to format the dates is as such:

private fun setupDateTimeInterpreter(shortDate: Boolean) {
    val calendar = Calendar.getInstance()
    calendar.set(Calendar.MINUTE, 0)
    calendar.set(Calendar.SECOND, 0)
    calendar.set(Calendar.MILLISECOND, 0)
    val dateFormat = DateFormat.getTimeFormat(this@BaseActivity)
            ?: SimpleDateFormat("HH:mm", Locale.getDefault())
    val format = SimpleDateFormat(" M/d", Locale.getDefault())
    weekView.dateTimeInterpreter = object : DateTimeInterpreter {
        ...

        override fun interpretDate(date: Calendar): String {
            var weekday = DateUtils.getDayOfWeekString(date.get(Calendar.DAY_OF_WEEK), DateUtils.LENGTH_SHORT)
            if (shortDate) {
                val dayOfWeekString = DateUtils.getDayOfWeekString(date.get(Calendar.DAY_OF_WEEK), DateUtils.LENGTH_SHORTEST)
                weekday = dayOfWeekString
            }
            return weekday + format.format(date.time)
        }

    }
}

But for the RTL issue, this is something else...