Android-Week-View icon indicating copy to clipboard operation
Android-Week-View copied to clipboard

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

Open AndroidDeveloperLB opened this issue 7 years ago • 1 comments

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 avatar May 03 '18 07:05 AndroidDeveloperLB

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...

AndroidDeveloperLB avatar May 06 '18 14:05 AndroidDeveloperLB