fix timespan plurals (#1240)

* fix timespan plurals

* rename poll timestamp strings and helper method
This commit is contained in:
Konrad Pozniak 2019-05-06 09:59:06 +02:00 committed by GitHub
commit d7c32258ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 24 additions and 84 deletions

View file

@ -802,7 +802,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
if(useAbsoluteTime) {
pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.getExpiresAt()));
} else {
String pollDuration = DateUtils.formatDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp);
String pollDuration = DateUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp);
pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration);
}
}

View file

@ -78,7 +78,7 @@ public class DateUtils {
return context.getString(format, span);
}
public static String formatDuration(Context context, long then, long now) {
public static String formatPollDuration(Context context, long then, long now) {
long span = then - now;
if (span < 0) {
span = 0;
@ -86,20 +86,20 @@ public class DateUtils {
int format;
if (span < MINUTE_IN_MILLIS) {
span /= SECOND_IN_MILLIS;
format = R.string.timespan_seconds;
format = R.plurals.poll_timespan_seconds;
} else if (span < HOUR_IN_MILLIS) {
span /= MINUTE_IN_MILLIS;
format = R.string.timespan_minutes;
format = R.plurals.poll_timespan_minutes;
} else if (span < DAY_IN_MILLIS) {
span /= HOUR_IN_MILLIS;
format = R.string.timespan_hours;
format = R.plurals.poll_timespan_hours;
} else {
span /= DAY_IN_MILLIS;
format = R.string.timespan_days;
format = R.plurals.poll_timespan_days;
}
return context.getString(format, span);
return context.getResources().getQuantityString(format, (int) span, (int) span);
}
}