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 d6452fbbcf..5f7ce1a3e5 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 d88b0fb95a..3acc587d97 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 bf05100bf4..b31cf49746 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