From f553489ddf084da90ba3bb9fb25f6b44fb5218f9 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 23 Mar 2026 15:51:35 -0400 Subject: [PATCH] Improves the wording of the Last Seen --- .../amethyst/ui/note/TimeAgoFormatter.kt | 19 ++++++++++++------- .../profile/header/DrawAdditionalInfo.kt | 2 +- amethyst/src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/TimeAgoFormatter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/TimeAgoFormatter.kt index d6452fbbc..5f7ce1a3e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/TimeAgoFormatter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/TimeAgoFormatter.kt @@ -45,9 +45,14 @@ var monthNoDayFormatter = SimpleDateFormat(MONTH_NO_DAY_DATE_FORMAT, locale) fun timeAgo( time: Long?, context: Context, + prefix: String = " • ", + seconds: Int = R.string.now, + minutes: Int = R.string.m, + hours: Int = R.string.h, + days: Int = R.string.d, ): String { if (time == null) return " " - if (time == 0L) return " • ${stringRes(context, R.string.never)}" + if (time == 0L) return prefix + stringRes(context, R.string.never) val timeDifference = TimeUtils.now() - time @@ -60,7 +65,7 @@ fun timeAgo( monthFormatter = SimpleDateFormat(MONTH_DATE_FORMAT, locale) } - " • " + yearFormatter.format(time * 1000) + prefix + yearFormatter.format(time * 1000) } else if (timeDifference > TimeUtils.ONE_MONTH) { // Dec 12 if (locale != Locale.getDefault()) { @@ -69,16 +74,16 @@ fun timeAgo( monthFormatter = SimpleDateFormat(MONTH_DATE_FORMAT, locale) } - " • " + monthFormatter.format(time * 1000) + prefix + monthFormatter.format(time * 1000) } else if (timeDifference > TimeUtils.ONE_DAY) { // 2 days - " • " + (timeDifference / TimeUtils.ONE_DAY).toString() + stringRes(context, R.string.d) + prefix + (timeDifference / TimeUtils.ONE_DAY).toString() + stringRes(context, days) } else if (timeDifference > TimeUtils.ONE_HOUR) { - " • " + (timeDifference / TimeUtils.ONE_HOUR).toString() + stringRes(context, R.string.h) + prefix + (timeDifference / TimeUtils.ONE_HOUR).toString() + stringRes(context, hours) } else if (timeDifference > TimeUtils.ONE_MINUTE) { - " • " + (timeDifference / TimeUtils.ONE_MINUTE).toString() + stringRes(context, R.string.m) + prefix + (timeDifference / TimeUtils.ONE_MINUTE).toString() + stringRes(context, minutes) } else { - " • " + stringRes(context, R.string.now) + prefix + stringRes(context, seconds) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt index d88b0fb95..3acc587d9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DrawAdditionalInfo.kt @@ -309,7 +309,7 @@ fun DisplayLastSeen( lastSeen?.let { timestamp -> val context = LocalContext.current Text( - text = stringRes(R.string.last_seen, timeAgo(timestamp, context)), + text = stringRes(R.string.last_seen, timeAgo(timestamp, context, prefix = "", seconds = R.string.seconds)), color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, overflow = TextOverflow.Ellipsis, diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index bf05100bf..b31cf4974 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -309,6 +309,7 @@ LNURL… never now + seconds h m d