From 141fd1a9f1d1a69764215088f572456f8abf6ceb Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Fri, 2 Oct 2020 17:11:48 +0200 Subject: [PATCH] improve relative poll timestamp string format (#1939) --- .../tusky/adapter/StatusBaseViewHolder.java | 3 +-- .../com/keylesspalace/tusky/util/StatusViewHelper.kt | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index ba12d9eb..8bf86483 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -1032,8 +1032,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { if (statusDisplayOptions.useAbsoluteTime()) { pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.getExpiresAt())); } else { - String pollDuration = TimestampUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp); - pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration); + pollDurationInfo = TimestampUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp); } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt index cb2f0f3a..6ab8eb8b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt @@ -275,14 +275,13 @@ class StatusViewHelper(private val itemView: View) { val votes = NumberFormat.getNumberInstance().format(poll.votesCount.toLong()) val votesText = context.resources.getQuantityString(R.plurals.poll_info_votes, poll.votesCount, votes) val pollDurationInfo: CharSequence - if (poll.expired) { - pollDurationInfo = context.getString(R.string.poll_info_closed) + pollDurationInfo = if (poll.expired) { + context.getString(R.string.poll_info_closed) } else { if (useAbsoluteTime) { - pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.expiresAt)) + context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.expiresAt)) } else { - val pollDuration = TimestampUtils.formatPollDuration(context, poll.expiresAt!!.time, timestamp) - pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration) + TimestampUtils.formatPollDuration(context, poll.expiresAt!!.time, timestamp) } } @@ -327,4 +326,4 @@ class StatusViewHelper(private val itemView: View) { val COLLAPSE_INPUT_FILTER = arrayOf(SmartLengthInputFilter) val NO_INPUT_FILTER = arrayOfNulls(0) } -} \ No newline at end of file +}