Replace PrettyTime with DateUtils.getRelativeTimeSpanString() #3567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
Remove dependency on PrettyTime by replacing it with a call to
DateUtils.getRelativeTimeSpanString
, which formats relative time in a similar way (although slightly differently):https://developer.android.com/reference/android/text/format/DateUtils#getRelativeTimeSpanString(long)
One downside is that DateUtils abbreviates time unit names despite that the corresponding flag is not set (FORMAT_ABBREVIATE_RELATIVE), e.g.
день
->дн
. I didn't find a way to disable that...Update:
Actually that's not true - I tested on a newer device (Android 10) and it's showing the time as expected, i.e. not abbreviated. It only happens with my old tablet running KitKat. Screenshot:
Fixes the following issue(s)
PrettyTime has a bug with formatting relative time in Russian - ocpsoft/prettytime#182
For example, instead of "2 дня назад" (2 days ago) PrettyTime produces "2 дней назад", which is incorrect plural of "day" in Russian (same with other time units).
Testing apk
app-debug.zip
Agreement